From ec7cf9dbf1e4cb88ada65d18dc594646598d847a Mon Sep 17 00:00:00 2001 From: sebastienlanglois Date: Wed, 21 Jun 2023 16:56:41 -0400 Subject: [PATCH] remove dropna --- xdatasets/workflows.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/xdatasets/workflows.py b/xdatasets/workflows.py index 46f6a60..0e9e639 100644 --- a/xdatasets/workflows.py +++ b/xdatasets/workflows.py @@ -99,6 +99,7 @@ def hydrometric_request(dataset_name, ds = open_dataset(dataset_name, catalog) try: + ds = ds.sel(variable=variables) ds = ds[variables] except: pass @@ -164,8 +165,20 @@ def hydrometric_request(dataset_name, dataset_name) # Remove all dimension values that are not required anymore after previous filetring - for dim in ds.dims: - ds = ds.dropna(dim, 'all') + # This returns a cleaner dataset at the cost of a compute + # _to_stack = [] + # for dim in ds.dims: + # if len(ds[dim]) >1: + # _to_stack.append(dim) + # print('stack') + # ds = ds.stack(stacked=_to_stack) + + ## Drop the pixels that only have NA values. + # print('dropna') + # ds = ds.dropna("stacked", how="all") + + # print('unstack') + # ds = ds.unstack('stacked') return ds