Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading IGP data in zarr raises ValueError with shift_averages #442

Open
ThomasHaine opened this issue Jul 26, 2024 · 0 comments
Open

Reading IGP data in zarr raises ValueError with shift_averages #442

ThomasHaine opened this issue Jul 26, 2024 · 0 comments

Comments

@ThomasHaine
Copy link
Collaborator

I've rewritten the IGP netcdf data on SciServer into zarr. When I try to open the new zarr data I hit an error with the shift_average variables:

----> 5 od = ospy.open_oceandataset.from_catalog("IGPwinter",local_catalog_file)

~/mambaforge/envs/Oceanography/lib/python3.10/site-packages/oceanspy/open_oceandataset.py in ?(name, catalog_url)
    223 
    224     # Shift averages
    225     shift_averages = metadata.pop("shift_averages", None)
    226     if shift_averages is not None:
--> 227         od = od.shift_averages(**shift_averages)
    228 
    229     # Set OceanSpy stuff
    230     for var in ["aliases", "parameters", "name", "description", "projection"]:

~/mambaforge/envs/Oceanography/lib/python3.10/site-packages/oceanspy/_oceandataset.py in ?(self, averageList)
    996 
    997         for var in self._ds.data_vars:
    998             original_output = self._ds[var].attrs.pop("original_output", None)
    999             if original_output == "average" or var in averageList:
-> 1000                 ds_tmp = self._ds[var].drop_vars("time").isel(time=slice(1, None))
   1001                 self._ds[var] = ds_tmp.rename({"time": "time_midp"})
   1002             if original_output is not None:
   1003                 self._ds[var].attrs["original_output"] = original_output

~/mambaforge/envs/Oceanography/lib/python3.10/site-packages/xarray/core/dataarray.py in ?(self, names, errors)
   3143         Dimensions without coordinates: x, y
   3144         """
   3145         if callable(names):
   3146             names = names(self)
-> 3147         ds = self._to_temp_dataset().drop_vars(names, errors=errors)
   3148         return self._from_temp_dataset(ds)

~/mambaforge/envs/Oceanography/lib/python3.10/site-packages/xarray/core/dataset.py in ?(self, names, errors)
   5945             names_set = {names}
   5946         else:
   5947             names_set = set(names)
   5948         if errors == "raise":
-> 5949             self._assert_all_in_dataset(names_set)
   5950 
   5951         # GH6505
   5952         other_names = set()

~/mambaforge/envs/Oceanography/lib/python3.10/site-packages/xarray/core/dataset.py in ?(self, names, virtual_okay)
   5809         if virtual_okay:
   5810             bad_names -= self.virtual_variables
   5811         if bad_names:
   5812             ordered_bad_names = [name for name in names if name in bad_names]
-> 5813             raise ValueError(
   5814                 f"These variables cannot be found in this dataset: {ordered_bad_names}"
   5815             )

ValueError: These variables cannot be found in this dataset: ['time']

The issue is that the time-like variable for the shift_average data is not called time, it's called time_midp already. I'm confused why this doesn't also cause an issue reading from netcdf, but it doesn't. Ideas on how to fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant