endpoints

package
v0.0.0-...-043deff Latest Latest
Warning

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

Go to latest
Published: May 2, 2023 License: AGPL-3.0, GPL-3.0-or-later Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EcoGET

func EcoGET(cache *cache.Cache) func(url.Values) (*BenefitsWrapper, error)

func EcoScenarioPOST

func EcoScenarioPOST(cache *cache.Cache) func(*ScenarioPostData) (*Scenario, error)

Take an array of prospective trees where each tree contains an array of diamaters, one for each year the tree is alive, and return an array of eco calulations, one for each year

Trees will die of as part of the scenario, so the `diameters` arrays for the trees may have different lengths. Trees that die may be replaced with other trees, so there will be trees that appear in the scenario at t > 0, so the `diameters` array may have initial elements set to 0.

Specifying a "region" for an individual tree will override the scenario-level "region" value.

The "years" parameter must be >= the length of the longest "diameters" array under "scenario_trees".

Request (with bogus example parameters):

POST /eco_scenario.json

{
  "region": "NoEastXXX",
  "instance_id": 1,
  "years": 3
  "scenario_trees": [
    {
      "otmcode": "CACO",
      "species_id": 1,
      "region": "NoEastXXX",
      "diameters": [1, 1.3, 1.7]
    }
  ]
}

Response (with bogus example values):

{
  "Years": [
    {
      "aq_nox_avoided":     0.01548490,
	 "aq_nox_dep":         0.00771784,
	 "aq_pm10_avoided":    0.00546863
    },
    {
      "aq_nox_avoided":     0.02548420,
	 "aq_nox_dep":         0.01973722,
	 "aq_pm10_avoided":    0.00676823
    },
    {
      "aq_nox_avoided":     0.05484902,
	 "aq_nox_dep":         0.04774471,
	 "aq_pm10_avoided":    0.00946822
    }
  ],
  "Total": {
    "aq_nox_avoided": ... ,
    "aq_nox_dep": ... ,
    "aq_pm10_avoided": ...
  }
}

func EcoSummaryPOST

func EcoSummaryPOST(cache *cache.Cache) func(*SummaryPostData) (*BenefitsWrapper, error)

func ITreeCodesGET

func ITreeCodesGET(cache *cache.Cache) func() *ITreeCodes

Types

type BenefitsWrapper

type BenefitsWrapper struct {
	Benefits map[string]float64
}

We can't marshall maps directly with go-rest so we just wrap it here

type ITreeCodes

type ITreeCodes struct {
	Codes map[string][]string
}

type Scenario

type Scenario struct {
	Total map[string]float64
	Years []map[string]float64
}

type ScenarioPostData

type ScenarioPostData struct {
	Region         string
	Instance_id    string
	Years          int
	Scenario_trees []ScenarioTree
}

type ScenarioTree

type ScenarioTree struct {
	Otmcode    string
	Species_id int
	Region     string
	Diameters  []float64
}

type SummaryPostData

type SummaryPostData struct {
	Region      string
	Query       string
	Instance_id string
}

Jump to

Keyboard shortcuts

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