So I have a script, in this script I change the units of my temperature data from K to Celsius using the function ct.cdm.convert_units(dataarray, 'Celsius'). So far, so good.
But this is a bit unexpected:
print(mask)
print(data)
print(mask * data)
Giving the following output:
<xarray.DataArray 'nuts' (lat: 371, lon: 701)>
[260071 values with dtype=float64]
Coordinates:
* lon (lon) float64 -25.0 -24.9 -24.8 -24.7 ... 44.7 44.8 44.9 45.0
nuts_level0 object ...
* lat (lat) float64 34.0 34.1 34.2 34.3 34.4 ... 70.7 70.8 70.9 71.0
<xarray.DataArray 'tasmax' (time: 9, lat: 371, lon: 701)>
dask.array<xarray-tasmax, shape=(9, 371, 701), dtype=float32, chunksize=(9, 371, 701), chunktype=numpy.ndarray>
Coordinates:
* time (time) datetime64[ns] 2010-07-01 2011-07-01 ... 2018-07-01
* lon (lon) float64 -25.0 -24.9 -24.8 -24.7 -24.6 ... 44.7 44.8 44.9 45.0
* lat (lat) float64 34.0 34.1 34.2 34.3 34.4 ... 70.6 70.7 70.8 70.9 71.0
Attributes:
long_name: Maximum temperature at 2 meter (06-18LT)
units: Celsius
temporal_aggregation: Max 06-18LT
standard_name: air_temperature
type: real
<xarray.DataArray 'data' (lat: 371, lon: 701, time: 9)>
dask.array<xarray-data, shape=(371, 701, 9), dtype=float64, chunksize=(371, 701, 9), chunktype=numpy.ndarray>
Coordinates:
* lon (lon) float64 -25.0 -24.9 -24.8 -24.7 ... 44.7 44.8 44.9 45.0
nuts_level0 object ...
* lat (lat) float64 34.0 34.1 34.2 34.3 34.4 ... 70.7 70.8 70.9 71.0
* time (time) datetime64[ns] 2010-07-01 2011-07-01 ... 2018-07-01
Attributes:
units: K
Why oh why have the units reverted to K?
Any pointers appreciated!
Thanks
Rutger
2 Comments
Vivien MAVEL
Dear Rutger,
I am investigating why Celsius is not handled well.
In the meanwhile I would recommend to use 'K@273.15' as a unit which is more commonly used with the Toolbox:
Regard.
Vivien
Rutger Dankers
Hi Vivien
Great, thanks. Just to be clear, I believe it's only the 'units' attribute that gets changed back to 'K', the data itself is fine. For the time being I have fixed this by updating the attributes using ct.cdm.update_attributes(). But I'll try using 'K@273.15' as well.
Thanks
Rutger