[Thread Prev][Thread Next][Index]

Re: [ferret_users] list question



Hi Otacilio,
There are two questions here.  One is how to list the data for time1, time2, time3, time4 for a given site on a single line, and the other is how to include the text variable "name" on the line with the data.

Ferret limits the kinds of format specifiers it allows; we haven't implemented the more complex combinations of string and numeric specs, but there's still a way to do what you want.

You have a variable precip which depends on time and station number, so maybe it's a variable in x and t.  I'll make up a variable, just so we can work through an example.  Here is the variable and the listing we'd get with just the default LIST command.

 DEFINE AXIS/T=1-FEB-2001:5-FEB-2001:1/T0=1-JAN-2001/UNITS=days tday
 LET precip = 10*X[X=1:8] + T[GT=tday]
 LIST precip
             VARIABLE : 10*X[I=1:8] + T[GT=TDAY]
             SUBSET   : 8 by 5 points (X-TIME)
                        1      2      3      4      5      6      7      8   
                        1      2      3      4      5      6      7      8
 01-FEB-2001 00 / 1:   41.0   51.0   61.0   71.0   81.0   91.0  101.0  111.0
 02-FEB-2001 00 / 2:   42.0   52.0   62.0   72.0   82.0   92.0  102.0  112.0
 03-FEB-2001 00 / 3:   43.0   53.0   63.0   73.0   83.0   93.0  103.0  113.0
 04-FEB-2001 00 / 4:   44.0   54.0   64.0   74.0   84.0   94.0  104.0  114.0
 05-FEB-2001 00 / 5:   45.0   55.0   65.0   75.0   85.0   95.0  105.0  115.0

What you want is to to list the numbers in column 1 which is x=1, t=1:5 on one line, then on the next line the values at x=2, t=1:5, and so on.  For listing just the variable, we could just use the command "LIST/ORDER=TX precip" but because we also want to write the site name, we'll use a loop to set up a new Fortran format for each site.

You also have a list of site names, so I'll define a variable with the names.

 LET name = {"Site 1", "Site 2", "Site 3", "Site 4", "Site 5", "Site 6", "Site 7", "Site 8"}

Now, what I'm going to do is  a loop over I=1:8 where I get the site name and put it into a symbol, and then use that symbol to define a Fortran format for each line.  So the format for line 1 is /FORMAT=('Site 1', 5f8.2)  and so on.  The /I=`i`/ORDER=TX means that for each I, the variable will be listed with t  varying fastest, across the line.
 
   REPEAT/I=1:8  ( LET iname = name[I=`i`]; \
      DEFINE SYMBOL sname = `iname`; \
      LIST/NOHEADER/APPEND/FILE=filename.txt/FORM=('($sname)', 5F8.2)/I=`i`/ORDER=TX precip)

As it runs, the commands echo. Look at the format that is created.

!-> REPEAT: I=1
 !-> DEFINE VARIABLE iname = name[I=1]
 !-> DEFINE SYMBOL sname = Site 1
 !-> LIST/NOHEADER/APPEND/FILE=filename.txt/FORM=('Site 1', 5F8.2)/I=1/ORDER=tx precip
 LISTing to file filename.txt

!-> REPEAT: I=2
 !-> DEFINE VARIABLE iname = name[I=2]
 !-> DEFINE SYMBOL sname = Site 2
 !-> LIST/NOHEADER/APPEND/FILE=filename.txt/FORM=('Site 2', 5F8.2)/I=2/ORDER=tx precip
 LISTing to file filename.txt
 ...


and the contents of filename.txt are:

   Site 1   41.00   42.00   43.00   44.00   45.00
   Site 2   51.00   52.00   53.00   54.00   55.00
   Site 3   61.00   62.00   63.00   64.00   65.00
   Site 4   71.00   72.00   73.00   74.00   75.00
   Site 5   81.00   82.00   83.00   84.00   85.00
   Site 6   91.00   92.00   93.00   94.00   95.00
   Site 7  101.00  102.00  103.00  104.00  105.00
   Site 8  111.00  112.00  113.00  114.00  115.00



Otacilio Leandro wrote:
Dear friends,

I'm trying to write a time series of the preciptation for several diferent sites like this:

# Time 1 Time 2 Time 3 Time 4 Time 5
Site 1 Value Value Value Value Value
Site 2 Value Value Value Value Value
Site 3 Value Value Value Value Value
Site 4 Value Value Value Value Value
Site 5 Value Value Value Value Value
Site 6 Value Value Value Value Value
Site 7 Value Value Value Value Value
Site 8 Value Value Value Value Value

but when i use the comand:

list/nohead/append/format=(4f8.2)/file=`mod`-`label`-horaria.txt name, precip

where name is the string of the name of the site and precip is a value i got thos error:

**ERROR: invalid command: format disallowed for multiple variables w/ strings

Is that possible to wirte out a file like that?? 
Thanks for the help

--
Ms. Otacilio Leandro de Menezes Neto
Grupo de Modelagem Atmosférica
Departamento de Meteorologia e Oceanografia
Fundação Cearense de Meteorologia e Recursos Hídricos
Av. Rui Barbosa 1246 - CEP 60115-221
Fortaleza, Ceará
Fone: (85) 3101-1106 / 3101-1126

[Thread Prev][Thread Next][Index]

Contact Us
Dept of Commerce / NOAA / OAR / PMEL / TMAP

Privacy Policy | Disclaimer | Accessibility Statement