コード例 #1
0
def test_example():
    # shapefiles defining the model grid, and the area that will include SFR
    mf_grid = '../Examples/data/grid.shp'
    mf_domain = '../Examples/data/domain.shp'

    # NHDPlus input files (see the input requirements in the SFRmaker readme file
    # (Note that multiple datasets can be supplied as lists;
    # when the SFR area covers multiple drainage basins)
    pfvaa_files = ['../Examples/data/PlusFlowlineVAA.dbf']
    plusflow_files = ['../Examples/data/PlusFlow.dbf']
    elevslope_files = ['../Examples/data/elevslope.dbf']
    flowlines = ['../Examples/data/NHDFlowlines.shp']

    # dem used for streambed elevations
    dem = '../Examples/data/dem.tif'
    dem_units_mult = 1.  # convert dem elevation units to modflow units

    ta = time.time()
    # Read in the NHD datasets
    nhd = NHDdata(NHDFlowline=flowlines,
                  PlusFlowlineVAA=pfvaa_files,
                  PlusFlow=plusflow_files,
                  elevslope=elevslope_files,
                  mf_grid=mf_grid,
                  mf_units='feet',
                  model_domain=mf_domain)
    # Setup the segments, reaches, and other basic SFR parameters
    nhd.to_sfr()

    # Write out this information to Mat1 and Mat2 tables
    nhd.write_tables(basename='temp/example')

    # Write out a shapefile that has the SFR linework
    nhd.write_linework_shapefile(basename='temp/SFRlines')
    print("preproc finished in {:.2f}s\n".format(time.time() - ta))

    # Mat 1 and Mat2 files generated from preproc.py above
    m1 = 'temp/exampleMat1.csv'
    m2 = 'temp/exampleMat2.csv'

    # Read in Mat1 and Mat2 into an SFRdata object (postproc module)
    # also include MODFLOW DIS file, NAM file, and path to model datasets
    sfr = SFRdata(Mat1=m1,
                  Mat2=m2,
                  mfgridshp=mf_grid,
                  mfdis='example.dis',
                  mfpath='temp',
                  mfnam='example.nam')

    # For interior stream reaches (not at the ends of segments),
    # assign streambed tops from the minimum DEM elevations in the model cell
    sfr.reset_m1_streambed_top_from_dem(dem, dem_units_mult=dem_units_mult)

    # Often the NHDPlus elevations don't match DEM at scales below 100k.
    # reset the segment end elevations to the minimum dem elevation
    # encountered in the end reach and all reaches upstream
    # (to use the NHDPlus elevations for the segment ends, comment this out)
    sfr.reset_segment_ends_from_dem()

    # Create array listing all unique segment sequences from headwaters to outlet
    # used by other methods, and ensures that there is no circular routing
    sfr.map_outsegs()

    # Remove any bumps in the DEM elevations,
    # so that interior elevations in the segments always decrease in the downstream direction
    sfr.smooth_interior_elevations()

    # Create a PDF showing the elevation profile of each unique segment sequence,
    # in comparison to the mean DEM elevation in each cell along the profile
    # Note: this is optional but allows for inspection to verify that the elevations are reasonable
    # on large networks (with thousands of sequences) this step may take an hour or two.
    sfr.plot_stream_profiles()

    # In cells with multiple SFR reaches (at confluences), put all conductance in the dominant reach
    # (to avoid circular routing)
    sfr.consolidate_conductance()

    # Put all SFR reaches in layer 1, and adjust layer bottoms in SFR cells accordingly,
    # so that no streambed bottoms are below the bottom of layer 1, and
    # so that there are no cell thicknesses less than 1
    # Note: This produces a new MODFLOW DIS file with the suffix "_adjusted to streambed.dis"
    # (unless another suffix is specified)
    sfr.reset_model_top_2streambed(minimum_thickness=1)

    # write out a shapefile of the SFR dataset
    sfr.write_shapefile('temp/SFR_package.shp')

    # write out updated Mat1 and Mat2 tables
    sfr.write_tables(basename='temp/example_pp_')

    # write the SFR package file
    sfr.write_sfr_package(basename='temp/example')

    # flopy now includes an SFR module, with a checker
    # run the flopy suite of diagnostics
    import flopy
    m = flopy.modflow.Modflow.load('example.nam', model_ws='temp')
    #dis = flopy.modflow.ModflowDis.load('ozarkgwmod/3-Input/A-calibration/ozark_adjusted_to_streambed.dis', m)
    sfr = flopy.modflow.ModflowSfr2.load('temp/example.sfr', m)
    sfr.check(f='flopy_SFR_check')
