-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Can I convert an xarray dataset to a different timezone?
I have tried using similar steps that I would use in pandas to convert from UTC to 'Australia/Sydney'. I have pasted below some of these steps, along with a small section of the dataset I am working with.
Any feedback will be greatly appreciated.
ds = xray.open_mfdataset('/DATA/WRF///*T_SFC.nc')
import pytz
ds_utc = ds['time'].tz_localize(pytz.UTC)
au_tz = pytz.timezone('Australia/Sydney')
ds_local = ds_utc.astimezone(au_tz)
<xray.Dataset>
Dimensions: (latitude: 106, longitude: 193, time: 17520)
Coordinates:
- latitude (latitude) float32 -39.2 -39.1495 -39.099 -39.0486 -38.9981 ...
- longitude (longitude) float32 140.8 140.848 140.896 140.944 140.992 ...
- time (time) datetime64[ns] 2009-01-01 2009-01-01T01:00:00 ...
Data variables:
T_SFC (time, latitude, longitude) float64 13.83 13.86 13.89 13.92 ...
Attributes:
creationTime: 1431922712
creationTimeString: Sun May 17 21:18:32 PDT 2015
Conventions: COARDS