Project

General

Profile

Spatial average of a variable at selected grids-Regd.

Added by Naveen Pothula over 4 years ago

Dear all,

I have a .nc file spread over a large area at 0.5 x 0.5 resolution on regular lonlat grids. I want to take the average of the variable for selected grids. The grids are continuous but when put together they don't form a perfect rectangle. Is this possible to do in cdo. kindly give a solution, other wise I have to extract the data for the grids individually and then do the average.

Kindly help,
naveen.


Replies (3)

RE: Spatial average of a variable at selected grids-Regd. - Added by Karin Meier-Fleischer over 4 years ago

Hi Naveen,

you can use collgrid to reunion the region files.

Example:

Create an example data file topo_area.nc:

cdo -f nc -sellonlatbox,0,60,30,80 -topo topo_area.nc

Split data file into regions (-distgrid,nx,ny)

cdo -distgrid,3,2 topo_area.nc topo_parts

Loop: compute the timmean of each file

for f in $(ls topo_parts*.nc); do; cdo -timmean ${f} avg_${f}; done

Collect the regions (-collgrid,nx)

cdo -O -collgrid,3 avg_*.nc outfile.nc

-Karin

RE: Spatial average of a variable at selected grids-Regd. - Added by Naveen Pothula over 4 years ago

Dear Karin,

My intention is to get the spatial average of a variable at selected grids at different time steps. I don't intend to take the time mean.

I want to select a group of grid cell and take the spatial average at different time steps (same timesteps as individual grid).

Kindly suggest a solution.

best wishes,
naveen

RE: Spatial average of a variable at selected grids-Regd. - Added by Karin Meier-Fleischer over 4 years ago

Sorry, for this case you have to do it step by step.

    (1-3/3)