Documentation
¶
Index ¶
- Variables
- func AddCellsToOutput(v *Setup) error
- func ConnectSqlite(fileName string) (*sqlx.DB, error)
- func FilterCCDryLand(cSlice []CoeffCrop, z int, c int) (DryEtAdj float64, DryEtToRo float64, PerToRch float64, DpAdj float64, ...)
- func GetDescription(db *sqlx.DB) (desc string, err error)
- func GetFileKeys(db *sqlx.DB, wel bool) ([]string, error)
- func GetGrid(db *sqlx.DB) (grid int, err error)
- func GetSqlite(logger lg, path string, fileName string) (*sqlx.DB, error)
- func GetStartEndYrs(db *sqlx.DB) (SYr, EYr int, err error)
- func GetSteadyState(db *sqlx.DB) (bool, error)
- func InitializeDb(db *sqlx.DB, logger lg) error
- func PgConnx(myEnv map[string]string) (*sqlx.DB, error)
- type Adjustment
- type CellIntersect
- type Cellrc
- type CellrcDB
- type CoeffCrop
- type DB
- type DryCell
- type Efficiency
- type ExtRch
- type ExtWell
- type FileKeys
- type IrrCell
- type IrrCellResult
- type IrrDB
- type MIPumping
- type MIWell
- type MfResults
- func (m MfResults) ConvertToFt3PDay() float64
- func (m MfResults) ConvertToFtPDay() float64
- func (m MfResults) Date() time.Time
- func (m MfResults) IsNodeResult() bool
- func (m MfResults) Month() int
- func (m MfResults) Node() int
- func (m MfResults) RowCol() (int, int)
- func (m *MfResults) SetConvertedValue()
- func (m MfResults) UseValue() bool
- func (m MfResults) Value() float64
- func (m MfResults) Year() int
- type ModelCell
- type Note
- type NoteDB
- type Option
- type PNir
- type PPDB
- type Pumping
- type RchDB
- type RchResult
- type ResultsNote
- type SSWell
- type SWDelDB
- type SWDelResult
- type Setup
- type StDistances
- type WeatherStation
- type WelAnnualResult
- type WelDB
- type WelResult
- type WellNode
- type WellParcel
- type XyPoints
Constants ¶
This section is empty.
Variables ¶
var ( //go:embed sql/AggResultsNoExclude.sql AggResultsNoExclude string //go:embed sql/RchAggResultsNoExclude.sql RchAggResultsNoExclude string //go:embed sql/WelSingleResult.sql WelSingleResult string //go:embed sql/RchSingleResult.sql RchSingleResult string )
Functions ¶
func AddCellsToOutput ¶ added in v1.3.1
func FilterCCDryLand ¶
func FilterCCDryLand(cSlice []CoeffCrop, z int, c int) (DryEtAdj float64, DryEtToRo float64, PerToRch float64, DpAdj float64, RoAdj float64, err error)
FilterCCDryLand is a function that returns the dryland values of the coefficient of crops table by giving it a slice of CoeffCrop and a zone and crop.
func GetSqlite ¶
GetSqlite gets or sets the connection string for the sqlite3 results database.
It takes no args, and returns the db object for the connection
func InitializeDb ¶
InitializeDb creates the database results table if it doesn't exist, so the records of the transaction can be stored properly, also creates file_keys table for result file_type integer and a foreign key restriction to results table
Types ¶
type Adjustment ¶
type Adjustment int
const ( DryET Adjustment = 1 IrrEt Adjustment = 2 NirEt Adjustment = 3 )
type CellIntersect ¶
type CellIntersect struct { Node int `db:"node"` Soil int `db:"soil_code"` CZone int `db:"coeff_zone"` CellArea float64 `db:"cell_area"` Mtg sql.NullFloat64 `db:"mtg"` NpIrrArea sql.NullFloat64 `db:"nip_area"` NpDryArea sql.NullFloat64 `db:"ndp_area"` SpIrrArea sql.NullFloat64 `db:"sip_area"` SpDryArea sql.NullFloat64 `db:"sdp_area"` PointX float64 `db:"pointx"` PointY float64 `db:"pointy"` }
func GetCellAreas ¶
func GetCellAreas(v *Setup, y int) (cells []CellIntersect, err error)
GetCellAreas is a function to return the amount of area within each model cell that is covered by parcels of irrigated and dryland. It also returns the area, soil code, and zone of the cell in a slice of CellIntersect Struct. It implements the debug mode to only return 200 cells which were selected as having good data.
func GetSSCellAreas1 ¶ added in v1.3.12
func GetSSCellAreas1(v *Setup) (cells []CellIntersect, err error)
GetSSCellAreas1 is a function for the Steady State Run to return the amount of area within each model cell for the first two stress periods. NO parcels are included. It returns the area, soil code, and zone of the cell in a slice of CellIntersect Struct.
func GetSSCellAreas2 ¶ added in v1.3.12
func GetSSCellAreas2(v *Setup) (cells []CellIntersect, err error)
GetSSCellAreas2 is a function to return the amount of area within each model cell that is covered by parcels of surface water irrigated and dryland parcels. It returns the area, soil code, and zone of the cell in a slice of CellIntersect Struct.
func (CellIntersect) GetLossFactor ¶ added in v1.2.0
func (c CellIntersect) GetLossFactor() float64
func (CellIntersect) GetXY ¶
func (c CellIntersect) GetXY() (x float64, y float64)
GetXY is a method of CellIntersect struct that returns the XY locations for use in the Distances function and is required by the XyPoints interface.
func (CellIntersect) VegArea ¶
func (c CellIntersect) VegArea() float64
VegArea is a method of the CellIntersect struct that returns the total area that isn't covered by a parcel (dry or irr) of a cell and returns an area. Checks for cropArea > cell area as small parcel overlaps can make this negative which cannot be introduced to equations.
type CoeffCrop ¶
type CoeffCrop struct { Zone int `db:"zone"` Crop int `db:"crop"` DryEtAdj float64 `db:"dryetadj"` IrrEtAdj float64 `db:"irretadj"` NirAdjFactor float64 `db:"niradjfactor"` FslGW float64 `db:"fslgw"` DryEtToRo float64 `db:"dryettoro"` FslSW float64 `db:"fslsw"` PerToRch float64 `db:"pertorch"` DpAdj float64 `db:"dpadj"` RoAdj float64 `db:"roadj"` }
func GetCoeffCrops ¶
GetCoeffCrops is a function that calls the database to get the list of coefficients for each crop and zone in the model and returns a slice of CoeffCrop.
func (CoeffCrop) FilterValues ¶
FilterValues is a method that will return the values that you would use to filter a slice of CoeffCrop struct for a filter function, returns the zone and the crop as integers
type DryCell ¶
type DryCell struct { Node int `db:"node"` Mtg sql.NullFloat64 `db:"mtg"` CellArea float64 `db:"c_area"` DryArea float64 `db:"d_area"` PId int64 `db:"parcel_id"` Nrd string `db:"nrd"` }
DryCell is a struct that holds the data for each cell and the parcel data associated with it including crops and the amount of crop that is included.
func GetDryCells ¶
GetDryCells is a function that returns a struct of cells with parcels that are within it including the crops and acres within each cell. If there are more then one parcel within a cell, the cell will be listed multiple times.
func GetDrySSCells ¶ added in v1.3.12
func (DryCell) GetLossFactor ¶ added in v1.2.0
type Efficiency ¶
type Efficiency struct { Yr int `db:"yr"` AeFlood float64 `db:"ae_flood"` AeSprinkler float64 `db:"ae_sprinkler"` }
func GetAppEfficiency ¶
func GetAppEfficiency(pgDB *sqlx.DB) (efficiencies []Efficiency)
GetAppEfficiency is a function that returns the application efficiency for use in calculations throughout the app.
func GetSSAppEfficiency ¶ added in v1.3.12
func GetSSAppEfficiency() (efficiencies []Efficiency)
GetSSAppEfficiency is a function that returns the application efficiency for use in calculations throughout the Steady State portion of the app, it is fixed and doesn't use the database. The values are fixed and are made for years of 1893 through 1952.
type ExtRch ¶ added in v1.0.4
type ExtRch struct { Node int `db:"node"` Size float64 `db:"cell_size"` Yr int `db:"yr"` Mnth int `db:"mnth"` FileType int `db:"file_type"` Rch float64 `db:"rch"` }
func GetExtRecharge ¶ added in v1.0.4
GetExtRecharge is a function to return a slice of ExtRch filled with the ext_recharge data from the database and used in the model to create the recharge values for the external non-NRD areas.
type ExtWell ¶ added in v1.0.4
type ExtWell struct { Yr int `db:"yr"` Mnth int `db:"mnth"` FileType int `db:"file_type"` Pumping float64 `db:"pmp"` Node int `db:"node"` }
func GetExternalWells ¶ added in v1.0.4
GetExternalWells is a function to query the external pumping from the database and returns a slice of ExtWell as well as includes handling the debug mode.
type IrrCell ¶
type IrrCell struct { Node int `db:"node"` CellArea float64 `db:"c_area"` IrrArea float64 `db:"i_area"` ParcelId int `db:"parcel_id"` Nrd string `db:"nrd"` Mtg sql.NullFloat64 `db:"mtg"` }
IrrCell is a struct to hold the data of each cell and parcel intersect, it includes the cert, crops, and other characteristics important to the calculations.
func GetCellsIrr ¶
GetCellsIrr gets the cells that have irrigation within them and splits them by parcel. If a cell has multiple parcels there will be multiples of the same cell listed. This includes both nrd irrigated acres.
func GetCellsIrrPost97 ¶ added in v1.2.3
GetCellsIrrPost97 a Post 97 version of this function that gets the cells that have irrigation within them and splits them by parcel. If a cell has multiple parcels there will be multiples of the same cell listed. This includes both nrd irrigated acres. It limits to the actual parcels during that year without GWO, then goes to 1997 for GWO parcels, combines them and sends it off.
func GetSSCellsIrr ¶ added in v1.3.12
GetSSCellsIrr is a function to return the irrigated cells for 1953 only where there are surface water parcels. Any GW only parcels are not included in this function.
func (IrrCell) GetLossFactor ¶ added in v1.2.0
type IrrCellResult ¶
type IrrDB ¶
type IrrDB struct {
// contains filtered or unexported fields
}
func IrrResultDB ¶
IrrResultDB is a function that returns the IrrDB struct setup to insert values into the results database for the Irrigated parcel functions.
func (*IrrDB) Add ¶
func (db *IrrDB) Add(i IrrCellResult) error
Add is a method to NvDB to add a record that will get saved.
type MIWell ¶ added in v1.1.0
type MIWell struct { WellId int `db:"id"` WellName string `db:"wellname"` Rate int `db:"defaultq"` MuniWell bool `db:"muni_well"` IndustWell bool `db:"indust_well"` Stop97 bool `db:"stop_97"` Start97 bool `db:"start_97"` Node int `db:"node"` Pumping []MIPumping }
func GetMIWells ¶ added in v1.1.0
func (*MIWell) MIFileType ¶ added in v1.1.0
type MfResults ¶ added in v1.1.0
type MfResults struct { CellNode int `db:"cell_node"` CellSize sql.NullFloat64 `db:"cell_size"` ResultDate time.Time `db:"dt"` Rslt float64 `db:"rslt"` Rw sql.NullInt64 `db:"rw"` Clm sql.NullInt64 `db:"clm"` ConvertedValue bool // value in Rslt is already converted, no need to use convert methods }
func GetAggResults ¶ added in v1.1.0
func SingleResult ¶ added in v1.1.0
func (MfResults) ConvertToFt3PDay ¶ added in v1.3.12
func (MfResults) ConvertToFtPDay ¶ added in v1.3.12
func (MfResults) IsNodeResult ¶ added in v1.3.12
func (*MfResults) SetConvertedValue ¶ added in v1.3.12
func (m *MfResults) SetConvertedValue()
type ModelCell ¶
type ModelCell struct { Node int `db:"node"` SoilCode int `db:"soil_code"` CoeffZone int `db:"coeff_zone"` Zone int `db:"zone"` Mtg float64 `db:"mtg"` PointX float64 `db:"pointx"` PointY float64 `db:"pointy"` Rw int `db:"rw"` Clm int `db:"clm"` }
func GetCells ¶
GetCells is a function to retrieve the model cells from the database and return a struct of ModelCell. It also handles debug mode to only return a slice of 50 cells.
type NoteDB ¶ added in v1.2.3
type NoteDB struct {
// contains filtered or unexported fields
}
func ResultsNoteDB ¶ added in v1.2.3
ResultsNoteDB is a function that returns a db struct that includes a sql connection, a insert statement, and buffer to add notes to the output database.
type Option ¶ added in v1.2.0
type Option func(*Setup)
func WithLogger ¶ added in v1.2.0
func WithMF640Grid ¶ added in v1.3.7
func WithMF640Grid() Option
func WithNoExcessFlow ¶ added in v1.5.0
func WithNoExcessFlow() Option
func WithNoSQLite ¶ added in v1.2.0
func WithNoSQLite() Option
func WithOldGrid ¶ added in v1.3.0
func WithOldGrid() Option
func WithPost97 ¶ added in v1.2.3
func WithPost97() Option
func WithSteadyState ¶ added in v1.3.12
WithSteadyState sets the Steady State Bool to true and also sets the years to SYear to 1893 and EYear to 1952
type ResultsNote ¶ added in v1.1.1
type SSWell ¶ added in v1.0.4
type SSWell struct { Id int `db:"id"` WellName int `db:"wellname"` Rate int `db:"defaultq"` Node int `db:"node"` MVolume [12]float64 }
func GetSSWells ¶ added in v1.0.4
GetSSWells is a function that gets the data from the postgres DB and returns a slice of SSWell and also includes a call to the SSWell.monthlyVolume() method to set the monthly data from the annual data that is in the database.
type SWDelDB ¶ added in v1.2.2
type SWDelDB struct {
// contains filtered or unexported fields
}
func (*SWDelDB) Add ¶ added in v1.2.2
func (db *SWDelDB) Add(delivery SWDelResult) error
type SWDelResult ¶ added in v1.2.2
type Setup ¶
type Setup struct { PgDb *sqlx.DB SqliteDB bool SlDb *sqlx.DB SYear int EYear int Logger *logging.TheLogger PNirDB *DB RchDb *RchDB AppDebug bool NoExcessFlow bool Post97 bool OldGrid bool MF640Grid bool SteadyState bool }
type StDistances ¶
func Distances ¶
func Distances(points XyPoints, wStations []WeatherStation) (dist []StDistances, err error)
Distances is a function that that returns the top three weather stations from the list with the appropriate weighting factor. Used to make CSResults Distribution.
type WeatherStation ¶
type WeatherStation struct { Code string `db:"code"` PointX float64 `db:"pointx"` PointY float64 `db:"pointy"` }
func GetWeatherStations ¶
func GetWeatherStations(db *sqlx.DB) (wStations []WeatherStation, err error)
GetWeatherStations is a function to return a slice of WeatherStation that includes the weather station text id (code) and the X and Y coordinates of it's location.
type WelAnnualResult ¶ added in v1.0.4
WelAnnualResult is a struct that is used to construct the well result and includes a 12-month array
func (*WelAnnualResult) AddPumping ¶ added in v1.0.4
func (wr *WelAnnualResult) AddPumping(pump [12]float64, welCount float64)
AddPumping is a method to add more pumping to the WelAnnualResult by pumping and a welCount that is the number of wells that it should be divided by.
type WelDB ¶ added in v1.0.4
type WelDB struct {
// contains filtered or unexported fields
}
WelDB is a struct for the sql database, statement and buffer that is used to save information in chunks
func ResultsWelDB ¶ added in v1.0.4
ResultsWelDB is a function that creates the WelDB struct and contains the SQL statement to insert the records, it also accepts a slice of WelResult used for the buffer
func (*WelDB) Add ¶ added in v1.0.4
Add is a method of WelDB that adds a record to the buffer, but we accept a WelAnnualResult or WelResult struct and create 12 WelResult records for WelAnnualResult and remove the zeros. If there is a WelResult sent it will just save that value directly to the buffer. If the buffer is full it calls the Flush method.
type WelResult ¶ added in v1.0.4
type WelResult struct { Wellid int `db:"well_id"` Node int `db:"cell_node"` Dt time.Time `db:"dt"` FileType int `db:"file_type"` Result float64 `db:"result"` }
WelResult is a struct for the final result to be saved to db that is a value per well, per month
type WellNode ¶ added in v1.0.4
type WellNode struct { WellId int `db:"wellid"` RegCd sql.NullString `db:"regcd"` Node int `db:"node"` Nrd string `db:"nrd"` }
func GetWellNode ¶ added in v1.0.4
GetWellNode is a function that gets the wellid, regno and node number of the well so that we can add a location to the well when it is written out along with the nrd.
type WellParcel ¶ added in v1.0.4
type WellParcel struct { ParcelId int `db:"parcel_id"` WellId int `db:"wellid"` Nrd string `db:"nrd"` Yr int `db:"yr"` }
func GetWellParcels ¶ added in v1.0.4
func GetWellParcels(v *Setup) ([]WellParcel, error)
GetWellParcels is a function that gets all the well parcel junction table values and creates one struct from them and also includes the year of the join as well as the nrd.
func GetWellParcelsPost97 ¶ added in v1.2.3
func GetWellParcelsPost97(v *Setup) ([]WellParcel, error)
GetWellParcelsPost97 is a function that gets all the well parcel junction table values and creates one struct from them and also includes the year of the join as well as the nrd but replaces any GWO parcels with the 1997 GWO parcels.