Percentage anomaly values
Added by Brian Yalle almost 4 years ago
I want to group percentage values of precipitation and runoff anomalies in CSV format. The ideal output looks like:
- >-30
- [-30, -15]
- [-15, 15]
- [15, 30]
- >30
I don't know if the previous can be directly obtained using CDO but I guess it's simpler to get percentage anomalies. I wonder if there's a code to yield porcentages values from daily anomalies.
If not, then the another option is dividing daily anomalies for a specific year by mean daily values from a long period then multiplied by 100. I tried this last option, and the codes used until that point were:
To obtain daily anomalies for entire 2017 from the 30-year period (1981-2010)cdo ydaysub era5land_tp_daily_ene-dic_2017.nc -ydaymean era5land_tp_daily_ene-dic_1981-2010.nc daily-anomaly-2017_tp.nc
cdo -outputtab,date,lat:6,lon:6,value:8 daily-anomaly-2017_tp.nc | grep -v '#' | tr -s ' ' | sed -e 's/ /,/g;s/^.//;s/.$//' >> daily-anomaly-2017_tp.csv
To obtain mean daily values from 30-year periodcdo -ydaymean era5land_tp_daily_ene-dic_1981-2010.nc tp_daily-mean_1981-2010.nc
cdo -outputtab,date,lat:6:lon:6,value:8 tp_daily-mean_1981-2010.nc | grep -v '#' | tr -s ' ' | sed -e 's/ /,/g;s/^.//;s/.$//' >> tp_daily-mean_1981-2010.csv
These codes correspond to precipitation variables and they were also applied to runoff variable. Before I continued programming I found something unexpected:head -14 tp_daily-mean_1981-2010.csv
2010-01-01,-0.1,-32767
2010-01-01,-0.1,-32767
2010-01-01,-0.1,-32767
2010-01-01,-0.1,-32767
2010-01-01,-0.1,-32767
2010-01-01,-0.1,-32767
2010-01-01,-0.1,-32767
2010-01-01,-0.1,-32767
2010-01-01,-0.1,-32767
2010-01-01,-0.1,-32767
2010-01-01,-0.1,-32767
2010-01-01,-0.1,-32767
2010-01-01,-0.1,25.9561521281094
2010-01-01,-0.1,27.9590223039447
head -14 ro_daily-mean_1981-2010.csv
2010-01-01,-0.1,-81.4,-32767
2010-01-01,-0.1,-81.3,-32767
2010-01-01,-0.1,-81.2,-32767
2010-01-01,-0.1,-81.1,-32767
2010-01-01,-0.1,-81,-32767
2010-01-01,-0.1,-80.9,-32767
2010-01-01,-0.1,-80.8,-32767
2010-01-01,-0.1,-80.7,-32767
2010-01-01,-0.1,-80.6,-32767
2010-01-01,-0.1,-80.5,-32767
2010-01-01,-0.1,-80.4,-32767
2010-01-01,-0.1,-80.3,-32767
2010-01-01,-0.1,-80.2,5.43978407804101
2010-01-01,-0.1,-80.1,5.20370183084038
The second sample of observations shows all desired variables but there's no longitude variable in the first sample.
I'll appreciate your help in any step to achieve my main goal.
Thanks
Replies (2)
RE: Percentage anomaly values - Added by Karin Meier-Fleischer almost 4 years ago
Hi Brian,
there is a a typo (: instead of ,).
Instead of
cdo -outputtab,date,lat:6:lon:6,value:8 tp_daily-mean_1981-2010.nc | grep -v '#' | tr -s ' ' | sed -e 's/ /,/g;s/^.//;s/.$//' >> tp_daily-mean_1981-2010.csv
use
cdo -outputtab,date,lat:6,lon:6,value:8 tp_daily-mean_1981-2010.nc | grep -v '#' | tr -s ' ' | sed -e 's/ /,/g;s/^.//;s/.$//' >> tp_daily-mean_1981-2010.csv
-Karin
RE: Percentage anomaly values - Added by Brian Yalle almost 4 years ago
You're right Karin, I did not notice that.