Changeset 486 for trunk


Ignore:
Timestamp:
01/20/12 18:50:41 (12 years ago)
Author:
lelod
Message:

amelioration de l execution

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/extract_amsua.pro

    r483 r486  
    246246tbmin=100 
    247247tbmax=350 
    248  
     248PRINT, 'debut programme',SYSTIME()  
    249249; lecture fichier land - sea (S. Masson) 
    250250file=project_id_env+'/MASK/ETOPO1_Ice_g_gmt4.nc' 
    251 domdef,lon_min, lon_max, lat_min, lat_max 
     251domdef,lon_min-15, lon_max+15, lat_min-15, lat_max+15 
    252252bate = ncdf_lec(file, var = 'z') GT 0 
    253253xxe = float(ncdf_lec(file, var = 'lon')) 
     
    255255jpie = n_elements(xxe) 
    256256jpje = n_elements(yye) 
    257  
     257PRINT, 'lecture bathy terminee',SYSTIME()  
    258258; appel au ssprgm qui interpole les fonctions de correction (inutile 
    259259; de l'appeler a chaque fichier....) 
     
    266266 
    267267; lecture de la liste des fichiers AMSU-A 
    268 list_filea = project_id_env+'list_file' 
     268list_file = project_id_env+'list_file' 
    269269;list_filea='list_file' 
    270270    ;index_filea= 0 
    271 nb_filea = file_lines(list_filea) 
    272 a = STRARR(nb_filea) 
     271nb_file = file_lines(list_file) 
     272a = STRARR(nb_file) 
    273273   ; filea = STRARR(nb_filea) 
    274 print, 'ouverture pour lecture de ', list_filea 
    275 openr, lun_a, list_filea, /get_lun 
     274print, 'ouverture pour lecture de ', list_file 
     275openr, lun_a, list_file, /get_lun 
    276276filea='' 
    277277nlist=0 
    278278ilist=0 
    279 ;loadct,39 
    280 ;tek_color 
    281 numwindow=2 
    282 ;window,numwindow 
    283 ;plot,indgen(30)+1,cor_l+200,psym=2,color=0,yrange=[150,250] 
    284 ;oplot,indgen(30)+1,cor_s+200,psym=2,color=100 
    285  
    286 ;while ilist le nlist do begin 
     279PRINT,'demarrage boucle sur lichiers', SYSTIME()  
    287280while (not eof(lun_a)) do begin 
    288281   ilist=ilist+1 
     
    297290   COMMON amsua_header,ama_head 
    298291   COMMON amsua_data  ,ama_scan 
    299    print, 'ouverture et lecture du fichier ', filea 
     292   print, 'ouverture et lecture du fichier ', filea, SYSTIME()  
    300293   openr,lu1,filea,Error=erra,/get_lun 
    301294   read_amsua1c,filea, flag1 
     295   close,lu1 
     296   free_lun,lu1 
    302297   if (flag1 eq 0) then goto, labfile 
    303298   na=SIZE(reform(ama_scan.btemps[0,*,*])) 
     
    322317; latitude, et les Tbs des differents canaux (15 pour AMSUA) 
    323318 
    324 ; extraction du canal traite 
    325  
    326    amch=REFORM(ama_scan.btemps[nocanal,*,*]/100.) 
    327    amzen=REFORM(ama_scan.angles[0,*,*]/100.) 
    328    amalat=REFORM(ama_scan.latlon[0,*,*]/1.E4) 
    329    amalon=REFORM(ama_scan.latlon[1,*,*]/1.E4) 
    330    tt=REFORM(ama_scan.scnlintime/3600000.) 
    331    amaday=REFORM(ama_scan.scnlindy) 
    332    amafov= fovy_1 
    333    jour_ama=amaday[0]           ; jour du passage 
     319; extraction du canal traite dans un domaine enveloppant la zone choisie 
     320   midpix=fix(nbpix/2) 
     321   amalong=REFORM(ama_scan.latlon[1,*,*]/1.E4) 
     322   amalati=REFORM(ama_scan.latlon[0,*,*]/1.E4) 
     323   amcha=REFORM(ama_scan.btemps[nocanal,*,*]/100.) 
     324   amzeni=REFORM(ama_scan.angles[0,*,*]/100.) 
     325   ttt=REFORM(ama_scan.scnlintime/3600000.) 
     326 
     327   jnd=where(amalong[midpix,*] gt lon_min-15 and amalong[midpix,*] lt lon_max+15 and amalati[midpix,*] gt lat_min-15 and amalati[midpix,*] lt lat_max+15 ,nzon) 
     328   if nzon ne 0 then begin 
     329      amalat=amalati[*,jnd] 
     330      amalon=amalong[*,jnd] 
     331      amch=amcha[*,jnd] 
     332      amzen=amzeni[*,jnd] 
     333      tt=ttt[jnd] 
     334      dims = SIZE(amalon, /DIMENSIONS) 
     335      print,'dimension tableaux extraits',dims 
     336      n_scan=dims[1] 
     337      PRINT,'il y a des donnees dans la region ', SYSTIME()  
     338      amaday=REFORM(ama_scan.scnlindy) 
     339      amafov= fovy_1 
     340      jour_ama=amaday[0]        ; jour du passage 
    334341; recherche du sens de l'orbite : descendante (1) ou montante (0) 
    335    lat0=amalat[*,0] 
    336    lat1=amalat[*,1] 
    337    if (mean(lat1-lat0) lt 0) then begin 
    338       desc=1 
    339    endif else begin 
    340       desc=0 
    341    endelse 
    342  
     342      lat0=amalat[*,0] 
     343      lat1=amalat[*,1] 
     344      if (mean(lat1-lat0) lt 0) then begin 
     345         desc=1 
     346      endif else begin 
     347         desc=0 
     348      endelse 
     349  
    343350; correction nadir des donnees 
    344    ch_nadir=fltarr(nbpix,n_scan) 
    345    landseamask=intarr(nbpix,n_scan) 
    346    for isc=0L,n_scan-1L do begin 
    347       for ifo=0,nbpix-1 do begin 
     351         ch_nadir=fltarr(nbpix,n_scan) 
     352      ; ch_nadir=amch[ifo,isc] 
     353         landseamask=intarr(nbpix,n_scan)+2 ; valeur hors zone selectionnee 
     354         PRINT,'boucle sur les points du fichier, correction nadir', SYSTIME()  
     355 
     356         for isc=0L,n_scan-1L do begin 
     357;recherche de la zone xxe,yye englobant la fauchee 
     358            for ifo=0,nbpix-1 do begin 
    348359; approximation: 1km= 1deg/100, et on considere le quart en lon et lat 
    349360; de la surface du pixel pour optimiser la localisation du centre du 
    350361; pixel attention approximation brutale des distances en fractions dedegre 
    351362; recherche de la cote par rapport a la resolution AMSUA 
    352          xind=where (xxe ge amalon[ifo,isc]-swath[ifo]/400. and xxe le amalon[ifo,isc]+swath[ifo]/400.,nxlandsea) 
    353          yind=where (yye ge amalat[ifo,isc]-track[ifo]/400. and yye le amalat[ifo,isc]+track[ifo]/400.,nylandsea) 
    354          if(nxlandsea ne 0 and nylandsea ne 0) then begin 
    355             bate1=bate[xind,*] 
    356             bate2=bate1[*,yind] 
    357             if (mean(bate2) le 0.5) then begin 
    358                ch_nadir[ifo,isc]=amch[ifo,isc]-cor_s[ifo] 
    359                landseamask[ifo,isc]=0 ; mer 
    360             endif else begin 
    361                ch_nadir[ifo,isc]=amch[ifo,isc]-cor_l[ifo] 
    362                landseamask[ifo,isc]=1 ; terre 
    363             endelse 
    364          endif 
    365       endfor 
    366    endfor 
    367  
    368 moych=fltarr(nbpix) 
    369  
    370 for ifo=0,nbpix-1 do begin 
    371    jnd=where(ch_nadir[ifo,*] gt tbmin and ch_nadir[ifo,*] lt tbmax and amalon[ifo,*] ge lon_min and amalon[ifo,*] le lon_max $ 
    372          and amalat[ifo,*] ge lat_min and amalat[ifo,*] le lat_max,npts) 
    373   if npts ne 0 then begin 
    374      moych[ifo]= mean(ch_nadir[ifo,jnd]) 
    375   endif 
    376 endfor 
     363               xind=where (xxe ge amalon[ifo,isc]-swath[ifo]/400. and xxe le amalon[ifo,isc]+swath[ifo]/400.,nxlandsea) 
     364               yind=where (yye ge amalat[ifo,isc]-track[ifo]/400. and yye le amalat[ifo,isc]+track[ifo]/400.,nylandsea) 
     365               if(nxlandsea ne 0 and nylandsea ne 0) then begin 
     366                  bate1=bate[xind,*] 
     367                  bate2=bate1[*,yind] 
     368                  if (mean(bate2) le 0.5) then begin 
     369                     ch_nadir[ifo,isc]=amch[ifo,isc]-cor_s[ifo] 
     370                     landseamask[ifo,isc]=0 ; mer 
     371                  endif else begin 
     372                     ch_nadir[ifo,isc]=amch[ifo,isc]-cor_l[ifo] 
     373                     landseamask[ifo,isc]=1 ; terre 
     374                  endelse 
     375               endif 
     376            endfor 
     377         endfor 
     378         PRINT, 'fin boucle',SYSTIME()  
     379         moych=fltarr(nbpix) 
     380       
     381;for ifo=0,nbpix-1 do begin 
     382;   jnd=where(ch_nadir[ifo,*] gt tbmin and ch_nadir[ifo,*] lt tbmax and amalon[ifo,*] ge lon_min and amalon[ifo,*] le lon_max $ 
     383;         and amalat[ifo,*] ge lat_min and amalat[ifo,*] le lat_max,npts) 
     384;  if npts ne 0 then begin 
     385;     moych[ifo]= mean(ch_nadir[ifo,jnd]) 
     386;  endif 
     387;endfor 
    377388;print,'correction',moych 
    378389;print,'cor_s',cor_s 
     
    381392;print,'ecarts max a la valeur moyenne au nadir',min(moych)-mean(moych[12:17]),max(moych)-mean(moych[12:17]) 
    382393 
    383  
    384 numwindow=numwindow+1 
    385394 
    386395; appel a interpolswath pour ajuster les pixels amsua sur une grille 
     
    390399; pbs avec les fauchees qui traversent le meridien 180deg!!!! 
    391400; l'interpolation ajoute des points parasites dans la zone... 
    392    nbgrid=0 
    393 cont=0L 
    394    for i=0L,n_scan-1L do begin 
    395       tb=ch_nadir[*,i] 
    396       lon=amalon[*,i] 
    397       lat=amalat[*,i] 
    398       mask=landseamask[*,i] 
    399       ind=where(tb gt tbmin and lon gt lon_min-15 and lon lt lon_max+15,nbon)  
     401         nbgrid=0 
     402         cont=0L 
     403         chint=fltarr(1) 
     404         for i=0L,n_scan-1L do begin 
     405            tb=ch_nadir[*,i] 
     406            lon=amalon[*,i] 
     407            lat=amalat[*,i] 
     408            mask=landseamask[*,i] 
     409            ind=where(tb gt tbmin,nbon)  
    400410; test pour eviter pb d'interpolation de longitude (meridien 180) 
    401       if nbon eq nbpix then begin 
    402          cont=cont+1L 
    403          nbgrid1=nbgrid 
    404          interpolswath,tb,lat,lon,mask,resol,nbgrid,tbgrid,latgrid,longrid,maskgrid 
    405          if cont eq 1L then begin 
    406             fovgrid=indgen(nbgrid)+1 
    407          endif 
     411            if nbon eq nbpix then begin 
     412               cont=cont+1L 
     413               nbgrid1=nbgrid 
     414               interpolswath,tb,lat,lon,mask,resol,nbgrid,tbgrid,latgrid,longrid,maskgrid 
     415               if cont eq 1L then begin 
     416                  fovgrid=indgen(nbgrid)+1 
     417               endif 
    408418         ;longit=longrid 
    409419         ;latit=latgrid 
     
    411421 
    412422; selection des taches au sol situees dans la zone d'interet 
    413          zone=where((longrid ge lon_min) and (longrid le lon_max) $ 
    414                     and (latgrid ge lat_min) and (latgrid le lat_max) and (tbgrid gt tbmin) and (tbgrid lt tbmax), npt) 
    415          if npt ne 0 then begin 
    416             if (n_elements(chint) EQ 0) then begin 
    417                timeint=replicate(tt[i],npt) 
    418                chint=tbgrid[zone] 
    419                latint=latgrid[zone] 
    420                lonint=longrid[zone] 
    421                fovint=fovgrid[zone] 
    422                maskint=maskgrid[zone] 
    423             endif else begin 
    424                chint=[chint,tbgrid[zone]] 
    425                latint=[latint,latgrid[zone]] 
    426                lonint=[lonint,longrid[zone]] 
    427                fovint=[fovint,fovgrid[zone]] 
    428                maskint=[maskint,maskgrid[zone]] 
    429                timeint=[timeint,replicate(tt[i],npt)] 
    430             endelse 
    431          endif else begin 
     423               zone=where((longrid ge lon_min) and (longrid le lon_max) $ 
     424                          and (latgrid ge lat_min) and (latgrid le lat_max) and (tbgrid gt tbmin) and (tbgrid lt tbmax), npt) 
     425               if npt ne 0 then begin 
     426                  if (n_elements(chint) EQ 1) then begin 
     427                     timeint=replicate(tt[i],npt) 
     428                     chint=tbgrid[zone] 
     429                     latint=latgrid[zone] 
     430                     lonint=longrid[zone] 
     431                     fovint=fovgrid[zone] 
     432                     maskint=maskgrid[zone] 
     433                  endif else begin 
     434                     chint=[chint,tbgrid[zone]] 
     435                     latint=[latint,latgrid[zone]] 
     436                     lonint=[lonint,longrid[zone]] 
     437                     fovint=[fovint,fovgrid[zone]] 
     438                     maskint=[maskint,maskgrid[zone]] 
     439                     timeint=[timeint,replicate(tt[i],npt)] 
     440                  endelse 
     441               endif else begin 
    432442            ;print, 'www : aucun point dans la zone' 
    433          endelse 
    434       endif 
    435  
    436    endfor 
    437  
    438  
    439    nn=n_elements(chint) 
    440  
    441    print,'nb points dans la zone',nn 
    442  
    443    for i=0L, nn-1L do begin 
    444       if (n_elements(data) EQ 0) then begin 
    445          data = { desc : desc $ 
     443               endelse 
     444            endif 
     445         endfor 
     446     ; PRINT,'fin interpolation et selection des points de la zone', SYSTIME()  
     447 
     448         nn=n_elements(chint) 
     449 
     450         print,'nb points dans la zone',nn 
     451 
     452         for i=0L, nn-1L do begin 
     453            if (n_elements(data) EQ 0) then begin 
     454               data = { desc : desc $ 
    446455                  , hour : timeint[i] $ 
    447456                  , fov : fovint[i] $ 
     
    451460                  , tb : chint[i] $ 
    452461                } 
    453       endif else begin 
    454          data = [data , { desc : desc $ 
     462            endif else begin 
     463               data = [data , { desc : desc $ 
    455464                          , hour : timeint[i] $ 
    456465                          , fov : fovint[i] $ 
     
    460469                          , tb : chint[i] $ 
    461470                        }] 
    462       endelse 
    463    endfor 
     471            endelse 
     472         endfor 
     473  
    464474; fin boucle sur les fichiers lus 
     475   endif 
     476  ; PRINT,'passage au fichier suivant', SYSTIME()  
    465477endwhile 
    466478labfile: 
     
    488500  ;  print, 'www : no data to write' 
    489501endelse 
    490 ; loadct,39 
    491502; window,0 
    492 ; plot,lonint,latint,xrange=[lon_min,lon_max],yrange=[lat_min,lat_max],xstyle=1,ystyle=1,/nodata 
     503loadct,39 
     504 plot,lonint,latint,xrange=[lon_min,lon_max],yrange=[lat_min,lat_max],xstyle=1,ystyle=1,/nodata 
    493505; ind=where(maskint eq 1) 
    494506; ;oplot,lonint[ind],latint[ind],psym=1 
    495 ; jnd=where(chint gt tbmin and chint lt tbmax) 
     507;jnd=where(chint gt tbmin and chint lt tbmax) 
    496508; tb=chint[jnd] 
    497509; lolo=lonint[jnd] 
    498510; lala=latint[jnd] 
    499511; colscale=intarr(n_elements(tb)) 
    500 ; for j=0,n_elements(tb)-1 do begin 
    501 ;    colscale[j]=(tb[j]-min(tb))*255/(max(tb)-min(tb)) 
    502 ; endfor 
     512; for j=0,n_elements(tb)-1 do    colscale[j]=(tb[j]-min(tb))*255/(max(tb)-min(tb)) 
     513 ;endfor 
    503514; print,min(colscale),max(colscale) 
    504515;    plots,lolo,lala,psym=5,symsize=1,color=colscale 
     516tb=chint 
     517 lolo=lonint 
     518 lala=latint 
     519 colscale=intarr(n_elements(tb)) 
     520 for j=0,n_elements(tb)-1 do    colscale[j]=(tb[j]-min(tb))*255/(max(tb)-min(tb)) 
     521 plots,lolo,lala,psym=5,symsize=1,color=colscale,/noerase 
     522 
    505523end 
Note: See TracChangeset for help on using the changeset viewer.