Changeset 558


Ignore:
Timestamp:
05/22/12 09:59:38 (12 years ago)
Author:
llmlod
Message:

grille reguliere fic plusieurs orbites

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/amsu2ncdf_bis.pro

    r533 r558  
    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 
     
    8585; To produce AMSU netCDF file for 20060801:: 
    8686; 
    87 ;   use_amsua=1 
     87;   numch='a5' 
    8888;   yyyy=2006L 
    8989;   mm=8 
     
    9797; or:: 
    9898; 
    99 ;   use_amsua=0 
     99;   numch='a5' 
    100100;   yyyy=2006L 
    101101;   mm=8 
     
    131131; 
    132132;- 
    133 PRO amsu2ncdf, use_amsua, yyyy, mm, dd, lon_min, lon_max, lat_min, lat_max,resol 
     133PRO amsu2ncdf, numch, yyyy, mm, dd, lon_min, lon_max, lat_min, lat_max, resol 
    134134; 
    135135compile_opt idl2, strictarrsubs 
    136136; 
    137137@cm_project 
     138 
     139 
    138140testfilename='' 
    139 prefix=numch 
    140141look = 'filename' 
    141142 
    142143geomin = geolocation_to_string_idl(lon_min, lat_min, look,1) 
    143144geomax = geolocation_to_string_idl(lon_max, lat_max, look,1) 
     145 
     146testfilename='/homedata/eymard/varamma_d/AMSU/' $ 
     147   + string(yyyy,format='(I4.4)') + '/' $ 
     148   + string(mm,format='(I2.2)')   + '/' $ 
     149   + numch + '_' + string(yyyy,format='(I4.4)') $ 
     150   + string(mm,format='(I2.2)') $ 
     151   + string(dd,format='(I2.2)') + '_' $ 
     152   + geomin + '_' + geomax + '.dat' 
    144153 
    145154result=file_amsu_t2_to_mem( yyyy,mm,dd,numch,lon_min,lon_max,lat_min,lat_max,testfilename) 
     
    156165; grille de sortie xaxis, yaxis : 
    157166; -------------------------------- 
    158 ;    lon : (indgen((maxlon-minlon)/resolt+1)+long(minlon/resolt))*resolt+resolt/2., $ 
    159 ;    lat : (indgen((maxlat-minlat)/resolt+1)+long(minlat/resolt))*resolt+resolt/2. $ 
    160 xaxis=indgen((lmon_max-lon_min)/resol+1) 
    161 yaxis=indgen((lat_max-lat_min)/resol+1) 
    162 print,xaxis,yaxis 
     167xaxis=indgen((lon_max-lon_min)/resol+1)*resol+lon_min 
     168yaxis=indgen((lat_max-lat_min)/resol+1)*resol+lat_min 
    163169nlon=n_elements(xaxis) 
    164170nlat=n_elements(yaxis) 
    165 ;minlon=min(xaxis) 
    166 ;maxlon=max(xaxis) 
    167 ;minlat=min(yaxis) 
    168 ;maxlat=max(yaxis) 
    169 ;resolt=abs(yaxis[1]-yaxis[0]) 
    170  
    171 norbit=max(desc) 
    172 mask=fltarr(nlon,nlat) 
    173 tb=fltarr(nlon,nlat,nbo) 
    174 maskg[*]=!values.f_nan 
    175 tbg[*]=!values.f_nan 
     171 
     172; calcul seuil pour remplir la nouvelle grille 
     173; -------------------------------------------- 
     174; à adapter pour AMSU-B 
     175; pour AMU-A aussi car ne rempli pas tout les points de grille avec 
     176; ces seuils 
     177if strmid(numch,0,1) eq 'a' then begin 
     178; AMSU-A 
     179    ind_fov19=WHERE(fov eq 19) 
     180    ind_fov20=WHERE(fov eq 20) 
     181     
     182    seuil_lon=ABS(lon[ind_fov19[1]]-lon[ind_fov20[1]])/2. 
     183    seuil_lat=ABS(lat[ind_fov19[1]]-lat[ind_fov19[2]])/2. 
     184; arrondi au 0.01 superieur pour lisser un peu mais pas trop 
     185    seuil_lon=CEIL(seuil_lon*100.)/100. 
     186    seuil_lat=CEIL(seuil_lat*100.)/100. 
     187 
     188;seuil_lon=.3 
     189;seuil_lat=.25 
     190     
     191    print, seuil_lon 
     192    print, seuil_lat 
     193 
     194endif else begin 
     195; AMSU-B 
     196 
     197endelse 
     198 
     199; numero d'orbite 
     200norb=desc[UNIQ(desc)] 
     201; nombre d'orbites 
     202nbo=n_elements(norb) 
     203 
     204; initialisation 
     205maskg=fltarr(nlon,nlat) 
     206tbg=fltarr(nlon,nlat,nbo) 
     207temp=fltarr(nlon,nlat,nbo) 
    176208iheur=fltarr(nbo) 
    177 temp=fltarr(nlon,nlat) 
    178  
    179 norbit=0 
    180 for i=0,n_elements(tb1)-1 do begin 
    181   while desc[i] eq norbit do begin 
    182      ind=where(abs(lon[i]-xaxis) lt resol/2 and (abs(lat[i]-yaxis) lt resol/2,nbpt) 
    183      if nbpt ne 0 then begin 
    184         tbg[ind,norbit]=tb1[i] 
    185         maskg[ind]=mask[i] 
    186         temp[ind]=hour[i] 
    187      endif  
    188   endwhile 
    189   iheur[norbit]=mean(temp) 
    190   norbit=norbit+1 
     209 
     210; valeur erreur -999. 
     211val_err=-999. 
     212maskg[*]=val_err 
     213tbg[*]=val_err 
     214temp[*]=val_err 
     215 
     216;;; pour chaque orbite ;;; 
     217for k=0,nbo-1 do begin 
     218    ; trouve tous les indices de l'orbite 
     219    ind_orb=WHERE(desc eq norb[k]) 
     220;;; pour chaque latitude ;;; 
     221    for j=0,nlat-1 do begin 
     222        ; trouve la latitude d'origine la plus proche de la nouvelle latitude 
     223        ; en fonction du seuil choisi 
     224        ind_lat=WHERE(ABS(yaxis[j]-lat[ind_orb]) lt seuil_lat) 
     225        ; teste si un unique indice est trouvé 
     226        if (n_elements(ind_lat) eq 1) then begin 
     227        ; teste si l'indice trouvé n'est pas vide 
     228            if (ind_lat ne -1) then begin 
     229;;; pour chaque longitude ;;; 
     230                for i=0,nlon-1 do begin 
     231                    ind_lon=WHERE(ABS(xaxis[i]-lon[ind_orb[ind_lat]]) lt seuil_lon) 
     232                    ; si plusieurs indices sont trouvés, calcule la moyenne 
     233                    if (n_elements(ind_lon) gt 1) then begin 
     234                        tbg[i,j,k]=MEAN(tb1[ind_orb[ind_lat[ind_lon]]]) 
     235                        temp[i,j,k]=MEAN(hour[ind_orb[ind_lat[ind_lon]]]) 
     236                    endif else begin 
     237                        if (ind_lon ne -1) then begin 
     238                            tbg[i,j,k]=tb1[ind_orb[ind_lat[ind_lon]]] 
     239                            temp[i,j,k]=hour[ind_orb[ind_lat[ind_lon]]] 
     240                            maskg[i,j]=mask[ind_orb[ind_lat[ind_lon]]] 
     241                        endif 
     242                    endelse 
     243                endfor 
     244            endif 
     245        endif else begin 
     246;;; pour chaque longitude ;;; 
     247            for i=0,nlon-1 do begin 
     248                ind_lon=WHERE(ABS(xaxis[i]-lon[ind_orb[ind_lat]]) lt seuil_lon) 
     249                if (n_elements(ind_lon) gt 1) then begin 
     250                    tbg[i,j,k]=MEAN(tb1[ind_orb[ind_lat[ind_lon]]]) 
     251                    temp[i,j,k]=MEAN(hour[ind_orb[ind_lat[ind_lon]]]) 
     252                endif else begin 
     253                    if (ind_lon ne -1) then begin 
     254                        tbg[i,j,k]=tb1[ind_orb[ind_lat[ind_lon]]] 
     255                        temp[i,j,k]=hour[ind_orb[ind_lat[ind_lon]]] 
     256                        maskg[i,j]=mask[ind_orb[ind_lat[ind_lon]]] 
     257                    endif 
     258                endelse 
     259            endfor 
     260        endelse 
     261    endfor 
     262tps=temp[*,*,k] 
     263ind = WHERE(tps eq val_err) 
     264tps[ind]=!VALUES.F_NAN 
     265iheur[k]=MEAN(tps,/NaN) 
    191266endfor 
     267 
     268; decomposition de l'heure de l'orbite en heure, minute, seconde 
     269h_orb=fix(iheur) 
     270m_orb=fix((iheur-h_orb)*60) 
     271s_orb=fix((iheur-h_orb-m_orb/60.)*3600) 
    192272 
    193273  ; 
    194274  ; Creation du fichier NetCDF : 
    195275  ; ---------------------------- 
    196   htime=fix(iheur) 
    197   mtime=fix((iheur-htime)*60) 
    198   stime=fix((iheur-htime-mtime/60.)*3600) 
    199   caldat, julday(1,1,yyyy)+iday-1,mttime,dtime,ytime 
    200   file_ncdf=project_id_env+ 'AMSU/' $ 
    201         + string(yyyy,format='(I4.4)') + '/' $ 
    202         + string(mm,format='(I2.2)')   + '/' $ 
    203         + prefix+'ch5_' $ 
    204         + string(yyyy,format='(I4.4)') $ 
    205         + string(mm,format='(I2.2)') $ 
    206         + string(dd,format='(I2.2)') $ 
    207         +'_' $ 
    208         + string(htime,format='(I2.2)') $ 
    209         + string(mtime,format='(I2.2)') $ 
    210         + string(stime,format='(I2.2)') + '_' $ 
    211         + geomin + '_' $ 
    212         + geomax + '_' $ 
    213         + 'nadir.nc' 
    214   print, 'iii : avant ', 'create_amsu_netcdf pour ' + file_ncdf 
    215   create_amsu_netcdf, file_ncdf, ytime, mttime, dtime, htime, mtime, stime $ 
    216       ,xaxis,yaxis, tbg, maskg 
     276 
     277file_ncdf=project_id_env+ 'AMSU/' $ 
     278  + string(yyyy,format='(I4.4)') + '/' $ 
     279  + string(mm,format='(I2.2)')   + '/' $ 
     280  + numch + '_' $ 
     281  + string(yyyy,format='(I4.4)') $ 
     282  + string(mm,format='(I2.2)') $ 
     283  + string(dd,format='(I2.2)') + '_' $ 
     284  + geomin + '_' $ 
     285  + geomax + '_' $ 
     286  + 'nadir.nc' 
     287 
     288create_amsu_netcdf, file_ncdf, yyyy, mm, dd, h_orb, m_orb, s_orb $ 
     289  ,xaxis,yaxis, tbg, maskg, val_err, numch   
     290 
    217291  ; comment the next line to produce an image 
    218   goto, ret0 
     292;  goto, ret0 
    219293  ; 
    220294  ; Visualisation : 
    221295  ; --------------- 
    222   window 
     296minlon=min(xaxis) 
     297maxlon=max(xaxis) 
     298minlat=min(yaxis) 
     299maxlat=max(yaxis) 
     300  window, 0 
    223301  loadct, 39 
    224302  map_set, limit=[minlat,minlon,maxlat,maxlon] 
    225303 
    226   tabcolor = MAP_IMAGE(bch5,Startx,Starty, COMPRESS=1, $ 
     304  tabcolor = MAP_IMAGE(tbg[*,*,1],Startx,Starty, COMPRESS=1, $ 
    227305    LATMIN=minlat, LONMIN=minlon, $ 
    228306    LATMAX=maxlat, LONMAX=maxlon, $ 
    229     min_value=0, missing=-999.) 
    230  
    231   lewh=where(tabcolor ne -999., cnt, complement=lewhcmpl) 
     307    max_value=280., min_value=241., missing=val_err) 
     308 
     309  lewh=where(tabcolor ne val_err, cnt, complement=lewhcmpl) 
    232310  if (cnt ne n_elements(tabcolor)) then begin 
    233311    tabcolor[lewhcmpl]=255 
     
    246324  MAP_CONTINENTS, /coasts, color=0 
    247325 
     326;saveimage, '20060802_ficdat_orb2_sajust.png', PNG=PNG 
     327 
     328   window, 1 
     329   loadct, 39 
     330   map_set, limit=[minlat,minlon,maxlat,maxlon] 
     331 
     332   tabcolor = MAP_IMAGE(maskg,Startx,Starty, COMPRESS=1, $ 
     333     LATMIN=minlat, LONMIN=minlon, $ 
     334     LATMAX=maxlat, LONMAX=maxlon, $ 
     335     max_value=2., min_value=-1., missing=val_err) 
     336 
     337   lewh=where(tabcolor ne val_err, cnt, complement=lewhcmpl) 
     338   if (cnt ne n_elements(tabcolor)) then begin 
     339     tabcolor[lewhcmpl]=255 
     340     tabcolor[lewh]=bytscl(tabcolor[lewh], top=254) 
     341   endif else begin 
     342     tabcolor=bytscl(tabcolor, top=254) 
     343   endelse 
     344 
     345;   ; Display the warped image on the map at the proper position: 
     346   TV, tabcolor, Startx, Starty 
     347 
     348;   ; Draw gridlines over the map and image: 
     349   MAP_GRID, latdel=10, londel=10, /LABEL, /HORIZON  , color=0 
     350 
     351;   ; Draw continent outlines: 
     352   MAP_CONTINENTS, /coasts, color=0 
     353 
     354;saveimage, '20060802_mask_orb2_sajust.png', PNG=PNG 
     355 
    248356  ret0: 
    249 endwhile 
    250 if (debug eq 1) then begin 
    251    print, 'fin grand while' 
    252 endif 
    253  
    254 close, lun 
    255 free_lun, lun 
    256357 
    257358end 
     359 
Note: See TracChangeset for help on using the changeset viewer.