Scheduled Downtime
On Tuesday 24 October 2023 @ 5pm MT the forums will be in read only mode in preparation for the downtime. On Wednesday 25 October 2023 @ 5am MT, this website will be down for maintenance and expected to return online later in the morning.
Normal Operations
The forums are back online with normal operations. If you notice any issues or errors related to the forums, please reach out to help@ucar.edu

monthly average from direct output is difference from what I calculated from daily average

I created two history files, one outputs monthly average (h1) and the other one outputs daily average (h2). Then I calculate the monthly average using the daily average in file h2, but noticed that they are difference. This kind of surprises me because I suppose they would be identical. Variables I tested include FSNT, PS, and mixing ratio of BC. I got the default averageing flag for the variables, which is Average as I didn't specify any averaging flags when setting namelist variables fincl2 and fincl3.Could anyone please give me some suggestions on this issue?Thanks!
 

jedwards

CSEG and Liaisons
Staff member
How far off are they?   One issue may be that the defintion of a month may be unclear.  They won't be indentical in any case simply because changes in the order of sums will produce round off differences.  
 
For FSNT, the difference is generally a few percent for most of the regions, but can go up to 60% for very small value of FSNT (e.g., 2nd month in North Pole).I use the no-leap calendar (28 days for February). I was running F_2000_CAM5, the monthly average is calculated by taking the arithmetic mean of the daily data, and calculated as1st month: day1 - day312nd month: day32 - day593rd month: day60 -day90...Is this the correct way to calculate the monthly average? Thanks! 
 

eaton

CSEG and Liaisons
I just did a quick two month test to confirm that the daily and monthly average results are consistent.  I suspect the mistake in your calculation is due to not taking into account that the very first time sample in the daily average file will be for nstep=0, that is, it's the initial conditions that have been adjusted by the tphysbc physics.  The next 31 time samples are the 31 daily avgs for Jan and the following 28 time samples are for Feb.  Comparing the Jan monthly avg in the h0 file with one computed from the 31 daily avgs will only agree to about 3 digits because the monthly avg in the h0 file does contain the nstep=0 time sample.  However if you compare the feb monthly avg in the h0 file with the one computed from the correct 28 daily avgs you should see only roundoff differences.  Note that the timestamps (in the 'time' coordinate variable) of averaged data correspond to the end of the averaging interval, and the averaging interval bounds are given in the time_bnds variable.
 
Eaton, Thanks a lot for your reply. Do you mean that the monthly average should be calculated as follows?1st month: sample 2 - 32 (excluding the the first sample for nstep = 0 and following 31 samples for the 1st month)2nd month: sample 33 - 60.....The question is, when I run for 2 years, and output one history file with daily average for each year, I end up getting three history files, with XXX.h1.0001-01-01-0000.nc, XXX.h1.0002-01-01-0000.nc and XXX.h1.0003-01-01-0000.nc. And the file XXX.h1.0003-01-01-0000.nc only has one day data in it. Do you mean that the one day data in XXX.h1.0003-01-01-0000.nc is actually for the last day of the second year instead of the first day of the third year because the very first sample stored in XXX.h1.0001-01-01-0000.nc is for nstep = 0?Thanks a lot!
 

eaton

CSEG and Liaisons
Exactly.  The first file in the series has an extra time sample because of nstep=0.  You can always be sure you're processing the correct data by checking the time and time_bnds variables.
 
Top