Project

General

Profile

Summing up a field with area

Added by Matt Thompson over 7 years ago

All,

This is probably a FAQ, but I want to make sure I just don't do dumb things. I'm mainly a programmer, not a climate scientist.

Namely, I have some pictures I'm making of total precipitation (mm/day) at various resolutions, showing why finer and finer resolution is a Good Thing(TM). Each picture is over the same lat-lon box. So, what I was thinking was "I wonder if the total mass of water in each picture is the same", i.e., my 2-degree plot is all blocky, but the cells are big and all colored, while at 1/4-degree, much is now zero, but some gridcells are very high value. Now, I'm thinking to get the mass of water, I essentially need the volume. I have mm/day and I essentially would need to get the area of each cell and use that (and then get time step, etc.).

I guess my main question is: is fldsum() the operator I'd want? I'd think so, except it doesn't seem to have the area weights as part of its description in the doc. So, would I need to provide that separately? All my data are on lat-lon grids (nothing fancy) so it wouldn't be hard to calculate the grid area, I just didn't output it the first go around! (Running the globe at 6 km is...taxing.)

Am I on the right track?

Thanks,
Matt


Replies (3)

RE: Summing up a field with area - Added by Uwe Schulzweida over 7 years ago

Hi Matt,

the grid area can be computed with the CDO operator gridarea, the result is in square meters.
After weighting the field with the grid area you can use fldsum to compute the sum over all grid cells.

Cheers,
Uwe

RE: Summing up a field with area - Added by Matt Thompson over 7 years ago

Uwe,

Hope you don't mind if I ask some more questions. So, I did:

cdo gridarea TOTPREC.c48.nc4 gridarea.c48.nc4
cdo gridweights TOTPREC.c48.nc4 gridweights.c48.nc4

And that gets me areas and weights. I know my lonlatbox as well. How do I weight with grid area? This is my thought:

cdo mul gridarea.c48.nc4 TOTPREC.c48.nc4 TOTPREC_times_area.c48.nc4

Does that sound right? Then I can do

cdo fldsum -sellonlatbox in.nc4 out.nc4

and that would be the sum of the fields in the lon-lat box?

RE: Summing up a field with area - Added by Uwe Schulzweida over 7 years ago

Yes, and you can combine these commands to:

cdo fldsum -sellonlatbox -mul in.nc4 -gridarea in.nc4 out.nc4

    (1-3/3)