Hydrologic Projects
ESPAM2 Recharge Tools 1.5 Documentation
espam.core
ESPAM Core Module
Contains methods for building the following files for MKMOD:
.FPT, .ETI, *.NIR, *.TRB, *.PCH, *.SOL, *.OFF, *.ENT, *.DIV, *.CNL, *.CEL
All file builders subclass the class Builder, and have a method called generate_file, which at the minimum takes a settings object as an input, and a path to an output file. Some of the file types take additional information about stress periods, or PEST multipliers. See documentation for each individual Builder for details.
- class espam.core.Builder(settings)
Abstract builder class
All files built by the ESPA tool will inherit from the Builder class. This class defines the scratch workspace, initializes the logger, and creates a SQLite database if necessary.
This class should never by instantiated directly.
- build_database(database_name)
Generate a temporary processing database using SQLite.
Parameters: database_name (str) – Name of database that will be created
- check_file_relationship(table1, pkey_table1, table2, pkey_table2)
Compares the primary keys between two tables
Determines if the primary keys between two tables contain the exact same keys, or if one table has more records than the other
Parameters: - table1 – Table one to compare
- pkey_table1 – Primary key of table one to compare
- table2 – Table two to compare
- pkey_table2 – Primary key of table two to compare
Returns: Tuple – First parameter is True or False - True if the keys are identical. Second parameter is a dictionary with the key common, for items common between both shapefile and table, a key table1, which shows the key only in the first table, and table2 which shows the keys only in the second table
- class espam.core.CelBuilder(settings)
Generate A CEL File From ESPA Model Grid
- generate_file(output_file)
Builds a CEL file from the input settings
- Generates a CEL file, using the datasources from the settings.ini file:
- ESPA Model Grid Feature Class defined by the espagrid key
See the CEL File Format document for more details on the CEL file format.
generate_file is a common method shared by all *Builder classes. The generate_file method always takes an output_file parameter, which is the location the file will be saved to. The settings used by generate_file are passed to the *Builder object in the constructor.
Parameters: output_file (str) – Location to store output CEL file
- class espam.core.CnlBuilder(settings)
Generates a CNL File From Canal Feature Class and Seepage Spreadsheet
- generate_file(output_file)
Builds a CNL file from the input settings
- Generates a CNL file, using the datasources from the settings.ini file:
See the CNL File Format document for more details on the CNL file format.
generate_file is a common method shared by all *Builder classes. The generate_file method always takes an output_file parameter, which is the location the file will be saved to. The settings used by generate_file are passed to the *Builder object in the constructor.
Parameters: output_file (str) – Location to store output CNL file
- class espam.core.DivBuilder(settings)
Builder for DIV file format.
Creates a DIV file from the summary page of a diversions spreadsheet in Excel for input into MKMOD.
This class is a subclass of Builder
>>> buildDIV = DivBuilder(settings) >>> buildDIV.generate_file(1980,2,100,"D:\out.div", True)
- generate_file(starting_year, starting_month, number_of_stress_periods, zero_returns, output_file)
Builds a DIV file from the input settings
- Generates a DIV file, using the datasources from the settings.ini file:
- Diversion Spreadsheet defined by the diversion key
See the DIV File Format document for more details on the DIV file format.
generate_file is a common method shared by all *Builder classes. The generate_file method always takes an output_file parameter, which is the location the file will be saved to. The settings used by generate_file are passed to the *Builder object in the constructor.
Parameters: - starting_month (int) – Integer month (1-12) of the first stress period
- starting_year (int) – Integer year of the first stress period
- number_of_stress_periods (int) – Number of stress periods to process
- zero_returns (bool) – If True, then use zeros for all return values; otherwise use spreadsheet returns.
- output_file (str) – Location to store output DIV file
- class espam.core.EntBuilder(settings)
Builder for ENT file format.
Creates an ENT file from a table representing fraction of irrigated lands using sprinklers, and a table with sprinkler and gravity adjustments for all of the irrigation entities in the ESPA for input into MKMOD.
This class is a subclass of Builder
>>> buildENT = EntBuilder(settings) >>> buildENT.generate_file("D:\out.ent")
- generate_file(output_file)
Builds a ENT file from the input settings
- Generates a ENT file, using the datasources from the settings.ini file:
See the ENT File Format document for more details on the ENT file format.
generate_file is a common method shared by all *Builder classes. The generate_file method always takes an output_file parameter, which is the location the file will be saved to. The settings used by generate_file are passed to the *Builder object in the constructor.
Parameters: output_file (str) – Location to store output ENT file
- class espam.core.EtiBuilder(settings)
Builder for ETI file format.
Creates an ETI file from the Eastern Snake Plain Aquifer (ESPA) Model Grid GIS dataset, County GIS dataset, and Evapotranspiration (ET) spreadsheet for input into MKMOD.
This class is a subclass of Builder
>>> buildETI = EtiBuilder(settings) >>> buildETI.generate_file("D:\out.eti")
- generate_file(output_file)
Builds a ETI file from the input settings
- Generates a ETI file, using the datasources from the settings.ini file:
- County GIS dataset defined by the county key
- ET Spreadsheet defined by the etspreadsheet key
- ESPA Model Grid Feature Class defined by the espagrid key
See the ETI File Format document for more details on the ETI file format.
generate_file is a common method shared by all *Builder classes. The generate_file method always takes an output_file parameter, which is the location the file will be saved to. The settings used by generate_file are passed to the *Builder object in the constructor.
Parameters: output_file (str) – Location to store output ETI file
- class espam.core.FptBuilder(settings)
Builder for FPT file format.
Creates a FPT file for input into MKMOD given ESPA Grid, Fixed Point GIS Point dataset, and Fixed Point Spreadsheet
This class is a subclass of Builder
>>> buildFPT = FptBuilder(settings) >>> buildFPT.generate_file("D:\out.fpt")
- generate_file(output_file)
Builds a FPT file from the input settings
- Generates a FPT file, using the datasources from the settings.ini file:
- Fixed Point GIS dataset defined by the fixedpoint key
- Fixed Point Spreadsheet defined by the fixedpointspreadsheet key
- ESPA Model Grid Feature Class defined by the espagrid key
See the FPT File Format document for more details on the FPT file format.
generate_file is a common method shared by all *Builder classes. The generate_file method always takes an output_file parameter, which is the location the file will be saved to. The settings used by generate_file are passed to the *Builder object in the constructor.
Parameters: output_file (str) – Location to store output FPT file
- class espam.core.NirBuilder(settings)
Builder for NIR file format.
Creates a NIR file from the Non-Irrigation Recharge table for input into MKMOD.
This class is a subclass of Builder
>>> buildNIR = NirBuilder(settings) >>> buildNIR.generate_file("D:\out.nir")
- generate_file(output_file)
Builds a NIR file from the input settings
- Generates a NIR file, using the datasources from the settings.ini file:
- Non-Irrigated Recharge Spreadsheet by the nonirrigatedrechargespreadsheet key
See the NIR File Format document for more details on the NIR file format.
generate_file is a common method shared by all *Builder classes. The generate_file method always takes an output_file parameter, which is the location the file will be saved to. The settings used by generate_file are passed to the *Builder object in the constructor.
Parameters: output_file (str) – Location to store output NIR file
- class espam.core.OffBuilder(settings)
Builder for OFF file format.
Creates an OFF file from the Eastern Snake Plain Aquifer (ESPA) Model Grid, an Offsite Well GIS dataset, and an Offsite Well table for input into MKMOD.
This class is a subclass of Builder
>>> buildOFF = OffBuilder(settings) >>> buildOFF.generate_file("D:\out.off")
- generate_file(output_file)
Builds a OFF file from the input settings
- Generates a OFF file, using the datasources from the settings.ini file:
- Offsite Well GIS dataset defined by the offsitewell key
- Offsite Well Spreadsheet defined by the offsitespreadsheet key
- ESPA Model Grid Feature Class defined by the espagrid key
See the OFF File Format document for more details on the OFF file format.
generate_file is a common method shared by all *Builder classes. The generate_file method always takes an output_file parameter, which is the location the file will be saved to. The settings used by generate_file are passed to the *Builder object in the constructor.
Parameters: output_file (str) – Location to store output OFF file
- class espam.core.PchBuilder(settings)
Builder for PCH file format.
Creates a PCH file from the Eastern Snake Plain Aquifer (ESPA) Model Grid, Perched Rivers GIS dataset, and Perched River spreadsheet for input into MKMOD.
This class is a subclass of Builder
>>> buildPCH = PchBuilder(settings) >>> buildPCH.generate_file("D:\out.pch")
- generate_file(output_file)
Builds a PCH file from the input settings
- Generates a PCH file, using the datasources from the settings.ini file:
- Perched Rivers GIS dataset defined by the perched key
- Perched Spreadsheet defined by the perchedspreadsheet key
- ESPA Model Grid Feature Class defined by the espagrid key
See the PCH File Format document for more details on the PCH file format.
generate_file is a common method shared by all *Builder classes. The generate_file method always takes an output_file parameter, which is the location the file will be saved to. The settings used by generate_file are passed to the *Builder object in the constructor.
Parameters: output_file (str) – Location to store output PCH file
- class espam.core.SolBuilder(settings)
Builder for SOL file format.
Creates a SOL file from the Eastern Snake Plain Aquifer (ESPA) Model Grid, and Soils GIS dataset for input into MKMOD.
This class is a subclass of Builder
>>> buildSOL = SolBuilder(settings) >>> buildSOL.generate_file("D:\out.sol")
- generate_file(output_file)
Builds a SOL file from the input settings
- Generates a SOL file, using the datasources from the settings.ini file:
See the SOL File Format document for more details on the SOL file format.
generate_file is a common method shared by all *Builder classes. The generate_file method always takes an output_file parameter, which is the location the file will be saved to. The settings used by generate_file are passed to the *Builder object in the constructor.
Parameters: output_file (str) – Location to store output SOL file
- class espam.core.TrbBuilder(settings)
Builder for TRB file format.
Creates a SOL file from the Eastern Snake Plain Aquifer (ESPA) Model Grid GIS dataset, Tributary GIS dataset, and Tributary spreadsheet for input into MKMOD.
This class is a subclass of Builder
>>> buildTRB = TrbBuilder(settings) >>> buildTRB.generate_file("D:\out.trb")
- generate_file(output_file)
Builds a TRB file from the input settings
- Generates a TRB file, using the datasources from the settings.ini file:
- Tributary GIS dataset defined by the tributary key
- Tributary Spreadsheet defined by the tributaryspreadsheet key
- ESPA Model Grid Feature Class defined by the espagrid key
See the TRB File Format document for more details on the TRB file format.
generate_file is a common method shared by all *Builder classes. The generate_file method always takes an output_file parameter, which is the location the file will be saved to. The settings used by generate_file are passed to the *Builder object in the constructor.
Parameters: output_file (str) – Location to store output TRB file
- espam.core.actual_month_from_water_year_month(water_year_month)
Get the actual month ordinal from the water year month ordinal A water year begins in October, making that month #1 in a water year. Water Year Month 12 is September.
- espam.core.actual_year_from_water_year(water_month, water_year)
Get gregorian year from water year
Get the actual gregorian year ordinal from the water year Water year begins in October, though it is numbered for the following year. So October of water year 1979, is actually 1978.