Re,Replacedef axis/t/units=years tyears=v1[i=1]bydef axis/t=01-JUL-`v1[i=1,l=1]`:01-JUL-`v1[i=1,l=($nblines)]`:1/units=years/cal=360_day tyearsfor a correct time definition axis.Patrick--
Data Analytics and Visualization Engineer / Project Manager
LSCE/IPSL, CEA-CNRS-UVSQ laboratory
LSCE - Climate and Environment Sciences Laboratory
IPSL - Institut Pierre Simon Laplace
--De: "Patrick Brockmann" <patrick.brockmann@xxxxxxxxxxxx>
À: "ferret users" <ferret_users@xxxxxxxx>
Cc: "Pierre Friedlingstein" <P.Friedlingstein@xxxxxxxxxxxx>
Envoyé: Mardi 19 Janvier 2021 16:53:19
Objet: Re: [ferret_users] Reading ascii fileHi Pierre,Here is a solution.Haven't found simpler.!####################################################################################################def symb fileInput=($01%nbp.txt%)
def sym nblines=`{SPAWN:"cat ($fileInput) | wc -l"}`
def sym nbcolumns=`{SPAWN:"head -n 1 ($fileInput) | awk '{ print NF}'"}`
!====================================================
! Read file
def axis/x=1:($nbcolumns):1 xaxis
def axis/t=1:($nblines):1 taxis
def grid/x=xaxis/t=taxis mygrid
file/g=mygrid/column=($nbcolumns) "($fileInput)"
list v1
!====================================================
! First colum is a time axis
def axis/x=1:`($nbcolumns)-1`:1 regions
def axis/t/units=years tyears=v1[i=1]
def grid/t=tyears/x=regions myvargrid
let/title="nbp"/units="" nbp=reshape(v1[i=2:($nbcolumns)], x[g=myvargrid]*t[g=myvargrid])
list nbp
show grid nbp
shade/transpose nbp!####################################################################################################RegardsPatrick--
Data Analytics and Visualization Engineer / Project Manager
LSCE/IPSL, CEA-CNRS-UVSQ laboratory
LSCE - Climate and Environment Sciences Laboratory
IPSL - Institut Pierre Simon Laplace
--De: "Pierre Friedlingstein" <P.Friedlingstein@xxxxxxxxxxxx>
À: "ferret users" <ferret_users@xxxxxxxx>
Envoyé: Mardi 19 Janvier 2021 12:30:28
Objet: [ferret_users] Reading ascii fileHi allSimple question…I’m trying to read an ascii file with 60 rows (each row is one year of data) and 19 columns : column 1 is year; columns 2 to 19 are the same variable but different regions (18 regions).I want to create one variable (nbp) with 18 levels, one per region.Here is what I do, which doesn’t work :define axis/T=1960:2019:1/units=year taxisdefine axis/X=1:18:1 xaxisdefine grid/T=taxis/X=xaxis mygridfile/grid=mygrid/var= -,nbp "nbp.txt"nbp.txt data set looks like:1960 0.1057 0.1246 0.0017 0.0261 0.1735 0.0007 0.1255 -0.0361 0.1433 0.0259 0.2508 0.0715 -0.0019 0.0497 0.0097 -0.0506 0.0337 0.11551961 0.1384 0.0131 0.0600 -0.0145 -0.1744 -0.0061 0.0745 0.0995 0.0983 0.2071 0.1119 -0.0024 -0.0095 0.0683 -0.0033 0.1095 0.1027 -0.13601962 0.1392 0.1059 -0.0192 0.0475 0.1448 -0.1352 0.0794 0.0687 0.3754 0.0063 0.2532 -0.0055 -0.0132 0.1012 0.0167 0.0619 0.1222 0.02421963 0.0146 0.1110 0.0093 0.0423 -0.2498 0.0166 0.0950 0.1127 0.2832 0.1909 0.0421 0.0049 0.0688 0.0115 0.0124 0.0391 -0.0151 0.1944When I do this I get the following, which is obviously not right.yes? show datacurrently SET data sets:1> ./nbp.txt (default)name title I J K LNBP nbp 1:18 ... ... 1:60
yes? list nbp[i=1]VARIABLE : nbpFILENAME : nbp.txtSUBSET : 3 points (T (YEAR))X : 1111960 / 1: 0.10571961 / 2: 0.18631962 / 3: 0.2176yes? list nbp[l=1]VARIABLE : nbpFILENAME : nbp.txtSUBSET : 18 points (X)T (YEAR) : 19601 / 1: 0.10572 / 2: 0.13843 / 3: 0.13924 / 4: 0.01465 / 5: 0.06766 / 6: 0.26047 / 7: 0.10938 / 8: 0.19799 / 9: 0.264810 / 10: 0.193311 / 11: 0.030912 / 12: 0.086113 / 13: 0.202014 / 14: 0.235915 / 15: 0.186816 / 16: 0.241617 / 17: 0.203718 / 18: -0.0313Thanks for you help.Pierre
Attachment:
xconv1.94_linux_x86_64.tar.gz
Description: application/gzip