Changeset 13 for trunk/src/file_asc_long2mem.pro
- Timestamp:
- 02/18/14 11:03:22 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/file_asc_long2mem.pro
r9 r13 21 21 ; :examples: 22 22 ; 23 ; ::23 ; .. code-block:: idl 24 24 ; 25 ; IDL>filename='/usr/work/incas/fplod/pomme_d/sta.P1L2.asc'26 ; IDL> result=file_asc_long2mem(filename)25 ; filename='/usr/work/incas/fplod/pomme_d/sta.P1L2.asc' 26 ; result = file_asc_long2mem(filename) 27 27 ; 28 ; impression de contrôle : structure, 1re station, toutes les stations : :28 ; impression de contrôle : structure, 1re station, toutes les stations : 29 29 ; 30 ; IDL> print, result, /structure 31 ; IDL> print, result[0].station 32 ; IDL> print, result.station 30 ; .. code-block:: idl 31 ; 32 ; print, result, /structure 33 ; print, result[0].station 34 ; print, result.station 33 35 ; 34 36 ; :uses: … … 62 64 ;- 63 65 FUNCTION file_asc_long2mem, filename 64 ;65 compile_opt idl2, strictarrsubs66 ;67 ; Return to caller if errors68 ON_ERROR, 269 ;70 usage = 'result=file_asc_long2mem(filename)'71 ;72 nparam = N_PARAMS()73 IF (nparam LT 1) THEN BEGIN74 ras = report(['Incorrect number of arguments.' $75 76 77 return, -178 ENDIF79 ;80 arg_type = size(filename,/type)81 IF (arg_type NE 7) THEN BEGIN82 ras = report(['Incorrect arg type filename' $83 84 85 return, -186 ENDIF87 ;88 arg_dim = size(filename,/n_elements)89 IF (arg_dim LT 1) THEN BEGIN90 ras = report(['Incorrect arg dimension filename' $91 92 93 return, -194 ENDIF95 ;96 ; initialize header97 header = STRARR(1)98 ;99 resultstruct = { station: 0L $100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 ;119 nrows = file_lines(filename) - N_ELEMENTS(header)120 result = Replicate(resultstruct, nrows)121 ;122 ; open file123 OPENR, lun, filename, /GET_LUN124 ;++ hanlde error125 ;126 ; read header127 READF, lun, header128 ;129 ; read data lines130 READF, lun, result131 ;132 ; close file133 FREE_LUN, lun134 ;135 return, result136 ;66 ; 67 compile_opt idl2, strictarrsubs 68 ; 69 ; Return to caller if errors 70 ON_ERROR, 2 71 ; 72 usage = 'result = file_asc_long2mem(filename)' 73 ; 74 nparam = N_PARAMS() 75 IF (nparam LT 1) THEN BEGIN 76 ras = report(['Incorrect number of arguments.' $ 77 + '!C' $ 78 + 'Usage : ' + usage]) 79 return, -1 80 ENDIF 81 ; 82 arg_type = size(filename,/type) 83 IF (arg_type NE 7) THEN BEGIN 84 ras = report(['Incorrect arg type filename' $ 85 + '!C' $ 86 + 'Usage : ' + usage]) 87 return, -1 88 ENDIF 89 ; 90 arg_dim = size(filename,/n_elements) 91 IF (arg_dim LT 1) THEN BEGIN 92 ras = report(['Incorrect arg dimension filename' $ 93 + '!C' $ 94 + 'Usage : ' + usage]) 95 return, -1 96 ENDIF 97 ; 98 ; initialize header 99 header = STRARR(1) 100 ; 101 resultstruct = { station: 0L $ 102 , sonde: 0L $ 103 , zmax: 0L $ 104 , an: 0L $ 105 , mm: 0L $ 106 , jj: 0L $ 107 , hh_begin: 0L $ 108 , mm_begin: 0L $ 109 , ss: 0L $ 110 , deg_lat_begin : 0L $ 111 , mm_lat_begin: 0.0 $ 112 , deg_lon_begin: 0L $ 113 , mm_lon_begin: 0.0 $ 114 , deg_lat_end: 0L $ 115 , mm_lat_end: 0.0 $ 116 , deg_lon_end: 0L $ 117 , mm_lon_end: 0.0 $ 118 , hh_end: 0L $ 119 , mm_end: 0L } 120 ; 121 nrows = file_lines(filename) - N_ELEMENTS(header) 122 result = Replicate(resultstruct, nrows) 123 ; 124 ; open file 125 OPENR, lun, filename, /GET_LUN 126 ;++ hanlde error 127 ; 128 ; read header 129 READF, lun, header 130 ; 131 ; read data lines 132 READF, lun, result 133 ; 134 ; close file 135 FREE_LUN, lun 136 ; 137 return, result 138 ; 137 139 END
Note: See TracChangeset
for help on using the changeset viewer.