-
Notifications
You must be signed in to change notification settings - Fork 415
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
Bug in vertical coordinate verification #1124
Comments
So actually the example above (cobbled together from code that was failing), for some reason works--this seems to be a subtle issue. The following is verified to fail: from datetime import datetime
import metpy.calc as mpcalc
from siphon.catalog import TDSCatalog
import xarray as xr
cat = TDSCatalog('http://thredds.ucar.edu/thredds/catalog/grib/'
'NCEP/GFS/Global_0p5deg/catalog.xml')
best = cat.datasets['Best GFS Half Degree Forecast Time Series']
subset_access = best.subset()
query = subset_access.query()
query.time(datetime.utcnow())
query.variables('Temperature_isobaric', 'Geopotential_height_isobaric',
'u-component_of_wind_isobaric', 'v-component_of_wind_isobaric',
'Relative_humidity_isobaric')
query.lonlat_box(west=-130, east=-50, south=10, north=60)
query.accept('netcdf4')
nc = subset_access.get_data(query)
from xarray.backends import NetCDF4DataStore
ds = xr.open_dataset(NetCDF4DataStore(nc))
ds = ds.metpy.parse_cf()
temperature = ds['Temperature_isobaric']
lon = temperature.metpy.x
temperature = temperature[0]
u = ds['u-component_of_wind_isobaric'][0]
temperature.metpy.vertical
u.metpy.vertical but for some reason the following similar code works: from datetime import datetime
import metpy.calc as mpcalc
from siphon.catalog import TDSCatalog
import xarray as xr
cat = TDSCatalog('http://thredds.ucar.edu/thredds/catalog/grib/'
'NCEP/GFS/Global_0p5deg/catalog.xml')
best = cat.datasets['Best GFS Half Degree Forecast Time Series']
subset_access = best.subset()
query = subset_access.query()
query.time(datetime.utcnow())
query.variables('Temperature_isobaric', 'Geopotential_height_isobaric',
'u-component_of_wind_isobaric', 'v-component_of_wind_isobaric',
'Relative_humidity_isobaric')
query.lonlat_box(west=-130, east=-50, south=10, north=60)
query.accept('netcdf4')
nc = subset_access.get_data(query)
from xarray.backends import NetCDF4DataStore
ds = xr.open_dataset(NetCDF4DataStore(nc))
ds = ds.metpy.parse_cf()
temperature = ds['Temperature_isobaric'][0]
lon = temperature.metpy.x
u = ds['u-component_of_wind_isobaric'][0]
temperature.metpy.vertical
u.metpy.vertical The only difference is where |
So, here's what I think is going on... In the failing example, In the working example, the indexed assignment of temperature acts as a copy of that subset of the variable, rather than a reference, so, Long story short, the cached result check in #1058 isn't holding up to real-world use cases. 😲 Fixing this, however, gets interesting. While I'd be tempted to suggest removing that existing-parsed-coordinates check as a quick fix, that would mean automatically overwriting the previously identified coordinates, which could be very bad if the user manually specified them. What this may take is another refactor to have the coordinate parsing take place on a type-by-type basis and not all grouped together in an all-or-nothing fashion like it currently is? Side note: to force "clean" coordinates, you can call |
A note for reference: at one point, I had the idea of caching the coordinate identification information on the accessor class itself to help resolve this, but this definitely won't work (see geoxarray/geoxarray#13, pydata/xarray#3205, pydata/xarray#3268). So, I think the way forward for this will be checking for coordinate types on a coordinate-by-coordinate basis. |
Stumbled upon an issue in (vertical) coordinate identification. This
DataArray
results invertical attribute is not available
(fromu.metpy.vertical
):whereas it works for temperature:
These data were obtained using NCSS through siphon:
This code works fine on 0.10.2.
The text was updated successfully, but these errors were encountered: