Closed juliettelavoie closed 1 year ago
I think I have a solution:
I think I can just do ds_ref_unstack = xs.utils.unstack_fill_nan(ds_ref_stack, coords=('rlat', 'rlon'))
.
I think the point of the coords file is for nans and there is no real nans over the domain in the RDRS data.
On the QC domain, when I extract my region, I have nans but only outside of my region. After the unstack, I lose the data for lat and lon outside of my domain, but that doesn't matter.
# search
cat_ref = xs.search_data_catalogs(variables_and_freqs={'tasmax':'D'},
allow_resampling= False,
data_catalogs=['reconstruction-extra.json'],
allow_conversion= True,
periods=['1995','1996'],
other_search_criteria={'source': 'RDRS'})
# extract
region_dict= {
'name': 'QC-RSDS',
'method': 'bbox',
'bbox':{
'lon_bnds': [ -83, -55 ],
'lat_bnds': [ 42, 63 ] }}
dc = cat_ref.popitem()[1]
ds_ref = xs.extract_dataset(catalog=dc,
region=region_dict,
)['D']
mask=ds_ref.tasmax.isel(time=0, drop=True).notnull()
ds_ref_stack = xs.utils.stack_drop_nans(ds_ref,mask)
ds_ref_unstack = xs.utils.unstack_fill_nan(ds_ref_stack, coords=('rlat', 'rlon'))
diff= ds_ref_unstack.tasmax- ds_ref.tasmax
plt.figure()
diff.isel(time=0).plot()
diff_lat= ds_ref_unstack.lat- ds_ref.lat
plt.figure()
diff_lat.plot()
diff_lon= ds_ref_unstack.lat- ds_ref.lat
plt.figure()
diff_lon.plot()
I will test it on the complete workflow when the issue with the disk where I store my files is fixed.
Still no solution for using a file with stack_drop_nan
and a rotated grid. But, the info-crue workflow works using coords=('rlat', 'rlon')
, so I will close this issue.
We are adding NaNs to RDRS now, so this is an issue again.
Setup Information
Description
I don't know if this is really a bug or a feature request. I have reference data on a rotated grid and I want to use it in my workflow. The dataset set has dimensions rlat and rlon. It also has lat and lon as coordinates. In my workflow, I stack the reference, extract simulation, regrid sim on ref and bias_adjust.
When I try to unstack, I run into an error (see below).
Steps To Reproduce
Here is the raw ref data and the stack ref data:
The issue is here.
Additional context
If I drop
lat
andlon
fromds
the unstacking works, but I can't regrid my simulation (in lat and lon) to my ref (in loc with only rlat and rlon).I am trying to modify
stack_fill_nan
to make it work, but I haven't figured it out yet. Any help would be welcome !(I will do a PR if I can figure out a way to fix it in xscen, but I am also looking for a way to just fix it in my workflow.)
Contribution