home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 335640601

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
335640601 MDU6SXNzdWUzMzU2NDA2MDE= 2252 can't save wrf Mercator projection attribute to new netcdf file 1971123 closed 0     3 2018-06-26T03:02:16Z 2018-06-26T17:54:23Z 2018-06-26T17:54:23Z NONE      

I'm brand new (TODAY) to xarray, so I'm not going to use the right lingo... I want to save a wrf diagnostic variable 'pvo' (https://wrf-python.readthedocs.io/en/latest/diagnostics.html#diagnostic-table) to its own new netcdf file.

```python dataset = xr.Dataset({'pvo':pvo}) dataset.info() Coordinates: XLONG float32 -101.73564 XLAT float32 1.7164688 Time datetime64[ns] 2014-09-15T21:00:00 xarray.Dataset { dimensions: bottom_top = 42 ; south_north = 243 ; west_east = 378 ;

variables: float32 XLONG(south_north, west_east) ; float32 XLAT(south_north, west_east) ; datetime64[ns] Time() ; float32 pvo(bottom_top, south_north, west_east) ; pvo:FieldType = 104 ; pvo:MemoryOrder = XYZ ; pvo:description = potential vorticity ; pvo:units = PVU ; pvo:stagger = ; pvo:coordinates = XLONG XLAT ; pvo:projection = Mercator(stand_lon=-65.0, moad_cen_lat=23.722755432128906, truelat1=30.0, truelat2=60.0, pole_lat=90.0, pole_lon=0.0) ; pvo:_FillValue = 9.969209968386869e+36 ; pvo:missing_value = 9.969209968386869e+36 ;

``` Looks great, let's save it (am I doing this right?)

python pvo.to_dataset().to_netcdf("analysis_d01_2014-09-15_21h.nc","a") It breaks and complains about the projection attribute:

python Traceback (most recent call last): File "matplotwrf.py", line 86, in <module> pvo.to_dataset().to_netcdf("analysis_d01_2014-09-15_21h.nc","a") File "/software/Anaconda3-5.1.0-el6-x86_64/envs/wrf-python/lib/python3.6/site-packages/xarray/core/dataset.py", line 1150, in to_netcdf compute=compute) File "/software/Anaconda3-5.1.0-el6-x86_64/envs/wrf-python/lib/python3.6/site-packages/xarray/backends/api.py", line 659, in to_netcdf _validate_attrs(dataset) File "/software/Anaconda3-5.1.0-el6-x86_64/envs/wrf-python/lib/python3.6/site-packages/xarray/backends/api.py", line 120, in _validate_attrs check_attr(k, v) File "/software/Anaconda3-5.1.0-el6-x86_64/envs/wrf-python/lib/python3.6/site-packages/xarray/backends/api.py", line 111, in check_attr 'files'.format(value)) TypeError: Invalid value for attr: Mercator(stand_lon=-65.0, moad_cen_lat=23.722755432128906, truelat1=30.0, truelat2=60.0, pole_lat=90.0, pole_lon=0.0) must be a number string, ndarray or a list/tuple of numbers/strings for serialization to netCDF files

Do I have to chop up, rework or remove the projection attribute? Surely these diagnostic variables are immediately ready to save as complete netcdf variables, what am I doing wrong?

Thank you!

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/2252/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed 13221727 issue

Links from other tables

  • 1 row from issues_id in issues_labels
  • 3 rows from issue in issue_comments
Powered by Datasette · Queries took 0.642ms · About: xarray-datasette