parcels

package
v1.5.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2023 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdjFactor added in v1.3.12

func AdjFactor(cCrops []database.CoeffCrop, zone int, crop int, adj database.Adjustment) (nf float64, err error)

AdjFactor is a filter function that returns the NirAdjFactor from the CoeffCrop slice and limits it to the zone of the Parcel and the crop type.

func AdjustmentFactor added in v1.3.12

func AdjustmentFactor(p *Parcel, cCrops []database.CoeffCrop, adj database.Adjustment) (float64, error)

AdjustmentFactor function calculates the Parcel adjustment factor by weighting the crops and distribution of the crops in a Parcel by calling the nirFactor and then weighting it based on crop distribution

func Crop added in v1.3.12

func Crop(c int64, aData []fileio.StationResults) (nir [12]float64, ro [12]float64, dp [12]float64, et [12]float64)

Crop function filters the results to the integer crop that is included and returns the NIR, RunOff and Deep Percolation from those crops as three arrays.

func DistDeltaET added in v1.3.12

func DistDeltaET(deltaET [12]float64, roDpWt [12]float64) (ro [12]float64, dp [12]float64)

DistDeltaET is a function that returns the run off and deep percolation of the delta ET

func DistEtGain added in v1.3.12

func DistEtGain(etGain float64, psl [12]float64, etIrr [12]float64, etDry [12]float64) (distEtGain [12]float64, err error)

DistEtGain distributes the ET Gain by the monthly gain listed by post surface loss water, and if there are any remaining, it apportions it again to months without PSL but with ET differences.

func DistUsage added in v1.3.12

func DistUsage(annUsage []Usage, parcels *[]Parcel, post97 bool) error

func ExcessIrrReturnFlow added in v1.3.12

func ExcessIrrReturnFlow(psl [12]float64, distEtGain [12]float64, roDpWt [12]float64) (ro [12]float64, dp [12]float64)

ExcessIrrReturnFlow is a function that returns the excess irrigation return flows using the post surface loss irrigation with et gain and then distributed to ro and dp using the weighted values

func FilterEff added in v1.3.12

func FilterEff(efficiencies []database.Efficiency, year int) (f float64, s float64)

FilterEff returns the efficiency of flood and sprinkler for a given year.

func FilterParcelByCert added in v1.2.3

func FilterParcelByCert(p *[]Parcel, c string, post97 bool) (fParcels []int)

FilterParcelByCert filters a slice of parcels by the CertNum and returns a slice of the parcels that have that CertNum.

func GetUsage added in v1.3.12

func GetUsage(v *database.Setup) map[int][]Usage

GetUsage function returns a map with a year of year and a value of slice of usage struct for all cert usage in both nrds. It includes all years.

func PValues added in v1.3.12

func PValues(parcelValues [12]float64, cropsNIR [4][12]float64, cropCov [4]float64, stWeight float64, area float64) (values [12]float64)

PValues creates the parcel nir, ro, or dp by multiplying the cropNir with crop coverage by station weight to return a nir, ro, or dp portion for that parcel.

func SetAppWat added in v1.3.12

func SetAppWat(sw [12]float64, gw [12]float64, fsl float64) (appWat [12]float64, sL [12]float64, pSL [12]float64)

SetAppWat is a function that sets the applied water (appWat), surface loss of water (sL) and post surface loss of water (pSL) for each month of the parcel. It takes in surface water applied (sw), ground water applied (gw) and fraction of surface loss (fsl) and returns three arrays of monthly results.

func SetDeltaET added in v1.3.12

func SetDeltaET(et [12]float64, adjFactor float64) (deltaET [12]float64)

SetDeltaET returns the monthly amount of adjustment of ET that is created from the adjustment factor application

func SetET added in v1.3.12

func SetET(etBase [12]float64, distEtGain [12]float64) (et [12]float64)

SetET combines the distributed ET Gain with the base ET for a final ET Value

func SetEtBase added in v1.3.12

func SetEtBase(psl [12]float64, etIrr [12]float64, etDry [12]float64) (etBase [12]float64)

SetEtBase is a function that uses post surface loss irrigation to determine the etBase from etIrr and etDry and returns a monthly etBase value

func SetEtGain added in v1.3.12

func SetEtGain(cIR float64, psl float64, gir float64, appWat float64, eff float64, irrEt float64, dryEt float64) (gain float64, err error)

SetEtGain sets the annual gain for the parcel using a diminishing returns production function. Returns the amount of gain

func SetGirFact added in v1.3.12

func SetGirFact(eff float64) (gir float64, fsl float64)

SetGirFact is a function that sets the gross irrigation factor for the WSPP program and the fraction of surface loss amount depending on the efficiency passed in. It returns two float64 values used within the app.

func SetInitialRoDp added in v1.3.12

func SetInitialRoDp(csRo [12]float64, csDp [12]float64, adjRo float64, adjDp float64) (ro [12]float64, dp [12]float64)

SetInitialRoDp is a function to set the initial run off (Ro2) and Deep Perc (Dp2) from irrigation in the model of zero and handle the condition where water was applied but no nir was calculated so that all the water goes back to Ro and DP.

func SetPreGain added in v1.3.12

func SetPreGain(et [12]float64, dryEt [12]float64, appWat [12]float64, pslIrr [12]float64) (gainApWat float64, gainPsl float64, gainIrrEt float64, gainDryEt float64)

SetPreGain is a function to set some total variables if there is a presence of ETGain where irrEt > DryEt. This sums the irrigated ET, Dry ET, Applied Water, and Post Surface Loss Water during those months where the condition is met.

func SetRoDpWt added in v1.3.12

func SetRoDpWt(ro [12]float64, dp [12]float64) ([12]float64, error)

SetRoDpWt sets the weight of the runoff to deep percolation values for each month but is bound by 0.2 to 0.8. It returns a monthly array of percent that is runoff of the total of runoff + deep percolation; has a default value of 0.5.

func SumAnnual added in v1.3.12

func SumAnnual(data [12]float64) (total float64)

SumAnnual is a function to get the annual amount from a 12 month array of float64s, it returns a float64 total

func SumReturnFlows added in v1.3.12

func SumReturnFlows(v1 [12]float64, v2 [12]float64, v3 [12]float64) (sumValues [12]float64)

SumReturnFlows is a function to sum the three return flow sub variables into one.

Types

type IrrType

type IrrType int
const (
	Irrigated IrrType = 3
	DryLand   IrrType = 1
)

type Parcel

type Parcel struct {
	ParcelNo  int             `db:"parcel_id"`
	CertNum   sql.NullString  `db:"cert_num"`
	Area      float64         `db:"area"`
	Crop1     sql.NullInt64   `db:"crop1"`
	Crop2     sql.NullInt64   `db:"crop2"`
	Crop3     sql.NullInt64   `db:"crop3"`
	Crop4     sql.NullInt64   `db:"crop4"`
	IrrType   sql.NullString  `db:"irrig_type"`
	FirstIrr  sql.NullInt64   `db:"first_irr"`
	SwFac     sql.NullString  `db:"sw_fac"`
	ModelId   sql.NullString  `db:"model_id"`
	Crop1Cov  sql.NullFloat64 `db:"crop1_cov"`
	Crop2Cov  sql.NullFloat64 `db:"crop2_cov"`
	Crop3Cov  sql.NullFloat64 `db:"crop3_cov"`
	Crop4Cov  sql.NullFloat64 `db:"crop4_cov"`
	Sw        sql.NullBool    `db:"sw"`
	Gw        sql.NullBool    `db:"gw"`
	Subarea   sql.NullString  `db:"subarea"`
	Oa        sql.NullInt64   `db:"oa"`
	Nrd       string          `db:"nrd"`
	SwID      sql.NullInt64   `db:"sw_id"`
	PointX    float64         `db:"pointx"`
	PointY    float64         `db:"pointy"`
	SoilArea  float64         `db:"s_area"`
	SoilCode  int             `db:"soil_code"`
	CoeffZone int             `db:"coeff_zone"`
	Yr        int
	AppEff    float64
	Et        [12]float64
	DryEt     [12]float64
	Nir       [12]float64
	Ro        [12]float64
	Dp        [12]float64
	Pump      [12]float64
	SWDel     [12]float64
}

