Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions dweather_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
from timezonefinder import TimezoneFinder
from dweather_client import gridded_datasets
from dweather_client.storms_datasets import IbtracsDataset, AtcfDataset, SimulatedStormsDataset
from dweather_client.ipfs_queries import AustraliaBomStations, CedaBiomass, CmeStationsDataset, DutchStationsDataset, DwdStationsDataset, DwdHourlyStationsDataset, GlobalHourlyStationsDataset, JapanStations, StationDataset, EauFranceDataset,\
YieldDatasets, FsaIrrigationDataset, AemoPowerDataset, AemoGasDataset, AesoPowerDataset, ForecastDataset, AfrDataset, DroughtMonitor, CwvStations, SpeedwellStations, TeleconnectionsDataset, CsvStationDataset, StationForecastDataset, SapStations
from dweather_client.ipfs_queries import AustraliaBomStations, CedaBiomass, CmeStationsDataset, DutchStationsDataset, DwdStationsDataset, DwdHourlyStationsDataset, GlobalHourlyStationsDataset, JapanStations, StationDataset, EauFranceDataset, \
YieldDatasets, FsaIrrigationDataset, AemoPowerDataset, AemoGasDataset, AesoPowerDataset, ForecastDataset, AfrDataset, DroughtMonitor, CwvStations, SpeedwellStations, TeleconnectionsDataset, CsvStationDataset, StationForecastDataset, SapStations, NQH2ODataset
from dweather_client.slice_utils import DateRangeRetriever, has_changed
from dweather_client.ipfs_errors import *
from io import StringIO
Expand Down Expand Up @@ -871,6 +871,11 @@ def get_afr_history(ipfs_timeout=None):
return dataset_obj.get_data()


def get_nqh2o_history(ipfs_timeout=None):
with NQH2ODataset(ipfs_timeout=ipfs_timeout) as dataset_obj:
return dataset_obj.get_data()


def has_dataset_updated(dataset, slices, as_of, ipfs_timeout=None):
"""
Determine whether any dataset updates generated after `as_of` affect any `slices` of date ranges.
Expand Down
15 changes: 15 additions & 0 deletions dweather_client/ipfs_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,21 @@ def get_data(self):
return ret_dict


class NQH2ODataset(IpfsDataset):
@property
def dataset(self):
return "NQH2O-weekly"

def get_data(self):
super().get_data()
hashes = self.traverse_ll(self.head)
ret_dict = {}
for h in hashes:
f = self.get_file_object(f"{h}/NQH2O.json")
ret_dict = {**ret_dict, **json.load(f)}
return ret_dict


class CedaBiomass(IpfsDataset):
"""
Instantiable class to pull CEDA biomass data
Expand Down
13 changes: 9 additions & 4 deletions dweather_client/tests/test_client.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from dweather_client.ipfs_errors import *
from dweather_client.tests.mock_fixtures import get_patched_datasets
from dweather_client.client import get_australia_station_history, get_station_history, get_gridcell_history, get_tropical_storms,\
get_yield_history, get_irrigation_data, get_power_history, get_gas_history, get_alberta_power_history, GRIDDED_DATASETS, has_dataset_updated,\
get_forecast_datasets, get_forecast, get_cme_station_history, get_european_station_history, get_hourly_station_history, get_drought_monitor_history, get_japan_station_history,\
get_afr_history, get_cwv_station_history, get_teleconnections_history, get_station_forecast_history, get_station_forecast_stations, get_eaufrance_history, get_sap_station_history
from dweather_client.client import get_australia_station_history, get_station_history, get_gridcell_history, get_tropical_storms, \
get_yield_history, get_irrigation_data, get_power_history, get_gas_history, get_alberta_power_history, GRIDDED_DATASETS, has_dataset_updated, \
get_forecast_datasets, get_forecast, get_cme_station_history, get_european_station_history, get_hourly_station_history, get_drought_monitor_history, get_japan_station_history, \
get_afr_history, get_cwv_station_history, get_teleconnections_history, get_station_forecast_history, get_station_forecast_stations, get_eaufrance_history, get_sap_station_history, get_nqh2o_history
from dweather_client.aliases_and_units import snotel_to_ghcnd
import pandas as pd
from io import StringIO
Expand Down Expand Up @@ -458,6 +458,11 @@ def test_afr():
assert len(afr_dict) >= 32


def test_nqh2o():
nqh2o_dict = get_nqh2o_history()
assert len(nqh2o_dict) >= 260


def test_drought_monitor():
drought_dict = get_drought_monitor_history(
"48", "071", ipfs_timeout=IPFS_TIMEOUT)
Expand Down