# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3 (ipykernel)
#     language: python
#     name: python3
# ---

import flopy.modflow as fm
import mfexport

# ## export a model
#
# #### load the model using flopy

m = fm.Modflow.load('lpr_inset.nam',
                    model_ws='data/lpr')
m

# #### define the location of the model grid
# * spacing in meters

grid = mfexport.MFexportGrid(delr=m.dis.delr.array * .3048, # grid spacing in meters
                             delc=m.dis.delc.array * .3048, 
                             xul=557571, yul=446166, # upper left corner in CRS
                             epsg=3070 # epsg reference for projected CRS
                            )

# ### export all data arrays and stress period data (`MfLists`) to shapefiles, rasters and PDFs
# * array data are written to compressed GeoTIFFs
# * transient lists are written to shapefiles
#     * only model cells in the list are included
#     * stress period data are included as attributes; only periods where stresses change are included
# * all data are displayed in PDFs using `matplotlib.pyplot.imshow`

# %%capture
mfexport.export(m, grid, output_path='postproc')

# ### export a package

# %%capture
mfexport.export(m, grid, 'wel', output_path='postproc')

# ### summarize model input

df = mfexport.summarize(m)
df.head(20)

# ### Export model results
#
# #### cell by cell flows
# * written to compressed GeoTIFFs

mfexport.export_cell_budget('data/lpr/lpr_inset.cbc', 
                   grid,
                   kstpkper=(4, 0), output_path='postproc')

# #### heads
# * compressed GeoTIFFs
# * shapefiles of equipotential contours

# +
headsfile = 'data/lpr/lpr_inset.hds'

mfexport.export_heads(headsfile, grid, hdry=m.upw.hdry, hnflo=m.bas6.hnoflo,
                      kstpkper=(4, 0),
                      output_path='postproc')
# -

# #### drawdown
# * compressed GeoTIFFs
# * shapefiles of equipotential contours

mfexport.export_drawdown(headsfile, grid, hdry=m.upw.hdry, hnflo=m.bas6.hnoflo,
                         kstpkper0=(4, 0),
                         kstpkper1=(4, 8),
                         output_path='postproc')

# #### SFR results
# * shapefile of SFR water balance results
# * PDFs of simulated stream flows and stream/aquifer interactions

# %%capture
mf2005_sfr_outputfile = 'data/lpr/lpr_inset.sfr.out'
outfiles = mfexport.export_sfr_results(mf2005_sfr_outputfile=mf2005_sfr_outputfile,
                                       model=m,
                                       grid=grid,
                                       kstpkper=(4, 0),
                                       output_length_units='feet',
                                       output_time_units='seconds',
                                       output_path='postproc'
                                       )



StarcoderdataJupyterScriptsDedupFiltered