[Thread Prev][Thread Next][Index]

Re: [ferret_users] daily average from hourly data



Hi,
You're right that returning the average of data when there is missing data in the source data is a lenient way of computing the average. Ferret returns the average of whatever data lies in the destination grid cell when regridding using @AVE.

The @NGD transformation will tell you how many data points from the source axis lie in each destination grid cell (use SHOW TRANS to see a quick list of all the available transformations):

yes? show transformations
...
regridding transforms e.g.SST[GX=x5deg@AVE]
   code        description                  code        description
   ----        -----------                  ----        -----------
   @LIN        lin. interp.                 @MOD        modulo ave
   @AVE        box avgd                     @MODVAR     modulo var
   @XACT       exact match                  @MODNGD     # gd mod pts
   @ASN        index assn                   @MODNBD     #bad mod pts
   @VAR        variance                     @MODSUM     modulo sum
   @MIN        minimum                      @MODMIN     modulo min
   @MAX        maximum                      @MODMAX     modulo max
   @SUM        sum                          @NRST       nearst coord
   @NGD        # gd pts
 

So you could define a mask to use on the result using RD_495[gt=mytd@ngd]

Note in the documentation for @NGD, this detail
Note that the results of this calculation need not be integers—this is a length-weighted computation like the @AVE transformation. It is common for a grid cell on the source grid to span the boundary between grid cells on the destination grid, thereby contributing a fraction of its weight to multiple destination grid cells.

--Ansley


On 6/1/2015 2:45 PM, Dongxiao Zhang wrote:
Hi,

I am trying to calculate daily averages from hourly data with data gaps. A sample data is attached as test1.cdf.
I tried the following script to get the daily mean. It only works well for a timeseries without missing data.

use test1.cdf
def axis/t="31-jul-2010:23:30":"6-aug-2010:00:30":24/unit=hour/edges mytd
set var/bad=1e35 RD_495
let daily=RD_495[gt=mytd@ave]
plot RD_495, daily

The daily mean is defined as the average of 00 to 23 hours of each day. We should have missing values for the daily mean if any hour in that particular day has missing data. The above script simply averages all available data in each day as the mean, which is wrong. Is there a way to count how many good data points in each day so that they can be used as a mask? Or is there a better way to get daily means?

Thanks for any suggestions!

Dongxiao



[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement