source: trunk/src/file_asc_p1l1_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: 2.5 KB
Line 
1;+
2;
3; ========================
4; file_asc_p1l1_to_mem.pro
5; ========================
6;
7; .. function:: file_asc_p1l1_to_mem(filename)
8;
9;    Read P1L1 station information files and store data in a structure
10;
11;    :param filename: filename to be read
12;    :type filename: string
13;    :raise filename: required
14;
15;    :returns: data structure +todo+ details or -1 if error
16;    :rtype: structure +todo+ details
17;
18; notes
19; guessed header
20;
21; :examples:
22;
23; ::
24;
25;    IDL> filename='/usr/work/incas/fplod/pomme_d/sta.P1L1.asc'
26;    IDL> result=file_asc_p1l1_to_mem(filename)
27;
28; impression de contrôle : 1re station, toutes les stations ::
29;
30;    IDL> help, result, /structure
31;    IDL> print, result[0].station
32;    IDL> print, result.station
33;
34; :uses:
35;
36; :func:`report <saxo:report>`
37;
38; :restrictions:
39;
40; :todo:
41;
42; format fixe
43;
44; test existence of filename
45;
46; :history:
47;
48; - fplod 20101123T122132Z aedon.locean-ipsl.upmc.fr (Darwin)
49;
50;   * creation using "Reading Into a Structure" of
51;     http://www.dfanning.com/tips/ascii_column_data.html
52;
53;
54; :version:
55;
56; $Id$
57;
58;-
59FUNCTION file_asc_p1l1_to_mem, filename
60;
61compile_opt idl2, strictarrsubs
62;
63; Return to caller if errors
64ON_ERROR, 2
65;
66usage = 'result=file_asc_p1l1_to_mem(filename)'
67;
68nparam = N_PARAMS()
69IF (nparam LT 1) THEN BEGIN
70   ras = report(['Incorrect number of arguments.' $
71         + '!C' $
72         + 'Usage : ' + usage])
73   return, -1
74ENDIF
75;
76arg_type = size(filename,/type)
77IF (arg_type NE 7) THEN BEGIN
78   ras = report(['Incorrect arg type filename' $
79         + '!C' $
80         + 'Usage : ' + usage])
81   return, -1
82ENDIF
83;
84arg_dim =  size(filename,/n_elements)
85IF (arg_dim LT 1) THEN BEGIN
86   ras = report(['Incorrect arg dimension filename' $
87         + '!C' $
88         + 'Usage : ' + usage])
89  return, -1
90ENDIF
91;
92; initialize header
93header = STRARR(1)
94;
95resultstruct = { station:0L $
96                 , prof :0L $
97                 , zctd : 0L $
98                 , an: 0L $
99                 , mm: 0L $
100                 , jj: 0L $
101                 , hh_begin: 0L $
102                 , mm_begin: 0L $
103                 , ss_begin: 0L $
104                 , deg_lat_begin : 0L $
105                 , mm_lat_begin: 0.0 $
106                 , deg_lon_begin: 0L $
107                 , mm_lon_begin: 0.0 $
108               }
109nrows = file_lines(filename) - N_ELEMENTS(header);
110result = Replicate(resultstruct, nrows)
111;
112; open file
113OPENR, lun, filename, /GET_LUN
114;++ hanlde error
115;
116; read header
117READF, lun, header
118;
119; read data lines
120READF, lun, result
121;
122; close file
123FREE_LUN, lun
124;
125return, result
126;
127END
Note: See TracBrowser for help on using the repository browser.