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/ws_correction_ncdf.pro

    r172 r175  
    11;+ 
    2 ; 
    3 ; .. _ws_correction_ncdf.pro: 
    42; 
    53; ====================== 
     
    75; ====================== 
    86; 
     7; .. function:: ws_correction_ncdf(yyyymmddb,yyyymmdde) 
     8; 
     9; DESCRIPTION 
     10; =========== 
     11; 
    912; Correction of ws on OAFLUX grid 
    1013; 
    11 ; :file:`${PROJECT_OD}/erai_ws_19890101_20091231_oafluxgrid.nc` 
     14; :file:`${PROJECT_OD}/erai_ws_{yyyymmdd}_{yyyymmdd}_oafluxgrid.nc` 
    1215; containing 
    1316; ++ 
     
    1720; Corrected ws on OAFLUX grid 
    1821; is written in 
    19 ; :file:`${PROJECT_OD}/TropFlux_ws_19890101_20091231.nc` 
     22; :file:`${PROJECT_OD}/TropFlux_ws_{yyyymmdd}_{yyyymmdd}.nc` 
    2023; if this file not already exists. 
    2124; 
    2225; This output file 
    23 ; :file:`${PROJECT_OD}/TropFlux_ws_19890101_20091231.nc` 
     26; :file:`${PROJECT_OD}/TropFlux_ws_{yyyymmdd}_{yyyymmdd}.nc` 
    2427; will be used by 
    25 ; :ref:`TropFlux_19890101_20091231.pro`. 
     28; :func:`tropflux`. 
    2629; 
    2730; .. only:: man 
     
    3538;        digraph ws_correction_ncdf { 
    3639; 
    37 ;           file_in [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_ws_19890101_20091231_oafluxgrid.nc"]; 
    38 ;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_ws_19890101_20091231.nc"]; 
     40;           file_in [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_ws_{yyyymmdd}_{yyyymmdd}_oafluxgrid.nc"]; 
     41;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_ws_{yyyymmdd}_{yyyymmdd}.nc"]; 
    3942; 
    4043;           ws_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_ws` 
     
    6974; :: 
    7075; 
    71 ;  IDL> ws_correction_ncdf 
     76;  IDL> yyyymmddb = 20000101L 
     77;  IDL> yyyymmdde = 20001231L 
     78;  IDL> result = ws_correction_ncdf(yyyymmddb, yyyymmdde) 
     79;  IDL> print, result 
    7280; 
    7381; TODO 
     
    9098; 
    9199; $URL$ 
     100; 
     101; - fplod 20120322 
     102; 
     103;   * taking project_overwite into account 
     104;   * try to add compile_opt seems to be incompatible with ncdf_quickwrite 
     105;   * pro -> function 
     106;   * hard coded da1 and da2 replaced by yyyymmddb and yyyymmdde parameters 
     107;   * get rid of timegen 
    92108; 
    93109; - fplod 20110808T131954Z aedon.locean-ipsl.upmc.fr (Darwin) 
     
    110126; 
    111127;- 
    112 pro ws_correction_ncdf 
    113 ; 
    114 @cm_4cal 
     128function ws_correction_ncdf $ 
     129         , yyyymmddb $ 
     130         , yyyymmdde 
     131; 
     132;++compile_opt idl2, strictarrsubs, logical_predicate 
     133; 
    115134@cm_4data 
    116135@cm_4mesh 
     
    118137@cm_project 
    119138; 
     139; Return to caller if errors 
     140ON_ERROR, 2 
     141; 
     142result = -1 
     143; 
     144usage = 'result = ws_correction_ncdf(yyyymmddb, yyyymmdde)' 
     145nparam = N_PARAMS() 
     146IF (nparam NE 2) THEN BEGIN 
     147    ras = report(['Incorrect number of arguments.' $ 
     148          + '!C' $ 
     149          + 'Usage : ' + usage]) 
     150    return, result 
     151ENDIF 
     152; 
     153@cm_4cal 
    120154; test if ${PROJECT_OD} defined 
    121155CASE project_od_env OF 
     
    123157         msg = 'eee : ${PROJECT_OD} is not defined' 
    124158         ras = report(msg) 
    125        STOP 
     159       return, result 
    126160       END 
    127161  ELSE: BEGIN 
     
    138172   msg = 'eee : the directory' + iodirout  + ' is not accessible.' 
    139173   ras = report(msg) 
    140    STOP 
     174   return, result 
    141175ENDIF 
    142176; 
     
    145179    msg = 'eee : the directory' + iodirout  + ' was not found.' 
    146180    ras = report(msg) 
    147     STOP 
    148 ENDIF 
    149 ; 
    150 da1=19880101 
    151 da2=20101231 
     181    return, result 
     182ENDIF 
    152183; 
    153184; build data filename 
    154 filename='erai_ws_19890101_20091231_oafluxgrid.nc' 
     185filename='erai_ws_' $ 
     186    + string(yyyymmddb,format='(i8.8)') $ 
     187    + '_' $ 
     188    + string(yyyymmdde,format='(i8.8)') $ 
     189    + '_oafluxgrid.nc' 
    155190; 
    156191; check if this file exists 
     
    161196   msg = 'eee : the file ' + fullfilename + ' was not found.' 
    162197   ras = report(msg) 
    163    STOP 
     198   return, result 
    164199ENDIF 
    165200; 
    166201; build output filename 
    167 filename_out = 'TropFlux_ws_19890101_20091231.nc' 
     202filename_out = 'TropFlux_ws_' $ 
     203    + string(yyyymmddb,format='(i8.8)') $ 
     204    + '_' $ 
     205    + string(yyyymmdde,format='(i8.8)') $ 
     206    + '.nc' 
    168207fullfilename_out = iodirout + filename_out 
    169208; in order to avoid unexpected overwritten 
    170 IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN 
     209IF ((FILE_TEST(fullfilename_out) EQ 1)  AND (project_overwrite EQ 0)) THEN BEGIN 
    171210   msg = 'eee : the file ' + fullfilename_out  + ' already exists.' 
    172211   ras = report(msg) 
    173    STOP 
     212   return, result 
    174213ENDIF 
    175214; 
    176215initncdf, fullfilename 
    177 u=read_ncdf('u10',da1,da2,file=fullfilename,/nostr) 
    178 v=read_ncdf('v10',da1,da2,file=fullfilename,/nostr) 
     216u=read_ncdf('u10',yyyymmddb-.5d,yyyymmdde,file=fullfilename,/nostr) 
     217timein=24.d*(time-julday(1,1,1957,0,0,0)) 
     218jpt=n_elements(timein) 
     219da=jul2date(time[0]) 
     220cda0=string(da,format='(i8.8)') 
     221da=jul2date(time[jpt-1]) 
     222cda1=string(da,format='(i8.8)') 
     223print, 'u10 in ws_correction_ncdf first date ', cda0 
     224print, 'u10 in ws_correction_ncdf last date ' , cda1 
     225; 
     226v=read_ncdf('v10',yyyymmddb-.5d,yyyymmdde,file=fullfilename,/nostr) 
     227timein=24.d*(time-julday(1,1,1957,0,0,0)) 
     228jpt=n_elements(timein) 
     229da=jul2date(time[0]) 
     230cda0=string(da,format='(i8.8)') 
     231da=jul2date(time[jpt-1]) 
     232cda1=string(da,format='(i8.8)') 
     233print, 'v10 in ws_correction_ncdf first date ', cda0 
     234print, 'v10 in ws_correction_ncdf last date ' , cda1 
     235; 
    179236w=sqrt(u*u+v*v) 
    180237; 
     
    189246; 
    190247for jt=0,jpt-1 do begin 
    191   jtt=(time(jt)-julday(1,1,yea(jt))) < 364 
    192   q=reform(w_mean(*,*)) 
    193   w_m(*,*,jt)=q 
     248  jtt=(time[jt]-julday(1,1,yea[jt])) < 364 
     249  q=reform(w_mean[*,*]) 
     250  w_m[*,*,jt]=q 
    194251endfor 
    195252help, w_m 
     
    211268; 
    212269;writing field 
    213 lat=reform(gphit(0,0:jpj-1)) 
    214 lon=reform(glamt(0:jpi-1,0)) 
    215 time=timegen(7670, start=julday(1,1,1989,0), units='days') 
    216 jpt=n_elements(time) 
    217 ; 
    218 cda0=string(jul2date(time(0)),format='(i8.8)') 
    219 cda1=string(jul2date(time(jpt-1)),format='(i8.8)') 
    220 ; 
    221 time=time-julday(1,1,1950) 
    222 jpt=n_elements(time) 
     270lat=reform(gphit[0,0:jpj-1]) 
     271lon=reform(glamt[0:jpi-1,0]) 
    223272; 
    224273ncfile='!' + fullfilename_out 
     
    229278w_attr={units:'m/s',missing_value:1.e20,long_name:'mean wind speed',short_name:'w',axis:'TYX'} 
    230279; 
    231 ncfields = 'ws[longitude,latitude,time]=w_new:w_attr; ' $ 
     280ncfields = 'ws[longitude,latitude,*time]=w_new:w_attr; ' $ 
    232281                      + 'longitude[]=lon:lon_attr; ' $ 
    233282                      + 'latitude[]=lat:lat_attr; ' $ 
    234                       + 'time[*time]=time:time_attr ' $ 
     283                      + 'time[]=timein:time_attr ' $ 
    235284                      + ' @ globattr' 
    236285; 
    237286@ncdf_quickwrite 
    238287; 
     288result = 0 
     289return, result 
     290; 
    239291end 
Note: See TracChangeset for help on using the changeset viewer.