Integrals in ODV In taking budgets, you will want to calculate the integrals of variables. That way, you can convert between a list of fluxes to a total flux through a surface you choose, for example. ******** Depth Integration. ******** It is easy to integrate in z, you just make a derived variable that is the depth integral of a variable you've got. Step by Step: Open a dataset in ODV. Do Configuration>>Derived Variables Choose Vertical Integral and click add. A box will come up asking you what variable you want to integrate. Select one. It will then ask at what depth you want integration to start. Choose 0, and then you will integrate from the surface down. That's it! ********* Integration in Space. ********* Integration in space is more difficult, but using the box averaging tools we can do it for a gridded dataset. Open up the variable you want over the region you want to integrate using selection criteria. Make sure you have a box averaging file set up that has just the one depth you want (e.g., select only the surface values in ECCO using a box with ddepth < 20m centered around depth 5m). Now, an average is just (\int val dA)/(\int dA). So, if we do box averaging, we've got close to what we want, if only we knew what \int dA was. All we need to do then is count up the number of datapoints we've got and know the size of the boxes. There is one problem... we need to account for the curvature of the earth. Thus, boxes that are poleward of the equator are narrower (less distance spanned in longitude) than those at the equator. This is just a correction for sin(latitude). So, let's make a way to sum up the size of the boxes on average over our selected data: Open Configuration>>Derived Variables: Choose Expression on right. Click Add. Up will come a box where you can define expressions. First, get latitude available as a variable by selecting it from the list at right and clicking so it appears in 'defined'. Now enter the following in the Expression box: #1 sin where #1 represents the latitude (see above) This (in reverse Polish notation, ugh!) takes the sine of latitude. Name this variable as sin(lat) and click OK. Now, we actually want the area of a cell for integration. So, if it is a latitude-longitude face, we want delta(lat)*delta(lon)*sin(lat)*111.3km, since 1 degree of latitude is 6378km*2*pi/360=111.3km. So, if our model is on a 1 degree x 1 degree grid, we want to do box average(Area*Variable)/box average(Area) where Area=111.3km*111.3km*sin(lat). So, we can define Area just like we did with sin(lat) by using a derived variable and the expression: #1 sin 111.3 * 111.3 * Call this one area. Define one more variable: the product of Area * (variable to integrate). Then you will be all ready to go. There is one problem, which is that while the variables you might want to integrate vanish in land, the area function as defined won't. Thus box average(Area*Variable)/box average(Area) won't be over the right domain. So, instead you can just do a slightly different definition of Area: Set up #1 as latitude and #2 as the variable you want to integrate. #2 abs 100000 * 1 min =%0 #1 sin 111.3 * 111.3 * %0 * So, the idea is that first a new variable %0 is calculated which is 1 everywhere that the variable to average is greater than 0.000001 (which is everywhere except in land probably), and zero in land. Next, you multiply your area by the same function, which means that only non-land areas are used. Good Luck!