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 | ;- |
---|
46 | FUNCTION file_prn_to_mem |
---|
47 | ; |
---|
48 | ; Return to caller if errors |
---|
49 | ON_ERROR, 2 |
---|
50 | ; |
---|
51 | usage = 'result=file_prn_to_mem()' |
---|
52 | nparam = N_PARAMS() |
---|
53 | IF (nparam NE 0) THEN BEGIN |
---|
54 | ras = report(['Incorrect number of arguments.' $ |
---|
55 | + '!C' $ |
---|
56 | + 'Usage : ' + usage]) |
---|
57 | return, -1 |
---|
58 | ENDIF |
---|
59 | ; |
---|
60 | resultstruct = { 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 | ; |
---|
69 | nrows=0L |
---|
70 | ; |
---|
71 | filename='/usr/work/incas/fplod/pomme_d/mld_prieur_P1L1.prn' |
---|
72 | data_p1l1=file_prn2mem(filename) |
---|
73 | nrows = nrows + n_elements(data_p1l1) |
---|
74 | filename='/usr/work/incas/fplod/pomme_d/mld_prieur_P1L2_tot.prn' |
---|
75 | data_p1l2=file_prn2mem(filename) |
---|
76 | nrows = nrows + n_elements(data_p1l2) |
---|
77 | filename='/usr/work/incas/fplod/pomme_d/mld_prieur_P2L1.prn' |
---|
78 | data_p2l1=file_prn2mem(filename) |
---|
79 | nrows = nrows + n_elements(data_p2l1) |
---|
80 | filename='/usr/work/incas/fplod/pomme_d/mld_prieur_P2L2.prn' |
---|
81 | data_p2l2=file_prn2mem(filename) |
---|
82 | nrows = nrows + n_elements(data_p2l2) |
---|
83 | ; |
---|
84 | result = Replicate(resultstruct, nrows) |
---|
85 | ; |
---|
86 | offset = 0L |
---|
87 | ; |
---|
88 | nstations = n_elements(data_p1l1) |
---|
89 | FOR 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 |
---|
99 | ENDFOR |
---|
100 | |
---|
101 | offset=offset + nstations |
---|
102 | ; |
---|
103 | nstations = n_elements(data_p1l2) |
---|
104 | FOR 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 |
---|
113 | ENDFOR |
---|
114 | |
---|
115 | offset=offset + nstations |
---|
116 | ; |
---|
117 | nstations = n_elements(data_p2l1) |
---|
118 | ; |
---|
119 | FOR 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 |
---|
128 | ENDFOR |
---|
129 | |
---|
130 | offset=offset + nstations |
---|
131 | ; |
---|
132 | nstations = n_elements(data_p2l2) |
---|
133 | FOR 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 |
---|
142 | ENDFOR |
---|
143 | ; |
---|
144 | return, result |
---|
145 | |
---|
146 | END |
---|