Ignore:
Timestamp:
03/22/12 14:40:17 (12 years ago)
Author:
pinsard
Message:

an other bunch of new functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lwr_correction_ncdf.pro

    r167 r175  
    11;+ 
    2 ; 
    3 ; .. _lwr_correction_ncdf.pro: 
    42; 
    53; ======================= 
     
    75; ======================= 
    86; 
     7; .. function:: lwr_correction_ncdf(yyyymmddb,yyyymmdde) 
     8; 
     9; DESCRIPTION 
     10; =========== 
     11; 
    912; Correction of lwr on OAFLUX grid 
    1013; 
    11 ; :file:`${PROJECT_OD}/erai_lwr_19890101_20091231_oafluxgrid.nc` 
     14; :file:`${PROJECT_OD}/erai_lwr_{yyyymmdd}_{yyyymmdd}_oafluxgrid.nc` 
    1215; containing 
    1316; ++ 
     
    1720; Corrected lwr on OAFLUX grid 
    1821; is written in 
    19 ; :file:`${PROJECT_OD}/TropFlux_lwr_19890101_20091231.nc` 
     22; :file:`${PROJECT_OD}/TropFlux_lwr_{yyyymmdd}_{yyyymmdd}.nc` 
    2023; if this file not already exists. 
    2124; 
    2225; This output file 
    23 ; :file:`${PROJECT_OD}/TropFlux_lwr_19890101_20091231.nc` 
     26; :file:`${PROJECT_OD}/TropFlux_lwr_{yyyymmdd}_{yyyymmdd}.nc` 
    2427; will be used by 
    25 ; :ref:`TropFlux_19890101_20091231.pro`. 
     28; :func:`tropflux`. 
    2629; 
    2730; .. only:: man 
     
    3538;        digraph lwr_correction_ncdf { 
    3639; 
    37 ;           file_in [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_lwr_19890101_20091231_oafluxgrid.nc"]; 
    38 ;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_lwr_19890101_20091231.nc"]; 
     40;           file_in [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_lwr_{yyyymmdd}_{yyyymmdd}_oafluxgrid.nc"]; 
     41;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_lwr_{yyyymmdd}_{yyyymmdd}.nc"]; 
    3942; 
    4043;           lwr_correction_ncdf [shape=box, 
     
    5154; ======== 
    5255; 
     56; :ref:`mooring_corrections` 
     57; 
     58; Used by :ref:`tropflux.sh` 
     59; 
    5360; :ref:`project_profile.sh` 
    54 ; 
    55 ; :ref:`mooring_corrections` 
    5661; 
    5762; :func:`interp_erai_lwr` and :ref:`add_19890101.sh` 
     
    6974; :: 
    7075; 
    71 ;  IDL> lwr_correction_ncdf 
     76;  IDL> yyyymmddb = 20000101L 
     77;  IDL> yyyymmdde = 20001231L 
     78;  IDL> result = lwr_correction_ncdf(yyyymmddb, yyyymmdde) 
     79;  IDL> print, result 
    7280; 
    7381; TODO 
     
    94102; 
    95103; $URL$ 
     104; 
     105; - fplod 20120322 
     106; 
     107;   * taking project_overwite into account 
     108;   * try to add compile_opt seems to be incompatible with ncdf_quickwrite 
     109;   * pro -> function 
     110;   * hard coded da1 and da2 replaced by yyyymmddb and yyyymmdde parameters 
     111;   * get rid of timegen 
    96112; 
    97113; - fplod 20110819T105050Z aedon.locean-ipsl.upmc.fr (Darwin) 
     
    121137; 
    122138;- 
    123 pro lwr_correction_ncdf 
     139function lwr_correction_ncdf $ 
     140         , yyyymmddb $ 
     141         , yyyymmdde 
     142; 
     143;++compile_opt idl2, strictarrsubs, logical_predicate 
    124144; 
    125145@cm_4cal 
     
    129149@cm_project 
    130150; 
     151; Return to caller if errors 
     152ON_ERROR, 2 
     153; 
     154result = -1 
     155; 
     156usage = 'result = lwr_correction_ncdf(yyyymmddb, yyyymmdde)' 
     157nparam = N_PARAMS() 
     158IF (nparam NE 2) THEN BEGIN 
     159    ras = report(['Incorrect number of arguments.' $ 
     160          + '!C' $ 
     161          + 'Usage : ' + usage]) 
     162    return, result 
     163ENDIF 
     164; 
    131165; test if ${PROJECT_OD} defined 
    132166CASE project_od_env OF 
     
    134168         msg = 'eee : ${PROJECT_OD} is not defined' 
    135169         ras = report(msg) 
    136        STOP 
     170       return, result 
    137171       END 
    138172  ELSE: BEGIN 
     
    149183   msg = 'eee : the directory' + iodirout  + ' is not accessible.' 
    150184   ras = report(msg) 
    151    STOP 
     185   return, result 
    152186ENDIF 
    153187; 
     
    156190    msg = 'eee : the directory' + iodirout  + ' was not found.' 
    157191    ras = report(msg) 
    158     STOP 
    159 ENDIF 
    160 ; 
    161 da1=19880101 
    162 da2=20091231 
     192    return, result 
     193ENDIF 
    163194; 
    164195; build data filename 
    165 filename='erai_lwr_19890101_20091231_oafluxgrid.nc' 
     196filename='erai_lwr_' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '_oafluxgrid.nc' 
    166197; 
    167198; check if this file exists 
     
    172203   msg = 'eee : the file ' + fullfilename + ' was not found.' 
    173204   ras = report(msg) 
    174    STOP 
     205   return, result 
    175206ENDIF 
    176207; 
    177208; build output filename 
    178 filename_out = 'TropFlux_lwr_19890101_20091231.nc' 
     209filename_out = 'TropFlux_lwr_' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '.nc' 
    179210fullfilename_out = iodirout + filename_out 
    180211; in order to avoid unexpected overwritten 
    181 IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN 
     212IF ((FILE_TEST(fullfilename_out) EQ 1)  AND (project_overwrite EQ 0)) THEN BEGIN 
    182213   msg = 'eee : the file ' + fullfilename_out  + ' already exists.' 
    183214   ras = report(msg) 
    184    STOP 
     215   return, result 
    185216ENDIF 
    186217; 
    187218initncdf, fullfilename 
    188 lwr=read_ncdf('lwr',da1,da2,file=fullfilename,/nostr) 
     219lwr=read_ncdf('lwr',yyyymmddb-.5d,yyyymmdde,file=fullfilename,/nostr) 
     220timein=24.d*(time-julday(1,1,1957,0,0,0)) 
     221jpt=n_elements(timein) 
     222da=jul2date(time[0]) 
     223cda0=string(da,format='(i8.8)') 
     224da=jul2date(time[jpt-1]) 
     225cda1=string(da,format='(i8.8)') 
     226print, 'lwr in lwr_correction_ncdf first date ', cda0 
     227print, 'lwr in lwr_correction_ncdf last date ' , cda1 
     228; 
    189229help, lwr 
    190230; 
     
    197237; 
    198238for jt=0,jpt-1 do begin 
    199   jtt=(time(jt)-julday(1,1,yea(jt))) < 364 
    200   t=reform(lwr_mean(*,*)) 
    201   lwr_m(*,*,jt)=t 
     239  jtt=(time[jt]-julday(1,1,yea[jt])) < 364 
     240  t=reform(lwr_mean[*,*]) 
     241  lwr_m[*,*,jt]=t 
    202242endfor 
    203243help, lwr_m 
     
    219259; 
    220260;writing field 
    221 lat=reform(gphit(0,0:jpj-1)) 
    222 lon=reform(glamt(0:jpi-1,0)) 
    223 time=timegen(7670, start=julday(1,1,1989,0), units='days') 
    224 jpt=n_elements(time) 
    225 ; 
    226 cda0=string(jul2date(time(0)),format='(i8.8)') 
    227 cda1=string(jul2date(time(jpt-1)),format='(i8.8)') 
    228 ; 
    229 time=time-julday(1,1,1950) 
    230 jpt=n_elements(time) 
     261lat=reform(gphit[0,0:jpj-1]) 
     262lon=reform(glamt[0:jpi-1,0]) 
    231263; 
    232264ncfile='!' + fullfilename_out 
     
    237269lwr_attr={units:'degK',missing_value:1.e20,long_name:'Air Temperature at 2m',short_name:'lwr',axis:'TYX'} 
    238270; 
    239 ncfields = 'lwr[longitude,latitude,time]=lwr_new:lwr_attr; ' $ 
     271ncfields = 'lwr[longitude,latitude,*time]=lwr_new:lwr_attr; ' $ 
    240272                      + 'longitude[]=lon:lon_attr; ' $ 
    241273                      + 'latitude[]=lat:lat_attr; ' $ 
    242                       + 'time[*time]=time:time_attr ' $ 
     274                      + 'time[]=timein:time_attr ' $ 
    243275                      + ' @ globattr' 
    244276; 
    245277@ncdf_quickwrite 
    246278; 
     279result = 0 
     280return, result 
     281; 
    247282end 
Note: See TracChangeset for help on using the changeset viewer.