コード例 #2
0
import sys
sys.path.insert(0, 'D:/ATLData/Documents/GitHub/SFR')
#sys.path.append('D:\JointBaseModel\SFRMakerData\TestModel')
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from rasterstats import zonal_stats
from postproc import SFRdata

path = 'D:/ATLData/SFR_testing/TestModel/'

# intantiate SFRdata object
sfr = SFRdata(Mat1=path + 'SFR_GWVmat1.txt',
              Mat2=path + 'SFR_GWVmat2.txt',
              mfgridshp='ForsyGrd.shp',
              mfgridshp_node_field='CellNum', 
              mfgridshp_row_field='ROW', mfgridshp_column_field='COLUMN')

# create columns in Mat2 of Min and Max elevation for each segment
# (these columns are not created by sfr_classes.py)
sfr.update_Mat2_elevations()

# update the reach elevations in Mat1 with minimum elevations from DEM
sfr.reset_m1_streambed_top_from_dem(dem=path + 'forsy_lid')

# trace routing from headwater segments to outlets; assign outlet to each segment
sfr.map_outsegs()

# creates table of segment confluences
sfr.map_confluences()
コード例 #3
0
ファイル: diagnostics.py プロジェクト: pjuckem/SFR
    def __init__(self, sfrobject=None, Mat1=None, Mat2=None, sfr=None, node_column=None,
                     mfpath=None, mfnam=None, mfdis=None,
                     xll=0, yll=0, outpath=os.getcwd()):

        SFRdata.__init__(self, sfrobject=sfrobject, Mat1=Mat1, Mat2=Mat2, sfr=sfr, node_column=node_column,
                         mfpath=mfpath, mfnam=mfnam, mfdis=mfdis, xll=xll, yll=yll)
コード例 #4
0
# Write out this information to Mat1 and Mat2 tables
nhd.write_tables(basename='{}/{}'.format(outdir, basename))

# Write out a shapefile that has the SFR linework
nhd.write_linework_shapefile(basename='{}/{}'.format(outdir, basename))
print("preproc finished in {:.2f}s\n".format(time.time() - ta))

# Mat 1 and Mat2 files generated from preproc.py above
m1 = '{}/{}Mat1.csv'.format(outdir, basename)
m2 = '{}/{}Mat2.csv'.format(outdir, basename)

# Read in Mat1 and Mat2 into an SFRdata object (postproc module)
# also include MODFLOW DIS file, NAM file, and path to model datasets
sfr = SFRdata(Mat1=m1, Mat2=m2, mfgridshp=mf_grid,
              mfdis=mfdis, mfpath=model_ws,
              mfnam=mfnam)

# For interior stream reaches (not at the ends of segments),
# assign streambed tops from the minimum DEM elevations in the model cell
sfr.reset_m1_streambed_top_from_dem(dem, dem_units_mult=dem_units_mult)

# Often the NHDPlus elevations don't match DEM at scales below 100k.
# reset the segment end elevations to the minimum dem elevation
# encountered in the end reach and all reaches upstream
# (to use the NHDPlus elevations for the segment ends, comment this out)
sfr.reset_segment_ends_from_dem()

# Remove any bumps in the DEM elevations,
# so that interior elevations in the segments always decrease in the downstream direction
sfr.smooth_interior_elevations()
コード例 #5
0
# Write out this information to Mat1 and Mat2 tables
nhd.write_tables(basename='ozark')

# Write out a shapefile that has the SFR linework
nhd.write_linework_shapefile(basename='SFRlines')
print("preproc finished in {:.2f}s\n".format(time.time() - ta))

# Mat 1 and Mat2 files generated from preproc.py above
m1 = 'ozarkMat1.csv'
m2 = 'ozarkMat2.csv'

# Read in Mat1 and Mat2 into an SFRdata object (postproc module)
# also include MODFLOW DIS file, NAM file, and path to model datasets
sfr = SFRdata(Mat1=m1, Mat2=m2, mfgridshp=mf_grid,
              mfdis='ozark.dis', mfpath='ozarkgwmod/3-Input/A-calibration/',
              mfnam='ozark.nam',
              mfgridshp_node_field='cellnum',
              mfgridshp_row_field='irow',
              mfgridshp_column_field='icol')

