source: trunk/src/file_asc_to_mem.pro @ 9

Last change on this file since 9 was 9, checked in by pinsard, 13 years ago

new SAXO and IDL init

  • 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; parametrisation ??
29;
30; learn how to concatenate array of structure (and avoid loop)
31;
32; :history:
33;
34; - fplod 20101126T134144Z aedon.locean-ipsl.upmc.fr (Darwin)
35;
36;   * creation
37;
38; :version:
39;
40; $Id$
41;
42;-
43FUNCTION file_asc_to_mem
44;
45; Return to caller if errors
46ON_ERROR, 2
47;
48usage = 'result=file_asc_to_mem()'
49nparam = N_PARAMS()
50IF (nparam NE 0) THEN BEGIN
51   ras = report(['Incorrect number of arguments.' $
52         + '!C' $
53         + 'Usage : ' + usage])
54   return, -1
55ENDIF
56;
57resultstruct = { station: 0L $
58                 , aa: 0L $
59                 , mm: 0L $
60                 , jj: 0L $
61                 , hh: 0L $
62                 , mn: 0L $
63                 , lat : 0.0 $
64                 , lon: 0.0 $
65               }
66nrows=0L
67;
68filename='/usr/work/incas/fplod/pomme_d/sta.P1L1.asc'
69data_p1l1=file_asc_p1l1_to_mem(filename)
70nrows = nrows + n_elements(data_p1l1)
71filename='/usr/work/incas/fplod/pomme_d/sta.P1L2.asc'
72data_p1l2=file_asc_long2mem(filename)
73nrows = nrows + n_elements(data_p1l2)
74filename='/usr/work/incas/fplod/pomme_d/sta.P2L1.asc'
75data_p2l1=file_asc_p2l1_to_mem(filename)
76nrows = nrows + n_elements(data_p2l1)
77filename='/usr/work/incas/fplod/pomme_d/sta.P2L2.asc'
78data_p2l2=file_asc_p2l2_to_mem(filename)
79nrows = nrows + n_elements(data_p2l2)
80;
81result = Replicate(resultstruct, nrows)
82;
83offset = 0L
84;
85nstations = n_elements(data_p1l1)
86FOR istation=0L, nstations -1 DO BEGIN
87
88   rstation = istation + offset
89   result[rstation].station=data_p1l1[istation].station
90   result[rstation].aa=data_p1l1[istation].an
91   result[rstation].mm=data_p1l1[istation].mm
92   result[rstation].jj=data_p1l1[istation].jj
93   result[rstation].hh=data_p1l1[istation].hh_begin
94   result[rstation].mn=data_p1l1[istation].mm_begin
95   result[rstation].lat=dm2dd(data_p1l1[istation].deg_lat_begin,data_p1l1[istation].mm_lat_begin)
96   result[rstation].lon=dm2dd(data_p1l1[istation].deg_lon_begin,data_p1l1[istation].mm_lon_begin)
97ENDFOR
98
99offset=offset + nstations
100;
101nstations = n_elements(data_p1l2)
102FOR istation=0L, nstations -1 DO BEGIN
103   rstation = istation + offset
104   result[rstation].station=data_p1l2[istation].station
105   result[rstation].aa=data_p1l2[istation].an
106   result[rstation].mm=data_p1l2[istation].mm
107   result[rstation].jj=data_p1l2[istation].jj
108   result[rstation].hh=data_p1l2[istation].hh_begin
109   result[rstation].mn=data_p1l2[istation].mm_begin
110   result[rstation].lat=dm2dd(data_p1l2[istation].deg_lat_begin,data_p1l2[istation].mm_lat_begin)
111   result[rstation].lon=dm2dd(data_p1l2[istation].deg_lon_begin,data_p1l2[istation].mm_lon_begin)
112ENDFOR
113
114offset=offset + nstations
115;
116nstations = n_elements(data_p2l1)
117;
118FOR istation=0L, nstations -1 DO BEGIN
119   rstation = istation + offset
120   result[rstation].station=data_p2l1[istation].station
121   result[rstation].aa=data_p2l1[istation].an
122   result[rstation].mm=data_p2l1[istation].mm
123   result[rstation].jj=data_p2l1[istation].jj
124   result[rstation].hh=data_p2l1[istation].hh_begin
125   result[rstation].mn=data_p2l1[istation].mm_begin
126   result[rstation].lat=data_p2l1[istation].lat_begin
127   result[rstation].lon=data_p2l1[istation].lon_begin
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].aa=data_p2l2[istation].an
137   result[rstation].mm=data_p2l2[istation].mm
138   result[rstation].jj=data_p2l2[istation].jj
139   result[rstation].hh=data_p2l2[istation].hh_begin
140   result[rstation].mn=data_p2l2[istation].mm_begin
141   result[rstation].lat=dm2dd(data_p2l2[istation].deg_lat_begin,data_p2l2[istation].mm_lat_begin)
142   result[rstation].lon=dm2dd(data_p2l2[istation].deg_lon_begin,data_p2l2[istation].mm_lon_begin)
143ENDFOR
144;
145return, result
146
147END
Note: See TracBrowser for help on using the repository browser.