Skip to content

Commit

Permalink
Feat tio zarr reader (#179)
Browse files Browse the repository at this point in the history
* update fixture dataset_attrib for tio

* add zarr reader for tio shortterm forecast

* fix lint

* add tio attributes to measurement documentation

* add test for tio zarr reader
  • Loading branch information
danangmassandy authored Oct 10, 2024
1 parent 294ac32 commit 678893e
Show file tree
Hide file tree
Showing 5 changed files with 668 additions and 4 deletions.
88 changes: 88 additions & 0 deletions django_project/gap/fixtures/8.dataset_attribute.json
Original file line number Diff line number Diff line change
Expand Up @@ -955,5 +955,93 @@
"source_unit": 5,
"ensembles": false
}
},
{
"model": "gap.datasetattribute",
"pk": 88,
"fields": {
"dataset": 4,
"attribute": 15,
"source": "total_rainfall",
"source_unit": 1,
"ensembles": false
}
},
{
"model": "gap.datasetattribute",
"pk": 89,
"fields": {
"dataset": 4,
"attribute": 8,
"source": "total_evapotranspiration_flux",
"source_unit": 1,
"ensembles": false
}
},
{
"model": "gap.datasetattribute",
"pk": 90,
"fields": {
"dataset": 4,
"attribute": 9,
"source": "max_temperature",
"source_unit": 5,
"ensembles": false
}
},
{
"model": "gap.datasetattribute",
"pk": 91,
"fields": {
"dataset": 4,
"attribute": 17,
"source": "min_temperature",
"source_unit": 5,
"ensembles": false
}
},
{
"model": "gap.datasetattribute",
"pk": 92,
"fields": {
"dataset": 4,
"attribute": 36,
"source": "precipitation_probability",
"source_unit": 6,
"ensembles": false
}
},
{
"model": "gap.datasetattribute",
"pk": 93,
"fields": {
"dataset": 4,
"attribute": 54,
"source": "humidity_maximum",
"source_unit": 6,
"ensembles": false
}
},
{
"model": "gap.datasetattribute",
"pk": 94,
"fields": {
"dataset": 4,
"attribute": 55,
"source": "humidity_minimum",
"source_unit": 6,
"ensembles": false
}
},
{
"model": "gap.datasetattribute",
"pk": 95,
"fields": {
"dataset": 4,
"attribute": 56,
"source": "wind_speed_avg",
"source_unit": 8,
"ensembles": false
}
}
]
15 changes: 12 additions & 3 deletions django_project/gap/providers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
.. note:: Helper for reading NetCDF File
"""

from gap.models import Dataset
from gap.models import Dataset, DatasetStore
from gap.utils.netcdf import NetCDFProvider
from gap.providers.cbam import CBAMZarrReader, CBAMNetCDFReader # noqa
from gap.providers.salient import SalientNetCDFReader, SalientZarrReader # noqa
from gap.providers.tahmo import TahmoDatasetReader
from gap.providers.tio import (
TomorrowIODatasetReader,
PROVIDER_NAME as TIO_PROVIDER
PROVIDER_NAME as TIO_PROVIDER,
TioZarrReader
)


Expand All @@ -31,8 +32,16 @@ def get_reader_from_dataset(dataset: Dataset):
return SalientZarrReader
elif dataset.provider.name == 'Tahmo':
return TahmoDatasetReader
elif dataset.provider.name == TIO_PROVIDER:
elif (
dataset.provider.name == TIO_PROVIDER and
dataset.store_type == DatasetStore.EXT_API
):
return TomorrowIODatasetReader
elif (
dataset.provider.name == TIO_PROVIDER and
dataset.store_type == DatasetStore.ZARR
):
return TioZarrReader
else:
raise TypeError(
f'Unsupported provider name: {dataset.provider.name}'
Expand Down
Loading

0 comments on commit 678893e

Please sign in to comment.