Changeset 175


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

an other bunch of new functions

Location:
trunk
Files:
23 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/docs/docs_dev/source/guides/data_content.rst

    r172 r175  
    133133 - :func:`oaflux_mask_30n30s` 
    134134 
    135  - :ref:`TropFlux_19890101_20091231.pro` 
     135 - :func:`tropflux` 
    136136 
    137137 - :func:`interp_erai_dewt` 
  • trunk/docs/docs_dev/source/guides/generate_tropflux.rst

    r174 r175  
    131131tools : 
    132132 - :func:`tropflux_swr_dt`, :func:`tropflux_swr_nrt`, :func:`tropflux_swr_blnd` 
    133  - :ref:`lwr_correction_ncdf.pro` 
    134  - :ref:`q2m_correction_ncdf.pro` 
    135  - :ref:`sst_correction_ncdf.pro` 
    136  - :ref:`t2m_correction_ncdf.pro` 
    137  - :ref:`ws_correction_ncdf.pro` 
     133 - :func:`lwr_correction_ncdf` 
     134 - :func:`q2m_correction_ncdf` 
     135 - :func:`sst_correction_ncdf` 
     136 - :func:`t2m_correction_ncdf` 
     137 - :func:`ws_correction_ncdf` 
    138138 
    139139Result after that, 7 netcdf files for: NOAA OLR, ERA-I :math:`T_a`, ERA-I :math:`q_a`, ERA-I wind speed, ERA-I SST, ISCCP net SW, ERA-I net LW. 
     
    148148tools : 
    149149 - :func:`cronin_gustiness_ncdf` 
    150  - :ref:`TropFlux_19890101_20091231.pro` (:func:`cor30a`), :ref:`TropFlux_NRT_ncdf.pro`  
     150 - :func:`tropflux` (:func:`cor30a`), :ref:`TropFlux_NRT_ncdf.pro`  
    151151 
    152152After that step, there are 5 files: Tropflux :math:`T_{2m}`, :math:`q_{2m}`, SST, wind, and one file with the 4 components of the net flux (sensible, latent, SWR, LWR) 
  • trunk/src/TropFlux_NRT_ncdf.pro

    r174 r175  
    1717; lwr corrected on OAFLUX grid 
    1818; has been produced by 
    19 ; :ref:`lwr_correction_ncdf.pro`. 
     19; :func:`lwr_correction_ncdf`. 
    2020; 
    2121; :file:`${PROJECT_OD}/TropFlux_19890101_20091231_coare3.nc` 
     
    2323; ++ 
    2424; has been produced by 
    25 ; :ref:`TropFlux_19890101_20091231.pro`. 
     25; :func:`tropflux`. 
    2626; 
    2727; ++ are written 
  • trunk/src/cor30a.pro

    r97 r175  
    6969; ======== 
    7070; 
    71 ; used by :ref:`TropFlux_19890101_20091231.pro` 
     71; used by :func:`tropflux` 
    7272; 
    7373; call :func:`psiu`, :func:`psit`. 
  • trunk/src/cronin_gustiness_ncdf.pro

    r174 r175  
    1313; 
    1414; :file:`${PROJECT_OD}/TropFlux_sst_19890101_20091231.nc` have been produced by 
    15 ; :ref:`sst_correction_ncdf.pro`. 
     15; :func:`sst_correction_ncdf`. 
    1616; 
    1717; Cronin gustiness corrected ++ on corrected sst on OAFLUX grid 
     
    2323; :func:`tropflux_swr_blnd` 
    2424; and 
    25 ; :ref:`TropFlux_19890101_20091231.pro`. 
     25; :func:`tropflux`. 
    2626; 
    2727;     .. graphviz:: 
     
    5858; :ref:`mooring_corrections` 
    5959; 
    60 ; :ref:`sst_correction_ncdf.pro`. 
     60; :func:`sst_correction_ncdf`. 
    6161; 
    6262; :func:`initncdf <saxo:initncdf>` 
  • trunk/src/d2m_to_q2m_erai.pro

    r174 r175  
    3939; :file:`${PROJECT_OD}/erai_q2m_{yyyymmdd}_{yyyymmdd}_oafluxgrid.nc` 
    4040; will be used by 
    41 ; :ref:`q2m_correction_ncdf.pro`. 
     41; :func:`q2m_correction_ncdf`. 
    4242; 
    4343; .. only:: man 
     
    8383; :func:`interp_erai_t2m` 
    8484; 
    85 ; :ref:`q2m_correction_ncdf.pro` 
     85; :func:`q2m_correction_ncdf` 
    8686; 
    8787; :func:`rh_to_spechum` 
  • trunk/src/interp_erai_lwr.pro

    r174 r175  
    9191; 
    9292; lwr first date 19991231 vs yyyymmddb = 20000101L 
    93 ;  
     93; 
    9494; make it work : pb on loholt1 idl8: 
    9595; 
     
    154154; - fplod 20110819T084310Z aedon.locean-ipsl.upmc.fr (Darwin) 
    155155; 
    156 ;   * replace next step :ref:`lwr_correction_ncdf.pro` by :ref:`add_19890101.sh` 
     156;   * replace next step lwr_correction_ncdf.pro by :ref:`add_19890101.sh` 
    157157;   * fix output file name to erai_lwr_19890102_20091231_oafluxgrid.nc 
    158158; 
  • trunk/src/interp_erai_sst.pro

    r174 r175  
    3232; :file:`${PROJECT_OD}/erai_sst_{yyyymmdd}_{yyyymmdd}_oafluxgrid.nc` 
    3333; must be processed after by 
    34 ; :ref:`sst_correction_ncdf.pro`. 
     34; :func:`sst_correction_ncdf`. 
    3535; 
    3636; .. only:: man 
     
    7676; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>` 
    7777; 
    78 ; :ref:`sst_correction_ncdf.pro` 
     78; :func:`sst_correction_ncdf` 
    7979; 
    8080; EXAMPLES 
  • trunk/src/interp_erai_t2m.pro

    r174 r175  
    3131; :file:`${PROJECT_OD}/erai_t2m_{yyyymmdd}_{yyyymmdd}_oafluxgrid.nc` 
    3232; must be processed after by 
    33 ; :ref:`t2m_correction_ncdf.pro`. 
     33; :func:`t2m_correction_ncdf`. 
    3434; 
    3535; .. only:: man 
     
    8181; :func:`ncdf_getatt <saxo:ncdf_getatt>` 
    8282; 
    83 ; :ref:`t2m_correction_ncdf.pro` 
     83; :func:`t2m_correction_ncdf` 
    8484; 
    8585; EXAMPLES 
     
    380380t2min=read_ncdf('t2',yyyymmddb-.5d,yyyymmdde,file=fullfilename_t2,/nost) 
    381381;; time:units = "hours since 1957-01-01 00:00:0.0" ; 
    382 timein=24.d*(time-julday(1,1,1957,0,0,0))  
     382timein=24.d*(time-julday(1,1,1957,0,0,0)) 
    383383jptin=n_elements(timein) 
    384384da=jul2date(time[0]) 
    385385cda0=string(da,format='(i8.8)') 
    386 da=jul2date(time[jpt-1])  
     386da=jul2date(time[jpt-1]) 
    387387cda1=string(da,format='(i8.8)') 
    388388print, 't2m first date ', cda0 
  • trunk/src/interp_erai_ws.pro

    r172 r175  
    3737; :file:`${PROJECT_OD}/erai_ws_19890101_20091231_oafluxgrid.nc` 
    3838; must be processed after by 
    39 ; :ref:`ws_correction_ncdf.pro`. 
     39; :func:`ws_correction_ncdf`. 
    4040; 
    4141; .. only:: man 
     
    8282; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>` 
    8383; 
    84 ; :ref:`ws_correction_ncdf.pro` 
     84; :func:`ws_correction_ncdf` 
    8585; 
    8686; EXAMPLES 
     
    306306u10in=read_ncdf("u10", yyyymmddb - .5d, yyyymmdde, file=fullfilename,/nostr) 
    307307; 
    308 timein=24.d*(time-julday(1,1,1957,0,0,0))  
     308timein=24.d*(time-julday(1,1,1957,0,0,0)) 
    309309jpt=n_elements(timein) 
    310310da=jul2date(time[0]) 
    311311cda0=string(da,format='(i8.8)') 
    312 da=jul2date(time[jpt-1])  
     312da=jul2date(time[jpt-1]) 
    313313cda1=string(da,format='(i8.8)') 
    314314print, 'u10 first date ', cda0 
  • 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 
  • trunk/src/oaflux_mask_30n30s.pro

    r172 r175  
    6262; 
    6363; Following program use :func:`oaflux_mask_30n30s` output: 
    64 ; :ref:`TropFlux_19890101_20091231.pro`, 
     64; :func:`tropflux`, 
    6565; :func:`interp_erai_dewt`, 
    6666; :func:`interp_erai_lwr`, 
  • trunk/src/paper01/fig11/swr_isccp_tropflux_correlation_fig10.pro

    r100 r175  
    1313; sst corrected on OAFLUX grid 
    1414; has been produced by 
    15 ; :ref:`sst_correction_ncdf.pro`. 
     15; :func:`sst_correction_ncdf`. 
    1616; 
    1717; :file:`${PROJECT_OD}/correlation_isccp_olr.idl` 
  • trunk/src/paper01/fig11/swr_isccp_tropflux_new_v1.pro

    r100 r175  
    1414; sst corrected on OAFLUX grid 
    1515; has been produced by 
    16 ; :ref:`sst_correction_ncdf.pro`. 
     16; :func:`sst_correction_ncdf`. 
    1717; 
    1818; ++ are written in 
  • trunk/src/paper01/fig13/net_flux_validation_scatter_2000_2007.pro

    r174 r175  
    2424; ; containing ++ 
    2525; has been produced by 
    26 ; :ref:`TropFlux_19890101_20091231.pro`. 
     26; :func:`tropflux`. 
    2727; 
    2828; .. graphviz:: 
  • trunk/src/paper01/fig16/fig16_timeseries_nino3.pro

    r97 r175  
    1313; sst corrected on OAFLUX grid 
    1414; has been produced by 
    15 ; :ref:`sst_correction_ncdf.pro`. 
     15; :func:`sst_correction_ncdf`. 
    1616; 
    1717; :file:`${PROJECT_OD}/netflux_nino3_1989_2007.idl` 
  • trunk/src/q2m_correction_ncdf.pro

    r172 r175  
    11;+ 
    2 ; 
    3 ; .. _q2m_correction_ncdf.pro: 
    42; 
    53; ======================= 
     
    75; ======================= 
    86; 
     7; .. function:: q2m_correction_ncdf(yyyymmddb,yyyymmdde) 
     8; 
    99; DESCRIPTION 
    1010; =========== 
     
    1212; Correction of q2m on OAFLUX grid 
    1313; 
    14 ; :file:`${PROJECT_OD}/erai_q2m_19890101_20091231_oafluxgrid.nc` 
     14; :file:`${PROJECT_OD}/erai_q2m_{yyyymmdd}_{yyyymmdd}_oafluxgrid.nc` 
    1515; containing 
    1616; ++ 
     
    2020; Corrected q2m on OAFLUX grid 
    2121; is written in 
    22 ; :file:`${PROJECT_OD}/TropFlux_q2m_19890101_20091231.nc` 
     22; :file:`${PROJECT_OD}/TropFlux_q2m_{yyyymmdd}_{yyyymmdd}.nc` 
    2323; if this file not already exists. 
    2424; 
    2525; This file will be used by 
    26 ; :ref:`TropFlux_19890101_20091231.pro`. 
     26; :func:`tropflux`. 
    2727; 
    2828; .. only:: man 
     
    3636;        digraph q2m_correction_ncdf { 
    3737; 
    38 ;           file_in [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_q2m_19890101_20091231_oafluxgrid.nc"]; 
    39 ;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_q2m_19890101_20091231.nc"]; 
     38;           file_in [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_q2m_{yyyymmdd}_{yyyymmdd}_oafluxgrid.nc"]; 
     39;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_q2m_{yyyymmdd}_{yyyymmdd}.nc"]; 
    4040; 
    4141;           q2m_correction_ncdf [shape=box, 
     
    5252; ======== 
    5353; 
     54; :ref:`mooring_corrections` 
     55; 
     56; Used by :ref:`tropflux.sh` 
     57; 
    5458; :ref:`project_profile.sh` 
    55 ; 
    56 ; :ref:`mooring_corrections` 
    5759; 
    5860; :func:`d2m_to_q2m_erai` 
     
    6971; :: 
    7072; 
    71 ;  IDL> q2m_correction_ncdf 
     73;  IDL> yyyymmddb = 20000101L 
     74;  IDL> yyyymmdde = 20001231L 
     75;  IDL> result = q2m_correction_ncdf(yyyymmddb, yyyymmdde) 
     76;  IDL> print, result 
    7277; 
    7378; TODO 
    7479; ==== 
    7580; 
    76 ; work on cratos idl7 even if NaNf values in erai_q2m_19890101_20091231_oafluxgrid.nc written by 
    77 ; d2m_to_q2m.pro. 
     81; make it work :: 
     82; 
     83;   Writing fields: 
     84;   q2m[longitude,latitude,time*]=q2m_new:q2m_attr; longitude[]=lon:lon_attr; latitude[]=lat:lat_attr; time[]=timein:time_attr  @ globattr 
     85;   % NCDF_DIMDEF: Unable to create dimension. (NC_ERROR=-59) 
     86;   % NCDF_VARDEF: Unable to define variable, bad dimension id . 
     87;   % NCDF_VARPUT: Variable Inquiry failed, -1 is not a valid variable id. 
     88;   % Stop encountered: Q2M_CORRECTION_NCDF    1 
     89;         /.autofs/lodyc/incas/fplod/tropflux/tropflux_ws/src/q2m_correction_ncdf.pro 
    7890; 
    7991; No way ... NaNf also in this output !! 
     
    88100; $URL$ 
    89101; 
     102; - fplod 20120322 
     103; 
     104;   * taking project_overwite into account 
     105;   * try to add compile_opt seems to be incompatible with ncdf_quickwrite 
     106;   * pro -> function 
     107;   * hard coded da1 and da2 replaced by yyyymmddb and yyyymmdde parameters 
     108;   * get rid of timegen 
     109; 
    90110; - fplod 20110808T143129Z aedon.locean-ipsl.upmc.fr (Darwin) 
    91111; 
     
    106126; 
    107127;- 
    108 pro q2m_correction_ncdf 
     128function q2m_correction_ncdf $ 
     129         , yyyymmddb $ 
     130         , yyyymmdde 
     131; 
     132;++compile_opt idl2, strictarrsubs, logical_predicate 
    109133; 
    110134@cm_4cal 
     
    114138@cm_project 
    115139; 
     140; Return to caller if errors 
     141ON_ERROR, 2 
     142; 
     143result = -1 
     144; 
     145usage = 'result = q2m_correction_ncdf(yyyymmddb, yyyymmdde)' 
     146nparam = N_PARAMS() 
     147IF (nparam NE 2) THEN BEGIN 
     148    ras = report(['Incorrect number of arguments.' $ 
     149          + '!C' $ 
     150          + 'Usage : ' + usage]) 
     151    return, result 
     152ENDIF 
     153 
    116154; test if ${PROJECT_OD} defined 
    117155CASE project_od_env OF 
     
    119157         msg = 'eee : ${PROJECT_OD} is not defined' 
    120158         ras = report(msg) 
    121        STOP 
     159       return, result 
    122160       END 
    123161  ELSE: BEGIN 
     
    134172   msg = 'eee : the directory' + iodirout  + ' is not accessible.' 
    135173   ras = report(msg) 
    136    STOP 
     174   return, result 
    137175ENDIF 
    138176; 
     
    141179    msg = 'eee : the directory' + iodirout  + ' was not found.' 
    142180    ras = report(msg) 
    143     STOP 
    144 ENDIF 
    145 ; 
    146 da1=19880101 
    147 da2=20101231 
     181    return, result 
     182ENDIF 
    148183; 
    149184; build data filename 
    150 filename='erai_q2m_19890101_20091231_oafluxgrid.nc' 
     185filename='erai_q2m_' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '_oafluxgrid.nc' 
    151186; 
    152187; check if this file exists 
     
    157192   msg = 'eee : the file ' + fullfilename + ' was not found.' 
    158193   ras = report(msg) 
    159    STOP 
     194   return, result 
    160195ENDIF 
    161196; 
    162197; build output filename 
    163 filename_out = 'TropFlux_q2m_19890101_20091231.nc' 
     198filename_out = 'TropFlux_q2m_' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '.nc' 
    164199fullfilename_out = iodirout + filename_out 
    165200; in order to avoid unexpected overwritten 
    166 IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN 
     201IF ((FILE_TEST(fullfilename_out) EQ 1)  AND (project_overwrite EQ 0)) THEN BEGIN 
    167202   msg = 'eee : the file ' + fullfilename_out  + ' already exists.' 
    168203   ras = report(msg) 
    169    STOP 
     204   return, result 
    170205ENDIF 
    171206; 
    172207initncdf, fullfilename 
    173 q2m=read_ncdf('q2m',da1,da2,file=fullfilename,/nostr) 
     208q2m=read_ncdf('q2m',yyyymmddb-.5d,yyyymmdde,file=fullfilename,/nostr) 
     209timein=24.d*(time-julday(1,1,1957,0,0,0)) 
     210jpt=n_elements(timein) 
     211da=jul2date(time[0]) 
     212cda0=string(da,format='(i8.8)') 
     213da=jul2date(time[jpt-1]) 
     214cda1=string(da,format='(i8.8)') 
     215print, 'q2m in q2m_correction_ncdf first date ', cda0 
     216print, 'q2m in q2m_correction_ncdf last date ' , cda1 
     217; 
    174218help, q2m 
    175219; 
     
    182226; 
    183227for jt=0,jpt-1 do begin 
    184   jtt=(time(jt)-julday(1,1,yea(jt))) < 364 
    185   q=reform(q2m_mean(*,*)) 
    186   q2m_m(*,*,jt)=q 
     228  jtt=(time[jt]-julday(1,1,yea[jt])) < 364 
     229  q=reform(q2m_mean[*,*]) 
     230  q2m_m[*,*,jt]=q 
    187231endfor 
    188232help, q2m_m 
     
    203247; 
    204248;writing field 
    205 lat=reform(gphit(0,0:jpj-1)) 
    206 lon=reform(glamt(0:jpi-1,0)) 
    207 time=timegen(7670, start=julday(1,1,1989,0), units='days') 
    208 jpt=n_elements(time) 
    209 ; 
    210 cda0=string(jul2date(time(0)),format='(i8.8)') 
    211 cda1=string(jul2date(time(jpt-1)),format='(i8.8)') 
    212 ; 
    213 time=time-julday(1,1,1950) 
    214 jpt=n_elements(time) 
     249lat=reform(gphit[0,0:jpj-1]) 
     250lon=reform(glamt[0:jpi-1,0]) 
    215251; 
    216252ncfile='!' + fullfilename_out 
     
    221257q2m_attr={units:'g/kg',missing_value:1.e20,long_name:'Specific humidity at 2m height',short_name:'q2m',axis:'TYX'} 
    222258; 
    223 ncfields = 'q2m[longitude,latitude,time]=q2m_new:q2m_attr; ' $ 
     259ncfields = 'q2m[longitude,latitude,time*]=q2m_new:q2m_attr; ' $ 
    224260                      + 'longitude[]=lon:lon_attr; ' $ 
    225261                      + 'latitude[]=lat:lat_attr; ' $ 
    226                       + 'time[*time]=time:time_attr ' $ 
     262                      + 'time[]=timein:time_attr ' $ 
    227263                      + ' @ globattr' 
    228264; 
    229265@ncdf_quickwrite 
    230266; 
     267result = 0 
     268return, result 
     269; 
    231270end 
  • trunk/src/sst_correction_ncdf.pro

    r174 r175  
    11;+ 
    2 ; 
    3 ; .. _sst_correction_ncdf.pro: 
    42; 
    53; ======================= 
     
    75; ======================= 
    86; 
     7; .. function:: sst_correction_ncdf(yyyymmddb,yyyymmdde) 
     8; 
     9; DESCRIPTION 
     10; =========== 
     11; 
    912; Correction of sst on OAFLUX grid 
    1013; 
    11 ; :file:`${PROJECT_OD}/erai_sst_19890101_20091231_oafluxgrid.nc` 
     14; :file:`${PROJECT_OD}/erai_sst_{yyyymmdd}_{yyyymmdd}_oafluxgrid.nc` 
    1215; containing 
    1316; ++ 
     
    1720; Corrected sst on OAFLUX grid 
    1821; is written in 
    19 ; :file:`${PROJECT_OD}/TropFlux_sst_19890101_20091231.nc` 
     22; :file:`${PROJECT_OD}/TropFlux_sst_{yyyymmdd}_{yyyymmdd}.nc` 
    2023; if this file not already exists. 
    2124; 
    2225; This output file 
    23 ; :file:`${PROJECT_OD}/TropFlux_sst_19890101_20091231.nc` 
     26; :file:`${PROJECT_OD}/TropFlux_sst_{yyyymmdd}_{yyyymmdd}.nc` 
    2427; will be used by 
    2528; :func:`cronin_gustiness_ncdf` 
    2629; and 
    27 ; :ref:`TropFlux_19890101_20091231.pro`. 
     30; :func:`tropflux`. 
    2831; 
    2932; This output file 
    30 ; :file:`${PROJECT_OD}/TropFlux_sst_19890101_20091231.nc` 
     33; :file:`${PROJECT_OD}/TropFlux_sst_{yyyymmdd}_{yyyymmdd}.nc` 
    3134; is one of the deliverable of TropFlux. 
    3235; 
     
    4144;        digraph sst_correction_ncdf { 
    4245; 
    43 ;           file_in [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_sst_19890101_20091231_oafluxgrid.nc"]; 
    44 ;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_sst_19890101_20091231.nc"]; 
     46;           file_in [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_sst_{yyyymmdd}_{yyyymmdd}_oafluxgrid.nc"]; 
     47;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_sst_{yyyymmdd}_{yyyymmdd}.nc"]; 
    4548; 
    4649;           sst_correction_ncdf [shape=box, 
     
    5760; ======== 
    5861; 
     62; :ref:`mooring_corrections` 
     63; 
     64; Used by :ref:`tropflux.sh` 
     65; 
    5966; :ref:`project_profile.sh` 
    60 ; 
    61 ; :ref:`mooring_corrections` 
    6267; 
    6368; :func:`interp_erai_sst` 
     
    7479; :: 
    7580; 
    76 ;  IDL> sst_correction_ncdf 
     81;  IDL> yyyymmddb = 20000101L 
     82;  IDL> yyyymmdde = 20001231L 
     83;  IDL> result = sst_correction_ncdf(yyyymmddb, yyyymmdde) 
     84;  IDL> print, result 
    7785; 
    7886; TODO 
     
    8088; 
    8189; make it work on loholt1 idl8: 
    82 ; reach end whtiout error but with bad values (9.96921e+36 on time and sst, nb timestep  5716 
     90; reach end whithout error but with bad values (9.96921e+36 on time and sst, nb timestep  5716 
    8391; 
    8492; see commands:: 
     
    156164; $URL$ 
    157165; 
     166; - fplod 20120322 
     167; 
     168;   * taking project_overwite into account 
     169;   * try to add compile_opt seems to be incompatible with ncdf_quickwrite 
     170;   * pro -> function 
     171;   * hard coded da1 and da2 replaced by yyyymmddb and yyyymmdde parameters 
     172;   * get rid of timegen 
     173; 
    158174; - fplod 20110808T124236Z cratos (Linux) 
    159175; 
     
    175191; 
    176192;- 
    177 pro sst_correction_ncdf 
     193function sst_correction_ncdf $ 
     194         , yyyymmddb $ 
     195         , yyyymmdde 
     196; 
     197;++compile_opt idl2, strictarrsubs, logical_predicate 
    178198; 
    179199@cm_4cal 
     
    183203@cm_project 
    184204; 
     205; Return to caller if errors 
     206ON_ERROR, 2 
     207; 
     208result = -1 
     209; 
     210usage = 'result = sst_correction_ncdf(yyyymmddb, yyyymmdde)' 
     211nparam = N_PARAMS() 
     212IF (nparam NE 2) THEN BEGIN 
     213    ras = report(['Incorrect number of arguments.' $ 
     214          + '!C' $ 
     215          + 'Usage : ' + usage]) 
     216    return, result 
     217ENDIF 
     218; 
    185219; test if ${PROJECT_OD} defined 
    186220CASE project_od_env OF 
     
    188222         msg = 'eee : ${PROJECT_OD} is not defined' 
    189223         ras = report(msg) 
    190        STOP 
     224       return, result 
    191225       END 
    192226  ELSE: BEGIN 
     
    203237   msg = 'eee : the directory' + iodirout  + ' is not accessible.' 
    204238   ras = report(msg) 
    205    STOP 
     239   return, result 
    206240ENDIF 
    207241; 
     
    210244    msg = 'eee : the directory' + iodirout  + ' was not found.' 
    211245    ras = report(msg) 
    212     STOP 
    213 ENDIF 
    214 ; 
    215 da1=19880101 
    216 da2=20091231 
     246    return, result 
     247ENDIF 
    217248; 
    218249; build data filename 
    219 filename='erai_sst_19890101_20091231_oafluxgrid.nc' 
     250filename='erai_sst_' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '_oafluxgrid.nc' 
    220251; 
    221252; check if this file exists 
     
    226257   msg = 'eee : the file ' + fullfilename + ' was not found.' 
    227258   ras = report(msg) 
    228    STOP 
     259   return, result 
    229260ENDIF 
    230261; 
    231262; build output filename 
    232 filename_out = 'TropFlux_sst_19890101_20091231.nc' 
     263filename_out = 'TropFlux_sst_' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '.nc' 
    233264fullfilename_out = iodirout + filename_out 
    234265; in order to avoid unexpected overwritten 
    235 IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN 
     266IF ((FILE_TEST(fullfilename_out) EQ 1)  AND (project_overwrite EQ 0)) THEN BEGIN 
    236267   msg = 'eee : the file ' + fullfilename_out  + ' already exists.' 
    237268   ras = report(msg) 
    238    STOP 
     269   return, result 
    239270ENDIF 
    240271; 
    241272initncdf, fullfilename 
    242 sst=read_ncdf('sst',da1,da2,file=fullfilename,/nostr) 
     273sst=read_ncdf('sst',yyyymmddb-.5d,yyyymmdde,file=fullfilename,/nostr) 
     274timein=24.d*(time-julday(1,1,1957,0,0,0)) 
     275jpt=n_elements(timein) 
     276da=jul2date(time[0]) 
     277cda0=string(da,format='(i8.8)') 
     278da=jul2date(time[jpt-1]) 
     279cda1=string(da,format='(i8.8)') 
     280print, 'sst in sst_correction_ncdf first date ', cda0 
     281print, 'sst in sst_correction_ncdf last date ' , cda1 
     282; 
    243283sst=sst-273.15 
    244284help, sst 
     
    250290caldat, time,mon,day,yea 
    251291; 
    252 ; debug to understand some time value 9.9692100e+36 on idl 6 lohloht1 
    253 print, time[7080:7090] 
     292;++ debug to understand some time value 9.9692100e+36 on idl 6 lohloht1 
     293; print, time[7080:7090] when working on [19890101,19891231] 
    254294; 
    255295sst_m=sst*0. 
    256296; 
    257297for jt=0,jpt-1 do begin 
    258   jtt=(time(jt)-julday(1,1,yea(jt))) < 364 
    259   t=reform(sst_mean(*,*)) 
    260   sst_m(*,*,jt)=t 
     298  jtt=(time[jt]-julday(1,1,yea[jt])) < 364 
     299  t=reform(sst_mean[*,*]) 
     300  sst_m[*,*,jt]=t 
    261301endfor 
    262302help, sst_m 
     
    278318; 
    279319;writing field 
    280 lat=reform(gphit(0,0:jpj-1)) 
    281 lon=reform(glamt(0:jpi-1,0)) 
    282 time=timegen(7670, start=julday(1,1,1989,0), units='days') 
    283 jpt=n_elements(time) 
    284 ; 
    285 cda0=string(jul2date(time(0)),format='(i8.8)') 
    286 cda1=string(jul2date(time(jpt-1)),format='(i8.8)') 
    287 ; 
    288 time=time-julday(1,1,1950) 
    289 jpt=n_elements(time) 
     320lat=reform(gphit[0,0:jpj-1]) 
     321lon=reform(glamt[0:jpi-1,0]) 
    290322; 
    291323ncfile='!' + fullfilename_out 
     
    296328sst_attr={units:'degK',missing_value:1.e20,long_name:'Sea Surface Temperature',short_name:'sst',axis:'TYX'} 
    297329; 
    298 ncfields = 'sst[longitude,latitude,time]=sst_new:sst_attr; ' $ 
     330ncfields = 'sst[longitude,latitude,*time]=sst_new:sst_attr; ' $ 
    299331                      + 'longitude[]=lon:lon_attr; ' $ 
    300332                      + 'latitude[]=lat:lat_attr; ' $ 
    301                       + 'time[*time]=time:time_attr ' $ 
     333                      + 'time[]=timein:time_attr ' $ 
    302334                      + ' @ globattr' 
    303335; 
    304336@ncdf_quickwrite 
    305337; 
     338result = 0 
     339return, result 
     340; 
    306341end 
  • trunk/src/t2m_correction_ncdf.pro

    r155 r175  
    11;+ 
    2 ; 
    3 ; .. _t2m_correction_ncdf.pro: 
    42; 
    53; ======================= 
     
    75; ======================= 
    86; 
     7; .. function:: t2m_correction_ncdf(yyyymmddb,yyyymmdde) 
     8; 
     9; DESCRIPTION 
     10; =========== 
     11; 
    912; Mean correction for air temperature bias and correction for variability are 
    1013; applied. 
    1114; 
    12 ; :file:`${PROJECT_ID}/erai_t2m_19890101_20091231_oafluxgrid.nc` 
     15; :file:`${PROJECT_ID}/erai_t2m_{yyyymmdd}_{yyyymmdd}_oafluxgrid.nc` 
    1316; containing 
    1417; air temperature at 2 m height from ERA-I interpolated on OAFLUX grid 
     
    1821; Corrected air temperature at 2 m height 
    1922; is written in 
    20 ; :file:`${PROJECT_OD}/TropFlux_t2m_19890101_20091231.nc` 
     23; :file:`${PROJECT_OD}/TropFlux_t2m_{yyyymmdd}_{yyyymmdd}.nc` 
    2124; if this file not already exists. 
    2225; 
    2326; This output file 
    24 ; :file:`${PROJECT_OD}/TropFlux_t2m_19890101_20091231.nc` 
     27; :file:`${PROJECT_OD}/TropFlux_t2m_{yyyymmdd}_{yyyymmdd}.nc` 
    2528; will be used by 
    26 ; :ref:`TropFlux_19890101_20091231.pro`. 
     29; :func:`tropflux`. 
    2730; 
    2831; .. only:: man 
     
    3639;        digraph t2m_correction_ncdf { 
    3740; 
    38 ;           file_in [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_t2m_19890101_20091231_oafluxgrid.nc"]; 
    39 ;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_t2m_19890101_20091231.nc"]; 
     41;           file_in [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_t2m_{yyyymmdd}_{yyyymmdd}_oafluxgrid.nc"]; 
     42;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_t2m_{yyyymmdd}_{yyyymmdd}.nc"]; 
    4043; 
    4144;           t2m_correction_ncdf [shape=box, 
     
    5255; ======== 
    5356; 
     57; :ref:`mooring_corrections` 
     58; 
     59; Used by :ref:`tropflux.sh` 
     60; 
    5461; :ref:`project_profile.sh` 
    55 ; 
    56 ; :ref:`mooring_corrections` 
    5762; 
    5863; :func:`interp_erai_t2m` 
     
    7277; :: 
    7378; 
    74 ;  IDL> t2m_correction_ncdf 
     79;  IDL> yyyymmddb = 20000101L 
     80;  IDL> yyyymmdde = 20001231L 
     81;  IDL> result = t2m_correction_ncdf(yyyymmddb, yyyymmdde) 
     82;  IDL> print, result 
    7583; 
    7684; TODO 
     
    97105; check time values 
    98106; 
    99 ; hard coded time in module name and in output filename 
    100 ; 
    101107; hard coded correction values 
    102108; 
     
    121127; 
    122128; $URL$ 
     129; 
     130; - fplod 20120322 
     131; 
     132;   * taking project_overwite into account 
     133;   * try to add compile_opt seems to be incompatible with ncdf_quickwrite 
     134;   * pro -> function 
     135;   * hard coded da1 and da2 replaced by yyyymmddb and yyyymmdde parameters 
     136;   * replace t2m=ncdf_lec(... by a t2m=read_ncdf( 
    123137; 
    124138; - fplod 20110822T112525Z aedon.locean-ipsl.upmc.fr (Darwin) 
     
    156170; 
    157171;- 
    158 pro t2m_correction_ncdf 
     172function t2m_correction_ncdf $ 
     173         , yyyymmddb $ 
     174         , yyyymmdde 
     175; 
     176;++compile_opt idl2, strictarrsubs, logical_predicate 
    159177; 
    160178@cm_4cal 
     
    164182@cm_project 
    165183; 
     184; Return to caller if errors 
     185ON_ERROR, 2 
     186; 
     187result = -1 
     188; 
     189usage = 'result = sst_correction_ncdf(yyyymmddb, yyyymmdde)' 
     190nparam = N_PARAMS() 
     191IF (nparam NE 2) THEN BEGIN 
     192    ras = report(['Incorrect number of arguments.' $ 
     193          + '!C' $ 
     194          + 'Usage : ' + usage]) 
     195    return, result 
     196ENDIF 
     197 
    166198; test if ${PROJECT_OD} defined 
    167199CASE project_id_env OF 
     
    169201     msg = 'eee : ${PROJECT_OD} is not defined' 
    170202     ras = report(msg) 
    171      STOP 
     203     return, result 
    172204           END 
    173205 ELSE: BEGIN 
     
    184216   msg = 'eee : the directory' + iodirout  + ' is not accessible.' 
    185217   ras = report(msg) 
    186    STOP 
     218   return, result 
    187219ENDIF 
    188220; 
     
    191223    msg = 'eee : the directory' + iodirout  + ' was not found.' 
    192224    ras = report(msg) 
    193     STOP 
    194 ENDIF 
    195 ; 
    196 da1=19890101 
    197 da2=20091231 
     225    return, result 
     226ENDIF 
    198227; 
    199228; build uncorrected t2 filename 
    200229filename_t2_uncor = 'erai_t2m_' $ 
    201     + string(da1,format='(i8.8)') $ 
     230    + string(yyyymmddb,format='(i8.8)') $ 
    202231    + '_' $ 
    203     + string(da2,format='(i8.8)') $ 
     232    + string(yyyymmdde,format='(i8.8)') $ 
    204233    + '_oafluxgrid.nc' 
    205234; 
     
    211240   msg = 'eee : the file ' + fullfilename_t2_uncor + ' was not found.' 
    212241   ras = report(msg) 
    213    STOP 
     242   return, result 
    214243ENDIF 
    215244; 
    216245; build output filename 
    217246filename_out = 'TropFlux_t2m_' $ 
    218     + string(da1,format='(i8.8)') $ 
     247    + string(yyyymmddb,format='(i8.8)') $ 
    219248    + '_' $ 
    220     + string(da2,format='(i8.8)') $ 
     249    + string(yyyymmdde,format='(i8.8)') $ 
    221250    + '.nc' 
    222251; 
    223252fullfilename_out = iodirout + filename_out 
    224253; in order to avoid unexpected overwritten 
    225 IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN 
     254IF ((FILE_TEST(fullfilename_out) EQ 1)  AND (project_overwrite EQ 0)) THEN BEGIN 
    226255   msg = 'eee : the file ' + fullfilename_out  + ' already exists.' 
    227256   ras = report(msg) 
    228    STOP 
     257   return, result 
    229258ENDIF 
    230259; 
     
    239268; 
    240269; find first and last dates yyyymmdd 
    241 ; they will be written in global attributes of output file 
    242270da=jul2date(julday(01, 01, 1957,timein[0])) 
    243271cda0=string(da,format='(i8.8)') 
    244272da=jul2date(julday(01, 01, 1957,timein[jptin-1])) 
    245273cda1=string(da,format='(i8.8)') 
    246 print, 'first date ', cda0 
    247 print, 'last date ' , cda1 
     274print, 'for time checking first date ', cda0 
     275print, 'for time checking last date ' , cda1 
    248276; 
    249277; read t2 data 
    250 t2m=ncdf_lec(fullfilename_t2_uncor,var='t2m') 
     278initncdf, fullfilename_t2_uncor 
     279t2m=read_ncdf('t2m',yyyymmddb-.5d,yyyymmdde,file=fullfilename_t2_uncor,/nostr) 
     280timein=24.d*(time-julday(1,1,1957,0,0,0)) 
     281jpt=n_elements(timein) 
     282da=jul2date(time[0]) 
     283cda0=string(da,format='(i8.8)') 
     284da=jul2date(time[jpt-1]) 
     285cda1=string(da,format='(i8.8)') 
     286print, 't2m in t2m_correction_ncdf first date ', cda0 
     287print, 't2m in t2m_correction_ncdf last date ' , cda1 
    251288; 
    252289t2m=t2m-273.15 
     
    267304  ;++print,day 
    268305  jtt=(julday(01, 01, 1957,timein[jt])-julday(1,1,yea)) < 364 
    269   t=reform(t2m_mean(*,*)) 
    270   t2m_m(*,*,jt)=t 
    271   bias_cor(*,*,jt)=(((t-22.6)*0.4004896/(28-22.6)) > 0.) <0.4     ; (2000-2009) 
     306  t=reform(t2m_mean[*,*]) 
     307  t2m_m[*,*,jt]=t 
     308  bias_cor[*,*,jt]=(((t-22.6)*0.4004896/(28-22.6)) > 0.) <0.4     ; (2000-2009) 
    272309endfor 
    273310help, t2m_m,bias_cor 
     
    290327; 
    291328;writing field 
    292 lat=reform(gphit(0,0:jpj-1)) 
    293 lon=reform(glamt(0:jpi-1,0)) 
    294 cda0=string(da1) 
    295 cda1=string(da2) 
    296 ; 
    297 ; conversion for hours since 19570101 to days from 19500101 
    298 time=julday(01, 01, 1957,timein)-julday(1,1,1950) 
    299 jpt=n_elements(time) 
     329lat=reform(gphit[0,0:jpj-1]) 
     330lon=reform(glamt[0:jpi-1,0]) 
    300331; 
    301332ncfile='!' + fullfilename_out 
     
    313344t2m_attr={units:units,missing_value:1.e20,long_name:long_name,short_name:'t2m',axis:'TYX'} 
    314345; 
    315 ncfields = 't2m[longitude,latitude,time]=t2m_new:t2m_attr; ' $ 
     346ncfields = 't2m[longitude,latitude,*time]=t2m_new:t2m_attr; ' $ 
    316347                      + 'longitude[]=lon:lon_attr; ' $ 
    317348                      + 'latitude[]=lat:lat_attr; ' $ 
    318                       + 'time[*time]=time:time_attr ' $ 
     349                      + 'time[]=timein:time_attr ' $ 
    319350                      + ' @ globattr' 
    320351; 
    321352@ncdf_quickwrite 
    322353; 
     354result = 0 
     355return, result 
     356; 
    323357end 
  • trunk/src/tropflux.pro

    • Property svn:keywords changed from URL to Id URL
    r174 r175  
    11;+ 
    22; 
    3 ; .. _TropFlux_19890101_20091231.pro: 
    4 ; 
    5 ; ============================== 
    6 ; TropFlux_19890101_20091231.pro 
    7 ; ============================== 
     3; ============ 
     4; tropflux.pro 
     5; ============ 
     6; 
     7; .. function:: tropflux(yyyymmddb,yyyymmdde) 
     8; 
     9; DESCRITION 
     10; ========== 
    811; 
    912; This program computes net heat flux components on the 1° oaflux grid. 
     
    2023; :func:`oaflux_mask_30n30s`. 
    2124; 
    22 ; :file:`${PROJECT_OD}/TropFlux_sst_19890101_20091231.nc` 
     25; :file:`${PROJECT_OD}/TropFlux_sst_{yyyymmdd}_{yyyymmdd}.nc` 
    2326; containing 
    2427; sst corrected on OAFLUX grid 
    2528; has been produced by 
    26 ; :ref:`sst_correction_ncdf.pro`. 
    27 ; 
    28 ; :file:`${PROJECT_OD}/TropFlux_ws_19890101_20091231.nc` 
     29; :func:`sst_correction_ncdf`. 
     30; 
     31; :file:`${PROJECT_OD}/TropFlux_ws_{yyyymmdd}_{yyyymmdd}.nc` 
    2932; containing 
    3033; ws corrected on OAFLUX grid 
    3134; has been produced by 
    32 ; :ref:`ws_correction_ncdf.pro`. 
    33 ; 
    34 ; :file:`${PROJECT_OD}/TropFlux_gustiness_19890101_20091231.nc` 
     35; :func:`ws_correction_ncdf`. 
     36; 
     37; :file:`${PROJECT_OD}/TropFlux_gustiness_{yyyymmdd}_{yyyymmdd}.nc` 
    3538; containing 
    3639; ++ 
     
    3841; :func:`cronin_gustiness_ncdf`. 
    3942; 
    40 ; :file:`${PROJECT_OD}/TropFlux_swr_19890101_20091231_BLND.nc` 
     43; :file:`${PROJECT_OD}/TropFlux_swr_{yyyymmdd}_{yyyymmdd}_BLND.nc` 
    4144; containing 
    4245; ws corrected on OAFLUX grid 
     
    4447; :func:`tropflux_swr_blnd`. 
    4548; 
    46 ; :file:`${PROJECT_OD}/TropFlux_lwr_19890101_20091231.nc` 
     49; :file:`${PROJECT_OD}/TropFlux_lwr_{yyyymmdd}_{yyyymmdd}.nc` 
    4750; containing 
    4851; lwr corrected on OAFLUX grid 
    4952; has been produced by 
    50 ; :ref:`lwr_correction_ncdf.pro`. 
     53; :func:`lwr_correction_ncdf`. 
    5154; 
    5255; containing 
    5356; t2m corrected on OAFLUX grid 
    5457; has been produced by 
    55 ; :ref:`t2m_correction_ncdf.pro`. 
    56 ; 
    57 ; :file:`${PROJECT_OD}/TropFlux_q2m_19890101_20091231.nc` 
     58; :func:`t2m_correction_ncdf`. 
     59; 
     60; :file:`${PROJECT_OD}/TropFlux_q2m_{yyyymmdd}_{yyyymmdd}.nc` 
    5861; containing 
    5962; q2m corrected on OAFLUX grid 
     
    6265; 
    6366; net heat flux components are written 
    64 ; in :file:`${PROJECT_OD}/TropFlux_19890101_20091231_coarev3.nc` 
     67; in :file:`${PROJECT_OD}/TropFlux_{yyyymmdd}_{yyyymmdd}_coarev3.nc` 
    6568; if this file not already exists. 
    6669; 
    6770; This output file 
    68 ; :file:`${PROJECT_OD}/TropFlux_19890101_20091231_coarev3.nc` 
     71; :file:`${PROJECT_OD}/TropFlux_{yyyymmdd}_{yyyymmdd}_coarev3.nc` 
    6972; will be used by 
    7073; :ref:`TropFlux_NRT_ncdf.pro`. 
     
    7275;     .. graphviz:: 
    7376; 
    74 ;        digraph tropflux_19890101_20091231 { 
     77;        digraph tropflux { 
    7578; 
    7679;           mask [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/mask_oaflux_30N30S.nc"]; 
    77 ;           file_sst [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_sst_19890101_20091231.nc"]; 
    78 ;           file_ws [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_ws_19890101_20091231.nc"]; 
    79 ;           file_wg [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_gustiness_19890101_20091231.nc"]; 
    80 ;           file_swr [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_19890101_20091231_BLND.nc"]; 
    81 ;           file_lwr [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_lwr_19890101_20091231.nc"]; 
    82 ;           file_t2m [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_t2m_19890101_20091231.nc"]; 
    83 ;           file_q2m [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_q2m_19890101_20091231.nc"]; 
    84 ; 
    85 ;           file_out[shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_19890101_20091231_coarev3.nc"]; 
    86 ; 
    87 ;           tropflux_19890101_20091231 [shape=box, 
     80;           file_sst [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_sst_{yyyymmdd}_{yyyymmdd}.nc"]; 
     81;           file_ws [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_ws_{yyyymmdd}_{yyyymmdd}.nc"]; 
     82;           file_wg [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_gustiness_{yyyymmdd}_{yyyymmdd}.nc"]; 
     83;           file_swr [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_{yyyymmdd}_{yyyymmdd}_BLND.nc"]; 
     84;           file_lwr [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_lwr_{yyyymmdd}_{yyyymmdd}.nc"]; 
     85;           file_t2m [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_t2m_{yyyymmdd}_{yyyymmdd}.nc"]; 
     86;           file_q2m [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_q2m_{yyyymmdd}_{yyyymmdd}.nc"]; 
     87; 
     88;           file_out[shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_{yyyymmdd}_{yyyymmdd}_coarev3.nc"]; 
     89; 
     90;           tropflux [shape=box, 
    8891;           fontname=Courier, 
    8992;           color=blue, 
    90 ;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/TropFlux_19890101_20091231.pro", 
    91 ;           label="${PROJECT}/src/TropFlux_19890101_20091231.pro"]; 
    92 ; 
    93 ;           {mask file_sst file_ws file_wg file_swr file_lwr file_t2m file_q2m} -> {tropflux_19890101_20091231} -> {file_out} 
     93;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/tropflux.pro", 
     94;           label="${PROJECT}/src/tropflux.pro"]; 
     95; 
     96;           {mask file_sst file_ws file_wg file_swr file_lwr file_t2m file_q2m} -> {tropflux} -> {file_out} 
    9497; 
    9598;        } 
     
    99102; 
    100103; :ref:`project_profile.sh` 
     104; 
     105; Used by :ref:`tropflux.sh` 
    101106; 
    102107; :func:`report <saxo:report>` 
     
    124129; :: 
    125130; 
    126 ;  IDL> .compile TropFlux_19890101_20091231 
    127 ;  IDL> tropflux_19890101_20091231 
    128 ; 
     131;  IDL> yyyymmddb = 20000101L 
     132;  IDL> yyyymmdde = 20001231L 
     133;  IDL> result = tropflux(yyyymmddb, yyyymmdde) 
     134;  IDL> print, result 
     135 
    129136; TODO 
    130137; ==== 
    131138; 
    132139; describe usage of tau 
     140; 
     141; compare time between all inputs after reading 
    133142; 
    134143; make it work :: 
     
    180189;   wg=read_ncdf('wg',da1-1,da2,file=fullfilename_wg,/nostr) 
    181190; 
    182 ; avoid mix lower/uppercase in pro name to avoid compile 
    183 ; 
    184191; coding rules 
    185192; 
     
    196203; 
    197204; $URL$ 
     205; 
     206; - fplod 20120322 
     207; 
     208;   * pro -> func 
     209;   * rename with lower case TropFlux_19890101_20091231 become tropflux 
     210;   * taking project_overwite into account 
     211;   * try to add compile_opt 
     212;   * hard coded da1 and da2 replaced by yyyymmddb and yyyymmdde parameters 
     213;   * get rid of timegen 
    198214; 
    199215; - fplod 20110830T135832Z cratos (Linux) 
     
    241257;- 
    242258; 
    243 pro TropFlux_19890101_20091231 
     259function tropflux $ 
     260         , yyyymmddb $ 
     261         , yyyymmdde 
     262; 
     263compile_opt idl2, strictarrsubs, logical_predicate 
    244264; 
    245265@cm_4cal 
     
    249269@cm_project 
    250270; 
     271; Return to caller if errors 
     272ON_ERROR, 2 
     273; 
     274result = -1 
     275; 
     276usage = 'result = tropflux_swr_nrt(yyyymmddb, yyyymmdde)' 
     277nparam = N_PARAMS() 
     278IF (nparam NE 2) THEN BEGIN 
     279    ras = report(['Incorrect number of arguments.' $ 
     280          + '!C' $ 
     281          + 'Usage : ' + usage]) 
     282    return, result 
     283ENDIF 
     284; 
    251285; check for input directory 
    252286; 
     
    256290     msg = 'eee : ${PROJECT_ID} is not defined' 
    257291     ras = report(msg) 
    258      STOP 
     292     return, result 
    259293           END 
    260294 ELSE: BEGIN 
     
    270304   msg = 'eee : the directory' + iodirin  + ' is not accessible.' 
    271305   ras = report(msg) 
    272    STOP 
     306   return, result 
    273307ENDIF 
    274308; 
     
    283317   msg = 'eee : the file ' + fullfilename_msk + ' was not found.' 
    284318   ras = report(msg) 
    285    STOP 
     319   return, result 
    286320ENDIF 
    287321; 
     
    291325         msg = 'eee : ${PROJECT_OD} is not defined' 
    292326         ras = report(msg) 
    293        STOP 
     327       return, result 
    294328       END 
    295329  ELSE: BEGIN 
     
    306340   msg = 'eee : the directory' + iodirout  + ' is not accessible.' 
    307341   ras = report(msg) 
    308    STOP 
     342   return, result 
    309343ENDIF 
    310344; 
     
    313347    msg = 'eee : the directory' + iodirout  + ' was not found.' 
    314348    ras = report(msg) 
    315     STOP 
     349    return, result 
    316350ENDIF 
    317351; 
    318352; build sst data filename 
    319 filename_sst='TropFlux_sst_19890101_20091231.nc' 
     353filename_sst='TropFlux_sst_' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '.nc' 
    320354; 
    321355; check if this file exists 
     
    326360   msg = 'eee : the file ' + fullfilename_sst + ' was not found.' 
    327361   ras = report(msg) 
    328    STOP 
     362   return, result 
    329363ENDIF 
    330364; 
    331365; build ws data filename 
    332 filename_ws='TropFlux_ws_19890101_20091231.nc' 
     366filename_ws='TropFlux_ws_' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '.nc' 
    333367; 
    334368; check if this file exists 
     
    339373   msg = 'eee : the file ' + fullfilename_ws + ' was not found.' 
    340374   ras = report(msg) 
    341    STOP 
     375   return, result 
    342376ENDIF 
    343377; 
    344378; build swr data filename 
    345 filename_swr='TropFlux_swr_19890101_20091231_BLND.nc' 
     379filename_swr='TropFlux_swr_' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '_BLND.nc' 
    346380; 
    347381; check if this file exists 
     
    352386   msg = 'eee : the file ' + fullfilename_swr + ' was not found.' 
    353387   ras = report(msg) 
    354    STOP 
     388   return, result 
    355389ENDIF 
    356390; 
    357391; build lwr data filename 
    358 filename_lwr='TropFlux_lwr_19890101_20091231.nc' 
     392filename_lwr='TropFlux_lwr_' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '.nc' 
    359393; 
    360394; check if this file exists 
     
    365399   msg = 'eee : the file ' + fullfilename_lwr + ' was not found.' 
    366400   ras = report(msg) 
    367    STOP 
     401   return, result 
    368402ENDIF 
    369403; 
    370404; build t2m data filename 
    371 filename_t2m='TropFlux_t2m_19890101_20091231.nc' 
     405filename_t2m='TropFlux_t2m_' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '.nc' 
    372406; 
    373407; check if this file exists 
     
    378412   msg = 'eee : the file ' + fullfilename_t2m + ' was not found.' 
    379413   ras = report(msg) 
    380    STOP 
     414   return, result 
    381415ENDIF 
    382416; 
    383417; build q2m data filename 
    384 filename_q2m='TropFlux_q2m_19890101_20091231.nc' 
     418filename_q2m='TropFlux_q2m_' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '.nc' 
    385419; 
    386420; check if this file exists 
     
    391425   msg = 'eee : the file ' + fullfilename_q2m + ' was not found.' 
    392426   ras = report(msg) 
    393    STOP 
     427   return, result 
    394428ENDIF 
    395429; 
    396430; build wg data filename 
    397 filename_wg='TropFlux_gustiness_19890101_20091231.nc' 
     431filename_wg='TropFlux_gustiness_' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '.nc' 
    398432; 
    399433; check if this file exists 
     
    404438   msg = 'eee : the file ' + fullfilename_wg + ' was not found.' 
    405439   ras = report(msg) 
    406    STOP 
     440   return, result 
    407441ENDIF 
    408442; 
    409443; build output filename 
    410 filename_out = 'TropFlux_19890101_20091231_coarev3.nc' 
     444filename_out = 'TropFlux_' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '_coarev3.nc' 
    411445fullfilename_out = iodirout + filename_out 
    412446; in order to avoid unexpected overwritten 
     
    414448   msg = 'eee : the file ' + fullfilename_out  + ' already exists.' 
    415449   ras = report(msg) 
    416    STOP 
    417 ENDIF 
    418 ; 
    419 da1=19880101 
    420 da2=20101231 
     450   return, result 
     451ENDIF 
    421452; 
    422453initncdf, fullfilename_msk 
     
    425456initncdf, fullfilename_sst 
    426457; 
    427 ws=read_ncdf('ws',da1,da2,file=fullfilename_ws,/nostr) 
    428 wg=read_ncdf('wg',da1-1,da2,file=fullfilename_wg,/nostr) 
     458ws=read_ncdf('ws',yyyymmddb-.5d,yyyymmdde,file=fullfilename_ws,/nostr) 
     459timein=24.d*(time-julday(1,1,1957,0,0,0)) 
     460jpt=n_elements(timein) 
     461da=jul2date(time[0]) 
     462cda0=string(da,format='(i8.8)') 
     463da=jul2date(time[jpt-1]) 
     464cda1=string(da,format='(i8.8)') 
     465print, 'ws in tropflux first date ', cda0 
     466print, 'ws in ws_correction_ncdf last date ' , cda1 
     467; 
     468wg=read_ncdf('wg',yyyymmddb-.5d-1,yyyymmdde,file=fullfilename_wg,/nostr) 
     469timein=24.d*(time-julday(1,1,1957,0,0,0)) 
     470jpt=n_elements(timein) 
     471da=jul2date(time[0]) 
     472cda0=string(da,format='(i8.8)') 
     473da=jul2date(time[jpt-1]) 
     474cda1=string(da,format='(i8.8)') 
     475print, 'wg in tropflux first date ', cda0 
     476print, 'wg in ws_correction_ncdf last date ' , cda1 
    429477tt=time 
    430478jpt=n_elements(time) 
    431 sst=read_ncdf('sst',da1,da2,file=fullfilename_sst,/nostr) 
     479sst=read_ncdf('sst',yyyymmddb-.5d,yyyymmdde,file=fullfilename_sst,/nostr) 
     480timein=24.d*(time-julday(1,1,1957,0,0,0)) 
     481jpt=n_elements(timein) 
     482da=jul2date(time[0]) 
     483cda0=string(da,format='(i8.8)') 
     484da=jul2date(time[jpt-1]) 
     485cda1=string(da,format='(i8.8)') 
     486print, 'sst in tropflux first date ', cda0 
     487print, 'sst in ws_correction_ncdf last date ' , cda1 
    432488sst=reform(sst-273.15) 
    433 swd=read_ncdf('swr',da1,da2,file=fullfilename_swr,/nostr) 
    434 lw=read_ncdf('lwr',da1,da2,file=fullfilename_lwr,/nostr) 
     489swd=read_ncdf('swr',yyyymmddb-.5d,yyyymmdde,file=fullfilename_swr,/nostr) 
     490timein=24.d*(time-julday(1,1,1957,0,0,0)) 
     491jpt=n_elements(timein) 
     492da=jul2date(time[0]) 
     493cda0=string(da,format='(i8.8)') 
     494da=jul2date(time[jpt-1]) 
     495cda1=string(da,format='(i8.8)') 
     496print, 'swr in tropflux first date ', cda0 
     497print, 'swr in ws_correction_ncdf last date ' , cda1 
     498lw=read_ncdf('lwr',yyyymmddb-.5d,yyyymmdde,file=fullfilename_lwr,/nostr) 
     499timein=24.d*(time-julday(1,1,1957,0,0,0)) 
     500jpt=n_elements(timein) 
     501da=jul2date(time[0]) 
     502cda0=string(da,format='(i8.8)') 
     503da=jul2date(time[jpt-1]) 
     504cda1=string(da,format='(i8.8)') 
     505print, 'lwr in tropflux first date ', cda0 
     506print, 'lwr in ws_correction_ncdf last date ' , cda1 
    435507swd=swd/0.94  ; converting from net swr to downward swr 
    436508; 
    437 t2m=read_ncdf('t2m',da1,da2,file=fullfilename_t2m,/nostr)-273.15   ; in C 
    438 q2m=read_ncdf('q2m',da1,da2,file=fullfilename_q2m,/nostr)    ; in g/kg 
     509t2m=read_ncdf('t2m',yyyymmddb-.5d,yyyymmdde,file=fullfilename_t2m,/nostr)-273.15   ; in C 
     510timein=24.d*(time-julday(1,1,1957,0,0,0)) 
     511jpt=n_elements(timein) 
     512da=jul2date(time[0]) 
     513cda0=string(da,format='(i8.8)') 
     514da=jul2date(time[jpt-1]) 
     515cda1=string(da,format='(i8.8)') 
     516print, 't2m in tropflux first date ', cda0 
     517print, 't2m in ws_correction_ncdf last date ' , cda1 
     518q2m=read_ncdf('q2m',yyyymmddb-.5d,yyyymmdde,file=fullfilename_q2m,/nostr)    ; in g/kg 
     519timein=24.d*(time-julday(1,1,1957,0,0,0)) 
     520jpt=n_elements(timein) 
     521da=jul2date(time[0]) 
     522cda0=string(da,format='(i8.8)') 
     523da=jul2date(time[jpt-1]) 
     524cda1=string(da,format='(i8.8)') 
     525print, 'q2m in tropflux first date ', cda0 
     526print, 'q2m in ws_correction_ncdf last date ' , cda1 
    439527; 
    440528w=sqrt(ws*ws+wg*wg)  ; wind corrected for gustiness 
     
    471559; 
    472560for jt=0,jpt-1 do begin 
    473   jday=time(jt)-julday(1,1,yea(jt)) 
     561  jday=time[jt]-julday(1,1,yea[jt]) 
    474562  print, 'Computing Fluxes ',jt,' / ',jpt-1 
    475563; 
     
    478566; 
    479567  ; wind speed (m/s) 
    480   wn=w(*,*,jt) 
    481   wn=wn(ocean) 
     568  wn=w[*,*,jt] 
     569  wn=wn[ocean] 
    482570  ; Bulk sst (°C) 
    483   ts=sst(*,*,jt) 
    484   ts=ts(ocean) 
     571  ts=sst[*,*,jt] 
     572  ts=ts[ocean] 
    485573  ; 2m Air T (°C) 
    486   t=t2m(*,*,jt) 
    487   t=t(ocean) 
     574  t=t2m[*,*,jt] 
     575  t=t[ocean] 
    488576  ; Sea surface sat. spec. humidity (g/kg) 
    489577  qs=qsee(ts,P) 
    490578  ; 2m AIr specific humidity  (g/kg) 
    491   q=q2m(*,*,jt) 
    492   q=q(ocean) 
     579  q=q2m[*,*,jt] 
     580  q=q[ocean] 
    493581  ; Downward solar flux (W/m2) 
    494   Rs=swd(*,*,jt) 
    495   Rs=Rs(ocean) 
    496   ylat=gphit(ocean) 
     582  Rs=swd[*,*,jt] 
     583  Rs=Rs[ocean] 
     584  ylat=gphit[ocean] 
    497585  ;  cld=calc_cloud(jday,Rs,ylat) 
    498586  cld=calc_cloud_vlat(jday,Rs,ylat) 
    499587  ; Downward IR flux (W/m2) 
    500588  ;  Rl=lwdown_clark(ts,q,cld,t,P) 
    501   Rl=lw(*,*,jt) 
    502   Rl=Rl(ocean) 
     589  Rl=lw[*,*,jt] 
     590  Rl=Rl[ocean] 
    503591  rain=0. 
    504592  lw_clrk=-lwnet_clark(ts,q,cld,t,P) 
    505 ;  junk(*,*,jt)=lw_clrk 
     593;  junk[*,*,jt]=lw_clrk 
    506594; 
    507595;stop 
     
    509597; A few punctual missing values (coare does not converge): filled by spatial extrapolation 
    510598  tab=fltarr(jpi,jpj)+!values.f_nan 
    511   x=reform(y(*,0)) 
    512   tab(ocean)=x 
     599  x=reform(y[*,0]) 
     600  tab[ocean]=x 
    513601  m=finite(tab) 
    514602  help, tab, m, swr 
    515603  tab=extrapolate(tab,m) 
    516   swr(*,*,jt)=tab*msk+valmask*(1-msk) 
     604  swr[*,*,jt]=tab*msk+valmask*(1-msk) 
    517605; 
    518606  tab=fltarr(jpi,jpj)+!values.f_nan 
    519   x=reform(y(*,1)) 
    520   tab(ocean)=x 
     607  x=reform(y[*,1]) 
     608  tab[ocean]=x 
    521609  m=finite(tab) 
    522610  help, tab, m, lwr 
     
    524612  print, 'www : extrapolation for lwr is not done' 
    525613  tab=tab 
    526   lwr(*,*,jt)=tab*msk+valmask*(1-msk) 
     614  lwr[*,*,jt]=tab*msk+valmask*(1-msk) 
    527615; 
    528616  tab=fltarr(jpi,jpj)+!values.f_nan 
    529   x=reform(y(*,2)) 
    530   tab(ocean)=x 
     617  x=reform(y[*,2]) 
     618  tab[ocean]=x 
    531619  m=finite(tab) 
    532620  help, tab, m, lat 
     
    534622  print, 'www : extrapolation for lat is not done' 
    535623  tab=tab 
    536   lat(*,*,jt)=tab*msk+valmask*(1-msk) 
     624  lat[*,*,jt]=tab*msk+valmask*(1-msk) 
    537625  tab=fltarr(jpi,jpj)+!values.f_nan 
    538   x=reform(y(*,3)) 
    539   tab(ocean)=x 
     626  x=reform(y[*,3]) 
     627  tab[ocean]=x 
    540628  m=finite(tab) 
    541629  help, tab, m, sen 
     
    543631  print, 'www : extrapolation for sen is not done' 
    544632  tab=tab 
    545   sen(*,*,jt)=tab*msk+valmask*(1-msk) 
    546   ;  tab=fltarr(jpi,jpj)+!values.f_nan & x=reform(lw_clrk) & tab(ocean)=x & m=finite(tab) & tab=extrapolate(tab,m) & lwnet_clrk(*,*,jt)=tab*msk+valmask*(1-msk) 
    547   tab=fltarr(jpi,jpj)+!values.f_nan & x=reform(y(*,5)) & tab(ocean)=x & m=finite(tab) & tab=extrapolate(tab,m) & tau(*,*,jt)=tab*msk+valmask*(1-msk) 
    548   ;  tab=fltarr(jpi,jpj)+!values.f_nan & x=reform(y(*,6)) & tab(ocean)=x & m=finite(tab) & tab=extrapolate(tab,m) & Ch(*,*,jt)=tab*msk+valmask*(1-msk) 
    549   ;  tab=fltarr(jpi,jpj)+!values.f_nan & x=reform(y(*,7)) & tab(ocean)=x & m=finite(tab) & tab=extrapolate(tab,m) & Ce(*,*,jt)=tab*msk+valmask*(1-msk) 
    550   tab=fltarr(jpi,jpj)+!values.f_nan & x=reform(y(*,8)) & tab(ocean)=x & m=finite(tab) & tab=extrapolate(tab,m) & wg(*,*,jt)=tab*msk+valmask*(1-msk) 
     633  sen[*,*,jt]=tab*msk+valmask*(1-msk) 
     634  ;  tab=fltarr(jpi,jpj)+!values.f_nan & x=reform(lw_clrk) & tab[ocean]=x & m=finite(tab) & tab=extrapolate(tab,m) & lwnet_clrk[*,*,jt]=tab*msk+valmask*(1-msk) 
     635  tab=fltarr(jpi,jpj)+!values.f_nan & x=reform(y[*,5]) & tab[ocean]=x & m=finite(tab) & tab=extrapolate(tab,m) & tau[*,*,jt]=tab*msk+valmask*(1-msk) 
     636  ;  tab=fltarr(jpi,jpj)+!values.f_nan & x=reform(y[*,6]) & tab[ocean]=x & m=finite(tab) & tab=extrapolate(tab,m) & Ch[*,*,jt]=tab*msk+valmask*(1-msk) 
     637  ;  tab=fltarr(jpi,jpj)+!values.f_nan & x=reform(y[*,7]) & tab[ocean]=x & m=finite(tab) & tab=extrapolate(tab,m) & Ce[*,*,jt]=tab*msk+valmask*(1-msk) 
     638  tab=fltarr(jpi,jpj)+!values.f_nan & x=reform(y[*,8]) & tab[ocean]=x & m=finite(tab) & tab=extrapolate(tab,m) & wg[*,*,jt]=tab*msk+valmask*(1-msk) 
    551639endfor 
    552 time=timegen(7670, start=julday(1,1,1989,0), units='days') 
    553640jpt=n_elements(time) 
    554641; 
    555 cda0=string(jul2date(time(0)),format='(i8.8)') 
    556 cda1=string(jul2date(time(jpt-1)),format='(i8.8)') 
     642cda0=string(jul2date(time[0]),format='(i8.8)') 
     643cda1=string(jul2date(time[jpt-1]),format='(i8.8)') 
    557644time=time-julday(1,1,1950,00,00,00) 
    558 xlon=reform(glamt(*,0) ) 
    559 ylat=reform(gphit(0,*)) 
     645xlon=reform(glamt[*,0]) 
     646ylat=reform(gphit[0,*]) 
    560647; 
    561648ncfile='!' + fullfilename_out 
     
    590677@ncdf_quickwrite 
    591678; 
     679result = 0 
     680return, result 
     681; 
    592682end 
  • trunk/src/tropflux.sh

    r174 r175  
    8989# 
    9090# Use : 
    91 # :func:`oaflux_mask_30n30s`, :func:`interp_erai_t2m`,  
     91# :func:`oaflux_mask_30n30s`, :func:`interp_erai_t2m`, 
    9292# :func:`interp_erai_msl`, :func:`interp_erai_dewt`, :func:`interp_erai_lwr`, 
    93 # :func:`interp_erai_sst`, :func:`interp_erai_ws`, :func:`interp_olr_30n30s`,  
    94 # :func:`d2m_to_q2m_erai`, 
     93# :func:`interp_erai_sst`, :func:`interp_erai_ws`, :func:`interp_olr_30n30s`, 
     94# :func:`d2m_to_q2m_erai`, :func:`sst_correction_ncdf`, 
     95# :func:`lwr_correction_ncdf`, :func:`q2m_correction_ncdf`, 
     96# :func:`t2m_correction_ncdf`, :func:`ws_correction_ncdf`, 
     97# :func:`tropflux_swr_dt`, :func:`tropflux_swr_nrt`, :func:`tropflux_swr_blnd`, 
    9598# etc. 
    9699# 
     
    114117# 
    115118# $URL$ 
     119# 
     120# - pinsard 20120322 
     121# 
     122#   * handling error of sst_correction_ncdf (now function) 
     123#   * handling error of lwr_correction_ncdf (now function) 
     124#   * handling error of q2m_correction_ncdf (now function) 
     125#   * handling error of t2m_correction_ncdf (now function) 
     126#   * handling error of ws_correction_ncdf (now function) 
    116127# 
    117128# - pinsard 20120321 
     
    382393   exit 
    383394ENDIF 
    384 ;sst_correction_ncdf 
     395result = sst_correction_ncdf(${yyyymmddb}, ${yyyymmdde}) 
     396IF result < 0 THEN BEGIN 
     397   msg = 'eee : pb after sst_correction_ncdf ' + string(result) 
     398   err = report(msg) 
     399   exit 
     400ENDIF 
    385401result = cronin_gustiness_ncdf(${yyyymmddb}, ${yyyymmdde}) 
    386402IF result < 0 THEN BEGIN 
    387403   msg = 'eee : pb after cronin_gustiness_ncdf ' + string(result) 
    388   err = report(msg) 
    389 exit 
     404   err = report(msg) 
     405   exit 
     406ENDIF 
    390407result = tropflux_swr_blnd(${yyyymmddb}, ${yyyymmdde}) 
    391408IF result < 0 THEN BEGIN 
    392409   msg = 'eee : pb after tropflux_swr_blnd ' + string(result) 
    393   err = report(msg) 
    394 exit 
    395 ;lwr_correction_ncdf 
    396 ;q2m_correction_ncdf 
    397 ;t2m_correction_ncdf 
    398 ;ws_correction_ncdf 
     410   err = report(msg) 
     411   exit 
     412ENDIF 
     413result = lwr_correction_ncdf(${yyyymmddb}, ${yyyymmdde}) 
     414IF result < 0 THEN BEGIN 
     415   msg = 'eee : pb after lwr_correction_ncdf ' + string(result) 
     416   err = report(msg) 
     417   exit 
     418ENDIF 
     419result = q2m_correction_ncdf(${yyyymmddb}, ${yyyymmdde}) 
     420IF result < 0 THEN BEGIN 
     421   msg = 'eee : pb after q2m_correction_ncdf ' + string(result) 
     422   err = report(msg) 
     423   exit 
     424ENDIF 
     425result = t2m_correction_ncdf(${yyyymmddb}, ${yyyymmdde}) 
     426IF result < 0 THEN BEGIN 
     427   msg = 'eee : pb after t2m_correction_ncdf ' + string(result) 
     428   err = report(msg) 
     429   exit 
     430ENDIF 
     431result = ws_correction_ncdf(${yyyymmddb}, ${yyyymmdde}) 
     432IF result < 0 THEN BEGIN 
     433   msg = 'eee : pb after ws_correction_ncdf ' + string(result) 
     434   err = report(msg) 
     435   exit 
     436ENDIF 
    399437;.compile TropFlux_19890101_20091231 
    400 ;tropflux_19890101_20091231 
     438result = tropflux(${yyyymmddb}, ${yyyymmdde}) 
     439IF result < 0 THEN BEGIN 
     440   msg = 'eee : pb after tropflux' + string(result) 
     441   err = report(msg) 
     442   exit 
     443ENDIF 
    401444;.compile TropFlux_NRT_ncdf 
    402445;tropflux_nrt_ncdf 
  • trunk/src/tropflux_swr_blnd.pro

    r174 r175  
    5353; ======== 
    5454; 
     55; :ref:`mooring_corrections` 
     56; 
     57; Used by :ref:`tropflux.sh` 
     58; 
    5559; :ref:`project_profile.sh` 
    56 ; 
    57 ; :ref:`mooring_corrections` 
    5860; 
    5961; :ref:`data_in_swr` 
  • trunk/src/tropflux_swr_nrt.pro

    r174 r175  
    4747; ======== 
    4848; 
    49 ; :ref:`project_profile.sh` 
    50 ; 
    5149; :ref:`mooring_corrections` 
    5250; 
    5351; :ref:`data_in_swr` 
    5452; :ref:`data_in_olr` 
     53; 
     54; Used by :ref:`tropflux.sh` 
     55; 
     56; :ref:`project_profile.sh` 
    5557; 
    5658; :func:`initncdf <saxo:initncdf>` 
  • 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.