geobeyond / Arpav-PPCV-backend

Backend di Piattaforma Proiezioni Climatiche per il Nord-Est.
Creative Commons Attribution 4.0 International
0 stars 1 forks source link

Implement API endpoint for generating time series for historical data #96

Closed ricardogsilva closed 3 months ago

ricardogsilva commented 3 months ago

Let's implement an API endpoint for generating time series data suitable for producing plots on the frontend.

Chart data for observations data has the following requirements:

With these requirements in mind, an API endpoint for requesting observation-related time series will look like this:

/api/v2/observations/{station_id}/time-series/{observation-variable-identifier}?
  datetime={datetime}&
  include_observations_data={true/false}&
  smoothing_algorithm={smoothing_algorithm}&
  include_decade_aggregation={true/false}&
  include_mann_kendall_trend={true/false}&
  mann_kendall_trend_start_year={mann_kendall_start_year}&
  mann_kendall_trend_end_year={mann_kendall_end_year}

Where:

The API response would be a JSON object of the form:

{
  "station_id": "{station_id}",
  "mann_kendall_trend": {
    "slope": 0.6,
    "intercept": 3.4,
    "significance": 0.9
  } 
  "values": [
    {
      "value": 5.6,
      "series": "tas_mean",
      "date": "1980-05-01"
    },
    {
      "value": 5.7,
      "series": "tas_mean",
      "date": "1980-06-01",
    },
    {
      "value": 5.4,
      "series": "mann_kendall_trend",
      "date": "1980-06-01",
    },
     {
      "value": 5.4,
      "series": "decade-1981-1990",
      "date": "1981-01-01",
    }
  ]
}