Changeset 597


Ignore:
Timestamp:
07/23/12 18:07:26 (12 years ago)
Author:
llmlod
Message:

creation fichier nc sur grille reguliere MAJ

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/amsu2ncdf.pro

    r528 r597  
    1212; +todo+ 
    1313; 
    14 ;    :param use_amsua: flag to tell if amsub only or amsub 
    15 ;    :type use_amsua: int 0 or 1 
    16 ;    :raise use_amsua: required 
     14;    :param numch: number of the channel 
     15;    :type numch: string 
     16;    :raise numch: required 
    1717; 
    1818;    :param yyyy: year 
     
    2828;    :raise dd: required 
    2929; 
    30 ;    :param lonmin: longitude min, W < 0 
    31 ;    :units lonmin: deg 
    32 ;    :type lonmin: double 
    33 ;    :raise lonmin: required 
    34 ; 
    35 ;    :param lonmax: longitude max, W < 0 
    36 ;    :units lonmax: deg 
    37 ;    :type lonmax: double 
    38 ;    :raise lonmax: required 
    39 ; 
    40 ;    :param latmin: latitude min, N > 0 
    41 ;    :units latmin: deg 
    42 ;    :type latmin: double 
    43 ;    :raise latmin: required 
    44 ; 
    45 ;    :param latmax: latitude max, N > 0 
    46 ;    :units latmax: deg 
    47 ;    :type latmax: double 
    48 ;    :raise latmax: required 
     30;    :param lon_min: longitude min, W < 0 
     31;    :units lon_min: deg 
     32;    :type lon_min: double 
     33;    :raise lon_min: required 
     34; 
     35;    :param lon_max: longitude max, W < 0 
     36;    :units lon_max: deg 
     37;    :type lon_max: double 
     38;    :raise lon_max: required 
     39; 
     40;    :param lat_min: latitude min, N > 0 
     41;    :units lat_min: deg 
     42;    :type lat_min: double 
     43;    :raise lat_min: required 
     44; 
     45;    :param lat_max: latitude max, N > 0 
     46;    :units lat_max: deg 
     47;    :type lat_max: double 
     48;    :raise lat_max: required 
    4949; 
    5050; read :file:`${PROJECT_ID}/AMSU/yyyy/mm/dd/amsua[_amsub]_{yyyymmdd}_{geomin}_{geomax}_nadir.dat` 
     
    8585; To produce AMSU netCDF file for 20060801:: 
    8686; 
    87 ;   use_amsua=1 
     87;   numch='a5' 
    8888;   yyyy=2006L 
    8989;   mm=8 
    9090;   dd=01 
    91 ;   lonmin=-60. 
    92 ;   lonmax=50. 
    93 ;   latmin=-30. 
    94 ;   latmax=45. 
    95 ;   amsu2ncdf, use_amsua, yyyy, mm, dd, lonmin, lonmax, latmin, latmax 
     91;   lon_min=-60. 
     92;   lon_max=50. 
     93;   lat_min=-30. 
     94;   lat_max=45. 
     95;   amsu2ncdf, use_amsua, yyyy, mm, dd, lon_min, lon_max, lat_min, lat_max 
    9696; 
    9797; or:: 
    9898; 
    99 ;   use_amsua=0 
     99;   numch='a5' 
    100100;   yyyy=2006L 
    101101;   mm=8 
    102102;   dd=01 
    103 ;   lonmin=-60. 
    104 ;   lonmax=50. 
    105 ;   latmin=-30. 
    106 ;   latmax=45. 
    107 ;   amsu2ncdf, use_amsua, yyyy, mm, dd, lonmin, lonmax, latmin, latmax 
     103;   lon_min=-60. 
     104;   lon_max=50. 
     105;   lat_min=-30. 
     106;   lat_max=45. 
     107;   amsu2ncdf, use_amsua, yyyy, mm, dd, lon_min, lon_max, lat_min, lat_max 
    108108; 
    109109; 
     
    118118; Called by :ref:`traite_amsuab.sh` 
    119119; 
    120 ; Previous step : :ref:`correct_nadir_amsu.pro` 
     120; Previous step : :ref:`extract_amsu.pro` 
    121121; 
    122122; Next step : ... science ! 
     
    125125; ==== 
    126126; 
    127 ; mettre a jour nouvelle structure et nouveau fichier de référence 
    128 ; 
    129 ; coding rules 
    130 ; 
    131 ; pourquoi autant de calcul de tmpmin 
    132 ; 
    133 ; accept uncorrected amsu file 
    134 ; 
    135 ; ajout parametre pour changer de grille ou de fichier (ie Karim a fourni à Laurence un 
    136 ; nouveau fichier MSG sur une nouvelle grille). 
    137 ; 
    138 ; created daily file  : need to change loop and create_amsu_netcdf.pro !! 
    139127; 
    140128; EVOLUTIONS 
    141129; ========== 
    142130; 
    143 ; $Id: amsu2ncdf.pro 336 2011-08-10 12:07:19Z pinsard $ 
    144 ; 
    145 ; $URL$ 
    146 ; 
    147 ; - fplod 20110818T155126Z aedon.locean-ipsl.upmc.fr (Darwin) 
    148 ; 
    149 ;   * fix array syntax (not detected on idl8 climserv !) 
    150 ; 
    151 ; - pinsard 2011-08-18T09:40:48Z loholt1.ipsl.polytechnique.fr (Linux) 
    152 ; 
    153 ;   * avoid amsub__ch5 file name 
    154 ; 
    155 ; - pinsard 2011-08-17T14:58:13Z loholt1.ipsl.polytechnique.fr (Linux) 
    156 ; 
    157 ;   * use geolocation_to_string_idl 
    158 ; 
    159 ; - pinsard 2011-08-10T14:11:58Z loholt1.ipsl.polytechnique.fr (Linux) 
    160 ; 
    161 ;   * complete description with parameters 
    162 ;   * add lonmin, lonmax, latmin, latmax parameter 
    163 ;   * align parameters order to correct_nadir_amsu 
    164 ;   * change output filename 
    165 ; 
    166 ; - lelod 2011-08-09 
    167 ; 
    168 ;   * mise a jour lecture des fichiers issus de 
    169 ;     extract_amsuab.pro et correct_nadir_amsu.pro 
    170 ;   * modification des formats et adaptation aux cas use_amsua=0 ou 1 
    171 ;   * remplacement des -999. par !values.f_nan 
    172 ;   * /MSG/2006/08/01/200608010000_msg-tb108_map_15min.nc have been replaced by 
    173 ;     project_id_env + '/MSG/2006/06/01/msg_IR108_20060601.nc' 
    174 ; 
    175 ; - pinsard 2011-08-10T11:58:43Z loholt1.ipsl.polytechnique.fr (Linux) 
    176 ; 
    177 ;   * remove blank in input filename 
    178 ;   * complete description 
    179 ; 
    180 ; - pinsard 2011-05-30T15:15:52Z loholt1.ipsl.polytechnique.fr (Linux)" 
    181 ; 
    182 ;   * remove noaa and satellite number from filename to avoid 
    183 ;     difference between alphanumeric and chronologic order 
    184 ; 
    185 ; - fplod 20110530T125608Z aedon.locean-ipsl.upmc.fr (Darwin) 
    186 ; 
    187 ;   * new parameters for :ref:`create_amsu_netcdf.pro` 
    188 ;   * limit stdout if debug=1 (more if debug=2) 
    189 ; 
    190 ; - pinsard 2011-05-27T08:10:27Z loholt1.ipsl.polytechnique.fr 
    191 ; 
    192 ;   * replace dirout by proetc_id_env 
    193 ;   * add compile_opt 
    194 ; 
    195 ; - pinsard 2011-05-26T15:17:36Z loholt1.ipsl.polytechnique.fr 
    196 ; 
    197 ;   * add dd, use_amsua, use_amsub parameters 
    198 ; 
    199 ; - fplod 20110422T160635Z aedon.locean-ipsl.upmc.fr (Darwin) 
    200 ; 
    201 ;   * use PROJECT 
    202 ; 
    203 ; - fplod 20110121T150550Z aedon.locean-ipsl.upmc.fr (Darwin) 
    204 ; 
    205 ;   * externalize function and pro 
    206 ; 
    207 ; - pinsard 2010-07-23T10:42:49Z loholt1.ipsl.polytechnique.fr (Linux) 
    208 ; 
    209 ;   * add graphic 
    210 ;   * file save in ${PROJECT_OD}/AMSU/yyyy/mm/ 
    211 ;   * remove condition yrday eq 241 and hour gt 21 
    212131; 
    213132;- 
    214 PRO amsu2ncdf, use_amsua, yyyy, mm, dd, lonmin, lonmax, latmin, latmax 
     133PRO amsu2ncdf, numch, yyyy, mm, dd, lon_min, lon_max, lat_min, lat_max, resol 
    215134; 
    216135compile_opt idl2, strictarrsubs 
    217136; 
    218137@cm_project 
    219 ; 
    220 ;set debug to 1 to print info 
    221 debug=0 
    222 ; 
    223 ; 
    224 s = size(SCOPE_TRACEBACK(/STRUCTURE),/DIMENSION) 
    225 routine = (SCOPE_TRACEBACK(/STRUCTURE))[s-1].Routine 
    226 if keyword_set(key_performance) EQ 1 THEN BEGIN 
    227     time1 = SYSTIME(1) 
    228 ENDIF 
    229 ; Initialisation des variables : 
    230 ; ------------------------------ 
    231 if (use_amsua eq 1) then begin 
    232    prefix='amsua_amsub_' 
    233 endif else begin 
    234    prefix='amsub_' 
    235 endelse 
    236  
    237 look='filename' 
    238 scale = 1. 
    239 geomin=geolocation_to_string_idl(lonmin,latmin, look, scale) 
    240 geomax=geolocation_to_string_idl(lonmax,latmax, look, scale) 
    241 filename=project_id_env+ 'AMSU/' $ 
    242         + string(yyyy,format='(I4.4)') + '/' $ 
    243         + string(mm,format='(I2.2)') + '/' $ 
    244         + prefix+string(yyyy,format='(I4.4)') $ 
    245         + string(mm,format='(I2.2)') $ 
    246         + string(dd,format='(I2.2)') + '_' $ 
    247         + geomin + '_' $ 
    248         + geomax + '_' $ 
    249         + 'nadir.dat' 
    250 ; 
    251 ; Lecture de la grille réguliere : 
     138 
     139 
     140testfilename='' 
     141look = 'filename' 
     142 
     143; ne pas utiliser les bornes lon et lat fournies en entree car elles 
     144; peuvent etre differentes de celle du fichier .dat puisqu'on peut 
     145; creer un fichier .nc extrait du .dat 
     146;geomin = geolocation_to_string_idl(lon_min, lat_min, look,1) 
     147;geomax = geolocation_to_string_idl(lon_max, lat_max, look,1) 
     148 
     149testfilename='/homedata/eymard/varamma_d/AMSU/' $ 
     150   + string(yyyy,format='(I4.4)') + '/' $ 
     151   + string(mm,format='(I2.2)')   + '/' $ 
     152   + numch + '_' + string(yyyy,format='(I4.4)') $ 
     153   + string(mm,format='(I2.2)') $ 
     154   + string(dd,format='(I2.2)') + '_' $ 
     155   + '*.dat' 
     156;   + geomin + '_' + geomax + '.dat' 
     157 
     158print, testfilename 
     159 
     160result=file_amsu_t2_to_mem( yyyy,mm,dd,numch,lon_min,lon_max,lat_min,lat_max,testfilename) 
     161         desc=result.data.desc 
     162         hour=result.data.hour 
     163         fov=result.data.fov 
     164         lon=result.data.lon 
     165         lat=result.data.lat 
     166         mask=result.data.landseamask 
     167         tb1=result.data.tb 
     168         ; decodage du nb de points (nn) 
     169         nn=n_elements(tb1) 
     170 
     171; numero d'orbite 
     172norb=desc[UNIQ(desc)] 
     173; nombre d'orbites 
     174nbo=n_elements(norb) 
     175 
     176; grille de sortie xaxis, yaxis : 
    252177; -------------------------------- 
    253 ;remplacement des fichiers msg initiaux (2006 seulement) par une 
    254 ;nopuvelle version, avec grille reellement reguliere, crees par 
    255 ;K. Ramage l'ete 2011. Ici un exemple, copie dans varamma_d 
    256 ;verifier la compatibilite avec les outils appeles ensuite 
    257 ;domaine -25 0 W, 0 - 20 N 
    258 ; old grid filemsgref=project_id_env + '/MSG/2006/08/01/200608010000_msg-tb108_map_15min.nc' 
    259 filemsgref=project_id_env + '/EPSAT/extracted-surf-rr_epsat-sg_multi-sat_010d_30min_20060801_v3.1-02c.nc' 
    260 print, 'Lecture de la grille reguliere ',filemsgref 
    261 reggrid=read_regular_grid(filemsgref) 
    262 minlon=min(reggrid.lon) 
    263 maxlon=max(reggrid.lon) 
    264 minlat=min(reggrid.lat) 
    265 maxlat=max(reggrid.lat) 
    266 resolt=abs(reggrid.lon[1]-reggrid.lon[0]) 
    267 ;resolt=0.1 
    268 ;reggrid={ $ 
    269 ;    lon : (indgen((maxlon-minlon)/resolt+1)+long(minlon/resolt))*resolt+resolt/2., $ 
    270 ;    lat : (indgen((maxlat-minlat)/resolt+1)+long(minlat/resolt))*resolt+resolt/2. $ 
    271 ;} 
    272 if (debug eq 1) then begin 
    273     print,'bords du domaine, lon, lat',minlon,maxlon,minlat,maxlat 
    274 endif 
    275 ; 
    276 ; Déclaration du tableau de reprojection : 
    277 ; ---------------------------------------- 
    278 ; 
    279 ; Lecture des données AMSU : 
    280 ; -------------------------- 
    281 print, 'Lecture du fichier de donnees ',filename 
    282 openr, lun, filename, /GET_LUN, ERROR = error 
    283 IF (error NE 0) then begin 
    284    ras = report(['eee : can not open for reading'$ 
    285          + '!C' $ 
    286          + 'code : ' + !ERROR_STATE.MSG $ 
    287          + filename]) 
    288    STOP 
    289 ENDIF 
    290  
    291 ; 
    292 ; Boucle sur les lignes du fichier : 
    293 ; ---------------------------------- 
    294 print, '--> Saut des donnees deja traitees' 
    295  
    296 kont1=0L 
    297 repeat begin 
    298    if (use_amsua eq 1) then begin 
    299  
    300        readf,lun, month,land_sea,yrday,hour,fov,nosat,lon,lat,zen,$ 
    301                      ach1_adj,ach2_adj,ach3,ach4_adj,ach5_adj,ach6_adj,ach7_adj,$ 
    302                      ach8_adj,ach15_adj,bch1_adj,bch2_adj,bch3_adj,bch4_adj,bch5_adj,$ 
    303                     format='(3(i3,1x),f8.4,2i3,20(1x,f8.3))' 
    304    endif else begin 
    305  
    306        readf,lun, month,land_sea,yrday,hour,fov,nosat,lon,lat,zen,$ 
    307                     bch1_adj,bch2_adj,bch3_adj,bch4_adj,bch5_adj,$ 
    308                     format='(3(i3,1x),f8.4,2i3,8(1x,f8.3))' 
    309    endelse 
    310  
    311   kont1=kont1+1L 
    312   if (debug eq 1) then begin 
    313       condition1=(lon ge minlon) 
    314       condition2=(lon le maxlon) 
    315       condition3=(lat ge minlat) 
    316       condition4=(lat le maxlat) 
    317       condition5=(yrday eq 241) 
    318       condition6=(hour gt 21) 
    319       condition7=eof(lun) 
    320       condition=(lon ge minlon and $ 
    321                  lon le maxlon and $ 
    322                  lat ge minlat and $ 
    323                  lat le maxlat and yrday eq 241 and hour gt 21) or eof(lun) 
    324       print,'lecture 1 lu',kont1, lon,lat,yrday,hour,condition 
    325       print,'lecture 1',condition,condition1,condition2,condition3,condition4,condition5,condition6,condition7 
    326       print,'lecture 1 seuil repeat', minlon,maxlon,minlat,maxlat,'241','21' 
    327   endif 
    328  
    329 endrep until ((lon ge minlon and $ 
    330                  lon le maxlon and $ 
    331                  lat ge minlat and $ 
    332                  lat le maxlat) or eof(lun) ) 
    333  
    334 if (debug eq 1) then begin 
    335     print,'fin lecture 1', kont1, lon,lat, eof(lun) 
    336 endif 
    337 while (not eof (lun)) do begin 
    338  
    339   if (debug eq 1) then begin 
    340      print,'entree grand while' 
    341   endif 
    342   mask=fltarr(n_elements(reggrid.lon), n_elements(reggrid.lat)) 
    343   bch5=fltarr(n_elements(reggrid.lon), n_elements(reggrid.lat)) 
    344   mask[*]=!values.f_nan 
    345   bch5[*]=!values.f_nan 
    346   print, '--> Recherche des premiers pixels dans la fenetre' 
    347   kont2=0L 
    348   if (debug eq 1) then begin 
    349      print, 'dernier lu ',lon,lat,yrday,hour 
    350   endif 
    351   repeat begin 
    352    if (use_amsua eq 1) then begin 
    353  
    354        readf,lun, month,land_sea,yrday,hour,fov,nosat,lon,lat,zen,$ 
    355                      ach1_adj,ach2_adj,ach3,ach4_adj,ach5_adj,ach6_adj,ach7_adj,$ 
    356                      ach8_adj,ach15_adj,bch1_adj,bch2_adj,bch3_adj,bch4_adj,bch5_adj,$ 
    357                     format='(3(i3,1x),f8.4,2i3,20(1x,f8.3))' 
    358    endif else begin 
    359  
    360        readf,lun, month,land_sea,yrday,hour,fov,nosat,lon,lat,zen,$ 
    361                     bch1_adj,bch2_adj,bch3_adj,bch4_adj,bch5_adj,$ 
    362                     format='(3(i3,1x),f8.4,2i3,8(1x,f8.3))' 
    363    endelse 
    364     if (debug eq 1) then begin 
    365         kont2=kont2+1L 
    366         print,'lecture 2 lu',kont2, lon,lat,yrday,hour 
    367         print,'lecture 2 seuil repeat', minlon,maxlon,minlat,maxlat 
    368     endif 
    369   endrep until ((lon ge minlon and $ 
    370                  lon le maxlon and $ 
    371                  lat ge minlat and $ 
    372                  lat le maxlat) or eof(lun) ) 
    373  
    374   if (debug eq 1) then begin 
    375       print,'fin lecture 2', kont2, lon,lat 
    376   endif 
    377   print, "--> Lecture de donnees de l'orbite" 
    378   iheur = hour 
    379   iday = yrday 
    380   numsat = nosat 
    381   print,'orbite',numsat,iday,iheur 
    382   lontab=[!values.f_nan] 
    383   lattab=[!values.f_nan] 
    384   masktab=[!values.f_nan] 
    385   bch5tab=[!values.f_nan] 
    386   kont3=0L 
    387   while (hour eq iheur and not eof(lun)) do begin 
    388     lontab=[lontab,lon] 
    389     lattab=[lattab,lat] 
    390     masktab=[masktab,land_sea] 
    391     bch5tab=[bch5tab,bch5_adj] 
    392    if (use_amsua eq 1) then begin 
    393  
    394        readf,lun, month,land_sea,yrday,hour,fov,nosat,lon,lat,zen,$ 
    395                      ach1_adj,ach2_adj,ach3,ach4_adj,ach5_adj,ach6_adj,ach7_adj,$ 
    396                      ach8_adj,ach15_adj,bch1_adj,bch2_adj,bch3_adj,bch4_adj,bch5_adj,$ 
    397                     format='(3(i3,1x),f8.4,2i3,20(1x,f8.3))' 
    398    endif else begin 
    399  
    400        readf,lun, month,land_sea,yrday,hour,fov,nosat,lon,lat,zen,$ 
    401                     bch1_adj,bch2_adj,bch3_adj,bch4_adj,bch5_adj,$ 
    402                     format='(3(i3,1x),f8.4,2i3,8(1x,f8.3))' 
    403    endelse 
    404     kont3=kont3+1 
    405     if (debug gt 1) then begin 
    406         print,'lecture 3 lu',kont2, lon,lat,yrday,hour 
    407     endif 
    408   endwhile 
    409     if (debug gt 1) then begin 
    410        print, 'tableau donnee', bch5tab 
    411     endif 
    412   ; 
    413   ; Extraction des données AMSU dans la fenetre : 
    414   ; --------------------------------------------- 
    415   lewh=where(lontab ge minlon and $ 
    416            lontab le maxlon and $ 
    417            lattab ge minlat and $ 
    418            lattab le maxlat and $ 
    419            bch5tab ne -999., cnt) 
    420   if (debug eq 1) then begin 
    421       print,'debut extraction ',cnt 
    422   endif 
    423   if (cnt gt 1) then begin 
    424     lontab=reform(lontab[lewh]) 
    425     lattab=reform(lattab[lewh]) 
    426     masktab=reform(masktab[lewh]) 
    427     bch5tab=reform(bch5tab[lewh]) 
    428   endif else begin 
    429     goto, ret0 
    430   endelse 
    431   ; 
    432   ; Reprojection dans une grille reguliere : 
    433   ; ---------------------------------------- 
    434   print, "Reprojection des donnees dans grille reguliere" 
    435   print, "--> Recherche de la fenetre encadrant l'orbite" 
    436 ; ++ pourquoi 5 calculs de tmpmin 
    437   tmpmin = min(abs(reggrid.lon-min(lontab)), imin) 
    438   tmpmin = min(abs(reggrid.lon-max(lontab)), imax) 
    439   tmpmin = min(abs(reggrid.lat-min(lattab)), jmin) 
    440   tmpmin = min(abs(reggrid.lat-max(lattab)), jmax) 
    441  
    442   tmpmin = min((reggrid.lon[imin]-lontab)^2+(reggrid.lat[jmin]-lattab)^2,iwh) 
    443   print, "--> Recherche pixel par pixel du plus proche voisin",imin,imax,jmin,jmax 
    444   for i=imin,imax do begin 
    445     for j=jmin,jmax do begin 
    446 ; ++ encore un calcul de tmpmin !! 
    447       tmpmin = min((reggrid.lon[i]-lontab)^2+(reggrid.lat[j]-lattab)^2,iwh) 
    448       tmptab=(lontab-lontab[iwh])^2+(lattab-lattab[iwh])^2 
    449       minvrf = min(tmptab[where(tmptab ne 0)]) 
    450       if (tmpmin le minvrf) then begin 
    451         mask[i,j] = masktab[iwh] 
    452         bch5[i,j] = bch5tab[iwh] 
    453         if (debug gt 1) then begin 
    454             print, ' remplissage bch5',i,j 
    455         endif 
    456      endif 
    457     endfor 
    458   endfor 
    459   status=where(bch5 ne !values.f_nan,nb_bch5_novm) 
    460   if (debug eq 1) then begin 
    461       print, 'compteur de bch5 non vm',nb_bch5_novm 
    462   endif 
    463   if (nb_bch5_novm eq 0) then begin 
    464      print, 'eee : aucun point non vm' 
    465      print, 'eee : we should stop here' 
    466   endif 
     178xaxis=indgen((lon_max-lon_min)/resol+1)*resol+lon_min 
     179yaxis=indgen((lat_max-lat_min)/resol+1)*resol+lat_min 
     180nlon=n_elements(xaxis) 
     181nlat=n_elements(yaxis) 
     182 
     183; calcul seuil pour remplir la nouvelle grille 
     184; -------------------------------------------- 
     185;seuil latitude = MAX((variation de latitude sur un meme fov)/2) 
     186;pour une orbite quelconque (on choisie la plus longue) 
     187;moyenne pour fov sur le bord (=min(fov)) et au milieu (=fix(max(fov)/2)) 
     188torb=LONARR(nbo) 
     189FOR i=0,nbo-1 DO BEGIN 
     190    inutile=WHERE(desc EQ norb[i],nb) 
     191    torb[i]=nb 
     192ENDFOR 
     193longorb=norb[WHERE(torb EQ MAX(torb))] 
     194 
     195ind_bor=WHERE(fov EQ MIN(fov) AND desc EQ longorb[0]) 
     196dif_bor=ABS(lat[ind_bor[1:N_ELEMENTS(ind_bor)-1]]-lat[ind_bor[0:N_ELEMENTS(ind_bor)-2]]) 
     197; arrondi au 0.1 superieur pour lisser un peu mais pas trop 
     198seuil_lat=CEIL(MAX([dif_bor])/2*10)/10. 
     199;print, seuil_lat 
     200 
     201;seuil longitude = MAX((difference de longitude sur une ligne)/2) 
     202;pour une orbite quelconque (on choisit la plus longue) 
     203;pour une ligne quelconque (on choisit la plus longue) 
     204ind_orb=WHERE(desc EQ longorb[0]) 
     205dif_lon=lon[ind_orb[1:N_ELEMENTS(ind_orb)-1]]-lon[ind_orb[0:N_ELEMENTS(ind_orb)-2]] 
     206; arrondi au 0.1 superieur pour lisser un peu mais pas trop 
     207seuil_lon=CEIL(MAX(dif_lon[WHERE(dif_lon LT 1)])/2*10)/10. 
     208;print, seuil_lon 
     209 
     210; initialisation 
     211maskg=fltarr(nlon,nlat) 
     212tbg=fltarr(nlon,nlat,nbo) 
     213temp=fltarr(nlon,nlat,nbo) 
     214iheur=fltarr(nbo) 
     215 
     216; valeur erreur -999. 
     217val_err=-999. 
     218maskg[*]=val_err 
     219tbg[*]=val_err 
     220temp[*]=val_err 
     221 
     222;;; pour chaque orbite ;;; 
     223rT=6371 ; rayon de la Terre 
     224for k=0,nbo-1 do begin 
     225; trouve tous les indices de l'orbite 
     226    ind_orb=WHERE(desc eq norb[k]) 
     227;;; pour chaque latitude ;;; 
     228    for j=0,nlat-1 do begin 
     229;;; pour chaque longitude ;;; 
     230        for i=0,nlon-1 do begin 
     231            ind_pt=WHERE(ABS(yaxis[j]-lat[ind_orb]) LT seuil_lat AND ABS(xaxis[i]-lon[ind_orb]) LT seuil_lon) 
     232            IF ind_pt[0] NE -1 THEN BEGIN 
     233;;;cherhce le plus proche en km;;; 
     234; lon/lat en radian 
     235                lat_rad=lat[ind_orb[ind_pt]]*!Pi/180. 
     236                lon_rad=lon[ind_orb[ind_pt]]*!Pi/180. 
     237                y_rad=yaxis[j]*!Pi/180. 
     238                x_rad=xaxis[i]*!Pi/180. 
     239; calcul distance 
     240                dist = 2*rT*ASIN(SQRT((SIN((y_rad-lat_rad)/2.)*SIN((y_rad-lat_rad)/2.))+(COS(x_rad)*COS(lon_rad)*SIN((x_rad-lon_rad)/2.)*SIN((x_rad-lon_rad)/2.)))) 
     241; selectionne le plus proche 
     242                dist_min=WHERE(dist EQ MIN(dist)) 
     243; attribut le point le plus proche 
     244                tbg[i,j,k]=tb1[ind_orb[ind_pt[dist_min]]] 
     245                temp[i,j,k]=hour[ind_orb[ind_pt[dist_min]]]  
     246                maskg[i,j]=mask[ind_orb[ind_pt[dist_min]]] 
     247            ENDIF  
     248        ENDFOR 
     249    ENDFOR 
     250    tps=temp[*,*,k] 
     251    ind = WHERE(tps eq val_err) 
     252    tps[ind]=!VALUES.F_NAN 
     253    iheur[k]=MEAN(tps,/NaN) 
     254;print, 'orbite '+string(norb[k])+' finie' 
     255endfor 
     256 
     257; decomposition de l'heure de l'orbite en heure, minute, seconde 
     258h_orb=fix(iheur) 
     259m_orb=fix((iheur-h_orb)*60) 
     260s_orb=fix((iheur-h_orb-m_orb/60.)*3600) 
     261 
    467262  ; 
    468263  ; Creation du fichier NetCDF : 
    469264  ; ---------------------------- 
    470   htime=fix(iheur) 
    471   mtime=fix((iheur-htime)*60) 
    472   stime=fix((iheur-htime-mtime/60.)*3600) 
    473   caldat, julday(1,1,yyyy)+iday-1,mttime,dtime,ytime 
    474   file_ncdf=project_id_env+ 'AMSU/' $ 
    475         + string(yyyy,format='(I4.4)') + '/' $ 
    476         + string(mm,format='(I2.2)')   + '/' $ 
    477         + prefix+'ch5_' $ 
    478         + string(yyyy,format='(I4.4)') $ 
    479         + string(mm,format='(I2.2)') $ 
    480         + string(dd,format='(I2.2)') $ 
    481         +'_' $ 
    482         + string(htime,format='(I2.2)') $ 
    483         + string(mtime,format='(I2.2)') $ 
    484         + string(stime,format='(I2.2)') + '_' $ 
    485         + geomin + '_' $ 
    486         + geomax + '_' $ 
    487         + 'nadir.nc' 
    488   print, 'iii : avant ', 'create_amsu_netcdf pour ' + file_ncdf 
    489   create_amsu_netcdf, file_ncdf, ytime, mttime, dtime, htime, mtime, stime $ 
    490       , reggrid.lon, reggrid.lat, bch5, mask 
     265 
     266geomin = geolocation_to_string_idl(lon_min, lat_min, look,1) 
     267geomax = geolocation_to_string_idl(lon_max, lat_max, look,1) 
     268 
     269 file_ncdf=project_id_env+ 'AMSU/' $ 
     270   + string(yyyy,format='(I4.4)') + '/' $ 
     271   + string(mm,format='(I2.2)')   + '/' $ 
     272   + numch + '_' $ 
     273   + string(yyyy,format='(I4.4)') $ 
     274   + string(mm,format='(I2.2)') $ 
     275   + string(dd,format='(I2.2)') + '_' $ 
     276   + geomin + '_' $ 
     277   + geomax + '_' $ 
     278   + 'nadir.nc' 
     279 
     280create_amsu_netcdf, file_ncdf, yyyy, mm, dd, h_orb, m_orb, s_orb $ 
     281  ,xaxis,yaxis, tbg, maskg, val_err, numch   
     282 
    491283  ; comment the next line to produce an image 
    492   goto, ret0 
     284;  goto, ret0 
    493285  ; 
    494286  ; Visualisation : 
    495287  ; --------------- 
    496   window 
     288minlon=min(xaxis) 
     289maxlon=max(xaxis) 
     290minlat=min(yaxis) 
     291maxlat=max(yaxis) 
     292  window, 0 
    497293  loadct, 39 
    498294  map_set, limit=[minlat,minlon,maxlat,maxlon] 
    499295 
    500   tabcolor = MAP_IMAGE(bch5,Startx,Starty, COMPRESS=1, $ 
     296  tabcolor = MAP_IMAGE(tbg[*,*,1],Startx,Starty, COMPRESS=1, $ 
    501297    LATMIN=minlat, LONMIN=minlon, $ 
    502298    LATMAX=maxlat, LONMAX=maxlon, $ 
    503     min_value=0, missing=-999.) 
    504  
    505   lewh=where(tabcolor ne -999., cnt, complement=lewhcmpl) 
     299    max_value=280., min_value=241., missing=val_err) 
     300 
     301  lewh=where(tabcolor ne val_err, cnt, complement=lewhcmpl) 
    506302  if (cnt ne n_elements(tabcolor)) then begin 
    507303    tabcolor[lewhcmpl]=255 
     
    520316  MAP_CONTINENTS, /coasts, color=0 
    521317 
     318saveimage, 'test.png', PNG=PNG 
     319;saveimage, '20060802_ficdat_orb2_sajust.png', PNG=PNG 
     320 
     321   window, 3 
     322   loadct, 39 
     323   map_set, limit=[minlat,minlon,maxlat,maxlon] 
     324 
     325   tabcolor = MAP_IMAGE(maskg,Startx,Starty, COMPRESS=1, $ 
     326     LATMIN=minlat, LONMIN=minlon, $ 
     327     LATMAX=maxlat, LONMAX=maxlon, $ 
     328     max_value=2., min_value=-1., missing=val_err) 
     329 
     330   lewh=where(tabcolor ne val_err, cnt, complement=lewhcmpl) 
     331   if (cnt ne n_elements(tabcolor)) then begin 
     332     tabcolor[lewhcmpl]=255 
     333     tabcolor[lewh]=bytscl(tabcolor[lewh], top=254) 
     334   endif else begin 
     335     tabcolor=bytscl(tabcolor, top=254) 
     336   endelse 
     337 
     338;   ; Display the warped image on the map at the proper position: 
     339   TV, tabcolor, Startx, Starty 
     340 
     341;   ; Draw gridlines over the map and image: 
     342   MAP_GRID, latdel=10, londel=10, /LABEL, /HORIZON  , color=0 
     343 
     344;   ; Draw continent outlines: 
     345   MAP_CONTINENTS, /coasts, color=0 
     346 
     347saveimage, 'essai_mask.png', PNG=PNG 
     348;saveimage, '20060802_mask_orb2_sajust.png', PNG=PNG 
     349 
    522350  ret0: 
    523 endwhile 
    524 if (debug eq 1) then begin 
    525    print, 'fin grand while' 
    526 endif 
    527  
    528 close, lun 
    529 free_lun, lun 
    530  
    531 IF key_performance EQ 1 THEN BEGIN 
    532     msg = report(['ppp : ' + routine + ' : durée totale ' $ 
    533                    + string(SYSTIME(1)-time1,format='(F12.6)')]) 
    534 ENDIF 
    535351 
    536352end 
     353 
  • trunk/src/create_amsu_netcdf.pro

    r559 r597  
    128128; ------------------ 
    129129time_id = NCDF_VARDEF(id, 'time', [dtime_id], /double) 
     130NCDF_ATTPUT, id, time_id, 'long_name', 'Time' 
    130131NCDF_ATTPUT, id, time_id, 'units', $ 
    131132    STRING(format = '("hours since ",I4.4,"-",I2.2,"-",I2.2," ",I2.2,":",I2.2,":",I2.2," UTC")', $ 
    132133    ytime_org, mtime_org, dtime_org, htime_org, mmtime_org, stime_org) 
    133134NCDF_ATTPUT, id, time_id, 'calendar', 'standard' 
    134 NCDF_ATTPUT, id, time_id, 'long_name', 'Time' 
    135135NCDF_ATTPUT, id, time_id, 'actual_range', [min(timetab),max(timetab)], /double 
    136136; 
     
    138138; --------------------- 
    139139latd_id = NCDF_VARDEF(id, 'lat', [dlatd_id], /float) 
     140NCDF_ATTPUT, id, latd_id, 'long_name', 'Latitude' 
    140141NCDF_ATTPUT, id, latd_id, 'units', 'degrees_north' 
    141 NCDF_ATTPUT, id, latd_id, 'long_name', 'Latitude' 
    142142NCDF_ATTPUT, id, latd_id, 'actual_range', [min(lats),max(lats)] 
    143143; 
     
    145145; ---------------------- 
    146146long_id = NCDF_VARDEF(id, 'lon', [dlong_id], /float) 
     147NCDF_ATTPUT, id, long_id, 'long_name', 'Longitude' 
    147148NCDF_ATTPUT, id, long_id, 'units', 'degrees_east' 
    148 NCDF_ATTPUT, id, long_id, 'long_name', 'Longitude' 
    149149NCDF_ATTPUT, id, long_id, 'actual_range', [min(lons),max(lons)], /float 
    150150; 
     
    152152; ----------------- 
    153153data_id = NCDF_VARDEF(id, 'tb'+numch, [dlong_id,dlatd_id,dtime_id], /float) 
     154NCDF_ATTPUT, id, data_id, 'long_name', "AMSU-"+strupcase(strmid(numch,0,1))+" Channel "+strmid(numch,1,1)+" Brightness Temperature" 
    154155NCDF_ATTPUT, id, data_id, 'units', "Kelvin" 
    155 NCDF_ATTPUT, id, data_id, 'long_name', "AMSU-"+strupcase(strmid(numch,0,1))+" Channel "+strmid(numch,1,1)+" Brightness Temperature" 
    156 NCDF_ATTPUT, id, data_id, 'valid_range', [100,500] 
     156;NCDF_ATTPUT, id, data_id, 'valid_range', [100,500] 
    157157if (debug eq 1) then begin 
    158158   print, 'dans create_amsu_netcdf' 
     
    167167; Variable : Mask : 
    168168; ----------------- 
    169 mask_id = NCDF_VARDEF(id, 'mask', [dlong_id,dlatd_id,dtime_id], /float) 
    170 NCDF_ATTPUT, id, mask_id, 'units', '1' 
    171 NCDF_ATTPUT, id, mask_id, 'long_name', "land-sea mask, 1 all land, 0 all sea" 
     169mask_id = NCDF_VARDEF(id, 'mask', [dlong_id,dlatd_id], /float) 
     170;mask_id = NCDF_VARDEF(id, 'mask', [dlong_id,dlatd_id,dtime_id], /float) 
     171NCDF_ATTPUT, id, mask_id, 'units', '1 = land, 0 = sea' 
     172NCDF_ATTPUT, id, mask_id, 'long_name', "land-sea mask" 
    172173NCDF_ATTPUT, id, mask_id, 'valid_range', [0,1] 
    173174NCDF_ATTPUT, id, mask_id, 'missing_value', val_err 
Note: See TracChangeset for help on using the changeset viewer.