source: trunk/src/file_asc_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: 4.2 KB
Line 
1;+
2;
3; ========================
4; file_asc_to_mem.pro
5; ========================
6;
7; .. function:: file_asc_to_mem()
8;
9;    Read all station information files and store data in a structure
10;
11;    :returns: data structure +todo+ details or -1 if error
12;    :rtype: structure +todo+ details
13;
14; :examples:
15;
16; Realistic example with POMME files::
17;
18;    IDL> result=file_asc_to_mem()
19;
20; impression de controle::
21;
22;    IDL> help, result,/structure
23;    IDL> print, result
24;
25;
26; :todo:
27;
28; usage of ${POMME_ID}
29;
30; parametrisation ??
31;
32; learn how to concatenate array of structure (and avoid loop)
33;
34; :history:
35;
36; - fplod 20101126T134144Z aedon.locean-ipsl.upmc.fr (Darwin)
37;
38;   * creation
39;
40; :version:
41;
42; $Id$
43;
44;-
45FUNCTION file_asc_to_mem
46;
47; Return to caller if errors
48ON_ERROR, 2
49;
50usage = 'result=file_asc_to_mem()'
51nparam = N_PARAMS()
52IF (nparam NE 0) THEN BEGIN
53   ras = report(['Incorrect number of arguments.' $
54         + '!C' $
55         + 'Usage : ' + usage])
56   return, -1
57ENDIF
58;
59resultstruct = { station: 0L $
60                 , aa: 0L $
61                 , mm: 0L $
62                 , jj: 0L $
63                 , hh: 0L $
64                 , mn: 0L $
65                 , lat : 0.0 $
66                 , lon: 0.0 $
67               }
68nrows=0L
69;
70filename='/usr/work/incas/fplod/pomme_d/sta.P1L1.asc'
71data_p1l1=file_asc_p1l1_to_mem(filename)
72nrows = nrows + n_elements(data_p1l1)
73filename='/usr/work/incas/fplod/pomme_d/sta.P1L2.asc'
74data_p1l2=file_asc_long2mem(filename)
75nrows = nrows + n_elements(data_p1l2)
76filename='/usr/work/incas/fplod/pomme_d/sta.P2L1.asc'
77data_p2l1=file_asc_p2l1_to_mem(filename)
78nrows = nrows + n_elements(data_p2l1)
79filename='/usr/work/incas/fplod/pomme_d/sta.P2L2.asc'
80data_p2l2=file_asc_p2l2_to_mem(filename)
81nrows = nrows + n_elements(data_p2l2)
82;
83result = Replicate(resultstruct, nrows)
84;
85offset = 0L
86;
87nstations = n_elements(data_p1l1)
88FOR istation=0L, nstations -1 DO BEGIN
89
90   rstation = istation + offset
91   result[rstation].station=data_p1l1[istation].station
92   result[rstation].aa=data_p1l1[istation].an
93   result[rstation].mm=data_p1l1[istation].mm
94   result[rstation].jj=data_p1l1[istation].jj
95   result[rstation].hh=data_p1l1[istation].hh_begin
96   result[rstation].mn=data_p1l1[istation].mm_begin
97   result[rstation].lat=dm2dd(data_p1l1[istation].deg_lat_begin,data_p1l1[istation].mm_lat_begin)
98   result[rstation].lon=dm2dd(data_p1l1[istation].deg_lon_begin,data_p1l1[istation].mm_lon_begin)
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].aa=data_p1l2[istation].an
108   result[rstation].mm=data_p1l2[istation].mm
109   result[rstation].jj=data_p1l2[istation].jj
110   result[rstation].hh=data_p1l2[istation].hh_begin
111   result[rstation].mn=data_p1l2[istation].mm_begin
112   result[rstation].lat=dm2dd(data_p1l2[istation].deg_lat_begin,data_p1l2[istation].mm_lat_begin)
113   result[rstation].lon=dm2dd(data_p1l2[istation].deg_lon_begin,data_p1l2[istation].mm_lon_begin)
114ENDFOR
115
116offset=offset + nstations
117;
118nstations = n_elements(data_p2l1)
119;
120FOR istation=0L, nstations -1 DO BEGIN
121   rstation = istation + offset
122   result[rstation].station=data_p2l1[istation].station
123   result[rstation].aa=data_p2l1[istation].an
124   result[rstation].mm=data_p2l1[istation].mm
125   result[rstation].jj=data_p2l1[istation].jj
126   result[rstation].hh=data_p2l1[istation].hh_begin
127   result[rstation].mn=data_p2l1[istation].mm_begin
128   result[rstation].lat=data_p2l1[istation].lat_begin
129   result[rstation].lon=data_p2l1[istation].lon_begin
130ENDFOR
131
132offset=offset + nstations
133;
134nstations = n_elements(data_p2l2)
135FOR istation=0L, nstations -1 DO BEGIN
136   rstation = istation + offset
137   result[rstation].station=data_p2l2[istation].station
138   result[rstation].aa=data_p2l2[istation].an
139   result[rstation].mm=data_p2l2[istation].mm
140   result[rstation].jj=data_p2l2[istation].jj
141   result[rstation].hh=data_p2l2[istation].hh_begin
142   result[rstation].mn=data_p2l2[istation].mm_begin
143   result[rstation].lat=dm2dd(data_p2l2[istation].deg_lat_begin,data_p2l2[istation].mm_lat_begin)
144   result[rstation].lon=dm2dd(data_p2l2[istation].deg_lon_begin,data_p2l2[istation].mm_lon_begin)
145ENDFOR
146;
147return, result
148
149END
Note: See TracBrowser for help on using the repository browser.