oceanspy
oceanspy copied to clipboard
LLC cutout with varList = None
- OceanSpy version: 0.2.0
Description
I was trying to make a cutout on the ECCO dataset in the ./oceanspy/tests/ECCO directory. I did almost the same thing as the test_subsample:
od_cut = od.subsample.cutout(
XRange=[-90, 20],
YRange=[20, 80],
ZRange=None,
transformation = 'arctic_crown',
centered = 'Atlantic'
)
The error message was
File ~/workspace/Temporary/wenrui/scratch/oceanspy/oceanspy/llc_rearrange.py:106, in LLCtransformation.arctic_crown(self, ds, varlist, centered, faces, chunks, drop)
104 for i in range(len(ARCT)):
105 if type(ARCT[i][0]) == _datype:
--> 106 ARCT[i] = _xr.merge(ARCT[i])
108 DSa2, DSa5, DSa7, DSa10 = ARCT
109 if type(DSa2) != _dstype:
File ~/miniconda3/envs/oceanspy_test/lib/python3.10/site-packages/xarray/core/merge.py:892, in merge(objects, compat, join, fill_value, combine_attrs)
890 for obj in objects:
891 if not isinstance(obj, (DataArray, Dataset, dict)):
--> 892 raise TypeError(
893 "objects must be an iterable containing only "
894 "Dataset(s), DataArray(s), and dictionaries."
895 )
897 obj = obj.to_dataset(promote_attrs=True) if isinstance(obj, DataArray) else obj
898 dict_like_objects.append(obj)
TypeError: objects must be an iterable containing only Dataset(s), DataArray(s), and dictionaries.
If I include varList = ['T'] in the argument, the message will be gone. I think this is likely because the LLC_rearrange assumes that there is no DataArray to rearrange when the varList is None. What it should assume is that all of the arrays are being transformed, to be consistent with the rest of the subsampling package.
Thanks @MaceKuailv for catching this up! you are correct and this should be an easy fix! Will work on this over the weekend
I was looking into solving this problem. But couldn't reproduce the error....
I ran the exact code above (after loading the ECCO dataset on sciserver, using Ali's tutorial notebook) but ran fine. I have not made any changes to the code. Now I am not so sure there is an issue with this.
@MaceKuailv Can you reproduce this error?
I am able to reproduce this error. The difference is that I was using the ECCO test dataset earlier. (I was playing around with the code, so I wanted it to be faster)
The most important difference between the test dataset and the entire ECCO is that the test is a snapshot and the time dimension has a length of 1. I have been wrestling with datasets that are not 4D lately, so I am pretty sure this is the root of the error. So, I guess this is not as important as thought it would be.
It is still quite curious that it works when varList is ['T'] though.
@MaceKuailv you have code in the works that will resolve this?
I guess the problem is similar but I don't have code available to fix this. I am assuming this problem is with cutout rather than llc_rearrange.
It would be a good idea to include more test datasets and do a thorough survey before we solve this rather small and benign issue.
Thanks @MaceKuailv for catching this up! you are correct and this should be an easy fix! Will work on this over the weekend
@Mikejmnez Can you make the easy fix for now please?
We decided to include an Error about using data in which time is not a dimension (e.g. time average)
. So that the best practice is to always have a dataset in which time
appears as a dimension.