Extracting data from grid cells
Added by Josh Butterworth about 6 years ago
Hello,
I think that this can be done in cdo but i'm not having much luck at the moment as i'm very new. Could anyone let me know if there's an operator that will transform my lat/lon grid data so that I can plot a time-series with the values from each cell (averaged values for a region). For context I'm trying to create a time-series for the average changes in X variable over X time period, however my data covers a large area...
I realise this question may not be that clear, please let me know if there's anything else I can do to clarify - any help is greatly appreciated.
Many thanks,
J
Replies (11)
RE: Extracting data from grid cells - Added by Ralf Mueller about 6 years ago
hi Josh!
check out the fldmean
operator. it generates global means, which essentially is a 1-D timeseries. you can mask regions with missing values to process certain regions only.
hth
ralf
RE: Extracting data from grid cells - Added by Josh Butterworth about 6 years ago
Hi Ralf,
Thanks for the solution, works perfectly!
Cheers,
Josh
RE: Extracting data from grid cells - Added by Khumo Monaka almost 6 years ago
Greetings Josh.
Kindly explain how you used fldmean to generate a 1D timeseries. I am new on cdo and i want to use it to generate a 1d timeseries.
I am working on RegCM4 climate model and now i have successfully done a test simulation. i tried doing a timeseries using remapnn i.e (cdo cat -remapnn,lon=25.6/lat=24.6 inputfile.nc outputfile.nc
I used ncview to view the results of the above command.
Kindly assist/explain more about fldmean
Kind Regards
RE: Extracting data from grid cells - Added by Ralf Mueller almost 6 years ago
hi Khumo Monaka!
you can use fldmean like this
cat -fldmean inputfile.nc outputfile.ncIt computes an area weighted mean value ignoring all locations with missing values. of course you can pipe/chain this operators as ususal
- without
fldmean
:% cdo -s -infov -log -settaxis,2001-01-01,00:00:00:,2hours -mul -addc,1 -abs -topo -enlarge,global_0.5 -for,1,10 [Thu 2019-03-28|09:32:12] -1 : Date Time Level Gridsize Miss : Minimum Mean Maximum : Parameter name 1 : 2001-01-01 00:00:00 0 259200 0 : 0.0000 7.1888 9.2389 : for 2 : 2001-01-01 02:00:00 0 259200 0 : 0.69315 7.8820 9.9320 : for 3 : 2001-01-01 04:00:00 0 259200 0 : 1.0986 8.2874 10.337 : for 4 : 2001-01-01 06:00:00 0 259200 0 : 1.3863 8.5751 10.625 : for 5 : 2001-01-01 08:00:00 0 259200 0 : 1.6094 8.7983 10.848 : for 6 : 2001-01-01 10:00:00 0 259200 0 : 1.7918 8.9806 11.031 : for 7 : 2001-01-01 12:00:00 0 259200 0 : 1.9459 9.1347 11.185 : for 8 : 2001-01-01 14:00:00 0 259200 0 : 2.0794 9.2683 11.318 : for 9 : 2001-01-01 16:00:00 0 259200 0 : 2.1972 9.3860 11.436 : for 10 : 2001-01-01 18:00:00 0 259200 0 : 2.3026 9.4914 11.541 : for
- adding
fldmean
:% cdo -s -infov -fldmean -log -settaxis,2001-01-01,00:00:00:,2hours -mul -addc,1 -abs -topo -enlarge,global_0.5 -for,1,10 [Thu 2019-03-28|09:32:08] -1 : Date Time Level Gridsize Miss : Minimum Mean Maximum : Parameter name 1 : 2001-01-01 00:00:00 0 1 0 : 7.2993 : for 2 : 2001-01-01 02:00:00 0 1 0 : 7.9924 : for 3 : 2001-01-01 04:00:00 0 1 0 : 8.3979 : for 4 : 2001-01-01 06:00:00 0 1 0 : 8.6856 : for 5 : 2001-01-01 08:00:00 0 1 0 : 8.9087 : for 6 : 2001-01-01 10:00:00 0 1 0 : 9.0911 : for 7 : 2001-01-01 12:00:00 0 1 0 : 9.2452 : for 8 : 2001-01-01 14:00:00 0 1 0 : 9.3787 : for 9 : 2001-01-01 16:00:00 0 1 0 : 9.4965 : for 10 : 2001-01-01 18:00:00 0 1 0 : 9.6019 : for
For regular-gridded data CDO can compute the ares needed, but for other grids like unstructured of curvilinear the coordinates variables need a proper bound
attribute given.
hth + best wishes from my side of the planet ;-)
ralf
RE: Extracting data from grid cells - Added by Khumo Monaka almost 6 years ago
Ok Thank you very much. and thanks for the prompt reply. I highly appreciate that.
Warm Regards from my side of the planet
Many thanks
RE: Extracting data from grid cells - Added by Christ Reflin over 3 years ago
Dear Mr/Mrs,
I have a question regarding the mean from your example above.
Why are the mean between them (without and adding fldmean) not the same?
Thank you
Christ
RE: Extracting data from grid cells - Added by Karin Meier-Fleischer over 3 years ago
Hi Christian,
I guess the difference is that fldmean computation is weighted by the area weights obtained by the input field (see docu).
-Karin
RE: Extracting data from grid cells - Added by Christ Reflin over 3 years ago
Here I attached the example,
I apologize if my question is not well described
data1 is the temperature data of specific regions in 3D
flmean_data1 is the temperature data after performing fldmean operator.
I use "cdo info" operator to check the mean among them. what I found the mean are different
Could you explain that why?
Thank you
Christ
data1.nc (4.3 MB) data1.nc | |||
fldmean_data1.nc (73.3 KB) fldmean_data1.nc |
RE: Extracting data from grid cells - Added by Ralf Mueller over 3 years ago
hi!
the MEAN output of the info
operators is not an area weighted mean, but a simple arithmetic mean. Area weighted mean would be to costly for a simple information overview.
cheers
ralf
RE: Extracting data from grid cells - Added by Karin Meier-Fleischer over 3 years ago
When you use the fldmean operator with the weights=false argument the result is the same as the column of Mean of data1.nc:
cdo -fldmean,weights=false data1.nc fldmean_weights_false.nc
cdo -fldmean data1.nc fldmean.nc
Let's see what the ouput for the first 5 timesteps looks like for data1.nc, fldmean.nc and fldmean_weights_false.nc:
cdo infon -seltimestep,1/5 data1.nc -seltimestep,1/5 fldmean.nc -seltimestep,1/5 fldmean_weights_false.nc cdo(1) seltimestep: Process started cdo(2) seltimestep: Process started cdo(3) seltimestep: Process started -1 : Date Time Level Gridsize Miss : Minimum Mean Maximum : Parameter name 1 : 1990-01-01 00:00:00 0 2451 0 : 7.5006 19.707 27.133 : Temperature_Air_2m_Mean_24h 2 : 1990-01-02 00:00:00 0 2451 0 : 8.8276 21.037 28.466 : Temperature_Air_2m_Mean_24h 3 : 1990-01-03 00:00:00 0 2451 0 : 9.0990 21.464 29.438 : Temperature_Air_2m_Mean_24h 4 : 1990-01-04 00:00:00 0 2451 0 : 10.010 22.400 30.088 : Temperature_Air_2m_Mean_24h 5 : 1990-01-05 00:00:00 0 2451 0 : 10.232 22.574 27.752 : Temperature_Air_2m_Mean_24h cdo(1) seltimestep: Processed 12255 values from 1 variable over 6 timesteps. -2 : Date Time Level Gridsize Miss : Minimum Mean Maximum : Parameter name 1 : 1990-01-01 00:00:00 0 1 0 : 19.711 : Temperature_Air_2m_Mean_24h 2 : 1990-01-02 00:00:00 0 1 0 : 21.046 : Temperature_Air_2m_Mean_24h 3 : 1990-01-03 00:00:00 0 1 0 : 21.468 : Temperature_Air_2m_Mean_24h 4 : 1990-01-04 00:00:00 0 1 0 : 22.402 : Temperature_Air_2m_Mean_24h 5 : 1990-01-05 00:00:00 0 1 0 : 22.577 : Temperature_Air_2m_Mean_24h cdo(2) seltimestep: Processed 5 values from 1 variable over 6 timesteps. -3 : Date Time Level Gridsize Miss : Minimum Mean Maximum : Parameter name 1 : 1990-01-01 00:00:00 0 1 0 : 19.707 : Temperature_Air_2m_Mean_24h 2 : 1990-01-02 00:00:00 0 1 0 : 21.037 : Temperature_Air_2m_Mean_24h 3 : 1990-01-03 00:00:00 0 1 0 : 21.464 : Temperature_Air_2m_Mean_24h 4 : 1990-01-04 00:00:00 0 1 0 : 22.400 : Temperature_Air_2m_Mean_24h 5 : 1990-01-05 00:00:00 0 1 0 : 22.574 : Temperature_Air_2m_Mean_24h
RE: Extracting data from grid cells - Added by Christ Reflin over 3 years ago
Thank you for the response,
I failed to understand that important part " fldmean wighted by area weights " and I have looked the cdo doc
one more short question Sir/Mam,
Why does fldmean consider the area weights in computing the mean?
Thank you
Christ