# For interior stream reaches (not at the ends of segments), 
# assign streambed tops from the minimum DEM elevations in the model cell
sfr.reset_m1_streambed_top_from_dem('dem30m1.tif', dem_units_mult=1/0.3048)

# Create array listing all unique segment sequences from headwaters to outlet
# used by other methods, and ensures that there is no circular routing
sfr.map_outsegs()

# Remove any bumps in the DEM elevations, 
# so that interior elevations in the segments always decrease in the downstream direction
sfr.smooth_interior_elevations()
コード例 #6
0
ファイル: diagnostics.py プロジェクト: jbellino-usgs/SFRmaker
    def __init__(self, sfrobject=None, Mat1=None, Mat2=None, sfr=None, node_column=None,
                     mfpath=None, mfnam=None, mfdis=None,
                     xll=0, yll=0, outpath=os.getcwd()):

        SFRdata.__init__(self, sfrobject=sfrobject, Mat1=Mat1, Mat2=Mat2, sfr=sfr, node_column=node_column,
                         mfpath=mfpath, mfnam=mfnam, mfdis=mfdis, xll=xll, yll=yll)
コード例 #7
0
# Write out this information to Mat1 and Mat2 tables
nhd.write_tables(basename='example')

# Write out a shapefile that has the SFR linework
nhd.write_linework_shapefile(basename='SFRlines')
print("preproc finished in {:.2f}s\n".format(time.time() - ta))

# Mat 1 and Mat2 files generated from preproc.py above
m1 = 'exampleMat1.csv'
m2 = 'exampleMat2.csv'

# Read in Mat1 and Mat2 into an SFRdata object (postproc module)
# also include MODFLOW DIS file, NAM file, and path to model datasets
sfr = SFRdata(Mat1=m1,
              Mat2=m2,
              mfgridshp=mf_grid,
              mfdis='example.dis',
              mfpath='data',
              mfnam='example.nam')

# For interior stream reaches (not at the ends of segments),
# assign streambed tops from the minimum DEM elevations in the model cell
sfr.reset_m1_streambed_top_from_dem(dem, dem_units_mult=dem_units_mult)

# Often the NHDPlus elevations don't match DEM at scales below 100k.
# reset the segment end elevations to the minimum dem elevation
# encountered in the end reach and all reaches upstream
# (to use the NHDPlus elevations for the segment ends, comment this out)
sfr.reset_segment_ends_from_dem()

