Replies: 1 comment
-
I've since learned about xr.DataArray.unstack and can use |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am creating global charts of daily UTCI highs (UTCI is a thermal stress index). Grouping by
time.dt.dayofyear
would not account for local time, resulting in a chart that is accurate only for longitudes near longitude 0. For other longitudes, the chart would show the highs for a 24-hour period that is not from around midnight to midnight. Rather than mess with time zones, I adjust the time using the longitude's nearest hour angle (using example data file 'utci.nc' from: utci.zip):Output:

To get daily highs, I'd like to do something similar to
ds.groupby("time.dayofyear").max(dim='time')
but the coordinates ofds.groupby('hour_angle_adjusted_time.dayofyear)
are "lat" and "stacked_time_lon" as seen here:Output:
So, I am looking for some guidance on how best to approach creating charts of daily highs that are time-zone-aware or hour-angle-aware data. Perhaps I am on the right track or perhaps my beginner's understanding has led me astray. My thoughts are that I could try shifting the data depending its longitude. Another idea is that pandas appears to be able to deal with time zones, so I could convert to a dataframe, and use a library like pytzwhere to label (lat, lon) coords with a time zone, and then create a new day of the year index using the time and time zone for each lat and lon. Then convert back to xarray for charting. I haven't used pandas much before though so I am not sure if this is feasible.
Thank you for your help!
Beta Was this translation helpful? Give feedback.
All reactions