Changeset 450 for trunk


Ignore:
Timestamp:
12/08/11 18:13:31 (13 years ago)
Author:
pinsard
Message:

new amsu_t2 organization

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/file_amsu_t2_to_mem.pro

    r445 r450  
    55; ======================= 
    66; 
    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) 
    88; 
    99; DESCRIPTION 
    1010; =========== 
    1111; 
    12 ; Read an amsu_t2 file and store data in a structure 
     12; Read an amsu_t2 file and store data and header in structure 
    1313; 
    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. 
    1519; 
    1620; :returns: data structure +todo+ details or -1 if error 
     
    2024; ======== 
    2125; 
    22 ; Realistic example with VARAMMA file 
    23 ; :file:`${PROJECT_ID}/AMSU/2006/08/amsua_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`:: 
    2428; 
    25 ;   IDL> use_amsua=1 
     29;   IDL> numch='a5' 
    2630;   IDL> yyyy=2006 
    2731;   IDL> mm=8 
     
    3135;   IDL> lat_min=-30. 
    3236;   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) 
    3439; 
    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:: 
    4941; 
    5042;  IDL> help, result, /structure 
    51 ;  IDL> print, result[0] 
    52 ; 
     43;  IDL> print, result.data[0] 
    5344; 
    5445; SEE ALSO 
    5546; ======== 
    5647; 
    57 ; :ref:`extract_amsuab.pro` 
     48; :ref:`extract_amsua.pro` 
    5849; 
    5950; :func:`mem_to_file_amsu_t2` 
     
    6859; check args 
    6960; 
    70 ; prendre en compte aussi les nadir.dat 
    71 ; 
    7261; ecrire le module de dessin 
    7362; 
     
    7867; 
    7968; $URL$ 
     69; 
     70; - fplod 20111208T110651Z cratos (Linux) 
     71; 
     72;   * changement de format et de terminologie 
    8073; 
    8174; - fplod 20111206T161848Z aedon.locean-ipsl.upmc.fr (Darwin) 
     
    9083; 
    9184;- 
    92 FUNCTION file_amsu_t2_to_mem, yyyy, mm, dd, use_amsua $ 
    93                             , lon_min, lon_max, lat_min, lat_max 
     85FUNCTION file_amsu_t2_to_mem, yyyy, mm, dd, numch $ 
     86                            , lon_min, lon_max, lat_min, lat_max $ 
     87                            , testfilename 
    9488; 
    9589compile_opt idl2, strictarrsubs 
     
    10094ON_ERROR, 2 
    10195; 
    102 usage = 'result=file_amsu_t2_to_mem(yyyy, mm, dd, use_amsua, lon_min, lon_max, lat_min, lat_max)' 
     96usage = 'result=file_amsu_t2_to_mem(yyyy, mm, dd, numch, lon_min, lon_max, lat_min, lat_max, testfilename)' 
    10397nparam = N_PARAMS() 
    104 IF (nparam NE 8) THEN BEGIN 
     98IF (nparam NE 9) THEN BEGIN 
    10599   ras = report(['Incorrect number of arguments.' $ 
    106100         + '!C' $ 
     
    109103ENDIF 
    110104; 
    111 if (use_amsua eq 1) then begin 
    112    prefix = 'amsua_amsub_' 
    113 endif else begin 
    114    prefix = 'amsub_' 
    115 endelse 
    116105look = 'filename' 
    117106scale = 1. 
    118107geomin = geolocation_to_string_idl(lon_min, lat_min, look, scale) 
    119108geomax = 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' 
     109if (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' 
     120endif else begin 
     121    fullfilename = testfilename 
     122endelse 
    129123; 
    130124print, 'ouverture pour lecture de ', fullfilename 
    131125; 
    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 
     127format_header = '(I4.4,I2.2,I2.2,1X,A)' 
     128; 
     129; build data format string 
     130format_data = '(i1,1x,f8.4,i3,2(1x,f8.3),1x,I1,1x,f8.3)' 
     131; 
     132; initialize header 
     133header = STRARR(1) 
     134; 
     135resultheaderstruct = { yyyy : 0L $ 
     136                    ,  mm : 0L $ 
     137                    ,  dd : 0L $ 
     138                    ,  numch : 'X' $ 
     139                     } 
     140resultdatastruct = { desc : 0 $ 
     141                   , hour : 0.0 $ 
     142                   , fov : 0 $ 
     143                   , lon : 0.0 $ 
     144                   , lat: 0.0 $ 
     145                   , landseamask: 0$ 
     146                   , tb : 0.0 $ 
    144147                   } 
    145 endif else begin 
    146     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 endelse 
    158148; 
    159 nrows = file_lines(fullfilename); 
     149nrows = file_lines(fullfilename) - N_ELEMENTS(header); 
    160150; 
    161 result = Replicate(resultstruct, nrows) 
     151resultdata = Replicate(resultdatastruct, nrows) 
     152result={header: resultheaderstruct, data: resultdata} 
    162153; 
    163154; open file 
     
    166157; 
    167158help, result,/structure 
     159; read header lines 
     160READF, lun, result.header, format=format_header 
    168161; read data lines 
    169 READF, lun, result 
     162READF, lun, result.data, format=format_data 
    170163; 
    171164; close file 
  • trunk/src/mem_to_file_amsu_t2.pro

    r445 r450  
    55; ======================= 
    66; 
    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) 
    88; 
    99; DESCRIPTION 
    1010; =========== 
    1111; 
    12 ; Write data in a structure to an amsu_t2 file 
     12; Write info and data of **amsu_t2** structure to an amsu_t2 file 
    1313; 
    1414; 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. 
    1616; 
    1717; :returns: 0 if ok or -1 if error 
    1818; :rtype: integer 
    1919; 
    20 ; EXAMPLE$ 
     20; EXAMPLES 
    2121; ======== 
    2222; 
    23 ; Realistic example with VARAMMA file 
    24 ; :file:`${PROJECT_ID}/AMSU/2006/08/amsua_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`:: 
    2525; 
    26 ;   IDL> use_amsua=1 
     26;   IDL> numch='a5' 
    2727;   IDL> yyyy=2006 
    2828;   IDL> mm=8 
     
    3232;   IDL> lat_min=-30. 
    3333;   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) 
    3536;   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) 
    3738; 
    3839; look for differences:: 
    3940; 
    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 
    6042; 
    6143; SEE ALSO 
    6244; ======== 
    6345; 
    64 ; :ref:`extract_amsuab.pro` where this function should be called 
     46; :ref:`extract_amsua.pro` where this function should be called 
    6547; 
    6648; :func:`file_amsu_t2_to_mem` 
     
    7153; ==== 
    7254; 
    73 ; à intégrer dans :ref:`extract_amsuab.pro` 
     55; crier sur valeur manquante de tb 
    7456; 
    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 ? 
    7761; 
    7862; check args 
    7963; 
    80 ; prendre en compte aussi les nadir.dat 
     64; spécial idl : je narrive pas à éviter la boucle sur les ligens de data !! 
    8165; 
    8266; EVOLUTIONS 
     
    8771; $URL$ 
    8872; 
     73; - fplod 20111208T105205Z cratos (Linux) 
     74; 
     75;   * nvelle terminologie 
     76;   * nouveau format (header + données) de fichier 
     77; 
    8978; - fplod 20111206T163330Z cratos (Linux) 
    9079; 
    91 ;   * creatio 
     80;   * creation 
    9281; 
    9382;- 
    94 FUNCTION mem_to_file_amsu_t2, yyyy, mm, dd, use_amsua $ 
     83FUNCTION mem_to_file_amsu_t2, yyyy, mm, dd, numch $ 
    9584                            , lon_min, lon_max, lat_min, lat_max $ 
    96                             , data_amsu_t2 $ 
     85                            , amsu_t2 $ 
    9786                            , testfilename 
    9887; 
     
    10695result = -1 
    10796; 
    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)' 
     97usage = 'result=mem_to_file_amsu_t2(yyyy, mm, dd, numch, lon_min, lon_max, lat_min, lat_max, amsu_t2, testfilename)' 
    10998nparam = N_PARAMS() 
    11099IF (nparam NE 10) THEN BEGIN 
     
    115104ENDIF 
    116105; 
    117 if (use_amsua eq 1) then begin 
    118    prefix = 'amsua_amsub_' 
    119 endif else begin 
    120    prefix = 'amsub_' 
    121 endelse 
    122106if (testfilename eq '') then begin 
    123107    look = 'filename' 
     
    127111    fullfilename = project_id_env+ 'AMSU/' $ 
    128112            + 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)') $ 
    131116            + string(mm,format='(I2.2)') $ 
    132117            + string(dd,format='(I2.2)') + '_' $ 
     
    140125print, 'ouverture pour ecriture de ', fullfilename 
    141126; 
    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 
     128format_header = '(I4.4,I2.2,I2.2,1X,A)' 
    148129; 
    149 nrows = n_elements(data_amsu_t2) 
     130; build data format string 
     131format_data = '(i1,1x,f8.4,i3,2(1x,f8.3),1x,I1,1x,f8.3)' 
     132; 
     133nrows = n_elements(amsu_t2.data) 
    150134; 
    151135; open file 
     
    153137;++ hanlde error 
    154138; 
     139; write header lines 
     140PRINTF, lun, amsu_t2.header, format=format_header 
     141; 
    155142; write data lines 
    156 for irow=0,nrows-1 do begin 
    157     PRINTF, lun, data_amsu_t2[irow], format=format_data 
     143for irow=0, nrows -1 do begin 
     144    PRINTF, lun, amsu_t2.data[irow], format=format_data 
    158145endfor 
    159146; 
Note: See TracChangeset for help on using the changeset viewer.