source: trunk/src/file_prn_to_mem.pro @ 2

Last change on this file since 2 was 2, checked in by pinsard, 14 years ago

first commit with original work of Marina Levy and Francoise Pinsard

  • Property svn:keywords set to Id
File size: 3.9 KB
Line 
1;+
2;
3; ===================
4; file_prn_to_mem.pro
5; ===================
6;
7; .. function:: file_prn_to_mem()
8;
9;    Read all station information files and store data in a structure
10;
11; nb : mld float to handle NaN in file
12;
13;    :returns: data structure +todo+ details or -1 if error
14;    :rtype: structure +todo+ details
15;
16; :examples:
17;
18; Realistic example with POMME files::
19;   
20;    IDL> result=file_prn_to_mem()
21;
22; impression de controle::
23;
24;    IDL> help, result, /structure
25;    IDL> print, result
26;
27; :todo:
28;
29; parametrisation ??
30;
31; usage of ${POMME_ID}
32;
33; learn how to concatenate array of structure (and avoid loop)
34;
35; :history:
36;
37; - fplod 20101126T134144Z aedon.locean-ipsl.upmc.fr (Darwin)
38;
39;   * creation
40;
41; :version:
42;
43; $Id$
44;
45;-
46FUNCTION file_prn_to_mem
47;
48; Return to caller if errors
49ON_ERROR, 2
50;
51usage = 'result=file_prn_to_mem()'
52nparam = N_PARAMS()
53IF (nparam NE 0) THEN BEGIN
54   ras = report(['Incorrect number of arguments.' $
55         + '!C' $
56         + 'Usage : ' + usage])
57   return, -1
58ENDIF
59;
60resultstruct = { station: 0L $
61               , doy: 0.0 $
62               , zhom001: 0.0 $
63               , zhom002 : 0.0 $
64               , zhom005 : 0.0 $
65               , zhom010: 0.0 $
66               , zhomelch : 0.0 $
67               }
68;
69nrows=0L
70;
71filename='/usr/work/incas/fplod/pomme_d/mld_prieur_P1L1.prn'
72data_p1l1=file_prn2mem(filename)
73nrows = nrows + n_elements(data_p1l1)
74filename='/usr/work/incas/fplod/pomme_d/mld_prieur_P1L2_tot.prn'
75data_p1l2=file_prn2mem(filename)
76nrows = nrows + n_elements(data_p1l2)
77filename='/usr/work/incas/fplod/pomme_d/mld_prieur_P2L1.prn'
78data_p2l1=file_prn2mem(filename)
79nrows = nrows + n_elements(data_p2l1)
80filename='/usr/work/incas/fplod/pomme_d/mld_prieur_P2L2.prn'
81data_p2l2=file_prn2mem(filename)
82nrows = nrows + n_elements(data_p2l2)
83;
84result = Replicate(resultstruct, nrows)
85;
86offset = 0L
87;
88nstations = n_elements(data_p1l1)
89FOR istation=0L, nstations -1 DO BEGIN
90
91   rstation = istation + offset
92   result[rstation].station=data_p1l1[istation].station
93   result[rstation].doy=data_p1l1[istation].doy
94   result[rstation].zhom001=data_p1l1[istation].zhom001
95   result[rstation].zhom002=data_p1l1[istation].zhom002
96   result[rstation].zhom005=data_p1l1[istation].zhom005
97   result[rstation].zhom010=data_p1l1[istation].zhom010
98   result[rstation].zhomelch=data_p1l1[istation].zhomelch
99ENDFOR
100
101offset=offset + nstations
102;
103nstations = n_elements(data_p1l2)
104FOR istation=0L, nstations -1 DO BEGIN
105   rstation = istation + offset
106   result[rstation].station=data_p1l2[istation].station
107   result[rstation].doy=data_p1l2[istation].doy
108   result[rstation].zhom001=data_p1l2[istation].zhom001
109   result[rstation].zhom002=data_p1l2[istation].zhom002
110   result[rstation].zhom005=data_p1l2[istation].zhom005
111   result[rstation].zhom010=data_p1l2[istation].zhom010
112   result[rstation].zhomelch=data_p1l2[istation].zhomelch
113ENDFOR
114
115offset=offset + nstations
116;
117nstations = n_elements(data_p2l1)
118;
119FOR istation=0L, nstations -1 DO BEGIN
120   rstation = istation + offset
121   result[rstation].station=data_p2l1[istation].station
122   result[rstation].doy=data_p2l1[istation].doy
123   result[rstation].zhom001=data_p2l1[istation].zhom001
124   result[rstation].zhom002=data_p2l1[istation].zhom002
125   result[rstation].zhom005=data_p2l1[istation].zhom005
126   result[rstation].zhom010=data_p2l1[istation].zhom010
127   result[rstation].zhomelch=data_p2l1[istation].zhomelch
128ENDFOR
129
130offset=offset + nstations
131;
132nstations = n_elements(data_p2l2)
133FOR istation=0L, nstations -1 DO BEGIN
134   rstation = istation + offset
135   result[rstation].station=data_p2l2[istation].station
136   result[rstation].doy=data_p2l2[istation].doy
137   result[rstation].zhom001=data_p2l2[istation].zhom001
138   result[rstation].zhom002=data_p2l2[istation].zhom002
139   result[rstation].zhom005=data_p2l2[istation].zhom005
140   result[rstation].zhom010=data_p2l2[istation].zhom010
141   result[rstation].zhomelch=data_p2l2[istation].zhomelch
142ENDFOR
143;
144return, result
145
146END
Note: See TracBrowser for help on using the repository browser.