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

add related coverages to coverage time series endpoint #86

Closed ricardogsilva closed 3 months ago

ricardogsilva commented 3 months ago

This PR adds the capability of getting time series data also for coverages which are related to the main one - this is useful in the context of showing the forecasts of several models for a given climatic variable.

The proposed implementation adds a self-referential many-to-many relationship to the coverageconfiguration table, and then exposes it in the admin, thus allowing a coverage configuration to be related to others. This is then used in the time-series API endpoint to retrieve data for these related coverages.

For example, a request like this:

GET http://webapp:5001/api/v2/coverages/time-series/tas_absolute_value_ensemble-rcp26-DJF?
    coords=POINT(11.5469 44.9524)&
    datetime=../..&
    include_coverage_data=true&
    coverage_data_smoothing=NO_SMOOTHING&
    coverage_data_smoothing=MOVING_AVERAGE_11_YEARS&
    include_coverage_related_data=true

Would cause the API to return:

The below image illustrates a possible outcome, where we show only the unsmoothed values of the main coverage and the smoothed values of all other time series:

image

In this example we are plotting the TAS absolute values of the 5-model ensemble for the RCP26 scenario in the DJF season (i.e. winter) as the main time series and also the individual values of four of those models (EC-EARTH-CCLM4-8-17, EC-EARTH-RACMO22E, EC-EARTH_RCA4 and HadGEM2-ES_RACMO22E)