Hi,
You can actually define a time axis directly from that data. Ferret
will interpret data in units of "year" including fraction of year.
yes? file/var="ty, co2" dat.txt
yes? define axis/t/units=year/t0=1-jan-0000 taxis = ty
yes? list/prec=7 t[gt=taxis]
VARIABLE : T
axis TAXIS
SUBSET : 14 points (TIME)
15-JAN-1750 / 1: 1750.042
15-FEB-1750 / 2: 1750.125
17-MAR-1750 / 3: 1750.209
17-APR-1750 / 4: 1750.292
17-MAY-1750 / 5: 1750.375
17-JUN-1750 / 6: 1750.459
17-JUL-1750 / 7: 1750.542
16-AUG-1750 / 8: 1750.625
16-SEP-1750 / 9: 1750.709
16-OCT-1750 / 10: 1750.792
15-NOV-1750 / 11: 1750.875
16-DEC-1750 / 12: 1750.959
15-JAN-1751 / 13: 1751.042
15-FEB-1751 / 14: 1751.125
So you can put the CO2data onto that axis, and you're all set.
On 3/5/2015 2:33 AM, 'Dessy Berlianty'
via _OAR PMEL Ferret Users wrote:
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
|