source: trunk/src/file_prn_to_mem.pro

Last change on this file was 15, checked in by pinsard, 10 years ago

fix thanks to coding rules; typo

  • Property svn:keywords set to Id
File size: 4.4 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; .. code-block:: idl
21;
22;    result = file_prn_to_mem()
23;
24; impression de contrÃŽle :
25;
26; .. code-block:: idl
27;
28;    help, result, /structure
29;    print, result
30;
31; :uses:
32;
33; :func:`file_prn2mem`
34;
35; :see also:
36;
37; :program:`fig_mld`
38;
39; :todo:
40;
41; parametrisation ??
42;
43; learn how to concatenate array of structure (and avoid loop)
44;
45; réparer lien sphinx à fig_mld
46;
47; :history:
48;
49; - fplod 20101126T134144Z aedon.locean-ipsl.upmc.fr (Darwin)
50;
51;   * creation
52;
53; :version:
54;
55; $Id$
56;
57;-
58FUNCTION file_prn_to_mem
59    ;
60    ; Return to caller if errors
61    ON_ERROR, 2
62    ;
63    usage = 'result = file_prn_to_mem()'
64    nparam = N_PARAMS()
65    IF (nparam NE 0) THEN BEGIN
66        ras = report(['Incorrect number of arguments.' $
67        + '!C' $
68        + 'Usage : ' + usage])
69        return, -1
70    ENDIF
71    ;
72    resultstruct = { station: 0L $
73    , doy: 0.0 $
74    , zhom001: 0.0 $
75    , zhom002 : 0.0 $
76    , zhom005 : 0.0 $
77    , zhom010: 0.0 $
78    , zhomelch : 0.0 $
79    }
80    ;
81    nrows = 0L
82    ;
83    filename='/usr/work/incas/fplod/pomme_d/mld_prieur_P1L1.prn'
84    data_p1l1 = file_prn2mem(filename)
85    nrows = nrows + n_elements(data_p1l1)
86    filename='/usr/work/incas/fplod/pomme_d/mld_prieur_P1L2_tot.prn'
87    data_p1l2 = file_prn2mem(filename)
88    nrows = nrows + n_elements(data_p1l2)
89    filename='/usr/work/incas/fplod/pomme_d/mld_prieur_P2L1.prn'
90    data_p2l1 = file_prn2mem(filename)
91    nrows = nrows + n_elements(data_p2l1)
92    filename='/usr/work/incas/fplod/pomme_d/mld_prieur_P2L2.prn'
93    data_p2l2 = file_prn2mem(filename)
94    nrows = nrows + n_elements(data_p2l2)
95    ;
96    result = Replicate(resultstruct, nrows)
97    ;
98    offset = 0L
99    ;
100    nstations = n_elements(data_p1l1)
101    FOR istation = 0L, nstations - 1 DO BEGIN
102        rstation = istation + offset
103        result[rstation].station = data_p1l1[istation].station
104        result[rstation].doy = data_p1l1[istation].doy
105        result[rstation].zhom001 = data_p1l1[istation].zhom001
106        result[rstation].zhom002 = data_p1l1[istation].zhom002
107        result[rstation].zhom005 = data_p1l1[istation].zhom005
108        result[rstation].zhom010 = data_p1l1[istation].zhom010
109        result[rstation].zhomelch = data_p1l1[istation].zhomelch
110    ENDFOR
111
112    offset = offset + nstations
113    ;
114    nstations = n_elements(data_p1l2)
115    FOR istation = 0L, nstations - 1 DO BEGIN
116        rstation = istation + offset
117        result[rstation].station = data_p1l2[istation].station
118        result[rstation].doy = data_p1l2[istation].doy
119        result[rstation].zhom001 = data_p1l2[istation].zhom001
120        result[rstation].zhom002 = data_p1l2[istation].zhom002
121        result[rstation].zhom005 = data_p1l2[istation].zhom005
122        result[rstation].zhom010 = data_p1l2[istation].zhom010
123        result[rstation].zhomelch = data_p1l2[istation].zhomelch
124    ENDFOR
125
126    offset = offset + nstations
127    ;
128    nstations = n_elements(data_p2l1)
129    ;
130    FOR istation = 0L, nstations - 1 DO BEGIN
131        rstation = istation + offset
132        result[rstation].station = data_p2l1[istation].station
133        result[rstation].doy = data_p2l1[istation].doy
134        result[rstation].zhom001 = data_p2l1[istation].zhom001
135        result[rstation].zhom002 = data_p2l1[istation].zhom002
136        result[rstation].zhom005 = data_p2l1[istation].zhom005
137        result[rstation].zhom010 = data_p2l1[istation].zhom010
138        result[rstation].zhomelch = data_p2l1[istation].zhomelch
139    ENDFOR
140
141    offset = offset + nstations
142    ;
143    nstations = n_elements(data_p2l2)
144    FOR istation = 0L, nstations - 1 DO BEGIN
145        rstation = istation + offset
146        result[rstation].station = data_p2l2[istation].station
147        result[rstation].doy = data_p2l2[istation].doy
148        result[rstation].zhom001 = data_p2l2[istation].zhom001
149        result[rstation].zhom002 = data_p2l2[istation].zhom002
150        result[rstation].zhom005 = data_p2l2[istation].zhom005
151        result[rstation].zhom010 = data_p2l2[istation].zhom010
152        result[rstation].zhomelch = data_p2l2[istation].zhomelch
153    ENDFOR
154    ;
155    return, result
156
157END
Note: See TracBrowser for help on using the repository browser.