-
Notifications
You must be signed in to change notification settings - Fork 21
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
metpy warning #68
Comments
@martindurant, xrviz is trying to use metpy to figure out if when the user selects a variable, if there are lon,lat variables it could use for plotting coordinates. @dopplershift, what would be the best way to use metpy to do this? Currently the code is trying: parsed_var = ds.metpy.parse_cf(var)
x, y = parsed_var.metpy.coordinates('x', 'y')
[coord.name for coord in (x, y)] But I'm not sure how this ever worked for this dataset! If we take a look at the great lakes dataset: import xarray as xr
import metpy
url = 'http://opendap.co-ops.nos.noaa.gov/thredds/dodsC/NOAA/LOOFS/MODELS/202003/glofs.loofs.fields.forecast.20200320.t06z.nc'
ds = xr.open_dataset(url) we get:
but while parsed_temp.metpy.time.name returns
trying the same for parsed_temp.metpy.x.name returns ---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-26-b90890c9912d> in <module>
----> 1 parsed_temp.metpy.x.name
/srv/conda/envs/notebook/lib/python3.7/site-packages/metpy/xarray.py in x(self)
350
351 """
--> 352 return self._axis('x')
353
354 @property
/srv/conda/envs/notebook/lib/python3.7/site-packages/metpy/xarray.py in _axis(self, axis)
288 return coord_var
289 else:
--> 290 raise AttributeError(axis + ' attribute is not available.')
291 else:
292 raise AttributeError("'" + axis + "' is not an interpretable axis.")
AttributeError: x attribute is not available. For what it's worth,
|
@rsignell-usgs, As mentioned in this comment, metpy is able to guess, if the data coords are set or available, so setting the coords by
before parsing works fine. However the deprecation and future removal warning is there. |
Thanks @hdsingh ! So the code below has this behavior with metpy:
import xarray as xr
import metpy
url = 'http://opendap.co-ops.nos.noaa.gov/thredds/dodsC/NOAA/LOOFS/MODELS/202003/glofs.loofs.fields.forecast.20200320.t06z.nc'
ds = xr.open_dataset(url)
ds = ds.set_coords(['lon', 'lat'])
ds.parsed_temp = ds.metpy.parse_cf('temp')
print(parsed_temp.metpy.x.name) @dopplershift, what would be a best way to modify this for the new metpy? |
Apologies for the inconvenience. The current (1.0) way would be: parsed_temp.metpy.longitude.name The relevant issue is Unidata/MetPy#1090, describing the rationale for the changes. |
@hdsingh , do you have any plans to change the code to cope with the new version of metpy? |
I looked into this. Changing this line to
according to current ( |
@hdsingh , is this the problem you are having? With name: metpy
channels:
- conda-forge
dependencies:
- python=3.7
- panel
- hvplot
- xarray
- netcdf4
- datashader
- geoviews
- xrviz
- pip
- pip:
- git+https://github.com/Unidata/MetPy.git I'm getting:
If so, perhaps @ocefpaf has insight? |
I would suggest specifying the tornado version (6.0.1?) if there is a problem. |
@rsignell-usgs Yes, somewhat similar. Since I tried installing in already existing environment, I got
So version checking seems a better option here. However we will still get warning message only in case of |
If it was already warning, then I suspect that the new method must be working by that version. |
@hdsingh and @rsignell-usgs what is the result of I was able to use the environment from #68 (comment) without any problems with
This is the
|
I have problems on windows if I set my show_channel_urls: true
channel_priority: strict
channels:
- conda-forge (base) c:\Users\rsignell\Documents\GitHub>conda env create -f metpy_env.yml Collecting package metadata (repodata.json): done Solving environment: \ Found conflicts! Looking for incompatible packages. This can take several minutes. Press CTRL-C to abort. Examining netcdf4: 10%|██████▍ | 1/10 [00:00<00:03, 2.32it/s]\failed / Solving environment: \ Found conflicts! Looking for incompatible packages. This can take several minutes. Press CTRL-C to abort. Determining conflicts: 0%| | 0/10 [00:00UnsatisfiableError: The following specifications were found to be incompatible with each other:
Your installed CUDA driver is: 10.1 Note that strict channel priority may have removed packages required for satisfiability. But I'll try on linux |
I'll get a Windows machine later today to debug that. We probably need to rebuild something there :-/ |
@ocefpaf I have been able to install Code:import xarray as xr
import metpy
url = 'http://opendap.co-ops.nos.noaa.gov/thredds/dodsC/NOAA/LOOFS/MODELS/202003/glofs.loofs.fields.forecast.20200320.t06z.nc'
ds = xr.open_dataset(url)
ds = ds.set_coords(['lon', 'lat'])
parsed_temp = ds.metpy.parse_cf('temp') Error DetailsUndefinedUnitError Traceback (most recent call last)
<ipython-input-3-22ddc53f81fc> in <module>
5 ds = xr.open_dataset(url)
6 # ds = ds.set_coords(['lon', 'lat'])
----> 7 parsed_temp = ds.metpy.parse_cf('temp')
~/anaconda3/envs/c2/lib/python3.7/site-packages/metpy/xarray.py in parse_cf(self, varname, coordinates)
659 if crs is not None:
660 var = var.assign_coords(coords={'crs': crs})
--> 661 return var.metpy.quantify()
662
663 def _rebuild_coords(self, var, crs):
~/anaconda3/envs/c2/lib/python3.7/site-packages/metpy/xarray.py in quantify(self)
166 ):
167 # Only quantify if not already quantified and is quantifiable
--> 168 quantified_dataarray = self._data_array.copy(data=self.unit_array)
169 if 'units' in quantified_dataarray.attrs:
170 del quantified_dataarray.attrs['units']
~/anaconda3/envs/c2/lib/python3.7/site-packages/metpy/xarray.py in unit_array(self)
145 return self._data_array.data
146 else:
--> 147 return units.Quantity(self._data_array.values, self.units)
148
149 def convert_units(self, units):
~/anaconda3/envs/c2/lib/python3.7/site-packages/metpy/xarray.py in units(self)
129 return self._data_array.data.units
130 else:
--> 131 return units.parse_units(self._data_array.attrs.get('units', 'dimensionless'))
132
133 @property
~/anaconda3/envs/c2/lib/python3.7/site-packages/pint/registry.py in parse_units(self, input_string, as_delta)
1063 for p in self.preprocessors:
1064 input_string = p(input_string)
-> 1065 units = self._parse_units(input_string, as_delta)
1066 return self.Unit(units)
1067
~/anaconda3/envs/c2/lib/python3.7/site-packages/pint/registry.py in _parse_units(self, input_string, as_delta)
1262 as_delta = self.default_as_delta
1263
-> 1264 return super()._parse_units(input_string, as_delta)
1265
1266 def _define(self, definition):
~/anaconda3/envs/c2/lib/python3.7/site-packages/pint/registry.py in _parse_units(self, input_string, as_delta)
1091 many = len(units) > 1
1092 for name in units:
-> 1093 cname = self.get_name(name)
1094 value = units[name]
1095 if not cname:
~/anaconda3/envs/c2/lib/python3.7/site-packages/pint/registry.py in get_name(self, name_or_alias, case_sensitive)
624 candidates = self.parse_unit_name(name_or_alias, case_sensitive)
625 if not candidates:
--> 626 raise UndefinedUnitError(name_or_alias)
627 elif len(candidates) == 1:
628 prefix, unit_name, _ = candidates[0]
UndefinedUnitError: 'Celsius' is not defined in the unit registry |
I'm not a |
The following installation works:
|
It looks like for some reason pint will only parse "celsius" and not "Celsius" (I just opened hgrecco/pint#1081). |
@rsignell-usgs , any idea what the following warning means? Seen when looking at the great-lakes data
Is mapping no longer done??
The text was updated successfully, but these errors were encountered: