- Timestamp:
- 12/08/11 18:13:31 (13 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/file_amsu_t2_to_mem.pro
r445 r450 5 5 ; ======================= 6 6 ; 7 ; .. function:: file_amsu_t2_to_mem(yyyy, mm, dd, use_amsua, lon_min, lon_max, lat_min, lat_max)7 ; .. function:: file_amsu_t2_to_mem(yyyy, mm, dd, numch, lon_min, lon_max, lat_min, lat_max, testfilename) 8 8 ; 9 9 ; DESCRIPTION 10 10 ; =========== 11 11 ; 12 ; Read an amsu_t2 file and store data in astructure12 ; Read an amsu_t2 file and store data and header in structure 13 13 ; 14 ; Ths type of file has been produced by :ref:`extract_amsuab.pro` 14 ; This type of file has been produced by :ref:`extract_amsua.pro` 15 ; thow landseamask is NaN++ 16 ; 17 ; If **testfilename** is not empty, this filename will be written, otherwise 18 ; amsu_t2 terminology will be applied. 15 19 ; 16 20 ; :returns: data structure +todo+ details or -1 if error … … 20 24 ; ======== 21 25 ; 22 ; Realistic example with VARAMMA file 23 ; :file:`${PROJECT_ID}/AMSU/2006/08/a msua_amsub_20060801_060w30s_050e45n.dat` AMSU_A and AMSU-B::26 ; Realistic example with VARAMMA file AMSU-A chanel 5 27 ; :file:`${PROJECT_ID}/AMSU/2006/08/a5_20060801_060w30s_050e45n.dat`:: 24 28 ; 25 ; IDL> use_amsua=129 ; IDL> numch='a5' 26 30 ; IDL> yyyy=2006 27 31 ; IDL> mm=8 … … 31 35 ; IDL> lat_min=-30. 32 36 ; IDL> lat_max=45. 33 ; IDL> result = file_amsu_t2_to_mem(yyyy, mm, dd, use_amsua, lon_min, lon_max, lat_min, lat_max) 37 ; IDL> testfilename='' 38 ; IDL> result = file_amsu_t2_to_mem(yyyy, mm, dd, numcha, lon_min, lon_max, lat_min, lat_max, testfilename) 34 39 ; 35 ; Realistic example with VARAMMA file 36 ; :file:`${PROJECT_ID}/AMSU/2006/08/amsub_20060801_060w30s_050e45n.dat` AMSU-B only:: 37 ; 38 ; IDL> use_amsua=0 39 ; IDL> yyyy=2006 40 ; IDL> mm=8 41 ; IDL> dd=1 42 ; IDL> lon_min=-60. 43 ; IDL> lon_max=50. 44 ; IDL> lat_min=-30. 45 ; IDL> lat_max=45. 46 ; IDL> result = file_amsu_t2_to_mem(yyyy, mm, dd, use_amsua, lon_min, lon_max, lat_min, lat_max) 47 ; 48 ; impression de controle : structure et 1re ligne:: 40 ; impression de controle : structure et 1re ligne de données:: 49 41 ; 50 42 ; IDL> help, result, /structure 51 ; IDL> print, result[0] 52 ; 43 ; IDL> print, result.data[0] 53 44 ; 54 45 ; SEE ALSO 55 46 ; ======== 56 47 ; 57 ; :ref:`extract_amsua b.pro`48 ; :ref:`extract_amsua.pro` 58 49 ; 59 50 ; :func:`mem_to_file_amsu_t2` … … 68 59 ; check args 69 60 ; 70 ; prendre en compte aussi les nadir.dat71 ;72 61 ; ecrire le module de dessin 73 62 ; … … 78 67 ; 79 68 ; $URL$ 69 ; 70 ; - fplod 20111208T110651Z cratos (Linux) 71 ; 72 ; * changement de format et de terminologie 80 73 ; 81 74 ; - fplod 20111206T161848Z aedon.locean-ipsl.upmc.fr (Darwin) … … 90 83 ; 91 84 ;- 92 FUNCTION file_amsu_t2_to_mem, yyyy, mm, dd, use_amsua $ 93 , lon_min, lon_max, lat_min, lat_max 85 FUNCTION file_amsu_t2_to_mem, yyyy, mm, dd, numch $ 86 , lon_min, lon_max, lat_min, lat_max $ 87 , testfilename 94 88 ; 95 89 compile_opt idl2, strictarrsubs … … 100 94 ON_ERROR, 2 101 95 ; 102 usage = 'result=file_amsu_t2_to_mem(yyyy, mm, dd, use_amsua, lon_min, lon_max, lat_min, lat_max)'96 usage = 'result=file_amsu_t2_to_mem(yyyy, mm, dd, numch, lon_min, lon_max, lat_min, lat_max, testfilename)' 103 97 nparam = N_PARAMS() 104 IF (nparam NE 8) THEN BEGIN98 IF (nparam NE 9) THEN BEGIN 105 99 ras = report(['Incorrect number of arguments.' $ 106 100 + '!C' $ … … 109 103 ENDIF 110 104 ; 111 if (use_amsua eq 1) then begin112 prefix = 'amsua_amsub_'113 endif else begin114 prefix = 'amsub_'115 endelse116 105 look = 'filename' 117 106 scale = 1. 118 107 geomin = geolocation_to_string_idl(lon_min, lat_min, look, scale) 119 108 geomax = geolocation_to_string_idl(lon_max, lat_max, look, scale) 120 fullfilename = project_id_env+ 'AMSU/' $ 121 + string(yyyy,format='(I4.4)') + '/' $ 122 + string(mm,format='(I2.2)') + '/' $ 123 + prefix+string(yyyy,format='(I4.4)') $ 124 + string(mm,format='(I2.2)') $ 125 + string(dd,format='(I2.2)') + '_' $ 126 + geomin + '_' $ 127 + geomax $ 128 + '.dat' 109 if (testfilename eq '') then begin 110 fullfilename = project_id_env+ 'AMSU/' $ 111 + string(yyyy,format='(I4.4)') + '/' $ 112 + string(mm,format='(I2.2)') + '/' $ 113 + numch + '_' $ 114 + string(yyyy,format='(I4.4)') $ 115 + string(mm,format='(I2.2)') $ 116 + string(dd,format='(I2.2)') + '_' $ 117 + geomin + '_' $ 118 + geomax $ 119 + '.dat' 120 endif else begin 121 fullfilename = testfilename 122 endelse 129 123 ; 130 124 print, 'ouverture pour lecture de ', fullfilename 131 125 ; 132 if (use_amsua eq 1) then begin 133 resultstruct = { month : 0L $ 134 , yrday : 0L $ 135 , orbit : 0L $ 136 , hour : 0.0$ 137 , fov : 0L$ 138 , nosat : 0L$ 139 , lon : 0.0$ 140 , lat: 0.0$ 141 , zen: 0.0$ 142 , ach_adj: fltarr(15) $ 143 , bch_adj: fltarr(5) $ 126 ; build header format string 127 format_header = '(I4.4,I2.2,I2.2,1X,A)' 128 ; 129 ; build data format string 130 format_data = '(i1,1x,f8.4,i3,2(1x,f8.3),1x,I1,1x,f8.3)' 131 ; 132 ; initialize header 133 header = STRARR(1) 134 ; 135 resultheaderstruct = { yyyy : 0L $ 136 , mm : 0L $ 137 , dd : 0L $ 138 , numch : 'X' $ 139 } 140 resultdatastruct = { desc : 0 $ 141 , hour : 0.0 $ 142 , fov : 0 $ 143 , lon : 0.0 $ 144 , lat: 0.0 $ 145 , landseamask: 0$ 146 , tb : 0.0 $ 144 147 } 145 endif else begin146 resultstruct = {month : 0L $147 , yrday : 0L $148 , orbit : 0L $149 , hour : 0.0$150 , fov : 0L$151 , nosat : 0L$152 , lon : 0.0$153 , lat: 0.0$154 , zen: 0.0$155 , bch_adj: fltarr(5) $156 }157 endelse158 148 ; 159 nrows = file_lines(fullfilename) ;149 nrows = file_lines(fullfilename) - N_ELEMENTS(header); 160 150 ; 161 result = Replicate(resultstruct, nrows) 151 resultdata = Replicate(resultdatastruct, nrows) 152 result={header: resultheaderstruct, data: resultdata} 162 153 ; 163 154 ; open file … … 166 157 ; 167 158 help, result,/structure 159 ; read header lines 160 READF, lun, result.header, format=format_header 168 161 ; read data lines 169 READF, lun, result 162 READF, lun, result.data, format=format_data 170 163 ; 171 164 ; close file -
trunk/src/mem_to_file_amsu_t2.pro
r445 r450 5 5 ; ======================= 6 6 ; 7 ; .. function:: mem_to_file_amsu_t2(yyyy, mm, dd, use_amsua, lon_min, lon_max, lat_min, lat_max, data_amsu_t2, testfilename)7 ; .. function:: mem_to_file_amsu_t2(yyyy, mm, dd, numch, lon_min, lon_max, lat_min, lat_max, amsu_t2, testfilename) 8 8 ; 9 9 ; DESCRIPTION 10 10 ; =========== 11 11 ; 12 ; Write data in astructure to an amsu_t2 file12 ; Write info and data of **amsu_t2** structure to an amsu_t2 file 13 13 ; 14 14 ; If **testfilename** is not empty, this filename will be written, otherwise 15 ; AMSU T2 terminology will be applied.15 ; amsu_t2 terminology will be applied. 16 16 ; 17 17 ; :returns: 0 if ok or -1 if error 18 18 ; :rtype: integer 19 19 ; 20 ; EXAMPLE $20 ; EXAMPLES 21 21 ; ======== 22 22 ; 23 ; Realistic example with VARAMMA file 24 ; :file:`${PROJECT_ID}/AMSU/2006/08/a msua_amsub_20060801_060w30s_050e45n.dat` AMSU_A and AMSU-B::23 ; Realistic example with VARAMMA file AMSU-A channel 5 24 ; :file:`${PROJECT_ID}/AMSU/2006/08/a5_20060801_060w30s_050e45n.dat`:: 25 25 ; 26 ; IDL> use_amsua=126 ; IDL> numch='a5' 27 27 ; IDL> yyyy=2006 28 28 ; IDL> mm=8 … … 32 32 ; IDL> lat_min=-30. 33 33 ; IDL> lat_max=45. 34 ; IDL> data_amsu_t2 = file_amsu_t2_to_mem(yyyy, mm, dd, use_amsua, lon_min, lon_max, lat_min, lat_max) 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 36 ; IDL> testfilename='./a' 36 ; IDL> result = mem_to_file_amsu_t2(yyyy, mm, dd, use_amsua, lon_min, lon_max, lat_min, lat_max, data_amsu_t2, testfilename)37 ; IDL> result = mem_to_file_amsu_t2(yyyy, mm, dd, numch, lon_min, lon_max, lat_min, lat_max, amsu_t2, testfilename) 37 38 ; 38 39 ; look for differences:: 39 40 ; 40 ; $ diff ./a ${PROJECT_ID}/AMSU/2006/08/amsua_amsub_20060801_060w30s_050e45n.dat 41 ; 42 ; Realistic example with VARAMMA file 43 ; :file:`${PROJECT_ID}/AMSU/2006/08/amsub_20060801_060w30s_050e45n.dat` AMSU-B only:: 44 ; 45 ; IDL> use_amsua=0 46 ; IDL> yyyy=2006 47 ; IDL> mm=8 48 ; IDL> dd=1 49 ; IDL> lon_min=-60. 50 ; IDL> lon_max=50. 51 ; IDL> lat_min=-30. 52 ; IDL> lat_max=45. 53 ; IDL> data_amsu_t2 = file_amsu_t2_to_mem(yyyy, mm, dd, use_amsua, lon_min, lon_max, lat_min, lat_max) 54 ; IDL> testfilename='./a' 55 ; IDL> result = mem_to_file_amsu_t2(yyyy, mm, dd, use_amsua, lon_min, lon_max, lat_min, lat_max, data_amsu_t2, testfilename) 56 ; 57 ; look for differences:: 58 ; 59 ; $ diff ./a ${PROJECT_ID}/AMSU/2006/08/amsub_20060801_060w30s_050e45n.dat 41 ; $ diff ./a ${PROJECT_ID}/AMSU/2006/08/a5_20060801_060w30s_050e45n.dat 60 42 ; 61 43 ; SEE ALSO 62 44 ; ======== 63 45 ; 64 ; :ref:`extract_amsua b.pro` where this function should be called46 ; :ref:`extract_amsua.pro` where this function should be called 65 47 ; 66 48 ; :func:`file_amsu_t2_to_mem` … … 71 53 ; ==== 72 54 ; 73 ; à intégrer dans :ref:`extract_amsuab.pro`55 ; crier sur valeur manquante de tb 74 56 ; 75 ; If other parameter than data_amsu_t2 needed, troule because that's show 76 ; that some information are only in file name 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 ? 77 61 ; 78 62 ; check args 79 63 ; 80 ; prendre en compte aussi les nadir.dat64 ; spécial idl : je narrive pas à éviter la boucle sur les ligens de data !! 81 65 ; 82 66 ; EVOLUTIONS … … 87 71 ; $URL$ 88 72 ; 73 ; - fplod 20111208T105205Z cratos (Linux) 74 ; 75 ; * nvelle terminologie 76 ; * nouveau format (header + données) de fichier 77 ; 89 78 ; - fplod 20111206T163330Z cratos (Linux) 90 79 ; 91 ; * creatio 80 ; * creation 92 81 ; 93 82 ;- 94 FUNCTION mem_to_file_amsu_t2, yyyy, mm, dd, use_amsua$83 FUNCTION mem_to_file_amsu_t2, yyyy, mm, dd, numch $ 95 84 , lon_min, lon_max, lat_min, lat_max $ 96 , data_amsu_t2 $85 , amsu_t2 $ 97 86 , testfilename 98 87 ; … … 106 95 result = -1 107 96 ; 108 usage = 'result=mem_to_file_amsu_t2(yyyy, mm, dd, use_amsua, lon_min, lon_max, lat_min, lat_max, data_amsu_t2, testfilename)'97 usage = 'result=mem_to_file_amsu_t2(yyyy, mm, dd, numch, lon_min, lon_max, lat_min, lat_max, amsu_t2, testfilename)' 109 98 nparam = N_PARAMS() 110 99 IF (nparam NE 10) THEN BEGIN … … 115 104 ENDIF 116 105 ; 117 if (use_amsua eq 1) then begin118 prefix = 'amsua_amsub_'119 endif else begin120 prefix = 'amsub_'121 endelse122 106 if (testfilename eq '') then begin 123 107 look = 'filename' … … 127 111 fullfilename = project_id_env+ 'AMSU/' $ 128 112 + string(yyyy,format='(I4.4)') + '/' $ 129 + string(mm,format='(I2.2)') + '/' $ 130 + prefix+string(yyyy,format='(I4.4)') $ 113 + string(mm,format='(I2.2)') + '/' $ 114 + numch + '_' $ 115 + string(yyyy,format='(I4.4)') $ 131 116 + string(mm,format='(I2.2)') $ 132 117 + string(dd,format='(I2.2)') + '_' $ … … 140 125 print, 'ouverture pour ecriture de ', fullfilename 141 126 ; 142 ; build format string 143 if (use_amsua eq 1) then begin 144 format_data='(3(i3,1x),f8.4,2i3,24(1x,f8.3))' 145 endif else begin 146 format_data='(3(i3,1x),f8.4,2i3,8(1x,f8.3))' 147 endelse 127 ; build header format string 128 format_header = '(I4.4,I2.2,I2.2,1X,A)' 148 129 ; 149 nrows = n_elements(data_amsu_t2) 130 ; build data format string 131 format_data = '(i1,1x,f8.4,i3,2(1x,f8.3),1x,I1,1x,f8.3)' 132 ; 133 nrows = n_elements(amsu_t2.data) 150 134 ; 151 135 ; open file … … 153 137 ;++ hanlde error 154 138 ; 139 ; write header lines 140 PRINTF, lun, amsu_t2.header, format=format_header 141 ; 155 142 ; write data lines 156 for irow=0, nrows-1 do begin157 PRINTF, lun, data_amsu_t2[irow], format=format_data143 for irow=0, nrows -1 do begin 144 PRINTF, lun, amsu_t2.data[irow], format=format_data 158 145 endfor 159 146 ;
Note: See TracChangeset
for help on using the changeset viewer.