;+ ; ; ======================== ; file_asc_to_mem.pro ; ======================== ; ; .. function:: file_asc_to_mem() ; ; Read all station information files and store data in a structure ; ; :returns: data structure +todo+ details or -1 if error ; :rtype: structure +todo+ details ; ; :examples: ; ; Realistic example with POMME files: ; ; .. code-block:: idl ; ; result = file_asc_to_mem() ; ; impression de contrĂ´le : ; ; .. code-block:: idl ; ; help, result,/structure ; print, result ; ; :todo: ; ; parametrisation ?? ; ; learn how to concatenate array of structure (and avoid loop) ; ; :history: ; ; - fplod 20101126T134144Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * creation ; ; :version: ; ; $Id$ ; ;- FUNCTION file_asc_to_mem ; ; Return to caller if errors ON_ERROR, 2 ; usage = 'result = file_asc_to_mem()' nparam = N_PARAMS() IF (nparam NE 0) THEN BEGIN ras = report(['Incorrect number of arguments.' $ + '!C' $ + 'Usage : ' + usage]) return, -1 ENDIF ; resultstruct = { station: 0L $ , aa: 0L $ , mm: 0L $ , jj: 0L $ , hh: 0L $ , mn: 0L $ , lat : 0.0 $ , lon: 0.0 $ } nrows = 0L ; filename='/usr/work/incas/fplod/pomme_d/sta.P1L1.asc' data_p1l1 = file_asc_p1l1_to_mem(filename) nrows = nrows + n_elements(data_p1l1) filename='/usr/work/incas/fplod/pomme_d/sta.P1L2.asc' data_p1l2 = file_asc_long2mem(filename) nrows = nrows + n_elements(data_p1l2) filename='/usr/work/incas/fplod/pomme_d/sta.P2L1.asc' data_p2l1 = file_asc_p2l1_to_mem(filename) nrows = nrows + n_elements(data_p2l1) filename='/usr/work/incas/fplod/pomme_d/sta.P2L2.asc' data_p2l2 = file_asc_p2l2_to_mem(filename) nrows = nrows + n_elements(data_p2l2) ; result = Replicate(resultstruct, nrows) ; offset = 0L ; nstations = n_elements(data_p1l1) FOR istation = 0L, nstations - 1 DO BEGIN rstation = istation + offset result[rstation].station = data_p1l1[istation].station result[rstation].aa = data_p1l1[istation].an result[rstation].mm = data_p1l1[istation].mm result[rstation].jj = data_p1l1[istation].jj result[rstation].hh = data_p1l1[istation].hh_begin result[rstation].mn = data_p1l1[istation].mm_begin result[rstation].lat = dm2dd(data_p1l1[istation].deg_lat_begin,data_p1l1[istation].mm_lat_begin) result[rstation].lon = dm2dd(data_p1l1[istation].deg_lon_begin,data_p1l1[istation].mm_lon_begin) ENDFOR offset = offset + nstations ; nstations = n_elements(data_p1l2) FOR istation = 0L, nstations - 1 DO BEGIN rstation = istation + offset result[rstation].station = data_p1l2[istation].station result[rstation].aa = data_p1l2[istation].an result[rstation].mm = data_p1l2[istation].mm result[rstation].jj = data_p1l2[istation].jj result[rstation].hh = data_p1l2[istation].hh_begin result[rstation].mn = data_p1l2[istation].mm_begin result[rstation].lat = dm2dd(data_p1l2[istation].deg_lat_begin,data_p1l2[istation].mm_lat_begin) result[rstation].lon = dm2dd(data_p1l2[istation].deg_lon_begin,data_p1l2[istation].mm_lon_begin) ENDFOR offset = offset + nstations ; nstations = n_elements(data_p2l1) ; FOR istation = 0L, nstations - 1 DO BEGIN rstation = istation + offset result[rstation].station = data_p2l1[istation].station result[rstation].aa = data_p2l1[istation].an result[rstation].mm = data_p2l1[istation].mm result[rstation].jj = data_p2l1[istation].jj result[rstation].hh = data_p2l1[istation].hh_begin result[rstation].mn = data_p2l1[istation].mm_begin result[rstation].lat = data_p2l1[istation].lat_begin result[rstation].lon = data_p2l1[istation].lon_begin ENDFOR offset = offset + nstations ; nstations = n_elements(data_p2l2) FOR istation = 0L, nstations - 1 DO BEGIN rstation = istation + offset result[rstation].station = data_p2l2[istation].station result[rstation].aa = data_p2l2[istation].an result[rstation].mm = data_p2l2[istation].mm result[rstation].jj = data_p2l2[istation].jj result[rstation].hh = data_p2l2[istation].hh_begin result[rstation].mn = data_p2l2[istation].mm_begin result[rstation].lat = dm2dd(data_p2l2[istation].deg_lat_begin,data_p2l2[istation].mm_lat_begin) result[rstation].lon = dm2dd(data_p2l2[istation].deg_lon_begin,data_p2l2[istation].mm_lon_begin) ENDFOR ; return, result END