Combining fldmean and maskregion for more than one region
Added by Sanita Dhaubanjar almost 7 years ago
Hi,
Is it possible to combine fldmean
and maskregion
operators to get regional means for more than one region at once? I am able to specify multiple polygon in maskregion
. But when combined with fldmean
I get mean for all regions combined. Is there a way to define the fldmean
for each region as a new parameter or something similar?
Replies (6)
RE: Combining fldmean and maskregion for more than one region - Added by Ralf Mueller almost 7 years ago
Hi Sanita!
Sorry, but fldmean
takes into account all elements of a grid. Hence it cannot identify multiple regions given by a single mask. You might upload some data and your calls so that I can checkm if there is a propper workaround.
cheers
ralf
RE: Combining fldmean and maskregion for more than one region - Added by Sanita Dhaubanjar almost 7 years ago
Hi Ralf,
In attached, the text file has boundaries for two regions of my interest. I want to extract say long term annual totals for the two regions for the entire timeperiod. I can do:cdo -L -outputtab,date,value -fldmean -maskregion,bndry_r1.txt -timsum -yearsum $ifile>yrLT_r1.txt
cdo -L -outputtab,date,value -fldmean -maskregion,bndry_r2.txt -timsum -yearsum $ifile>yrLT_r2.txt
Then i merge the text files to get long term annual totals for the two regions in one file.
I am wondering if I can do something like save r1_yrLT as one parameter and r2_yrLT as second parameter and then use outputtab after I have run through all the regions. I have multiple .nc file and multiple regions to work with. So with be nice if this could be automated in CDO.
Thanks!
RE: Combining fldmean and maskregion for more than one region - Added by Ralf Mueller almost 7 years ago
could you send both boundary files separately? cannot redo your calls otherwise
RE: Combining fldmean and maskregion for more than one region - Added by Sanita Dhaubanjar almost 7 years ago
Attached.
bndry_r1.txt (80.9 KB) bndry_r1.txt | |||
bndry_r2.txt (76.4 KB) bndry_r2.txt |
RE: Combining fldmean and maskregion for more than one region - Added by Ralf Mueller almost 7 years ago
you could write it in a single cdo call like this
cdo -L -cat \ -chname,pr,pr_regionA -fldmean -maskregion,bndry_r1.txt -timsum -yearsum pr_NPL-44i_MPI-M-MPI-ESM-LR_rcp85_r1i1p1_MPI-CSC-REMO2009_v1_day_2006-2016.nc \ -chname,pr,pr_regionB -fldmean -maskregion,bndry_r2.txt -timsum -yearsum pr_NPL-44i_MPI-M-MPI-ESM-LR_rcp85_r1i1p1_MPI-CSC-REMO2009_v1_day_2006-2016.nc \ mergedRegions.nc
this will work unless you don't have multple timesteps. if you want to process multiple years in on call, a sorting of time steps afterwards will be helpful.
output looks like this
cdo infov mergerdRegions.nc -1 : Date Time Level Gridsize Miss : Minimum Mean Maximum : Parameter name 1 : 2011-07-02 12:00:00 0 1 0 : 22241. : pr_regionA 2 : 2011-07-02 12:00:00 0 1 0 : 25145. : pr_regionA cdo infon: Processed 2 values from 1 variable over 2 timesteps ( 0.00s 40MB )
hth
ralf
RE: Combining fldmean and maskregion for more than one region - Added by Sanita Dhaubanjar almost 7 years ago
Thank you Ralf!