Dear Ferret Users,
I would like to ask a question regarding the data of global CO2 concentration (ppm), as followings:
1750.042 277.32 1750.125 277.32 1750.209 277.32 1750.292 277.33 1750.375 277.33 1750.459 277.33 1750.542 277.34 1750.625 277.34 1750.709 277.34 1750.792 277.34 1750.875 277.35 1750.959 277.35 1751.042 277.35 1751.125 277.36
I believe that the first column is the year with fraction (monthly data), then I would like to convert the txt file into nc file (yymm) by using ferret. As I found in ferret archive, there is an example of script (for daily data: date_decimal.jnl) created by Jason Kurian:
data: 1993.333333 361.7019 1993.354167 361.0358 1993.375000 360.2827 1993.395833 359.5100
script:
! Ferret will not read numbers like "1993.333333" properly. So read the ! integer part (1993) and the decimal part (333333) separately. ! This scipt expects a soft link of the original data CO2_obs.dat, ! in the name dummy.dat, to be present in pwd. ! To create soft links in Linux : ! [user@machine]$ ln -s CO2_obs.dat dummy.dat ! ! It is assumed that data exists only after 01-JAN-1991.
define axis/t=1:4:1 tfile ! modify this according to number of obs. ---- define grid/t=tfile gfile FILE/grid=gfile/format=delimited/DELIMITER=".,\b"\ /var="year,yfrac" CO2_obs.dat FILE/grid=gfile/var="-,co" dummy.dat
let year_length = 365 ! in days, NOLEAP Calendar let dfrac = (yfrac[d=1]/1E6)*year_length let tvals = (year[d=1] - 1991)*year_length + dfrac ! time axis defined below depends on the year 1991 ! used to calculate tvals above define axis/t/units=days/T0=31-DEC-1990/from_data time=tvals
let co2 = co[d=2,gt=time@ASN] ! CO2 comes from d=2, dummy.dat
plot co2 ========================
Then I've tried to adopt the script for monthly data with some modifications:
define axis/t=1:3169:1 tfile ! modify this according to number of obs. define grid/t=tfile gfile FILE/grid=gfile/format=delimited/DELIMITER=".,\b"\ /var="year,yfrac"/skip=18 CO2.txt FILE/grid=gfile/var="-,co" dummy.dat
let year_length = 12 ! in months let dfrac = (yfrac[d=1]/1E3)*year_length let tvals = (year[d=1] - 1750)*year_length + dfrac ! time axis defined below depends on the year 1750 ! used to calculate tvals above define axis/t/units=days/T0=31-DEC-1749/from_data time=tvals
let co2 = co[d=2,gt=time@ASN] ! CO2 comes from d=2, dummy.dat
plot co2
---- but there is a warning as followings:
*** NOTE: Axis has repeated values -- micro-adjusting ... **ERROR: improper grid or axis definition: unrepairable repeated axis coords define axis/t/units=days/T0=31-DEC-1749/from_data time=tvals Command file, command group, or REPEAT execution aborted
-----
I wish some advices about this script and I really appreciate for any suggestion about this matter.
Thank you in advance.
Sincerely yours, dessy
|