Aggregating CONUS404 hourly data to daily values. #412
amsnyder
started this conversation in
Data Processing and Analysis
Replies: 1 comment
-
Very useful info!! Thank you!! |
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
-
When aggregating the CONUS404 hourly data to daily values, it is important to keep track of whether the variable you are using is an instantaneous value or an aggregated value. Aggregated variables will have an attribute attached which indicates the period over which the data was aggregated, called
integration_length
.If you were processing the
PREC_ACC_NC
variable, for example, theintregration_length
attribute indicates that the data value isaccumulated over prior 60 minutes
. Therefore, to get a daily summary, you will want to sum the values for01:00:00
of that day to00:00:00
of the next day. You can do this with xarray by running a line of code likeds_daily_sum = ds.PREC_ACC_NC.resample(time="24H", base=1, loffset='-1H').sum()
. Thebase=1
parameter shifts the daily aggregation ahead one hour (by default, it would use00:00:00
to23:00:00
of that day), and theloffset='-1H'
adjusts the time stamp on the resulting aggregated dataset back to00:00:00
, rather that using the first time stamp it used of01:00:00
.If you are aggregating an instantaneous data variable, you do not need to do this offset, and you can calculate your aggregation with something like:
ds_daily_avg = ds.T2.resample(time="24H").mean()
.Beta Was this translation helpful? Give feedback.
All reactions