# Create array listing all unique segment sequences from headwaters to outlet
# used by other methods, and ensures that there is no circular routing
コード例 #8
0
ファイル: t001_test.py プロジェクト: jbellino-usgs/SFRmaker
def test_example():
    # shapefiles defining the model grid, and the area that will include SFR
    mf_grid = '../Examples/data/grid.shp'
    mf_domain = '../Examples/data/domain.shp'

    # NHDPlus input files (see the input requirements in the SFRmaker readme file
    # (Note that multiple datasets can be supplied as lists;
    # when the SFR area covers multiple drainage basins)
    pfvaa_files = ['../Examples/data/PlusFlowlineVAA.dbf']
    plusflow_files = ['../Examples/data/PlusFlow.dbf']
    elevslope_files = ['../Examples/data/elevslope.dbf']
    flowlines = ['../Examples/data/NHDFlowlines.shp']

    # dem used for streambed elevations
    dem = '../Examples/data/dem.tif'
    dem_units_mult = 1. # convert dem elevation units to modflow units

    ta = time.time()
    # Read in the NHD datasets
    nhd = NHDdata(NHDFlowline=flowlines, PlusFlowlineVAA=pfvaa_files, PlusFlow=plusflow_files,
                  elevslope=elevslope_files,
                  mf_grid=mf_grid, mf_units='feet',
                  model_domain=mf_domain)
    # Setup the segments, reaches, and other basic SFR parameters
    nhd.to_sfr()

    # Write out this information to Mat1 and Mat2 tables
    nhd.write_tables(basename='temp/example')

    # Write out a shapefile that has the SFR linework
    nhd.write_linework_shapefile(basename='temp/SFRlines')
    print("preproc finished in {:.2f}s\n".format(time.time() - ta))

    # Mat 1 and Mat2 files generated from preproc.py above
    m1 = 'temp/exampleMat1.csv'
    m2 = 'temp/exampleMat2.csv'

    # Read in Mat1 and Mat2 into an SFRdata object (postproc module)
    # also include MODFLOW DIS file, NAM file, and path to model datasets
    sfr = SFRdata(Mat1=m1, Mat2=m2, mfgridshp=mf_grid,
                  mfdis='example.dis', mfpath='temp',
                  mfnam='example.nam')

    # For interior stream reaches (not at the ends of segments),
    # assign streambed tops from the minimum DEM elevations in the model cell
    sfr.reset_m1_streambed_top_from_dem(dem, dem_units_mult=dem_units_mult)

    # Often the NHDPlus elevations don't match DEM at scales below 100k.
    # reset the segment end elevations to the minimum dem elevation
    # encountered in the end reach and all reaches upstream
    # (to use the NHDPlus elevations for the segment ends, comment this out)
    sfr.reset_segment_ends_from_dem()

    # Create array listing all unique segment sequences from headwaters to outlet
    # used by other methods, and ensures that there is no circular routing
    sfr.map_outsegs()

    # Remove any bumps in the DEM elevations,
    # so that interior elevations in the segments always decrease in the downstream direction
    sfr.smooth_interior_elevations()

    # Create a PDF showing the elevation profile of each unique segment sequence,
    # in comparison to the mean DEM elevation in each cell along the profile
    # Note: this is optional but allows for inspection to verify that the elevations are reasonable
    # on large networks (with thousands of sequences) this step may take an hour or two.
    sfr.plot_stream_profiles()

    # In cells with multiple SFR reaches (at confluences), put all conductance in the dominant reach
    # (to avoid circular routing)
    sfr.consolidate_conductance()

    # Put all SFR reaches in layer 1, and adjust layer bottoms in SFR cells accordingly,
    # so that no streambed bottoms are below the bottom of layer 1, and
    # so that there are no cell thicknesses less than 1
    # Note: This produces a new MODFLOW DIS file with the suffix "_adjusted to streambed.dis"
    # (unless another suffix is specified)
    sfr.reset_model_top_2streambed(minimum_thickness=1)

    # write out a shapefile of the SFR dataset
    sfr.write_shapefile('temp/SFR_package.shp')

    # write out updated Mat1 and Mat2 tables
    sfr.write_tables(basename='temp/example_pp_')

    # write the SFR package file
    sfr.write_sfr_package(basename='temp/example')

    # flopy now includes an SFR module, with a checker
    # run the flopy suite of diagnostics
    import flopy
    m = flopy.modflow.Modflow.load('example.nam', model_ws='temp')
    #dis = flopy.modflow.ModflowDis.load('ozarkgwmod/3-Input/A-calibration/ozark_adjusted_to_streambed.dis', m)
    sfr = flopy.modflow.ModflowSfr2.load('temp/example.sfr', m)
    sfr.check(f='flopy_SFR_check')
コード例 #9
0
# Write out this information to Mat1 and Mat2 tables
nhd.write_tables(basename='example')

# Write out a shapefile that has the SFR linework
nhd.write_linework_shapefile(basename='SFRlines')
print("preproc finished in {:.2f}s\n".format(time.time() - ta))

# Mat 1 and Mat2 files generated from preproc.py above
m1 = 'exampleMat1.csv'
m2 = 'exampleMat2.csv'

# Read in Mat1 and Mat2 into an SFRdata object (postproc module)
# also include MODFLOW DIS file, NAM file, and path to model datasets
sfr = SFRdata(Mat1=m1, Mat2=m2, mfgridshp=mf_grid,
              mfdis='example.dis', mfpath='data',
              mfnam='example.nam')

# For interior stream reaches (not at the ends of segments),
# assign streambed tops from the minimum DEM elevations in the model cell
sfr.reset_m1_streambed_top_from_dem(dem, dem_units_mult=dem_units_mult)

# Often the NHDPlus elevations don't match DEM at scales below 100k.
# reset the segment end elevations to the minimum dem elevation
# encountered in the end reach and all reaches upstream
# (to use the NHDPlus elevations for the segment ends, comment this out)
sfr.reset_segment_ends_from_dem()

# Create array listing all unique segment sequences from headwaters to outlet
# used by other methods, and ensures that there is no circular routing
sfr.map_outsegs()