[ncl-talk] Calculating annual averages from year/lat/lon grid

Toni Klemm toni-klemm at tamu.edu
Tue Jan 22 08:58:30 MST 2019


Hello NCL community,

I have a three dimensional grid dataset (year/latitude/longitude) that want to calculate the annual average of by averaging the second and third dimension, but I don’t think my approach is correct. 

The data are projections of net primary productivity (NPP) of grassland in the US Great Plains from 2015 to 2099. Most of the grid cells are missing values because most grid cells are classified as shrubland, forest, etc. … but not grassland and therefore have no grassland NPP. 

My approach so far was to average the third dimension first and then the second dimension using this command:
NPP_G_annual_avg = dim_avg_n(dim_avg_n(NPP_G,2),1)

However, I think this produces incorrect results. Comparing NCL with the average produced in Microsoft Excel, I get 394.8 from NCL and 417.6 from Excel for the year 2015 (the unit is grams of Carbon per square meter per year). I think Excel is correct, because it averages all values at once while NCL averages one dimension first and then the other, which I think creates a bias. Does anyone know how to average two dimensions at once in NCL? I attached the 2015 data for the Northern Great Plains as .csv file. Missing values are listed as “NaN”.

Thank you very much for your help! I really appreciate it.

Best,
Toni


Toni Klemm, Ph.D.
Postdoctoral Research Associate
Department of Ecosystem Science and Management
College of Agriculture and Life Sciences
Texas A&M University, College Station, TX
Contributor to the Early Career Climate Forum <http://www.eccforum.org/>
www.toni-klemm.de <http://www.toni-klemm.de/> | @toniklemm <http://twitter.com/toniklemm>







-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190122/72ec0b34/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: NPP_G_annual_avg_NP_2015.csv
Type: text/csv
Size: 168935 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190122/72ec0b34/attachment.csv>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190122/72ec0b34/attachment-0001.html>


More information about the ncl-talk mailing list