func DryLandParcels

func DryLandParcels(v *database.Setup, csResults map[string][]fileio.StationResults,
	wStations []database.WeatherStation, cCrop []database.CoeffCrop) (dryParcels []Parcel, err error)

DryLandParcels is a function that returns all the dryland parcels for the years of the simulation and also calls the methods to determine parcelNIR and dryland WSPP

func GetDryParcels added in v1.2.3

func GetDryParcels(v *database.Setup, Year int) []Parcel

GetDryParcels is a function that returns a slice of Parcel for a year of the dryland only parcels in the model.

func GetParcels added in v1.2.3

func GetParcels(v *database.Setup, Year int) []Parcel

GetParcels returns a list of all parcels with crops irrigation types and areas. Returns data for both nrds. There can be multiples of the same parcels listed with different soil types. It sets the year into a field in the struct.

func ParcelPump

func ParcelPump(v *database.Setup, csResults map[string][]fileio.StationResults,
	wStations []database.WeatherStation, cCrops []database.CoeffCrop) (AllParcels []Parcel, err error)

ParcelPump is the main function for the parcels, it gets the usage, efficiencies, operates the surface water conveyance loss and then calls the surface water delivery. It also creates the parcels then calls the ParcelPumpDB method to set the parcel pumping, it then loops through the years for each parcel and sends the diversions, calls parcel NIR, sets the efficiency for the parcel, adds SW delivery, adds the known pumping, and then simulates pumping for all other parcels. Finally, it writes out the pumping per parcel and then operates the WSPP routine to finish the RO and DP.

func ParcelPumpSS added in v1.3.12

func ParcelPumpSS(v *database.Setup, csResults map[string][]fileio.StationResults,
	wStations []database.WeatherStation, cCrops []database.CoeffCrop) (AllParcels []Parcel, err error)

ParcelPumpSS is the main function for the parcels, it gets the usage, efficiencies, operates the surface water conveyance loss and then calls the surface water delivery. It also creates the parcels then calls the ParcelPumpDB method to set the parcel pumping, it then loops through the years for each parcel and sends the diversions, calls parcel NIR, sets the efficiency for the parcel, adds SW delivery, adds the known pumping, and then simulates pumping for all other parcels. Finally, it writes out the pumping per parcel and then operates the WSPP routine to finish the RO and DP.

func ParcelsPost97 added in v1.3.12

func ParcelsPost97(allParcels []Parcel, p97GWOParcels []Parcel) (p97Parcels []Parcel)

func RemoveGWO added in v1.3.12

func RemoveGWO(allParcels []Parcel) (gwoRemoved []Parcel)

func (*Parcel) ChangeFallow added in v1.3.12

func (p *Parcel) ChangeFallow()

ChangeFallow is a method that changes any parcel with fallow to winter wheat as fallow is already built into winter wheat and rotates in that data.

func (*Parcel) DistributeUsage added in v1.3.12

func (p *Parcel) DistributeUsage(totalNIR float64, totalMonthlyNIR [12]float64, u float64)

DistributeUsage method receives the total NIR, monthly NIR values and usage for the cert and distributes that pumping to the parcel. It also sets the parcel metered property to true.

func (*Parcel) DpString added in v1.2.2

func (p *Parcel) DpString() string

DpString is a method to return a string of formatted data of the deep percolation data of a parcel

func (*Parcel) EstimatePumping added in v1.3.12

func (p *Parcel) EstimatePumping(v *database.Setup, cCrops []database.CoeffCrop) error

EstimatePumping is a method that is called on parcels that shouldEstimate == true so that we can estimate the amount of pumping that was done at the parcel since a well is present, but not metered. It fills the Pump field of the Parcel struct

