crops

package
v0.0.0-...-cd09ded Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NASSCropMap

func NASSCropMap() map[string]Crop

NASSCropMap is a map of Crops to NASS Crop ID #s

func NewProductionFunction

func NewProductionFunction(mcfp []float64, mclp []float64, mfc []float64, cs CropSchedule, hc float64, latePlantingLoss float64) productionFunction

NewProductionFunction is the constructor for the unexported productionFunction which represents the costs associated with producing a crop

Types

type Crop

type Crop struct {
	SubstituteCrop Substitute
	// contains filtered or unexported fields
}

Crop describes a crop that can be used to compute agricultural consequences

func BuildCrop

func BuildCrop(cropid byte, cropname string) Crop

BuildCrop builds a crop since the properties of crop are not exported

func ReadFromXML

func ReadFromXML(filePath string) Crop

ReadFromXML reads crop schedules loss functions and production functions from xml (HEC-FIA format)

func (Crop) Compute

func (c Crop) Compute(event hazards.HazardEvent) (consequences.Result, error)

Compute implements concequence.Receptor on crop

func (Crop) GetCropID

func (c Crop) GetCropID() byte

GetCropID fulfils the crops.CropType interface

func (Crop) GetCropName

func (c Crop) GetCropName() string

GetCropName fulfils the crops.CropType interface

func (Crop) GetTotalMarketValue

func (c Crop) GetTotalMarketValue() float64

GetTotalMarketValue returns crop.totalMarketValue

func (Crop) GetX

func (c Crop) GetX() float64

GetX fulfils the consequences.Locatable interface

func (Crop) GetY

func (c Crop) GetY() float64

GetY fulfils the consequences.Locatable interface

func (Crop) Location

func (c Crop) Location() geography.Location

func (*Crop) WithCropSchedule

func (c *Crop) WithCropSchedule(cs CropSchedule) Crop

WithCropSchedule allows the setting of the cropschedule

func (*Crop) WithLocation

func (c *Crop) WithLocation(xloc float64, yloc float64) Crop

WithLocation allows the construction of a location on a crop

func (*Crop) WithLossFunction

func (c *Crop) WithLossFunction(lf DamageFunction) Crop

WithLossFunction allows the setting of the loss function

func (*Crop) WithOutput

func (c *Crop) WithOutput(cropYeild float64, price float64) Crop

WithOutput allows the setting of the yeild per acre and price per unit of output and resulting value per output

func (*Crop) WithProductionFunction

func (c *Crop) WithProductionFunction(pf productionFunction) Crop

WithProductionFunction allows the setting of the production function

type CropDamageCase

type CropDamageCase byte

CropDamageCase provides a structured response for the possible outcomes from CropSchedule

const (
	Unassigned              CropDamageCase = 0
	Impacted                CropDamageCase = 1
	NotImpactedDuringSeason CropDamageCase = 2
	PlantingDelayed         CropDamageCase = 4
	NotPlanted              CropDamageCase = 8
	SubstituteCrop          CropDamageCase = 16
)

CropDamageCases include Unassigned, Impacted, NotImpactedDuringSeason, PlantingDelayed, NotPlanted, or SubstituteCrop

func (CropDamageCase) String

func (cdc CropDamageCase) String() string

type CropSchedule

type CropSchedule struct {
	StartPlantingDate time.Time
	LastPlantingDate  time.Time
	DaysToMaturity    int
}

CropSchedule stores the start and end of planting season, and time to maturity in days

func (CropSchedule) ComputeCropDamageCase

func (cs CropSchedule) ComputeCropDamageCase(h hazards.ArrivalandDurationEvent) CropDamageCase

ComputeCropDamageCase evaluates a crop schedule against a hazard arrival and duration to determine impact on the crop season.

type CropType

type CropType interface {
	GetCropID() byte
	GetCropCategory() string
}

CropType describes the relationship of the byte value in a NASSCDL to the Crop name (crop category in their terminology)

type DamageFunction

type DamageFunction struct {
	DurationDamageCurves map[float64][]float64 //[days]][]damages by month in percents
}

DamageFunction manages the methodology for computing damages to crops based on a duration and seasonal damage curves

func (DamageFunction) ComputeDamagePercent

func (df DamageFunction) ComputeDamagePercent(h hazards.ArrivalandDurationEvent) float64

ComputeDamagePercent takes an input Arrival time and duration based event and produces a duration damage based on the season of the start of the impact.

type Substitute

type Substitute struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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