-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* change dataset_type into separate table * add fixture for unit table * fix API response structure * refactor base dataset reader * combine forecast and historical into 1 api * add test for data reader * add providers filter in measurement api * fix lint * update database diagram with dataset_type table
- Loading branch information
1 parent
3c6609b
commit fdaf120
Showing
25 changed files
with
1,325 additions
and
708 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
[ | ||
{ | ||
"model": "gap.datasettype", | ||
"pk": 1, | ||
"fields": { | ||
"name": "Climate Reanalysis", | ||
"description": "", | ||
"type": "historical" | ||
} | ||
}, | ||
{ | ||
"model": "gap.datasettype", | ||
"pk": 2, | ||
"fields": { | ||
"name": "Short-term Forecast", | ||
"description": "", | ||
"type": "forecast" | ||
} | ||
}, | ||
{ | ||
"model": "gap.datasettype", | ||
"pk": 3, | ||
"fields": { | ||
"name": "Seasonal Forecast", | ||
"description": "", | ||
"type": "forecast" | ||
} | ||
}, | ||
{ | ||
"model": "gap.datasettype", | ||
"pk": 4, | ||
"fields": { | ||
"name": "Ground Observational", | ||
"description": "", | ||
"type": "historical" | ||
} | ||
}, | ||
{ | ||
"model": "gap.datasettype", | ||
"pk": 5, | ||
"fields": { | ||
"name": "Airborne Observational", | ||
"description": "", | ||
"type": "historical" | ||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
[ | ||
{ | ||
"model": "gap.unit", | ||
"pk": 1, | ||
"fields": { | ||
"name": "mm", | ||
"description": null | ||
} | ||
}, | ||
{ | ||
"model": "gap.unit", | ||
"pk": 3, | ||
"fields": { | ||
"name": "MJ/sqm", | ||
"description": null | ||
} | ||
}, | ||
{ | ||
"model": "gap.unit", | ||
"pk": 4, | ||
"fields": { | ||
"name": "mm day-1", | ||
"description": null | ||
} | ||
}, | ||
{ | ||
"model": "gap.unit", | ||
"pk": 5, | ||
"fields": { | ||
"name": "atm", | ||
"description": null | ||
} | ||
}, | ||
{ | ||
"model": "gap.unit", | ||
"pk": 6, | ||
"fields": { | ||
"name": "g/m3", | ||
"description": null | ||
} | ||
}, | ||
{ | ||
"model": "gap.unit", | ||
"pk": 7, | ||
"fields": { | ||
"name": "W/m2", | ||
"description": null | ||
} | ||
}, | ||
{ | ||
"model": "gap.unit", | ||
"pk": 8, | ||
"fields": { | ||
"name": "°C", | ||
"description": null | ||
} | ||
}, | ||
{ | ||
"model": "gap.unit", | ||
"pk": 9, | ||
"fields": { | ||
"name": "Degrees from North", | ||
"description": null | ||
} | ||
}, | ||
{ | ||
"model": "gap.unit", | ||
"pk": 10, | ||
"fields": { | ||
"name": "m/s", | ||
"description": null | ||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# coding=utf-8 | ||
""" | ||
Tomorrow Now GAP. | ||
.. note:: Helper for reading NetCDF File | ||
""" | ||
|
||
from gap.models import Dataset | ||
from gap.utils.netcdf import NetCDFProvider | ||
from gap.providers.cbam import CBAMNetCDFReader | ||
from gap.providers.salient import SalientNetCDFReader | ||
from gap.providers.tahmo import TahmoDatasetReader | ||
|
||
|
||
def get_reader_from_dataset(dataset: Dataset): | ||
"""Create a new Reader from given dataset. | ||
:param dataset: Dataset to be read | ||
:type dataset: Dataset | ||
:raises TypeError: if provider is neither CBAM or Salient | ||
:return: Reader Class Type | ||
:rtype: CBAMNetCDFReader|SalientNetCDFReader | ||
""" | ||
if dataset.provider.name == NetCDFProvider.CBAM: | ||
return CBAMNetCDFReader | ||
elif dataset.provider.name == NetCDFProvider.SALIENT: | ||
return SalientNetCDFReader | ||
elif dataset.provider.name == 'Tahmo': | ||
return TahmoDatasetReader | ||
else: | ||
raise TypeError( | ||
f'Unsupported provider name: {dataset.provider.name}' | ||
) |
Oops, something went wrong.