Creating mean value for specific area and time
Added by nazanin tavakoli about 5 years ago
Hello,
I have monthly precipitation data from 1901 to 2019 which I have sent in this link (https://drive.google.com/file/d/17Xl8YDPuiuFDwkS75ZkFuOAY-vO5IGjP/view?usp=sharing). I want to average all values in cells that are in the following extensions for every month from 2001-1-16 to 2019-12-31. I have a spatial average for 228 months.
lot= -33.25:-28.25
lon=151.25:153.75
At the end of this step, I should have 228 values for every month in 19 years.
Could anybody help me?
I really appreciate your help.
Replies (7)
RE: Creating mean value for specific area and time - Added by Karin Meier-Fleischer about 5 years ago
Hi Nazanin,
use the select operator to extract the time range and sellonlatbox to extract the region (see documentation and FAQ).
cdo -sellonlatbox,151.25,153.75,-33.25,-28.25 -select,startdate=2001-01-01,enddate=2019-12-31 -selname,pre prec.mon_cru.nc ooutfile.nc
-Karin
RE: Creating mean value for specific area and time - Added by nazanin tavakoli about 5 years ago
Thanks for your help.
RE: Creating mean value for specific area and time - Added by nazanin tavakoli almost 5 years ago
Hello,
I have used the following code to extract the region, but it did not extract completely my region. Could anybody help me?
cdo -sellonlatbox,140.9792,153.8958,-39.14583,-27.97917 -selname,ppt 2020_12.nc pre.nc
| 2020_12.rar (2.43 MB) 2020_12.rar |
RE: Creating mean value for specific area and time - Added by Karin Meier-Fleischer almost 5 years ago
The values are not quite correct. To select the region you want the following command line will do it:
cdo -sellonlatbox,140.9791,153.89584,-39.14584,-27.9791 -selname,ppt 2020_12.nc pre.nc
You have to choose the values as exactly as possible, or be a little below at the minimum and a little above at the maximum.
RE: Creating mean value for specific area and time - Added by nazanin tavakoli almost 5 years ago
Dear Karin,
Could you please tell me how I can find the exact lat or lan in CDO? It seems that Panoply does not show the exact one.
Thank you
RE: Creating mean value for specific area and time - Added by Karin Meier-Fleischer almost 5 years ago
Use CDO or ncdump to get more information (see both documentations).
cdo sinfon 2020_12.nc
File format : NetCDF4 classic
-1 : Institut Source T Steptype Levels Num Points Num Dtype : Parameter name
1 : unknown WorldClim v instant 1 1 37324800 1 I32 : ppt
Grid coordinates :
1 : lonlat : points=37324800 (8640x4320)
mapping : latitude_longitude
lon : -179.9792 to 179.9792 by 0.04166667 degrees_east circular
lat : 89.97917 to -89.97917 by -0.04166667 degrees_north
Vertical coordinates :
1 : surface : levels=1
Time coordinate : 1 step
RefTime = 1900-01-01 00:00:00 Units = days Calendar = gregorian
YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss
2020-12-01 00:00:00
ncdump -c 2020_12.nc | less
netcdf \2020_12 {
dimensions:
time = UNLIMITED ; // (1 currently)
lon = 8640 ;
lat = 4320 ;
variables:
double time(time) ;
time:standard_name = "time" ;
time:long_name = "time" ;
time:units = "days since 1900-01-01 00:00:00" ;
time:calendar = "gregorian" ;
time:axis = "T" ;
double lon(lon) ;
lon:standard_name = "longitude" ;
lon:long_name = "longitude" ;
lon:units = "degrees_east" ;
lon:axis = "X" ;
double lat(lat) ;
lat:standard_name = "latitude" ;
lat:long_name = "latitude" ;
lat:units = "degrees_north" ;
lat:axis = "Y" ;
int crs ;
crs:grid_mapping_name = "latitude_longitude" ;
crs:longitude_of_prime_meridian = 0. ;
crs:semi_major_axis = 6378137. ;
crs:inverse_flattening = 298.257223563 ;
crs:long_name = "crs" ;
int ppt(time, lat, lon) ;
ppt:standard_name = "precipitation_amount" ;
ppt:long_name = "precipitation_amount" ;
ppt:units = "mm" ;
ppt:grid_mapping = "crs" ;
ppt:add_offset = 0. ;
ppt:scale_factor = 0.1 ;
ppt:_FillValue = -2147483648 ;
ppt:missing_value = -2147483648 ;
ppt:description = "Accumulated Precipitation" ;
ppt:dimensions = "lon lat time" ;
ppt:coordinate_system = "WGS84,EPSG:4326" ;
// global attributes:
:CDI = "Climate Data Interface version ?? (http://mpimet.mpg.de/cdi)" ;
:history = "Fri Apr 30 19:52:40 2021: cdo -select,startdate=2020-12-01,enddate=2020-12-31 -selname,ppt -divc,31 TerraClimate_ppt_2020.nc 2020_12.nc\n",
"Created by John Abatzoglou, University of California Merced" ;
:source = "WorldClim v2.0 (2.5m), CRU Ts4.0, JRA-55" ;
:institution = "University of California Merced" ;
:Conventions = "CF-1.6" ;
....
data:
time = 44164 ;
lon = -179.979166666667, -179.9375, -179.895833333333, -179.854166666667,
-179.8125, -179.770833333333, -179.729166666667, -179.6875,
-179.645833333333, -179.604166666667, -179.5625, -179.520833333333,
-179.479166666667, -179.4375, -179.395833333333, -179.354166666667,
-179.3125, -179.270833333333, -179.229166666667, -179.1875,
-179.145833333333, -179.104166666667, -179.0625, -179.020833333333,
-178.979166666667, -178.9375, -178.895833333333, -178.854166666667,
-178.8125, -178.770833333333, -178.729166666667, -178.6875,
-178.645833333333, -178.604166666667, -178.5625, -178.520833333333,
-178.479166666667, -178.4375, -178.395833333333, -178.354166666667,
-178.3125, -178.270833333333, -178.229166666667, -178.1875,
-178.145833333333, -178.104166666667, -178.0625, -178.020833333333,
-177.979166666667, -177.9375, -177.895833333333, -177.854166666667,
-177.8125, -177.770833333333, -177.729166666667, -177.6875,
-177.645833333333, -177.604166666667, -177.5625, -177.520833333333,
-177.479166666667, -177.4375, -177.395833333333, -177.354166666667,
...
If you do not like to go through all values, you can select a bit larger region to see the grid information from less coordinate values, and use ncdump as described above.
cdo -sellonlatbox,140.95,153.9,-39.2,-27.9 -selname,ppt 2020_12.nc tmp.nc
RE: Creating mean value for specific area and time - Added by nazanin tavakoli almost 5 years ago
Thank you