- Timestamp:
- 12/09/11 18:08:09 (13 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/file_amsu_t2_to_mem.pro
r450 r454 5 5 ; ======================= 6 6 ; 7 ; .. function:: file_amsu_t2_to_mem(yyyy, mm, dd, numch, lon_min, lon_max, lat_min, lat_max,testfilename)7 ; .. function:: file_amsu_t2_to_mem(yyyy, mm, dd, numch, testfilename) 8 8 ; 9 9 ; DESCRIPTION … … 25 25 ; 26 26 ; Realistic example with VARAMMA file AMSU-A chanel 5 27 ; :file:`${PROJECT_ID}/AMSU/2006/08/a5_20060801 _060w30s_050e45n.dat`::27 ; :file:`${PROJECT_ID}/AMSU/2006/08/a5_20060801.dat`:: 28 28 ; 29 29 ; IDL> numch='a5' 30 ; IDL> yyyy=2006 30 ; IDL> yyyy=2006L 31 31 ; IDL> mm=8 32 32 ; IDL> dd=1 33 ; IDL> lon_min=-60.34 ; IDL> lon_max=50.35 ; IDL> lat_min=-30.36 ; IDL> lat_max=45.37 33 ; IDL> testfilename='' 38 ; IDL> result = file_amsu_t2_to_mem(yyyy, mm, dd, numch a, lon_min, lon_max, lat_min, lat_max, testfilename)34 ; IDL> result = file_amsu_t2_to_mem(yyyy, mm, dd, numch, testfilename) 39 35 ; 40 36 ; impression de controle : structure et 1re ligne de données:: … … 55 51 ; ==== 56 52 ; 53 ; ajouter de # dans les lignes d'entete 54 ; 57 55 ; à intégrer dans correct_nadir_amsu.pro 58 56 ; … … 68 66 ; $URL$ 69 67 ; 68 ; - fplod 20111209T150657Z cratos (Linux) 69 ; 70 ; * suppression des parametres de zone géographique 71 ; * ajout de nbpix dans la première ligne de header 72 ; * ajout d'une seconde ligne d'entete avec les coordonnées de la zone 73 70 74 ; - fplod 20111208T110651Z cratos (Linux) 71 75 ; … … 80 84 ; - fplod 20111205T094831Z aedon.locean-ipsl.upmc.fr (Darwin) 81 85 ; 82 ; * creation : semble ok pour le fichier de test amsub seul 86 ; * creation thanks to http://www.idlcoyote.com/tips/ascii_column_data.html 87 ; 88 ; semble ok pour le fichier de test amsub seul 83 89 ; 84 90 ;- 85 91 FUNCTION file_amsu_t2_to_mem, yyyy, mm, dd, numch $ 86 , lon_min, lon_max, lat_min, lat_max $87 92 , testfilename 88 93 ; … … 94 99 ON_ERROR, 2 95 100 ; 96 usage = 'result=file_amsu_t2_to_mem(yyyy, mm, dd, numch, lon_min, lon_max, lat_min, lat_max,testfilename)'101 usage = 'result=file_amsu_t2_to_mem(yyyy, mm, dd, numch, testfilename)' 97 102 nparam = N_PARAMS() 98 IF (nparam NE 9) THEN BEGIN103 IF (nparam NE 5) THEN BEGIN 99 104 ras = report(['Incorrect number of arguments.' $ 100 105 + '!C' $ … … 103 108 ENDIF 104 109 ; 105 look = 'filename'106 scale = 1.107 geomin = geolocation_to_string_idl(lon_min, lat_min, look, scale)108 geomax = geolocation_to_string_idl(lon_max, lat_max, look, scale)109 110 if (testfilename eq '') then begin 110 111 fullfilename = project_id_env+ 'AMSU/' $ … … 114 115 + string(yyyy,format='(I4.4)') $ 115 116 + string(mm,format='(I2.2)') $ 116 + string(dd,format='(I2.2)') + '_' $ 117 + geomin + '_' $ 118 + geomax $ 117 + string(dd,format='(I2.2)') $ 119 118 + '.dat' 120 119 endif else begin … … 125 124 ; 126 125 ; build header format string 127 format_header = '(I4.4,I2.2,I2.2,1X,A)' 126 format_header1 = '(I4.4,I2.2,I2.2,1X,A2,1X,I3.3)' 127 format_header2 = '(1x,f8.3,1x,f8.3,1x,f8.3,1x,f8.3)' 128 128 ; 129 129 ; build data format string 130 format_data = '(i1,1x,f8.4,i3, 2(1x,f8.3),1x,I1,1x,f8.3)'130 format_data = '(i1,1x,f8.4,i3,1x,f8.3,1x,f8.3,1x,I1,1x,f8.3)' 131 131 ; 132 ; initialize header 133 header = STRARR(1) 134 ; 135 resultheaderstruct = { yyyy : 0L $ 132 header1= { yyyy : 0L $ 136 133 , mm : 0L $ 137 134 , dd : 0L $ 138 135 , numch : 'X' $ 136 , nbpix : 0L $ 139 137 } 140 resultdatastruct = { desc : 0 $ 138 header2= { lon_min: 0L $ 139 , lon_max: 0L $ 140 , lat_min: 0L $ 141 , lat_max: 0L $ 142 } 143 144 datastruct = { desc : 0 $ 141 145 , hour : 0.0 $ 142 146 , fov : 0 $ … … 147 151 } 148 152 ; 149 nrows = file_lines(fullfilename) - N_ELEMENTS(header);153 nrows = file_lines(fullfilename) - 2 150 154 ; 151 resultdata = Replicate(resultdatastruct, nrows) 152 result={header: resultheaderstruct, data: resultdata} 155 data = Replicate(datastruct, nrows) 153 156 ; 154 157 ; open file 155 158 OPENR, lun, fullfilename, /GET_LUN 156 ;++ han lde error159 ;++ handle error 157 160 ; 158 161 help, result,/structure 162 help, header1,/structure 159 163 ; read header lines 160 READF, lun, result.header, format=format_header 164 READF, lun, header1, format=format_header1 165 print, header1 166 READF, lun, header2, format=format_header2 167 ; 168 print, header2 161 169 ; read data lines 162 READF, lun, result.data, format=format_data170 READF, lun, data, format=format_data 163 171 ; 164 172 ; close file 165 173 FREE_LUN, lun 166 174 ; 175 result={header1: header1, header2: header2, data: data} 167 176 return, result 168 177 ; -
trunk/src/mem_to_file_amsu_t2.pro
r451 r454 25 25 ; 26 26 ; IDL> numch='a5' 27 ; IDL> yyyy=2006 27 ; IDL> yyyy=2006L 28 28 ; IDL> mm=8 29 29 ; IDL> dd=1 … … 33 33 ; IDL> lat_max=45. 34 34 ; IDL> testfilename='' 35 ; IDL> amsu_t2 = file_amsu_t2_to_mem(yyyy, mm, dd, numch, lon_min, lon_max, lat_min, lat_max,testfilename)35 ; IDL> amsu_t2 = file_amsu_t2_to_mem(yyyy, mm, dd, numch, testfilename) 36 36 ; IDL> testfilename='./a' 37 ; IDL> result = mem_to_file_amsu_t2( yyyy, mm, dd, numch, lon_min, lon_max, lat_min, lat_max,amsu_t2, testfilename)37 ; IDL> result = mem_to_file_amsu_t2(amsu_t2, testfilename) 38 38 ; 39 39 ; look for differences:: … … 48 48 ; :func:`file_amsu_t2_to_mem` 49 49 ; 50 ; use :func:`geolocation_to_string_idl`51 ;52 50 ; TODO 53 51 ; ==== 52 ; 53 ; ajouter de # dans les lignes d'entete 54 54 ; 55 55 ; crier sur valeur manquante de tb 56 56 ; 57 57 ; à intégrer dans :ref:`extract_amsua.pro` 58 ;59 ; suppress other parameter than amsu_t2 : doublons !! pas sur lat_min, etc,60 ; est-ce qu'on es ajoute dans le header ?61 58 ; 62 59 ; check args … … 71 68 ; $URL$ 72 69 ; 70 ; - fplod 20111209T150209Z cratos (Linux) 71 ; 72 ; * ajout de nbpix dans la première ligne de header 73 ; * ajout d'une seconde ligne d'entete avec les coordonnées de la zone 74 ; * suppression de parametres redondants 75 ; 73 76 ; - fplod 20111208T173432Z aedon.locean-ipsl.upmc.fr (Darwin) 74 77 ; … … 82 85 ; - fplod 20111206T163330Z cratos (Linux) 83 86 ; 84 ; * creation 87 ; * creation thanks to http://www.idlcoyote.com/tips/ascii_column_data.html 85 88 ; 86 89 ;- 87 FUNCTION mem_to_file_amsu_t2, yyyy, mm, dd, numch $ 88 , lon_min, lon_max, lat_min, lat_max $ 89 , amsu_t2 $ 90 FUNCTION mem_to_file_amsu_t2, amsu_t2 $ 90 91 , testfilename 91 92 ; … … 99 100 result = -1 100 101 ; 101 usage = 'result=mem_to_file_amsu_t2( yyyy, mm, dd, numch, lon_min, lon_max, lat_min, lat_max,amsu_t2, testfilename)'102 usage = 'result=mem_to_file_amsu_t2(amsu_t2, testfilename)' 102 103 nparam = N_PARAMS() 103 IF (nparam NE 10) THEN BEGIN104 IF (nparam NE 2) THEN BEGIN 104 105 ras = report(['Incorrect number of arguments.' $ 105 106 + '!C' $ … … 109 110 ; 110 111 if (testfilename eq '') then begin 111 look = 'filename'112 scale = 1.113 geomin = geolocation_to_string_idl(lon_min, lat_min, look, scale)114 geomax = geolocation_to_string_idl(lon_max, lat_max, look, scale)115 112 fullfilename = project_id_env+ 'AMSU/' $ 116 113 + string(yyyy,format='(I4.4)') + '/' $ … … 119 116 + string(yyyy,format='(I4.4)') $ 120 117 + string(mm,format='(I2.2)') $ 121 + string(dd,format='(I2.2)') + '_' $ 122 + geomin + '_' $ 123 + geomax $ 118 + string(dd,format='(I2.2)') $ 124 119 + '.dat' 125 120 endif else begin … … 130 125 ; 131 126 ; build header format string 132 format_header = '(I4.4,I2.2,I2.2,1X,A)' 133 ; 127 format_header1 = '(I4.4,I2.2,I2.2,1X,A2,1X,I3.3)' 128 format_header2 = '(1x,f8.3,1x,f8.3,1x,f8.3,1x,f8.3)' 129 134 130 ; build data format string 135 format_data = '(i1,1x,f8.4,i3, 2(1x,f8.3),1x,I1,1x,f8.3)'131 format_data = '(i1,1x,f8.4,i3,1x,f8.3,1x,f8.3,1x,I1,1x,f8.3)' 136 132 ; 137 133 nrows = n_elements(amsu_t2.data) … … 142 138 ; 143 139 ; write header lines 144 PRINTF, lun, amsu_t2.header, format=format_header 140 header1=amsu_t2.header1 141 PRINTF, lun, header1, format=format_header1 142 header2=amsu_t2.header2 143 PRINTF, lun, header2, format=format_header2 145 144 ; 146 145 ; write data lines 147 146 for irow=0, nrows -1 do begin 148 PRINTF, lun, amsu_t2.data[irow], format=format_data 147 data=amsu_t2.data[irow] 148 PRINTF, lun, data, format=format_data 149 149 endfor 150 150 ;
Note: See TracChangeset
for help on using the changeset viewer.