func (*Parcel) GetFileType added in v1.3.12

func (p *Parcel) GetFileType() (int, error)

GetFileType is a method to get the Filetype int for parcel.

func (*Parcel) GetXY

func (p *Parcel) GetXY() (x float64, y float64)

GetXY is a method that returns the x and y coordinates of the centroid of the parcel

func (*Parcel) IsComingled added in v1.3.12

func (p *Parcel) IsComingled() bool

func (*Parcel) IsGW added in v1.3.12

func (p *Parcel) IsGW() bool

IsGW is a method that returns a bool if the parcel receives supply from groundwater

func (*Parcel) IsGWO added in v1.3.12

func (p *Parcel) IsGWO() bool

IsGWO is a method that returns a bool if the parcel is groundwater only

func (*Parcel) IsPost97 added in v1.3.12

func (p *Parcel) IsPost97() bool

func (*Parcel) IsSW added in v1.3.12

func (p *Parcel) IsSW() bool

IsSW is a method that returns a bool if the parcel receives surface water

func (*Parcel) IsSWO added in v1.3.12

func (p *Parcel) IsSWO() bool

IsSWO is a method that returns a bool true if a parcel is surface water only

func (*Parcel) NIRString added in v1.2.2

func (p *Parcel) NIRString() string

NIRString is a method to return the string of the NIR values and parcel number

func (*Parcel) NoCropCheck added in v1.3.12

func (p *Parcel) NoCropCheck()

NoCropCheck is a method to ensure that the parcel includes a crop to prevent errors in subsequent processes. It defaults a parcel to all corn if there is no crop present

func (*Parcel) ParcelNIR added in v1.2.3

func (p *Parcel) ParcelNIR(v *database.Setup, Year int, wStations []database.WeatherStation,
	csResults map[string][]fileio.StationResults, it IrrType) error

ParcelNIR is a method that adds the NIR, RO, and DP for each parcel from the CSResults and weather station data. It produces an intermediate results table of NIR in local sqlite for review and adds three maps to the parcel struct Values populated by this method are total acre-feet for the parcel

func (*Parcel) PrintNIR

func (p *Parcel) PrintNIR() string

PrintNIR is a method to return a string of the NIR of the parcel into a readable format

func (*Parcel) PumpString added in v1.3.12

func (p *Parcel) PumpString() string

PumpString is a method to return a string of data of the pumping

func (*Parcel) RoString added in v1.2.2

func (p *Parcel) RoString() string

RoString is a method to return a string of formatted data of the runoff data of a parcel

func (*Parcel) SWString added in v1.2.2

func (p *Parcel) SWString() string

SWString is a method to return a string of data of the surface water delivery and canal id of a parcel

func (*Parcel) SetAppEfficiency added in v1.3.12

func (p *Parcel) SetAppEfficiency(efficiencies []database.Efficiency, year int)

SetAppEfficiency is a Parcel method that uses the parcel IrrType and year to determine the application efficiency of the parcel and sets that in the Parcel struct. It takes a slice of Efficiency and year as they very through the study period.

func (*Parcel) SetWelFileType added in v1.0.4

func (p *Parcel) SetWelFileType() (fileType int, err error)

SetWelFileType is a method that returns the file type of the well that will be assigned pumping.

func (*Parcel) String

func (p *Parcel) String() string

String is a method of the parcel to return a string of data about the parcel for identification

func (*Parcel) WaterBalanceWSPP added in v1.3.12

func (p *Parcel) WaterBalanceWSPP(v *database.Setup) error

WaterBalanceWSPP method takes all the parcel information (SW delivery and GW Pumping) and creates a water balance to determine the amount of Runoff and Deep Percolation that occurs off of each parcel and sets those values within the parcel struct. This uses the methodology that is within the WSPP program.

type Usage

type Usage struct {
	CertNum string  `db:"cert_num"`
	UseAF   float64 `db:"usage_af"`
	Yr      int     `db:"yr"`
	Nrd     string  `db:"nrd"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL