From 96f7ff7a4b41f80cac7e1527a6a79efcbb5b7554 Mon Sep 17 00:00:00 2001 From: Matt Iannucci Date: Thu, 28 Sep 2023 10:42:09 -0400 Subject: [PATCH] Add ngofs loader --- xpublish-exploring/demo.py | 18 ++++++++++++------ xpublish-exploring/environment.yaml | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/xpublish-exploring/demo.py b/xpublish-exploring/demo.py index 5cf8323..f1b31c1 100644 --- a/xpublish-exploring/demo.py +++ b/xpublish-exploring/demo.py @@ -10,16 +10,22 @@ class TutorialDataset(Plugin): @hookimpl def get_datasets(self): - return list(xr.tutorial.file_formats) + tutorial_datasets = list(xr.tutorial.file_formats) + tutorial_datasets.append('ngofs2') + return tutorial_datasets @hookimpl def get_dataset(self, dataset_id: str): + print(dataset_id) try: - ds = xr.tutorial.open_dataset(dataset_id) - if ds.cf.coords['longitude'].dims[0] == 'longitude': - ds = ds.assign_coords(longitude=(((ds.longitude + 180) % 360) - 180)).sortby('longitude') - # TODO: Yeah this should not be assumed... but for regular grids we will viz with rioxarray so for now we will assume - ds = ds.rio.write_crs(4326) + if dataset_id == 'ngofs2': + ds = xr.open_dataset('nos.ngofs2.2ds.f001.20230928.t09z.nc', decode_times=False) + else: + ds = xr.tutorial.open_dataset(dataset_id) + if ds.cf.coords['longitude'].dims[0] == 'longitude': + ds = ds.assign_coords(longitude=(((ds.longitude + 180) % 360) - 180)).sortby('longitude') + # TODO: Yeah this should not be assumed... but for regular grids we will viz with rioxarray so for now we will assume + ds = ds.rio.write_crs(4326) return ds except HTTPError: return None diff --git a/xpublish-exploring/environment.yaml b/xpublish-exploring/environment.yaml index 4b2375b..cbad830 100644 --- a/xpublish-exploring/environment.yaml +++ b/xpublish-exploring/environment.yaml @@ -23,4 +23,4 @@ dependencies: - regionmask - ipykernel - pooch - \ No newline at end of file + - cftime \ No newline at end of file