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

Writing out a siphon'd xarray dataset as a netCDF #762

Open
ThomasMGeo opened this issue Jun 10, 2024 · 2 comments
Open

Writing out a siphon'd xarray dataset as a netCDF #762

ThomasMGeo opened this issue Jun 10, 2024 · 2 comments

Comments

@ThomasMGeo
Copy link

ThomasMGeo commented Jun 10, 2024

Hello! I am trying to write out a netCDF file from a siphon'd xarray dataset. Writing out to Zarr works fine. This may be in the wrong spot (see image).

That is the input:

catUrl = "https://thredds.ucar.edu/thredds/catalog/grib/NCEP/GFS/Global_onedeg_ana/catalog.xml";
datasetName = "Full Collection Dataset";

catalog = TDSCatalog(catUrl)

ds2 = catalog.datasets[datasetName].remote_access(use_xarray=True)
print('ds is a:', type(ds2))

and writing it out:

# Write the second dataset (ds2) to NetCDF format and print the output path
ds2.to_netcdf(paths['ds2'])
print(f"Second dataset written to {paths['ds2']} in NetCDF format.")
  • Problem description: this should explain why the current behavior is a problem and why
    the expected output is a better solution.

I just wanted to write out a netCDF file, I didn't modify the file to my knowledge. Happier to share a more in depth workflow. The error I get is below:

RuntimeError: NetCDF: Name contains illegal characters

  • Which platform
    MacOS, python 3.10
  • Versions. Include the output of:

siphon version 0.9
8tg06w

@ThomasMGeo ThomasMGeo changed the title Writing Writing out a siphon'd xarray dataset as a netCDF Jun 10, 2024
@ThomasMGeo
Copy link
Author

@tdrwenski
Copy link

I reproduced this and did notice that

print(ds2.dims)

returns

Frozen({'sigma_layer': 4, '': 2, 'pressure_difference_layer': 1, 'pressure_difference_layer1': 1, 'time': 1, 'isobaric': 41, 'lat': 181, 'lon': 360, 'hybrid': 1, 'isobaric1': 22, 'potential_vorticity_surface': 2, 'sigma': 1, 'altitude_above_msl': 3, 'height_above_ground': 2, 'height_above_ground1': 6})

I think possibly the "Name contains illegal characters" could be referring to a dimension of size 2 with an empty name. Not sure why that dimension has no name when reading in with xarray but is not present when reading with Opendap though.

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

No branches or pull requests

2 participants