Changeset 544 for trunk


Ignore:
Timestamp:
04/30/12 15:35:40 (12 years ago)
Author:
pinsard
Message:

replace pro by function

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/cresamsu.pro

    r543 r544  
    11; docformat = 'rst' 
    22;+ 
    3 ; .. _cresamsu.pro: 
    43; 
    54; ============ 
     
    76; ============ 
    87; 
     8; .. function: cresamsu(numch, yyyyb, mmb, ddb, yyyye, mme, dde, lonmin, lonmax, latmin, latmax, temp, rtemp, rhdeg) 
     9; 
    910; DESCRIPTION 
    1011; =========== 
    1112; 
    1213; programme d'interpolation avec algorithme de Cressmann 
     14; 
     15; grille de sortie en long / lat 
     16; recoit en entree les jours de l'annee jdeb et jfin correspondant au debut et la fin du mois 
    1317; 
    1418; adaptation aux donnees Tb AMSU lues avec la nouvelle chaîne de lecture 
     
    6468;    rtemp = 0.5 
    6569;    rhdeg = 1. 
    66 ;    cresamsu, numch, yyyyb, mmb, ddb $ 
     70;    result = cresamsu(numch, yyyyb, mmb, ddb $ 
    6771;            , yyyye, mme, dde $ 
    6872;            , lonmin, lonmax, latmin, latmax $ 
    69 ;            , temp, rtemp, rhdeg 
     73;            , temp, rtemp, rhdeg) 
    7074; 
    7175; SEE ALSO 
     
    113117; - fplod 20120430 
    114118; 
     119;   * pro -> function 
     120;   * idl_amsu_netcdf is a function 
    115121;   * add digraph 
    116122; 
     
    165171;- 
    166172 
    167 pro cresamsu $ 
     173function cresamsu $ 
    168174    , numch $ 
    169175    , yyyyb $ 
     
    177183    , latmin $ 
    178184    , latmax $ 
    179     , temp $  
     185    , temp $ 
    180186    , rtemp $ 
    181187    , rhdeg 
    182  
    183 ; grille de sortie en long / lat 
    184 ; recoit en entree les jours de l'annee jdeb et jfin correspondant au debut et la fin du mois 
    185188 
    186189compile_opt idl2, strictarrsubs 
     
    193196if key_performance EQ 1 THEN BEGIN 
    194197    time1 = SYSTIME(1) 
     198ENDIF 
     199; 
     200; Return to caller if errors 
     201ON_ERROR, 2 
     202result = -1 
     203; 
     204usage = 'result = cresamsu(numch, yyyyb, mmb, ddb, yyyye, mme, dde, lonmin, lonmax, latmin, latmax, temp, rtemp, rhdeg)' 
     205; 
     206nparam = N_PARAMS() 
     207IF (nparam NE 14) THEN BEGIN 
     208    ras = report(['Incorrect number of arguments.' $ 
     209          + '!C' $ 
     210          + 'Usage : ' + usage]) 
     211    return, result 
    195212ENDIF 
    196213; 
     
    223240;rtemp=0.5 ;en jours rayon de Cressmann (0.25, 0.5, 1, 2,... - nb entiers!) 
    224241rtemphor=rtemp*24. ; en heures 
    225 print,'rayon temporel en heures',rtemphor 
     242msg = report(['iii : ' + routine + ' : rayon temporel en heures' + string(rtemphor)]) 
    226243; valeurs utiles et conversions degres / radians 
    227244vbidon=-999. 
     
    248265hrdeb=jdeb*24 
    249266hrfin=jfin*24 
    250 print,'debut et fin', jdeb,jfin 
     267msg = report(['iii : ' + routine + ' : debut et fin = ' + string(jdeb) + ' ' + string(jfin)]) 
    251268 
    252269; grille des donnees en sortie 
     
    255272la1=latmin+rhdeg 
    256273la2=latmax-rhdeg 
    257 print,"bornes de la grille de sortie",lo1,lo2,la1,la2,jdeb,jfin 
     274msg = report(['iii : ' + routine + ' : bornes de la grille de sortie = ' + string(lo1) + ' ' + string(lo2)+ ' ' + string(la1) + ' ' + string(la2) + ' ' + string(jdeb) + ' ' + string(jfin)]) 
    258275kmax=fix((lo2-lo1)/pash) ; pour valeurs de 0 a kmax 
    259276nblon=kmax+1 
     
    262279jmax=fix((hrfin-hrdeb)/pasthor) ; valeurs de 0 a jmax 
    263280nbjour=jmax+1 
    264 print,'nb pas de temps',nbjour, ' nb lat',nblat,' nblon',nblon 
     281msg = report(['iii : ' + routine + ' : nb pas de temps = ' + string(nbjour)]) 
     282msg = report(['iii : ' + routine + ' : nb lat = ' + string(nblat)]) 
     283msg = report(['iii : ' + routine + ' : nb lon = ' + string(nblon)]) 
    265284 
    266285;____________________________________ 
     
    276295la2=max(yylat) 
    277296hrfin=max(jjours)*24. 
    278 print, 'pas de temps du fichier ncdf en jours decimaux',jjours 
    279 print,'derniers points de la grille',max(xxlon),max(yylat),hrfin 
     297msg = report(['iii : ' + routine + ' : pas de temps du fichier ncdf en jours decimaux= ' + string(jjours)]) 
     298msg = report(['iii : ' + routine + ' : derniers points de la grille (lon) = ' + string(max(xxlon))]) 
     299msg = report(['iii : ' + routine + ' : derniers points de la grille (lat) = ' + string(max(yylat))]) 
     300msg = report(['iii : ' + routine + ' : derniers points de la grille (temps) = ' + string(max(hrfin))]) 
    280301;----------------------------------- 
    281302t=indgen(nbjour)*pasthor+hrdeb ; en heures 
    282 print,'t',t 
     303msg = report(['iii : ' + routine + ' : t = ' + string(t)]) 
    283304 
    284305; initialisation des tableaux de sortie (s valeurs, z poids, kont nb points) 
     
    312333      if yyyy eq yyyye then mmye=mme 
    313334   endif 
    314    print,"traitement annee ",yyyy,'mois ',mmyb,'a ',mmye 
     335   msg = report(['iii : ' + routine + ' : traitement annee ' + string(yyyy) + ' '  + string(mmyb) + ' a ' +  string(mmye)]) 
    315336   for mm=mmyb,mmye do begin 
    316337      if (mme ne mmb) then begin 
     
    320341         if mm eq mme then ddme=dde 
    321342     endif 
    322       print,"mois ",mm,"jours ",ddmb,"a ",ddme 
     343      msg = report(['iii : ' + routine + ' : mois' + string(mm) + ' ' + string(ddmb) + ' a ' +  string(ddme)]) 
    323344      for dd=ddmb,ddme do begin 
    324          print, 'iii : traitement du jour ',yyyy,mm,dd 
     345         msg = report(['iii : ' + routine + ' : traitement du jour ' + string(yyyy) + string(mm) + string(dd)]) 
    325346         ; lecture du fichier journalier 
    326347         result=file_amsu_t2_to_mem( yyyy, mm, dd, numch $ 
     
    405426         goto, nextday 
    406427nofile: 
    407     print, 'www : no data to read for this day' 
     428    msg = report(['www : ' + routine + ' : no data to read for this day']) 
    408429    goto, nextday 
    409430 
     
    421442if nbfile GT 0 THEN BEGIN 
    422443    good=where (kont1 ge 1,nb) 
    423     print,'points valides',nb 
     444    msg = report(['iii : ' + routine + ' : points valides = ' + string(nb)]) 
    424445    if (nb ne 0) then tb1fin[good]=stb1[good]/z1[good] 
    425446    bad=where (kont1 eq 0,nbad) 
    426     print,'bad',nbad 
     447    msg = report(['iii : ' + routine + ' : nb bad = ' + string(nbad)]) 
    427448    if (nbad ne 0) then tb1fin[bad]=!values.f_Nan 
    428449                                    ; print,tb1fin 
    429     print,'extremes du compteur',min(kont1),max(kont1) 
    430      
     450    msg = report(['iii : ' + routine + ' : extremes du compteur = ' + string(min(kont1)) + ' ' + string(max(kont1))]) 
     451 
    431452    ;toto=reform(tb1fin[*,*,0]) 
    432453                                ;plt,xxlon,yylat,toto 
    433     idl_amsu_netcdf, numch, temp,rtemp,rhdeg, tb1fin, yylat, xxlon, jjours 
     454    result = idl_amsu_netcdf(numch, temp,rtemp,rhdeg, tb1fin, yylat, xxlon, jjours) 
     455    result_type=size(result,/type) 
     456    IF (result_type EQ 3) THEN BEGIN 
     457       IF (result NE 0) THEN BEGIN 
     458           msg = report(['eee : ' + routine + ' : pb idl_amsu_netcdf']) 
     459           ;return, result 
     460           STOP 
     461       ENDIF 
     462    ENDIF 
     463 
    434464ENDIF  ELSE BEGIN 
    435     print, 'www : no files at all' 
     465    msg = report(['www : ' + routine + 'no files at all']) 
    436466    goto, realend 
    437467ENDELSE 
     
    439469realend: 
    440470    IF key_performance EQ 1 THEN BEGIN 
    441          PRINT, 'ppp : durée totale cresamsu', SYSTIME(1)-time1, format='(a, 1x, F12.6)' 
     471         msg = report(['ppp : ' + routine $ 
     472         + ' : durée totale = ' $ 
     473         + string(SYSTIME(1)-time1, format='(a, 1x, F12.6)')]) 
    442474    ENDIF 
    443475 
    444     print,'fin cresamsu' 
    445  
     476msg = report(['iii : ' + routine + ': fin']) 
     477 
     478result = 0 
     479return, result 
    446480end 
  • trunk/src/cresamsu.sh

    r543 r544  
    4040# :file:`${PROJECT_ID}/AMSU/{numch}{temp}rt{rtemp}rh{rhdeg}_{yyyymmdd}_{yyyymmdd}_{geomin}_{geomax}_03150e4150n.nc` 
    4141# 
    42 # :ref:`cresamsu` is launched here using ${IDL_CMD} command 
     42# :func:`cresamsu` is launched here using ${IDL_CMD} command 
    4343# (see :ref:`varamma_profile.sh` to know how to set this environnement variable). 
    4444# 
     
    103103# 
    104104# Use : 
    105 # :ref:`cresamsu.pro` 
    106 # :ref:`geolocation_to_string_sh.sh` 
     105# :func:`cresamsu` 
    107106# 
    108107# .. todo:: 
     
    132131# - fplod 20120430 
    133132#  
     133#   * cresamsu is now a function 
    134134#   * creation 
    135135# 
     
    371371result = -1 
    372372; 
    373 cresamsu, '${numch}', ${yyyyb}, ${mmb}, ${ddb} $ 
     373result_cresamsu = cresamsu('${numch}', ${yyyyb}, ${mmb}, ${ddb} $ 
    374374        , ${yyyye}, ${mme}, ${dde} $ 
    375375        , ${lonmin}, ${lonmax}, ${latmin}, ${latmax} $ 
    376         , '${temp}' , ${rtemp} , ${rhdeg} 
     376        , '${temp}' , ${rtemp} , ${rhdeg}) 
     377result_type=size(result_cresamsu,/type) 
     378result_type=size(result_cresamsu,/type) 
     379IF (result_type EQ 3) THEN BEGIN 
     380   IF (result_cresamsu NE 0) THEN BEGIN 
     381       print, 'eee : pb cresamsu' 
     382       return, result_cresamsu 
     383   ENDIF 
     384ENDIF 
    377385result = 0 
    378386; 
     
    409417Profiler 
    410418result = cresamsu_${$}() 
     419print, 'result : ', result 
    411420print, 'ppp : profiler report begin' 
    412421Profiler, /REPORT 
     
    443452# 
    444453# end 
    445 set 
     454#set 
    446455exit 
  • trunk/src/idl_amsu_netcdf.pro

    r542 r544  
    1 ; 
    21;+ 
    3 ; 
    4 ; .. _idl_amsu_netcdf.pro: 
    52; 
    63; =================== 
    74; idl_amsu_netcdf.pro 
    85; =================== 
     6; 
     7; .. function:: idl_amsu_netcdf(numch, temp, rtemp, rhdeg, datain, lats, lons, timesin) 
    98; 
    109; DESCRIPTION 
     
    2726;           lats [shape=tab, label="latitude 1d array"] 
    2827;           timesin [shape=tab, label="time 1d array"] 
    29 ; 
    30 ;           amsu_t5 [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/AMSU/numch_yyyymmdd_yyyymmdd_geomin_geomax.nc"]; 
     28;           temp [shape=tab, label="temp"] 
     29;           rtemp [shape=tab, label="rtemp"] 
     30;           rhdeg [shape=tab, label="rhdeg"] 
     31; 
     32;           amsu_t5 [shape=ellipse, 
     33;               fontname=Courier, 
     34;               label="${PROJECT_OD}/AMSU/numch_temprtrtemprhrhdeg_yyyymmdd_yyyymmdd_geomin_geomax.nc"]; 
    3135; 
    3236;           idl_amsu_netcdf [shape=box, 
     
    4751; 
    4852;    numch = 'a5' 
     53;    temp = 'm' 
     54;    rtemp = 0.5 
     55;    rhdeg = 1. 
    4956;    lons = findgen(10) - 10 
    5057;    lats = findgen(11) + 20 
    5158;    timesin = indgen(12) + julday(8,1,2006L) 
    5259;    datain = findgen(size(lons,/dim), size(lats,/dim), size(timesin,/dim)) 
    53 ;    idl_amsu_netcdf, numch , datain, lats, lons, timesin 
     60;    result = idl_amsu_netcdf(numch, temp, rtemp, rhdeg, datain, lats, lons, timesin) 
    5461; 
    5562; TIPS 
     
    6572; :ref:`data_amsu` 
    6673; 
    67 ; Called by :ref:`cresamsu_cdf.pro` 
     74; Called by :func:`cresamsu` 
    6875; 
    6976; use :func:`geolocation_to_string_idl`, :func:`jul2date <saxo:jul2date>` 
     
    8491; coding rules 
    8592; 
    86 ; replace pro by function 
    87 ; 
    8893; check time in netcdf 
    8994; 
     
    101106; - fplod 20120430 
    102107; 
     108;   * add temp, rtemp, rhdeg in example 
     109;   * pro -> function 
    103110;   * time unlimited 
    104111;   * time origine is a ttribute of time not of tb 
     
    156163; 
    157164;- 
    158 pro idl_amsu_netcdf, numch, temp, rtemp, rhdeg, datain, lats, lons, timesin 
     165function idl_amsu_netcdf, numch, temp, rtemp, rhdeg, datain, lats, lons, timesin 
    159166; 
    160167compile_opt idl2, strictarrsubs 
    161168; 
    162169@cm_project 
     170; 
     171s = size(SCOPE_TRACEBACK(/STRUCTURE),/DIMENSION) 
     172routine = (SCOPE_TRACEBACK(/STRUCTURE))[s-1].Routine 
     173; 
     174key_performance=0 
     175if key_performance EQ 1 THEN BEGIN 
     176    time1 = SYSTIME(1) 
     177ENDIF 
     178; 
     179; Return to caller if errors 
     180ON_ERROR, 2 
     181; 
     182result = -1 
     183; 
     184usage = 'result = idl_amsu_netcdf(numch, temp, rtemp, rhdeg, datain, lats, lons, timesin)' 
     185nparam = N_PARAMS() 
     186IF (nparam NE 8) THEN BEGIN 
     187    ras = report(['Incorrect number of arguments.' $ 
     188          + '!C' $ 
     189          + 'Usage : ' + usage]) 
     190    return, result 
     191ENDIF 
    163192; 
    164193nblat = size(lats,/dim) 
     
    205234   moyenne_tb[ind]=-9999. 
    206235endif 
    207 print,"nb valeurs manquantes", nnbad 
     236msg = report(['iii : ' + routine + ' : nb valeurs manquantes = ' + string(nnbad)]) 
    208237; 
    209238; ++ test si toutes les valeurs sont des valeurs manquantes/aberantes 
     
    221250ENDIF 
    222251; 
    223 print, 'ouverture pour ecriture de ', cdfout 
     252msg = report(['iii : ' + routine + ' : ouverture pour ecriture de ' + cdfout]) 
    224253id = ncdf_create(cdfout,/clobber) 
    225254ncdf_control, id, /nofill 
     
    274303ncdf_close, id 
    275304; 
     305result = 0 
     306return, result 
     307; 
    276308end 
Note: See TracChangeset for help on using the changeset viewer.