Changeset 457 for trunk


Ignore:
Timestamp:
12/12/11 23:10:30 (12 years ago)
Author:
lelod
Message:

integration correction nadir dans extract_amsua

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/extract_amsua.pro

    r456 r457  
    88; ================== 
    99; 
    10 ; prgm de lecture des fichiers AMSU (A seulement) 
     10; prgm de lecture des fichiers AMSU (A seulement, a valider avant de 
     11; generaliser pour amsub aussi) 
    1112; 
    1213; decode les noms des fichiers dans la date choisie, puis 
    1314; appelle le prgm de lecture 
     15; 
     16; appelle interpol_correc, qui fournit les fonctions de correction au 
     17; nadir et les applique, en fonction du masque terre-mer issu de la 
     18; carte de bathymetrie de S. Masson 
     19; 
     20; applique une interpolation tenant compte de la dimension de la tache 
     21; au sol selon la position dans la fauchee 
    1422; 
    1523; ecrit les donnees pour la zone (lat/long) choisie 
     
    5058;   yyyy 
    5159;   mm 
     60;   resol 
    5261;   lon_min 
    5362;   lon_max 
     
    6978;   IDL> mm=8 
    7079;   IDL> dd=1 
     80;   IDL> resol=1 
    7181;   IDL> lon_min=-60. 
    7282;   IDL> lon_max=50. 
     
    7989; TODO 
    8090; 
     91; lelod 20111212 
     92; 
     93; 
     94; :History: 
     95; 
     96; $Id$ 
     97; 
    8198; lelod 20111211 
    82 ; attention, il faut transformer les donnees 2D en 1D 
    83 ; reprendre methode "extract_amsuab", qui utilisait un "where"? 
    84 ; ou passer directement dans l'ecriture??? 
    85 ; 
    86 ; :History: 
    87 ; 
    88 ; $Id$ 
    89 ; 
    90 ; lelod 20111211 
    91 ; mis en commentaires la partie interpolation 
     99;  reintegre les modules de correct_nadir_amsu dans extract 
    92100; prevu decodage de numch pour connaitre le nom instrument et le 
    93 ;numero du canal (pas fini, au debut) 
     101; numero du canal (pas fini, au debut) --> a faire aussi dans les 
     102; ssprgm appeles (interpol_correc) 
     103; espere que c'est le dernier avatar de cette !!!!?XX^! de 
     104; chaine de traitement AMSU 
     105; 
    94106; $URL: svn+ssh://lelod@forge.ipsl.jussieu.fr/ipsl/forge/projets/varamma/svn/trunk/src/extract_amsuab.pro $ 
    95107; 
     
    188200; 
    189201;- 
    190 PRO extract_amsua, numch, yyyy, mm, dd,lon_min, lon_max, lat_min, lat_max 
     202PRO extract_amsua, numch, yyyy, mm, dd, resol, lon_min, lon_max, lat_min, lat_max 
    191203; 
    192204compile_opt idl2, strictarrsubs 
     
    199211 
    200212 
     213tbmin=100 
     214tbmax=350 
     215 
     216 
     217; lecture fichier land - sea (S. Masson) 
     218file=project_id_env+'/MASK/ETOPO1_Ice_g_gmt4.nc' 
     219domdef,lon_min, lon_max, lat_min, lat_max 
     220 
     221bate = ncdf_lec(file, var = 'z') GT 0 
     222xxe = float(ncdf_lec(file, var = 'lon')) 
     223yye = float(ncdf_lec(file, var = 'lat')) 
     224jpie = n_elements(xxe) 
     225jpje = n_elements(yye) 
     226 
     227; extraction zone donnees AMSU  
     228domdef,lon_min,lon_max,lat_min,lat_max 
     229bate = ncdf_lec(file, var = 'z') GT 0 
     230xxe = float(ncdf_lec(file, var = 'lon')) 
     231yye = float(ncdf_lec(file, var = 'lat')) 
     232jpie = n_elements;module lecture fichier a introduire ici 
     233 
     234; inutile maintenant: ouverture du fichier de sortie 
    201235look = 'filename' 
    202236scale = 1. 
     
    213247        + geomax $ 
    214248        + '.dat' 
    215  
    216249print, 'ouverture pour ecriture de ', fileout 
    217250openw, lun_obs, fileout, /get_lun 
     251 
     252 
     253; appel au ssprgm qui interpole les fonctions de correction (inutile 
     254; de l'appeler a chaque fichier....) 
     255if nomcanal eq 'a' then nbpixel=30 
     256if nomcanal eq 'b' then nbpixel=90 
     257interpol_correc,nomcanal,nbpixel,cor_l,cor_s,swath,track 
     258 
    218259 
    219260; ouverture des fichiers liste (annee, mois, jour, tous satellites) pour 
     
    223264; lecture de la liste des fichiers AMSU-A 
    224265    ;list_filea = project_id_env+'list_filea' 
    225      list_filea='list_filea' 
     266list_filea='list_filea' 
    226267    ;index_filea= 0 
    227     nb_filea = file_lines(list_filea) 
    228     a = STRARR(nb_filea) 
     268nb_filea = file_lines(list_filea) 
     269a = STRARR(nb_filea) 
    229270   ; filea = STRARR(nb_filea) 
    230     print, 'ouverture pour lecture de ', list_filea 
    231     openr, lun_a, list_filea, /get_lun 
    232     filea='' 
    233     nlist=1 
    234     ilist=1 
     271print, 'ouverture pour lecture de ', list_filea 
     272openr, lun_a, list_filea, /get_lun 
     273filea='' 
     274nlist=1 
     275ilist=1 
    235276   ; while (not eof(lun_a)) do begin 
    236     while ilist le nlist do begin 
    237       ilist=ilist+1 
    238         onefile = '' 
    239         readf, lun_a, filea 
     277while ilist le nlist do begin 
     278   ilist=ilist+1 
     279   onefile = '' 
     280   readf, lun_a, filea 
    240281       ; filea[index_filea] = onefile 
    241282        ; isolate string independant from satellite 
     
    244285    ;endwhile 
    245286 
    246         COMMON amsua_header,ama_head 
    247         COMMON amsua_data  ,ama_scan 
    248         print, 'ouverture et lecture du fichier ', filea 
    249         openr,lu1,filea,Error=erra,/get_lun 
    250         read_amsua1c,filea, flag1 
    251         if (flag1 eq 0) then goto, labfile 
    252         na=SIZE(reform(ama_scan.btemps[0,*,*])) 
    253         na_scan=na[2]           ; nb lignes (fauchees) dans l'orbite 
    254         na_fov=na[1]            ; nb points dans la fauchee 
    255         nbpix= na_fov 
    256         nosat=ama_head.h_satid 
    257         ; nb pixels dans la fauchee AMSUA 
    258         fov=indgen(nbpix) 
    259         n=na 
    260         n_scan=na_scan 
    261         n_fov=na_fov 
    262  
    263     ntime_1=fltarr(nbpix,n_scan) 
    264     fovy_1=fltarr(nbpix,n_scan) 
    265  
    266     for j=0L, nbpix-1L do begin 
    267         fovy_1[j,*]=j+1 ; on remplit un tableau de nscan lignes avec les valeurs de no de pixel 
    268     endfor 
     287   COMMON amsua_header,ama_head 
     288   COMMON amsua_data  ,ama_scan 
     289   print, 'ouverture et lecture du fichier ', filea 
     290   openr,lu1,filea,Error=erra,/get_lun 
     291   read_amsua1c,filea, flag1 
     292   if (flag1 eq 0) then goto, labfile 
     293   na=SIZE(reform(ama_scan.btemps[0,*,*])) 
     294   na_scan=na[2]                ; nb lignes (fauchees) dans l'orbite 
     295   na_fov=na[1]                 ; nb points dans la fauchee 
     296   nbpix= na_fov 
     297   nosat=ama_head.h_satid 
     298                                ; nb pixels dans la fauchee AMSUA 
     299   fov=indgen(nbpix) 
     300   n=na 
     301   n_scan=na_scan 
     302   n_fov=na_fov 
     303 
     304   ntime_1=fltarr(nbpix,n_scan) 
     305   fovy_1=fltarr(nbpix,n_scan) 
     306 
     307   for j=0L, nbpix-1L do begin 
     308      fovy_1[j,*]=j+1          ; on remplit un tableau de nscan lignes avec les valeurs de no de pixel 
     309   endfor 
    269310; 
    270311; on lit la structure et on extrait les infos: temps, longitude, 
     
    273314; extraction du canal traite 
    274315 
    275     amch=REFORM(ama_scan.btemps[nocanal,*,*]/100.) 
    276     amzen=REFORM(ama_scan.angles[0,*,*]/100.) 
    277     amalat=REFORM(ama_scan.latlon[0,*,*]/1.E4) 
    278     amalon=REFORM(ama_scan.latlon[1,*,*]/1.E4) 
    279     tt=REFORM(ama_scan.scnlintime/3600000.) 
    280     amaday=REFORM(ama_scan.scnlindy) 
    281     amafov= fovy_1 
    282     jour_ama=amaday[0]          ; jour du passage 
     316   amch=REFORM(ama_scan.btemps[nocanal,*,*]/100.) 
     317   amzen=REFORM(ama_scan.angles[0,*,*]/100.) 
     318   amalat=REFORM(ama_scan.latlon[0,*,*]/1.E4) 
     319   amalon=REFORM(ama_scan.latlon[1,*,*]/1.E4) 
     320   tt=REFORM(ama_scan.scnlintime/3600000.) 
     321   amaday=REFORM(ama_scan.scnlindy) 
     322   amafov= fovy_1 
     323   jour_ama=amaday[0]           ; jour du passage 
    283324; recherche du sens de l'orbite : descendante (1) ou montante (0) 
    284     lat0=amalat[*,0] 
    285     lat1=amalat[*,1] 
    286     if (mean(lat1-lat0) lt 0) then begin 
    287         desc=1 
    288     endif else begin 
    289         desc=0 
    290     endelse 
    291 ; attention tableaux a deux dimensions 
    292  
    293  
    294  
    295 ; appel a interpolswatw pour ajuster les pixels amsua sur une grille 
     325   lat0=amalat[*,0] 
     326   lat1=amalat[*,1] 
     327   if (mean(lat1-lat0) lt 0) then begin 
     328      desc=1 
     329   endif else begin 
     330      desc=0 
     331   endelse 
     332 
     333; correction nadir des donnees 
     334   ch_nadir=fltarr(nbpix,n_scan) 
     335   lanseamask=intarr(nbpix,n_scan) 
     336   for isc=0L,n_scan-1L do begin 
     337      for ifo=0,nbpix-1 do begin 
     338; approximation: 1km= 1deg/100, et on considere le quart en lon et lat 
     339; de la surface du pixel pour optimiser la localisation du centre du 
     340; pixel attention approximation brutale des distances en fractions dedegre 
     341; recherche de la cote par rapport a la resolution AMSUA 
     342         xind=where (xxe ge amalon[ifo,isc]-swath[ifo]/400. and xxe le amalon[ifo,isc]+swath[ifo]/400.,nxlandsea) 
     343         yind=where (yye ge amalat[ifo,isc]-track[ifo]/400. and yye le amalat[ifo,isc]+track[ifo]/400.,nylandsea) 
     344         if(nxlandsea ne 0 and nylandsea ne 0) then begin 
     345            bate1=bate[xind,*] 
     346            bate2=bate1[*,yind] 
     347            if (mean(bate2) le 0.5) then begin 
     348               ch_nadir[ifo,isc]=amch[ifo,isc]-cor_s[numcanal,ifo] 
     349               landseamask[ifo,isc]=0 ; mer 
     350            endif else begin 
     351               ch_nadir[ifo,isc]=amch[ifo,isc]-cor_l[numcanal,ifo] 
     352               landseamask[ifo,isc]=1 ; terre 
     353            endelse 
     354         endif 
     355      endfor 
     356   endfor 
     357  
     358 
     359; appel a interpolswath pour ajuster les pixels amsua sur une grille 
    296360; reguliere dans la fauchee 
    297361; et selection de la zone conservee 
    298362;tek_color 
    299363;resol=1 
    300 ;nbgrid=0 
    301 ;chint=fltarr(100) 
    302 ;latint=fltarr(100) 
    303 ;lonint=fltarr(100) 
    304 ;fovint=fltarr(100) 
    305 ;timeint=fltarr(100) 
    306 ;time=fltarr(100) 
    307 ;n_scan-1L 
    308 ;for i=0L,10L do begin 
    309 ;   tb=amch[*,i] 
    310 ;   lon=amalon[*,i] 
    311 ;   lat=amalat[*,i] 
    312   ; nbgrid1=nbgrid 
    313 ;   interpolswath,tb,lat,lon,resol,nbgrid,tbgrid,latgrid,longrid 
    314 ;     if i eq 0L then begin 
     364   nbgrid=0 
     365   for i=0L,n_scan-1L do begin 
     366      tb=ch_nadir[*,i] 
     367      lon=amalon[*,i] 
     368      lat=amalat[*,i] 
     369      mask=landseamask[*,i] 
     370      nbgrid1=nbgrid 
     371      interpolswath,tb,lat,lon,mask,resol,nbgrid,tbgrid,latgrid,longrid,maskgrid 
     372      if i eq 0L then begin 
    315373       ; plot,lon,tb,psym=1 
    316374       ; oplot,longrid,tbgrid,psym=4; 
    317 ;        fovgrid=indgen(nbgrid)+1 
    318 ;     endif 
     375         fovgrid=indgen(nbgrid)+1 
     376      endif 
    319377  ; if nbgrid ne nbgrid1 then begin 
    320378  ;    oplot,lon,tb,psym=1,color=3 
    321379   ;   oplot,longrid,tbgrid,psym=4,color=5 
    322380   ;   endif 
    323 ;  zone=where((longrid ge lon_min) and (longrid le lon_max) $ 
    324 ;             and (latgrid ge lat_min) and (latgrid le lat_max),npt) 
     381; selection des taches au sol situees dans la zone d'interet 
     382      zone=where((longrid ge lon_min) and (longrid le lon_max) $ 
     383                 and (latgrid ge lat_min) and (latgrid le lat_max),npt) 
    325384;print, 'npt', npt 
    326 ;  if npt ne 0 then begin 
    327 ;     time[zone]=tt[i] 
    328 ;     chint=[chint,tbgrid[zone]] 
    329 ;     latint=[latint,latgrid[zone]] 
    330 ;     lonint=[lonint,longrid[zone]] 
    331 ;     fovint=[fovint,fovgrid[zone]] 
    332 ;     timeint=[timeint,time[zone]] 
    333 ;  endif else begin 
    334 ;     print, 'www : aucun point dans la zone' 
    335 ;  endelse 
    336  
    337 ; endfor 
    338  
    339  
    340  
    341       ; replace missing values -9999.99 by NaN 
    342   index_missing = where(chint EQ -9999.99, nb_missing) 
    343   if (nb_missing NE 0) THEN BEGIN 
    344      tb[index_missing]=!values.f_nan 
    345   endif 
    346 ; param landseamask mis fictivement pour unification du format 
    347         landseamask=!values.f_nan 
    348  
    349 print,'nb points dans la zone',nn 
    350  
    351       for i=0L, nn-1L do begin 
     385      if npt ne 0 then begin 
     386         time[zone]=tt[i] 
     387 ; alerte: comment initialiser les tableaux qu'on concatene???? 
     388         if (n_elements(chint) EQ 0) then begin 
     389            chint=tbgrid[zone] 
     390            latint=latgrid[zone] 
     391            lonint=longrid[zone] 
     392            fovint=fovgrid[zone] 
     393            maskint=maskgrid[zone] 
     394            timeint= time[zone] 
     395         endif else begin 
     396            chint=[chint,tbgrid[zone]] 
     397            latint=[latint,latgrid[zone]] 
     398            lonint=[lonint,longrid[zone]] 
     399            fovint=[fovint,fovgrid[zone]] 
     400            maskint=[maskint,maskgrid[zone]] 
     401            timeint=[timeint,time[zone]] 
     402         endelse 
     403      endif else begin 
     404         print, 'www : aucun point dans la zone' 
     405      endelse 
     406       
     407   endfor 
     408 
     409 
     410   for i=0L, npt-1L do begin 
     411      if (( chint[i] lt tbmin) or (chint[i] gt tbmax) ) then begin 
     412         ch_adj[i]=!values.f_nan 
     413      endif 
     414   endfor 
     415 
     416 
     417   print,'nb points dans la zone',npt 
     418 
     419   for i=0L, npt-1L do begin 
    352420;format: nosat,mois, day, lon, lat, zen,fov, time, ama_ch1:15,amb_ch1:5 
    353421; print, 'mois::::', mm,'-----', nab-i 
    354          printf,lun_obs, mm, jour_ama, desc, nosat, fovint[i], landseamask, lonint[i], latint[i], timeint[i],$ 
    355                 chint[i],format='(6(i3,1x),4(f8.4,1x))' 
    356          if (n_elements(data) EQ 0) then begin 
    357              data = { desc : desc $ 
    358                     , hour : timeint[i] $ 
    359                     , fov : fovint[i] $ 
    360                     , lon : lonint[i] $ 
    361                     , lat: latint[i] $ 
    362                     , landseamask: 9$ 
    363                     , tb : chint[i] $ 
    364                     } 
    365          endif else begin 
    366              data = [data , { desc : desc $ 
     422      printf,lun_obs, mm, jour_ama, desc, nosat, fovint[i], landseamask, lonint[i], latint[i], timeint[i],$ 
     423             chint[i],format='(6(i3,1x),4(f8.4,1x))' 
     424      if (n_elements(data) EQ 0) then begin 
     425         data = { desc : desc $ 
     426                  , hour : timeint[i] $ 
     427                  , fov : fovint[i] $ 
     428                  , lon : lonint[i] $ 
     429                  , lat: latint[i] $ 
     430                  , landseamask: maskint[i] $ 
     431                  , tb : chint[i] $ 
     432                } 
     433      endif else begin 
     434         data = [data , { desc : desc $ 
    367435                          , hour : timeint[i] $ 
    368436                          , fov : fovint[i] $ 
    369437                          , lon : lonint[i] $ 
    370438                          , lat: latint[i] $ 
    371                           , landseamask: 9$ 
     439                          , landseamask:  maskint[i] $ 
    372440                          , tb : chint[i] $ 
    373  
    374  
     441                        }] 
     442      endelse 
     443   endfor 
    375444; fin boucle sur les fichiers lus 
    376 labfile: 
    377445endwhile 
    378446print, 'fermeture de ', fileout 
     
    381449if (n_elements(data) NE 0) then begin 
    382450    ; write outputfile 
     451   ; ajouter resol dans le header 
    383452    header = { yyyy : yyyy $ 
    384453             ,  mm : mm $ 
     
    396465    print, 'www : no data to write' 
    397466endelse 
    398 ; 
     467 
    399468end 
  • trunk/src/interpol_correc.pro

    r455 r457  
    107107; 
    108108;- 
    109 PRO interpol_correc,canal,nbpix,cor_l,cor_s 
     109PRO interpol_correc,canal,nbpix,cor_l,cor_s,swath,track 
    110110; 
    111111@cm_project 
     
    115115 
    116116pixelsize,pixatot,pixbtot,alongatot,alongbtot 
     117if nomcanal eq 'a' then begin 
     118   swath=pixatot 
     119   track=alongatot 
     120endif else begin 
     121   swath=pixbtot 
     122   track=alongbtot 
     123endelse 
    117124 
    118125; parametres AMSU et calcul de la fauchee 
  • trunk/src/interpolswath.pro

    r449 r457  
    4141; 
    4242;- 
    43 pro interpolswath, tb, latlu, lonlu, resol, nbgrid, tbint, latgrid, longrid 
     43pro interpolswath, tb, latlu, lonlu, masklu, resol, nbgrid, tbint, latgrid, longrid, mask 
    4444 
    4545pixelsize,pixatot,pixbtot,alongatot,alongbtot 
     
    9292;print,tb 
    9393tbint=fltarr(nbgrid) 
     94mask=intarr(nbgrid) 
    9495for i=0,na-1 do begin 
    9596   ind=where(abs(grid-fova[i]) le pixatot[i]/2,nii) 
     
    9798   if nii ne 0 then begin 
    9899      tbint[ind]=tb[i] 
     100      mask[ind]=masklu[i] 
    99101   endif 
    100102   if nii eq 0 then begin 
Note: See TracChangeset for help on using the changeset viewer.