Changeset 179


Ignore:
Timestamp:
03/26/12 11:35:23 (12 years ago)
Author:
pinsard
Message:

tropflux_nrt_ncdf is now a function

Location:
trunk
Files:
4 edited
1 moved

Legend:

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

    r175 r179  
    148148tools : 
    149149 - :func:`cronin_gustiness_ncdf` 
    150  - :func:`tropflux` (:func:`cor30a`), :ref:`TropFlux_NRT_ncdf.pro`  
     150 - :func:`tropflux` (:func:`cor30a`), :func:`tropflux_nrt_ncdf`  
    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.pro

    r175 r179  
    7171; :file:`${PROJECT_OD}/TropFlux_{yyyymmdd}_{yyyymmdd}_coarev3.nc` 
    7272; will be used by 
    73 ; :ref:`TropFlux_NRT_ncdf.pro`. 
     73; :func:`tropflux_nrt_ncdf`. 
    7474; 
    7575;     .. graphviz:: 
  • trunk/src/tropflux.sh

    r175 r179  
    9696# :func:`t2m_correction_ncdf`, :func:`ws_correction_ncdf`, 
    9797# :func:`tropflux_swr_dt`, :func:`tropflux_swr_nrt`, :func:`tropflux_swr_blnd`, 
     98# :func:`tropflux_nrt_cdf`, 
    9899# etc. 
    99100# 
     
    117118# 
    118119# $URL$ 
     120# 
     121# - pinsard 20120326 
     122# 
     123#   * TropFlux_NRT_ncdf replace by tropflux_nrt_ncdf which is now a function 
    119124# 
    120125# - pinsard 20120322 
     
    435440   exit 
    436441ENDIF 
    437 ;.compile TropFlux_19890101_20091231 
    438442result = tropflux(${yyyymmddb}, ${yyyymmdde}) 
    439443IF result < 0 THEN BEGIN 
     
    442446   exit 
    443447ENDIF 
    444 ;.compile TropFlux_NRT_ncdf 
    445 ;tropflux_nrt_ncdf 
     448result = tropflux_nrt_ncf(${yyyymmddb}, ${yyyymmdde}) 
     449IF result < 0 THEN BEGIN 
     450   msg = 'eee : pb after tropflux_nrt_ncdf' + string(result) 
     451   err = report(msg) 
     452   exit 
     453ENDIF 
    446454end 
    447455EOF 
  • trunk/src/tropflux_nrt_ncdf.pro

    r176 r179  
    11;+ 
    22; 
    3 ; .. _TropFlux_NRT_ncdf.pro: 
    4 ; 
    53; ===================== 
    6 ; TropFlux_NRT_ncdf.pro 
     4; tropflux_nrt_ncdf.pro 
    75; ===================== 
    86; 
    9 ; :file:`${PROJECT_OD}/TropFlux_swr_19890101_20091231_BLND.nc` 
     7; .. function:: tropflux_nrt_ncdf(yyyymmddb, yyyymmdde) 
     8; 
     9; :file:`${PROJECT_OD}/TropFlux_swr_{yyyymmdd}_{yyyymmdd}_BLND.nc` 
    1010; containing 
    1111; ws corrected on OAFLUX grid 
     
    1313; :func:`tropflux_swr_blnd`. 
    1414; 
    15 ; :file:`${PROJECT_OD}/TropFlux_lwr_19890101_20091231.nc` 
     15; :file:`${PROJECT_OD}/TropFlux_lwr_{yyyymmdd}_{yyyymmdd}.nc` 
    1616; containing 
    1717; lwr corrected on OAFLUX grid 
     
    1919; :func:`lwr_correction_ncdf`. 
    2020; 
    21 ; :file:`${PROJECT_OD}/TropFlux_19890101_20091231_coare3.nc` 
     21; :file:`${PROJECT_OD}/TropFlux_{yyyymmdd}_{yyyymmdd}_coare3.nc` 
    2222; containing 
    2323; ++ 
     
    2626; 
    2727; ++ are written 
    28 ; in :file:`${PROJECT_OD}/TropFlux_19890101_20091231.nc` 
     28; in :file:`${PROJECT_OD}/TropFlux_{yyyymmdd}_{yyyymmdd}.nc` 
    2929; if this file not already exists. 
    3030; 
     
    3333;        digraph tropflux_nrt_ncdf { 
    3434; 
    35 ;           file_swr [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_19890101_20091231_BLND.nc"]; 
    36 ;           file_lwr [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_lwr_19890101_200912310.nc"]; 
    37 ;           file_coare [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_19890101_20091231_coarev3.nc"]; 
    38 ;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_19890101_20091231.nc"]; 
     35;           file_swr [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_{yyyymmdd}_{yyyymmdd}_BLND.nc"]; 
     36;           file_lwr [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_lwr_{yyyymmdd}_{yyyymmdd}.nc"]; 
     37;           file_coare [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_{yyyymmdd}_{yyyymmdd}_coarev3.nc"]; 
     38;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_{yyyymmdd}_{yyyymmdd}.nc"]; 
    3939; 
    4040;           tropflux_nrt_ncdf [shape=box, 
    4141;           fontname=Courier, 
    4242;           color=blue, 
    43 ;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/TropFlux_NRT_ncdf.pro", 
    44 ;           label="${PROJECT}/src/TropFlux_NRT_ncdf.pro" ]; 
     43;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/tropflux_nrt_ncdf.pro", 
     44;           label="${PROJECT}/src/tropflux_nrt_ncdf.pro" ]; 
    4545; 
    4646;           {file_swr file_lwr file_coare} -> {tropflux_nrt_ncdf} -> {file_out} 
     
    5050; SEE ALSO 
    5151; ======== 
     52; 
     53; Used by :ref:`tropflux.sh` 
     54; 
     55; :ref:`project_profile.sh` 
    5256; 
    5357; :func:`initncdf <saxo:initncdf>` 
     
    6266; :: 
    6367; 
    64 ;  IDL> .compile TropFlux_NRT_ncdf 
    65 ;  IDL> tropflux_nrt_ncdf 
     68;  yyyymmddb = 20000101L 
     69;  yyyymmdde = 20001231L 
     70;  result = tropflux_nrt_ncdf(yyyymmddb, yyyymmdde) 
     71;  print, result 
    6672; 
    6773; TODO 
    6874; ==== 
    6975; 
     76; handlind yyyymmdde > 20071231 see attributes also 
     77; 
    7078; coding rules 
    71 ; 
    72 ; get rid of uppercase to avoid compile 
    7379; 
    7480; create 4 files instead of one now 
     
    7783; ========== 
    7884; 
    79 ; $Id: TropFlux_NRT_ncdf.pro 88 2011-08-19 15:40:14Z pinsard $ 
     85; $Id: tropflux_nrt_ncdf.pro 88 2011-08-19 15:40:14Z pinsard $ 
    8086; 
    8187; $URL$ 
     88; 
     89; - fplod 20120326 
     90; 
     91;   * pro -> func 
     92;   * rename with lower case TropFlux_NRT_ncdf.pro become tropflux_nrt_ncdf.pro 
     93;   * taking project_overwite into account 
     94;   * try to add compile_opt seems to be incompatible with ncdf_quickwrite 
     95;   * hard coded st and en replaced by yyyymmddb and yyyymmdde parameters 
     96;   * get rid of timegen 
    8297; 
    8398; - fplod 20110809T133815Z cratos (Linux) 
     
    100115; 
    101116;- 
    102 pro TropFlux_NRT_ncdf 
     117function tropflux_nrt_ncdf $ 
     118         , yyyymmddb $ 
     119         , yyyymmdde 
     120; 
     121compile_opt idl2, strictarrsubs, logical_predicate 
    103122; 
    104123@cm_4cal 
     
    108127@cm_project 
    109128; 
     129; Return to caller if errors 
     130ON_ERROR, 2 
     131; 
     132result = -1 
     133; 
     134usage = 'result = tropflux_swr_dt(yyyymmddb, yyyymmdde)' 
     135nparam = N_PARAMS() 
     136IF (nparam NE 2) THEN BEGIN 
     137    ras = report(['Incorrect number of arguments.' $ 
     138              + '!C' $ 
     139              + 'Usage : ' + usage]) 
     140    return, result 
     141ENDIF 
     142; 
    110143; test if ${PROJECT_OD} defined 
    111144CASE project_od_env OF 
     
    113146         msg = 'eee : ${PROJECT_OD} is not defined' 
    114147         ras = report(msg) 
    115        STOP 
     148       return, result 
    116149       END 
    117150  ELSE: BEGIN 
     
    128161   msg = 'eee : the directory' + iodirout  + ' is not accessible.' 
    129162   ras = report(msg) 
    130    STOP 
     163   return, result 
    131164ENDIF 
    132165; 
     
    135168    msg = 'eee : the directory' + iodirout  + ' was not found.' 
    136169    ras = report(msg) 
    137     STOP 
     170    return, result 
    138171ENDIF 
    139172; 
    140173; build SWR blnd data filename 
    141 filename_swr_blnd="TropFlux_swr_19890101_20091231_BLND.nc" 
     174filename_swr_blnd="TropFlux_swr_' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '_BLND.nc" 
    142175; 
    143176; check if this file exists 
     
    148181   msg = 'eee : the file ' + fullfilename_swr_blnd + ' was not found.' 
    149182   ras = report(msg) 
    150    STOP 
     183   return, result 
    151184ENDIF 
    152185; 
    153186; build LWR data filename 
    154 filename_lwr="TropFlux_lwr_19890101_20091231.nc" 
     187filename_lwr="TropFlux_lwr_' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '.nc" 
    155188; 
    156189; check if this file exists 
     
    161194   msg = 'eee : the file ' + fullfilename_lwr + ' was not found.' 
    162195   ras = report(msg) 
    163    STOP 
     196   return, result 
    164197ENDIF 
    165198; 
    166199;  build COARE data filename 
    167 filename_coare="TropFlux_19890101_20091231_coarev3.nc" 
     200filename_coare="TropFlux_' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '_coarev3.nc" 
    168201; 
    169202; check if this file exists 
     
    174207   msg = 'eee : the file ' + fullfilename_coare + ' was not found.' 
    175208   ras = report(msg) 
    176    STOP 
    177 ENDIF 
    178 ; 
    179 filename_out='TropFlux_19890101_20091231.nc' 
     209   return, result 
     210ENDIF 
     211; 
     212filename_out='TropFlux_' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '.nc' 
    180213fullfilename_out = iodirout + filename_out 
    181214; in order to avoid unexpected overwritten 
    182 IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN 
     215IF ((FILE_TEST(fullfilename_out) EQ 1)  AND (project_overwrite EQ 0)) THEN BEGIN 
    183216   msg = 'eee : the file ' + fullfilename_out  + ' already exists.' 
    184217   ras = report(msg) 
    185    STOP 
    186 ENDIF 
    187 ; 
    188 st=19800101 
    189 en=20101231 
     218   return, result 
     219ENDIF 
    190220; 
    191221initncdf, fullfilename_swr_blnd 
    192222; 
    193 swr=read_ncdf("swr", st, en, file=fullfilename_swr_blnd,/nostr) 
     223swr=read_ncdf("swr", yyyymmddb - .5d, yyyymmdde, file=fullfilename_swr_blnd,/nostr) 
     224timein=24.d*(time-julday(1,1,1957,0,0,0)) 
     225jpt=n_elements(timein) 
     226da=jul2date(time[0]) 
     227cda0=string(da,format='(i8.8)') 
     228da=jul2date(time[jpt-1]) 
     229cda1=string(da,format='(i8.8)') 
     230print, 'swr in tropflux_nrt_ncdf first date ', cda0 
     231print, 'swr in tropflux_nrt_ncdf last date ' , cda1 
    194232; 
    195233initncdf, fullfilename_lwr 
    196 lwr=read_ncdf("lwr", st, en, file=fullfilename_lwr,/nostr) 
     234lwr=read_ncdf("lwr", yyyymmddb - .5d, yyyymmdde, file=fullfilename_lwr,/nostr) 
     235timein=24.d*(time-julday(1,1,1957,0,0,0)) 
     236jpt=n_elements(timein) 
     237da=jul2date(time[0]) 
     238cda0=string(da,format='(i8.8)') 
     239da=jul2date(time[jpt-1]) 
     240cda1=string(da,format='(i8.8)') 
     241print, 'lwr in tropflux_nrt_ncdf first date ', cda0 
     242print, 'lwr in tropflux_nrt_ncdf last date ' , cda1 
    197243; 
    198244initncdf, fullfilename_coare 
    199 lhf=read_ncdf("lhf", st, en, file=fullfilename_coare,/nostr) 
    200 shf=read_ncdf("shf", st, en, file=fullfilename_coare,/nostr) 
     245lhf=read_ncdf("lhf", yyyymmddb - .5d, yyyymmdde, file=fullfilename_coare,/nostr) 
     246timein=24.d*(time-julday(1,1,1957,0,0,0)) 
     247jpt=n_elements(timein) 
     248da=jul2date(time[0]) 
     249cda0=string(da,format='(i8.8)') 
     250da=jul2date(time[jpt-1]) 
     251cda1=string(da,format='(i8.8)') 
     252print, 'lhf in tropflux_nrt_ncdf first date ', cda0 
     253print, 'lhf in tropflux_nrt_ncdf last date ' , cda1 
     254; 
     255shf=read_ncdf("shf", yyyymmddb - .5d, yyyymmdde, file=fullfilename_coare,/nostr) 
     256timein=24.d*(time-julday(1,1,1957,0,0,0)) 
     257jpt=n_elements(timein) 
     258da=jul2date(time[0]) 
     259cda0=string(da,format='(i8.8)') 
     260da=jul2date(time[jpt-1]) 
     261cda1=string(da,format='(i8.8)') 
     262print, 'shf in tropflux_nrt_ncdf first date ', cda0 
     263print, 'shf in tropflux_nrt_ncdf last date ' , cda1 
    201264; 
    202265help, swr, lwr, lhf, shf 
    203266; 
    204 time=timegen(7670, start=julday(1,1,1989,0), units='days') 
    205 jpt=n_elements(time) 
    206 ; 
    207 cda0=string(jul2date(time(0)),format='(i8.8)') 
    208 cda1=string(jul2date(time(jpt-1)),format='(i8.8)') 
    209 ; 
    210 time=time-julday(1,1,1950,00,00) 
    211 ; 
    212 lat=reform(gphit(0,0:jpj-1)) 
    213 lon=reform(glamt(0:jpi-1,0)) 
     267lat=reform(gphit[0,0:jpj-1]) 
     268lon=reform(glamt[0:jpi-1,0]) 
    214269; 
    215270ncfile='!' + fullfilename_out 
     
    223278lh_attr={units:'w/m^2',missing_value:1.e20,long_name:'Latent Heat Flux',short_name:'lhf',axis:'TYX'} 
    224279; 
    225 ncfields = 'swr[longitude,latitude,time]=swr:sw_attr; ' $ 
    226           +'lwr[longitude,latitude,time]=lwr:lw_attr; ' $ 
    227           +'lhf[longitude,latitude,time]=lhf:lh_attr; ' $ 
    228           +'shf[longitude,latitude,time]=shf:sh_attr; ' $ 
     280ncfields = 'swr[longitude,latitude,*time]=swr:sw_attr; ' $ 
     281          +'lwr[longitude,latitude,*time]=lwr:lw_attr; ' $ 
     282          +'lhf[longitude,latitude,*time]=lhf:lh_attr; ' $ 
     283          +'shf[longitude,latitude,*time]=shf:sh_attr; ' $ 
    229284                      + 'longitude[]=lon:lon_attr; ' $ 
    230285                      + 'latitude[]=lat:lat_attr; ' $ 
    231                       + 'time[*time]=time:time_attr ' $ 
     286                      + 'time[]=timein:time_attr ' $ 
    232287                      + ' @ globattr' 
    233288; 
    234289@ncdf_quickwrite 
    235290; 
     291result = 0 
     292return, result 
     293; 
    236294end 
  • trunk/src/tropflux_swr_blnd.pro

    r175 r179  
    2929; 
    3030; This file will be used by 
    31 ; :ref:`TropFlux_NRT_ncdf.pro`. 
     31; :func:`tropflux_nrt_ncdf`. 
    3232; 
    3333;     .. graphviz:: 
     
    6666; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>` 
    6767; 
    68 ; :ref:`Tropflux_NRT_ncdf.pro` 
     68; :func:`tropflux_nrt_ncdf` 
    6969; 
    7070; EXAMPLES 
Note: See TracChangeset for help on using the changeset viewer.