Select to view content in your preferred language

Calculate an average for many many time steps

1408
1
10-16-2011 02:45 PM
SakuraOno
New Contributor
Hello all,

I have a netCDF file of temperature. It has 1308 time steps (12 months for 109 years).
I was wondering how would I go about calculating the average for the 1308 time steps?

I am trying to do this in Model Builder. If I had only a couple time steps, I would just add them up and then divide them using simple math tools in the toolbox. However, because I have 1308 of them, what should I do to make the summing automatic (so I don't have to manually specify the time step in the "make netCDF raster layer" tool for 1308 times!)?

I get a feeling that I might need to do this in python? or I can achieve this in Model builder as well? I'm fairly new to ArcGIS and my programming skills are not so stellar, so I don't know how to do that. 😞  although if python is the only way to do, I wouldn't mind learning it, although I would really appreciate any pointers or suggestions (books, web resources...etc.) on how I can quickly learn it.

I'm using ArcGIS 9.2 (although my school has ArcGIS 10, so suggestions on either or both would do!)

thanks so much for your help! 🙂

Sakura
0 Kudos
1 Reply
PhilMorefield
Frequent Contributor
You may have figured this out or moved on already, so I'll keep this reply short.

Option 1: Use Python to read the netCDF file as a numpy array object. If your dataset isn't too large, you can average all 1,308 time steps with a single keystroke. Search Google for 'scipy.io.netcdf' and 'numpy.mean'.

Option2: If your dataset is too large to read as a single three-dimensional array, you'll have to loop through each time step and use a simple formula: Tavg = ((n*aavg) + a) / n + 1
n = the # of timesteps you've already averaged
aavg = your current average
a = data for the current time step

Obviously for the first time step, aavg == a. But, for example, at the the fourth time step the formula would be:
((3*aavg) + a) / 4

Either way, you're going to need to use Python. I like to use a good scientific IDE like SPyDeR for this type of work.
0 Kudos