Changeset 174


Ignore:
Timestamp:
03/21/12 16:27:38 (12 years ago)
Author:
pinsard
Message:

bunch of new functions

Location:
trunk
Files:
15 edited
3 moved

Legend:

Unmodified
Added
Removed
  • trunk/docs/docs_dev/makefile_non_sphinx

    r168 r174  
    4040#     thanks to  
    4141#     http://morlockhq.blogspot.fr/2008/09/bash-tip-reverse-sorting-lists-revisted.html 
    42 # - fplod 20120319 
    43 #    
    4442#   * fix ferret and odv errors 
    4543# 
  • trunk/docs/docs_dev/source/guides/generate_tropflux.rst

    r172 r174  
    130130 
    131131tools : 
    132  - :ref:`TropFlux_swr_DT_19890101_20071231.pro`, :ref:`TropFlux_swr_NRT_19890101_20091231.pro`, :ref:`TropFlux_swr_BLND_19890101_20091231.pro` 
     132 - :func:`tropflux_swr_dt`, :func:`tropflux_swr_nrt`, :func:`tropflux_swr_blnd` 
    133133 - :ref:`lwr_correction_ncdf.pro` 
    134134 - :ref:`q2m_correction_ncdf.pro` 
     
    147147 
    148148tools : 
    149  - :ref:`cronin_gustiness_ncdf.pro` 
     149 - :func:`cronin_gustiness_ncdf` 
    150150 - :ref:`TropFlux_19890101_20091231.pro` (:func:`cor30a`), :ref:`TropFlux_NRT_ncdf.pro`  
    151151 
  • trunk/src/TropFlux_19890101_20091231.pro

    r172 r174  
    3636; ++ 
    3737; has been produced by 
    38 ; :ref:`cronin_gustiness_ncdf.pro`. 
     38; :func:`cronin_gustiness_ncdf`. 
    3939; 
    4040; :file:`${PROJECT_OD}/TropFlux_swr_19890101_20091231_BLND.nc` 
     
    4242; ws corrected on OAFLUX grid 
    4343; has been produced by 
    44 ; :ref:`TropFlux_swr_BLND_19890101_20091231.pro`. 
     44; :func:`tropflux_swr_blnd`. 
    4545; 
    4646; :file:`${PROJECT_OD}/TropFlux_lwr_19890101_20091231.nc` 
  • trunk/src/TropFlux_NRT_ncdf.pro

    r100 r174  
    1111; ws corrected on OAFLUX grid 
    1212; has been produced by 
    13 ; :ref:`TropFlux_swr_BLND_19890101_20091231.pro`. 
     13; :func:`tropflux_swr_blnd`. 
    1414; 
    1515; :file:`${PROJECT_OD}/TropFlux_lwr_19890101_20091231.nc` 
  • trunk/src/cronin_gustiness_ncdf.pro

    • Property svn:keywords set to Id URL
    r100 r174  
    11;+ 
    2 ; 
    3 ; .. _cronin_gustiness_ncdf.pro: 
    42; 
    53; ========================= 
     
    75; ========================= 
    86; 
     7; .. function:: cronin_gustiness_ncdf(yyyymmddb,yyyymmdde) 
     8; 
     9; DESCRIPTION 
     10; =========== 
     11; 
    912; Cronin gustiness correction on corrected sst on OAFLUX grid 
    1013; 
     
    1417; Cronin gustiness corrected ++ on corrected sst on OAFLUX grid 
    1518; is written in 
    16 ; :file:`${PROJECT_OD}/TropFlux_gustiness_19890101_20091231.nc` 
     19; :file:`${PROJECT_OD}/TropFlux_gustiness_{yyyymmdd}_{yyyymmdd}.nc` 
    1720; if this file not already exists. 
    1821; 
    1922; This file will be used by 
    20 ; :ref:`TropFlux_swr_BLND_19890101_20091231.pro` 
     23; :func:`tropflux_swr_blnd` 
    2124; and 
    2225; :ref:`TropFlux_19890101_20091231.pro`. 
     
    2730; 
    2831;           file_in [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_sst_19890101_20091231.nc"]; 
    29 ;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_gustiness_19890101_20091231.nc"]; 
     32;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_gustiness_{yyyymmdd}_{yyyymmdd}.nc"]; 
    3033; 
    3134;           cronin_gustiness_ncdf [shape=box, 
     
    4346; :: 
    4447; 
    45 ;  IDL> cronin_gustiness_ncdf 
     48;  IDL> yyyymmddb = 20000101L 
     49;  IDL> yyyymmdde = 20001231L 
     50;  IDL> result = cronin_gustiness_ncdf(yyyymmddb, yyyymmdde) 
     51;  IDL> print, result 
    4652; 
    4753; SEE ALSO 
     
    6167; ==== 
    6268; 
     69; going on time parametrization 
     70; 
    6371; coding rules 
    6472; 
     
    7886; 
    7987; $URL$ 
     88; 
     89; - fplod 20120321 
     90; 
     91;   * pro -> func 
     92;   * taking project_overwite into account 
    8093; 
    8194; - fplod 20110830T140029Z cratos (Linux) 
     
    103116; 
    104117;- 
    105 pro cronin_gustiness_ncdf 
     118function cronin_gustiness_ncdf $ 
     119         , yyyymmddb $ 
     120         , yyyymmdde 
     121; 
     122;++ compile_opt idl2, strictarrsubs, logical_predicate 
    106123; 
    107124@cm_4cal 
     
    111128@cm_project 
    112129; 
     130; Return to caller if errors 
     131ON_ERROR, 2 
     132; 
     133result = -1 
     134; 
     135usage = 'result = tropflux_swr_nrt(yyyymmddb, yyyymmdde)' 
     136nparam = N_PARAMS() 
     137IF (nparam NE 2) THEN BEGIN 
     138   ras = report(['Incorrect number of arguments.' $ 
     139         + '!C' $ 
     140         + 'Usage : ' + usage]) 
     141   return, result 
     142ENDIF 
     143; 
    113144; test if ${PROJECT_OD} defined 
    114145CASE project_od_env OF 
     
    116147         msg = 'eee : ${PROJECT_OD} is not defined' 
    117148         ras = report(msg) 
    118        STOP 
     149       return, result 
    119150       END 
    120151  ELSE: BEGIN 
     
    131162   msg = 'eee : the directory' + iodirout  + ' is not accessible.' 
    132163   ras = report(msg) 
    133    STOP 
     164   return, result 
    134165ENDIF 
    135166; 
     
    138169    msg = 'eee : the directory' + iodirout  + ' was not found.' 
    139170    ras = report(msg) 
    140     STOP 
     171    return, result 
    141172ENDIF 
    142173; 
     
    152183   msg = 'eee : the file ' + fullfilename + ' was not found.' 
    153184   ras = report(msg) 
    154    STOP 
     185   return, result 
    155186ENDIF 
    156187; 
    157188; build output filename 
    158 filename_out = 'TropFlux_gustiness_19890101_20091231.nc' 
     189filename_out = 'TropFlux_gustiness' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '.nc' 
    159190fullfilename_out = iodirout + filename_out 
    160191; in order to avoid unexpected overwritten 
    161 IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN 
     192IF ((FILE_TEST(fullfilename_out) EQ 1)  AND (project_overwrite EQ 0)) THEN BEGIN 
    162193   msg = 'eee : the file ' + fullfilename_out  + ' already exists.' 
    163194   ras = report(msg) 
    164    STOP 
     195   return, result 
    165196ENDIF 
    166197; 
     
    207238@ncdf_quickwrite 
    208239; 
     240result = 0 
     241return, result 
     242; 
    209243end 
  • trunk/src/d2m_to_q2m_erai.pro

    • Property svn:keywords set to Id URL
    r173 r174  
    104104; ==== 
    105105; 
    106 ; compare time between d2m and t2m after reading 
     106; fix time pb:: 
     107; 
     108;   % the time axis has no date before date 2: 20000302 
     109;   d2m first date 29811221 
     110;   d2m last date 29851224 
     111; 
     112; compare time between d2m and t2m and msl after reading 
    107113; 
    108114; pb on cratos idl7 even if output file is written:: 
     
    181187; 
    182188; Return to caller if errors 
    183 ON_ERROR, 2 
     189;+++ ON_ERROR, 2 
    184190; 
    185191result = -1 
    186192; 
    187 usage = 'result = interp_erai_t2m(yyyymmddb, yyyymmdde)' 
     193usage = 'result = d2m_to_q2m_erai(yyyymmddb, yyyymmdde)' 
    188194nparam = N_PARAMS() 
    189195IF (nparam NE 2) THEN BEGIN 
     
    294300da=jul2date(time[jpt-1]) 
    295301cda1=string(da,format='(i8.8)') 
    296 print, 't2m first date ', cda0 
    297 print, 't2m last date ' , cda1 
     302print, 't2m in d2m_to_q2m_erai first date ', cda0 
     303print, 't2m in d2m_to_q2m_erai last date ' , cda1 
    298304 
    299305help, t, td 
     
    314320initncdf, fullfilename_msl 
    315321P=read_ncdf("msl", yyyymmddb, yyyymmdde, file=fullfilename_msl,/nostr) 
     322timein=24.d*(time-julday(1,1,1957,0,0,0)) 
     323jpt=n_elements(timein) 
     324da=jul2date(time[0]) 
     325cda0=string(da,format='(i8.8)') 
     326da=jul2date(time[jpt-1]) 
     327cda1=string(da,format='(i8.8)') 
     328print, 'msl in d2m_to_q2m_erai first date ', cda0 
     329print, 'msl in d2m_to_q2m_erai last date ' , cda1 
    316330help, P 
    317331; ++ for debug ftp error 
  • trunk/src/interp_erai_dewt.pro

    r173 r174  
    291291da=jul2date(time[jpt-1]) 
    292292cda1=string(da,format='(i8.8)') 
    293 print, 'first date ', cda0 
    294 print, 'last date ' , cda1 
     293print, 'dewt first date ', cda0 
     294print, 'dewt last date ' , cda1 
    295295; 
    296296tab=d2min[*,*,0] 
  • trunk/src/interp_erai_lwr.pro

    r173 r174  
    8181; 
    8282; :: 
    83 ; 
    8483;  IDL> .compile file_interp 
    8584;  IDL> yyyymmddb = 20000101L 
     
    9190; ==== 
    9291; 
     92; lwr first date 19991231 vs yyyymmddb = 20000101L 
     93;  
    9394; make it work : pb on loholt1 idl8: 
    9495; 
     
    111112; 19890101 is not provided in ERA-Intermim file str : a possible workaround is to copy 19890102 
    112113; dataset to 19890101 using nco after this processing. see :ref:`compute_erai_daily_region_2d.sh` 
    113 ; 
    114 ; st and en not used 
    115114; 
    116115; check if there is the same issue with 19790101 vs 19790102. 
     
    314313da=jul2date(time[jpt-1]) 
    315314cda1=string(da,format='(i8.8)') 
    316 print, 'first date ', cda0 
    317 print, 'last date ' , cda1 
     315print, 'lwr first date ', cda0 
     316print, 'lwr last date ' , cda1 
    318317; 
    319318initncdf, fullfilename 
  • trunk/src/interp_erai_msl.pro

    r173 r174  
    272272da=jul2date(time[jpt-1]) 
    273273cda1=string(da,format='(i8.8)') 
    274 print, 'first date ', cda0 
    275 print, 'last date ' , cda1 
     274print, 'msl first date ', cda0 
     275print, 'msl last date ' , cda1 
    276276; 
    277277tab=mslin[*,*,0] 
  • trunk/src/interp_erai_sst.pro

    r173 r174  
    281281da=jul2date(time[jpt-1]) 
    282282cda1=string(da,format='(i8.8)') 
    283 print, 'first date ', cda0 
    284 print, 'last date ' , cda1 
     283print, 'sst first date ', cda0 
     284print, 'sst last date ' , cda1 
    285285; 
    286286tab=sstkin[*,*,0] 
  • trunk/src/interp_erai_t2m.pro

    r173 r174  
    386386da=jul2date(time[jpt-1])  
    387387cda1=string(da,format='(i8.8)') 
    388 print, 'first date ', cda0 
    389 print, 'last date ' , cda1 
     388print, 't2m first date ', cda0 
     389print, 't2m last date ' , cda1 
    390390help, t2min 
    391391; 
  • trunk/src/interp_olr_30n30s.pro

    r173 r174  
    2525; 
    2626; This output file will be used by 
    27 ; :ref:`TropFlux_swr_NRT_19890101_20091231.pro`. 
     27; :func:`tropflux_swr_nrt`. 
    2828; 
    2929;     .. graphviz:: 
     
    7979; ==== 
    8080; 
     81; hard coded attributes for time origine 
     82; 
    8183; how can we avoid this message :: 
    8284; 
     
    114116; 
    115117; $URL$ 
     118; 
     119; - fplod 20120321 
     120; 
     121;   * add timerange in global attributes 
     122;   * change time origne 1950 -> 1957 to homogenize wih others fields 
    116123; 
    117124; - fplod 20120320 
     
    262269olrin=read_ncdf("olr",yyyymmddb-.5d,yyyymmdde, file=fullfilename,/nostr) 
    263270; 
    264 timein=time 
    265 jptin=jpt 
     271timein=24.d*(time-julday(1,1,1957,0,0,0)) 
     272jptin=n_elements(timein) 
     273da=jul2date(time[0]) 
     274cda0=string(da,format='(i8.8)') 
     275da=jul2date(time[jptin-1]) 
     276cda1=string(da,format='(i8.8)') 
     277print, 'olr first date ', cda0 
     278print, 'olr last date ' , cda1 
     279 
    266280mskin=glamt*0.+1. 
    267281; 
     
    290304endfor 
    291305; 
    292 timein=timein-julday(1,1,1950,00,00) 
    293 ; 
    294306lat=latout 
    295307lon=lonout 
     
    297309lon_attr={units:'degrees_east',long_name:'Longitude'} 
    298310lat_attr={units:'degrees_north',long_name:'Latitude'} 
    299 time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:'1950-JAN-01 00:00:00'} 
    300 globattr={source:'NOAA OLR, cf http://www.cdc.noaa.gov/cdc/data.interp_OLR.html, interpolated to 1x1 degree grid and with oaflux mask'} 
     311time_attr={units:'days since 1957-01-01 00:00:00',long_name:'Time axis',time_origin:'1957-JAN-01 00:00:00'} 
     312globattr={source:'NOAA OLR, cf http://www.cdc.noaa.gov/cdc/data.interp_OLR.html, interpolated to 1x1 degree grid and with oaflux mask', timerange:cda0+' - '+cda1} 
    301313olr_attr={units:'w/m^2',missing_value:1e20,long_name:'Outgoing Longwave Radiation',short_name:'olr',axis:'TYX'} 
    302314; 
  • trunk/src/paper01/fig13/net_flux_validation_scatter_2000_2007.pro

    r99 r174  
    1111; This program will create the text files with statistics of respective variables 
    1212; 
    13 ; :file:`${PROJECT_OD}/TropFlux_swr_19890101_20071231_DT.nc` 
     13; :file:`${PROJECT_OD}/TropFlux_swr_19890101_20071231_DT.nc` ++dates 
    1414; containing ++ 
    1515; has been produced by 
    16 ; :ref:`TropFlux_swr_DT_19890101_20071231.pro`. 
     16; :func:`tropflux_swr_dt`. 
    1717; 
    1818; :file:`${PROJECT_OD}/TropFlux_swr_19890101_20091231_NRT.nc` 
    1919; containing ++ 
    2020; has been produced by 
    21 ; :ref:`TropFlux_swr_NRT_19890101_20091231.pro`. 
     21; :func:`tropflux_swr_nrt`. 
    2222; 
    2323; :file:`${PROJECT_OD}/TropFlux_19890101_20091231.nc` 
  • trunk/src/sst_correction_ncdf.pro

    r173 r174  
    2323; :file:`${PROJECT_OD}/TropFlux_sst_19890101_20091231.nc` 
    2424; will be used by 
    25 ; :ref:`cronin_gustiness_ncdf.pro` 
     25; :func:`cronin_gustiness_ncdf` 
    2626; and 
    2727; :ref:`TropFlux_19890101_20091231.pro`. 
  • trunk/src/tropflux.sh

    r172 r174  
    114114# 
    115115# $URL$ 
     116# 
     117# - pinsard 20120321 
     118# 
     119#   * TropFlux_swr_DT_19890101_20071231 replace by tropflux_swr_dt 
     120#     which is now a function 
     121#   * TropFlux_swr_NRT_19890101_20071231 replace by tropflux_swr_nrt 
     122#     which is now a function 
     123#   * TropFlux_swr_BLND_19890101_20071231 replace by tropflux_swr_blnd 
     124#     which is now a function 
     125#   * corrrection of messages when return badly 
     126#   * reorder for gustiness before tropflux_swr_blnd 
     127#   * cronin_gustiness_ncdf is now a function 
    116128# 
    117129# - pinsard 20120320 
     
    304316result = oaflux_mask_30n30s() 
    305317IF result < 0 THEN BEGIN 
    306    msg = 'eee : pb after oaflux_mask_30n30s' + string(result) 
     318   msg = 'eee : pb after oaflux_mask_30n30s ' + string(result) 
    307319   err = report(msg) 
    308320   exit 
     
    310322result = interp_erai_dewt(${yyyymmddb}, ${yyyymmdde}) 
    311323IF result < 0 THEN BEGIN 
    312    msg = 'eee : pb after interp_erai_dewt' + string(result) 
     324   msg = 'eee : pb after interp_erai_dewt ' + string(result) 
    313325   err = report(msg) 
    314326   exit 
     
    316328result = interp_erai_lwr(${yyyymmddb}, ${yyyymmdde}) 
    317329IF result < 0 THEN BEGIN 
    318    msg = 'eee : pb after interp_erai_lwr' + string(result) 
     330   msg = 'eee : pb after interp_erai_lwr ' + string(result) 
    319331   err = report(msg) 
    320332   exit 
     
    322334result = interp_erai_msl(${yyyymmddb}, ${yyyymmdde}) 
    323335IF result < 0 THEN BEGIN 
    324    msg = 'eee : pb after interp_erai_msl' + string(result) 
     336   msg = 'eee : pb after interp_erai_msl ' + string(result) 
    325337   err = report(msg) 
    326338   exit 
     
    328340result = interp_erai_sst(${yyyymmddb}, ${yyyymmdde}) 
    329341IF result < 0 THEN BEGIN 
    330    msg = 'eee : pb after interp_erai_t2m' + string(result) 
     342   msg = 'eee : pb after interp_erai_sst ' + string(result) 
    331343   err = report(msg) 
    332344   exit 
     
    334346result = interp_erai_t2m(${yyyymmddb}, ${yyyymmdde}) 
    335347IF result < 0 THEN BEGIN 
    336    msg = 'eee : pb after interp_erai_t2m' + string(result) 
     348   msg = 'eee : pb after interp_erai_t2m ' + string(result) 
    337349   err = report(msg) 
    338350   exit 
     
    340352result = interp_erai_ws(${yyyymmddb}, ${yyyymmdde}) 
    341353IF result < 0 THEN BEGIN 
    342    msg = 'eee : pb after interp_erai_t2m' + string(result) 
     354   msg = 'eee : pb after interp_erai_ws ' + string(result) 
    343355   err = report(msg) 
    344356   exit 
     
    346358result = interp_olr_30n30s(${yyyymmddb}, ${yyyymmdde}) 
    347359IF result < 0 THEN BEGIN 
    348    msg = 'eee : pb after interp_erai_t2m' + string(result) 
     360   msg = 'eee : pb after interp_olr_30n30s ' + string(result) 
    349361   err = report(msg) 
    350362   exit 
     
    352364result = d2m_to_q2m_erai(${yyyymmddb}, ${yyyymmdde}) 
    353365IF result < 0 THEN BEGIN 
    354    msg = 'eee : pb after interp_erai_t2m' + string(result) 
    355    err = report(msg) 
    356    exit 
    357 ENDIF 
    358 ;++Program caused arithmetic error: Floating overflow 
    359 ;++ Program caused arithmetic error: Floating illegal operand 
    360 ;.compile TropFlux_swr_DT_19890101_20071231 
    361 ;tropflux_swr_dt_19890101_20071231 
    362 ;.compile TropFlux_swr_NRT_19890101_20091231 
    363 ;tropflux_swr_nrt_19890101_20091231 
    364 ;.compile TropFlux_swr_BLND_19890101_20091231 
    365 ;tropflux_swr_blnd_19890101_20091231 
     366   msg = 'eee : pb after d2m_to_q2m_erai ' + string(result) 
     367   err = report(msg) 
     368   ;++Program caused arithmetic error: Floating overflow 
     369   ;++ Program caused arithmetic error: Floating illegal operand 
     370   ;++exit 
     371ENDIF 
     372result = tropflux_swr_dt(${yyyymmddb}, ${yyyymmdde}) 
     373IF result < 0 THEN BEGIN 
     374   msg = 'eee : pb after tropflux_swr_dt ' + string(result) 
     375   err = report(msg) 
     376   exit 
     377ENDIF 
     378result = tropflux_swr_nrt(${yyyymmddb}, ${yyyymmdde}) 
     379IF result < 0 THEN BEGIN 
     380   msg = 'eee : pb after tropflux_swr_nrt ' + string(result) 
     381   err = report(msg) 
     382   exit 
     383ENDIF 
     384;sst_correction_ncdf 
     385result = cronin_gustiness_ncdf(${yyyymmddb}, ${yyyymmdde}) 
     386IF result < 0 THEN BEGIN 
     387   msg = 'eee : pb after cronin_gustiness_ncdf ' + string(result) 
     388  err = report(msg) 
     389exit 
     390result = tropflux_swr_blnd(${yyyymmddb}, ${yyyymmdde}) 
     391IF result < 0 THEN BEGIN 
     392   msg = 'eee : pb after tropflux_swr_blnd ' + string(result) 
     393  err = report(msg) 
     394exit 
    366395;lwr_correction_ncdf 
    367396;q2m_correction_ncdf 
    368 ;sst_correction_ncdf 
    369397;t2m_correction_ncdf 
    370398;ws_correction_ncdf 
    371 ;cronin_gustiness_ncdf 
    372399;.compile TropFlux_19890101_20091231 
    373400;tropflux_19890101_20091231 
  • trunk/src/tropflux_swr_blnd.pro

    r170 r174  
    11;+ 
    22; 
    3 ; .. _TropFlux_swr_BLND_19890101_20091231.pro: 
    4 ; 
    5 ; ======================================= 
    6 ; TropFlux_swr_BLND_19890101_20091231.pro 
    7 ; ======================================= 
     3; ===================== 
     4; tropflux_swr_blnd.pro 
     5; ===================== 
     6; 
     7; .. function:: tropflux_swr_blnd(yyyymmddb,yyyymmdde) 
    88; 
    99; DESCRIPTION 
    1010; =========== 
    1111; 
    12 ; :file:`${PROJECT_OD}/TropFlux_swr_19890101_20071231_DT.nc` 
     12; :file:`${PROJECT_OD}/TropFlux_swr_{yyyymmdd}_{yyyymmdd}_DT.nc` 
    1313; containing ++ 
    1414; has been produced by 
    15 ; :ref:`TropFlux_swr_DT_19890101_20071231.pro`. 
    16 ; 
    17 ; :file:`${PROJECT_OD}/TropFlux_swr_19890101_20091231_NRT.nc` 
     15; :func:`tropflux_swr_dt`. 
     16; 
     17; :file:`${PROJECT_OD}/TropFlux_swr_{yyyymmdd}_{yyyymmdd}_NRT.nc` 
    1818; containing ++ 
    1919; has been produced by 
    20 ; :ref:`TropFlux_swr_NRT_19890101_20091231.pro`. 
    21 ; 
    22 ; :file:`${PROJECT_OD}/TropFlux_gustiness_19890101_20091231.nc` containing ++ 
     20; :func:`tropflux_swr_nrt`. 
     21; 
     22; :file:`${PROJECT_OD}/TropFlux_gustiness_{yyyymmdd}_{yyyymmdd}.nc` containing ++ 
    2323; has been produced by 
    24 ; :ref:` cronin_gustiness_ncdf.pro`. 
     24; :func:`cronin_gustiness_ncdf`. 
    2525; 
    2626; ++ are written 
    27 ; in :file:`${PROJECT_OD}/TropFlux_swr_19890101_20091231_BLND.nc` 
     27; in :file:`${PROJECT_OD}/TropFlux_swr_{yyyymmdd}_{yyyymmdd}_BLND.nc` 
    2828; if this file not already exists. 
    2929; 
     
    3333;     .. graphviz:: 
    3434; 
    35 ;        digraph tropflux_swr_blnd_19890101_20091231 { 
    36 ; 
    37 ;           file_dt [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_19890101_20071231_DT.nc"]; 
    38 ;           file_nrt [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_19890101_20091231_NRT.nc"]; 
    39 ;           file_gustiness [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_gustiness_19890101_20091231.nc"]; 
    40 ;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_19890101_20091231_blnd.nc"]; 
    41 ; 
    42 ;           tropflux_swr_blnd_19890101_20091231 [shape=box, 
     35;        digraph tropflux_swr_blnd { 
     36; 
     37;           file_dt [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_{yyyymmdd}_{yyyymmdd}_DT.nc"]; 
     38;           file_nrt [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_{yyyymmdd}_{yyyymmdd}_NRT.nc"]; 
     39;           file_gustiness [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_gustiness_{yyyymmdd}_{yyyymmdd}.nc"]; 
     40;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_{yyyymmdd}_{yyyymmdd}_blnd.nc"]; 
     41; 
     42;           tropflux_swr_blnd [shape=box, 
    4343;           fontname=Courier, 
    4444;           color=blue, 
    45 ;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/TropFlux_swr_BLND_19890101_20091231.pro", 
    46 ;           label="${PROJECT}/src/TropFlux_swr_BLND_19890101_20091231.pro"]; 
    47 ; 
    48 ;           {file_dt file_nrt file_gustiness} -> {tropflux_swr_blnd_19890101_20091231} -> {file_out} 
     45;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/tropflux_swr_blnd.pro", 
     46;           label="${PROJECT}/src/tropflux_swr_blnd.pro"]; 
     47; 
     48;           {file_dt file_nrt file_gustiness} -> {tropflux_swr_blnd} -> {file_out} 
    4949; 
    5050;       } 
     
    7171; :: 
    7272; 
    73 ;  IDL> .compile TropFlux_swr_BLND_19890101_20091231 
    74 ;  IDL> tropflux_swr_blnd_19890101_20091231 
     73;  IDL> yyyymmddb = 20000101L 
     74;  IDL> yyyymmdde = 20001231L 
     75;  IDL> result = tropflux_swr_blnd(yyyymmddb, yyyymmdde) 
     76;  IDL> print, result 
    7577; 
    7678; TODO 
    7779; ==== 
    7880; 
     81; handling date > 20071231 
     82; 
     83; read_ncdf usage of yyyymmddb yyyymmdde  
     84; 
     85; get rid of timegen 
     86; 
    7987; submit read_ncdf with 19890101 pb to saxo-dev 
    8088; 
    81 ; avoid mix lower/uppercase in pro name to avoid compile 
    82 ; 
    8389; coding rules 
    8490; 
     
    9096; 
    9197; according to pk 20110811 we can include this process in 
    92 ; TropFlux_swr_NRT_19890101_20091231.pro ... later 
     98; tropflux_swr_nrt.pro ... later 
    9399; 
    94100; KNOWN ISSUES 
     
    101107; ========== 
    102108; 
    103 ; $Id: TropFlux_swr_BLND_19890101_20091231.pro 88 2011-08-19 15:40:14Z pinsard $ 
     109; $Id: tropflux_swr_blnd.pro 88 2011-08-19 15:40:14Z pinsard $ 
    104110; 
    105111; $URL$ 
     112; 
     113; - fplod 20120321 
     114; 
     115;   * pro -> func 
     116;   * rename with lower case TropFlux_swr_BLND_19890101_20091231.pro become 
     117;     tropflux_swr_blnd.pro 
     118;   * taking project_overwite into account 
    106119; 
    107120; - fplod 20110819T120412Z aedon.locean-ipsl.upmc.fr (Darwin) 
     
    119132; 
    120133;     problably because  6938+731=7669 and not 7670 when 
    121 ;     :samp:`dt=read_ncdf("swr", 19890101, 20071231, file=fullfilename_dt,/nostr)` 
     134;     :samp:`dt=read_ncdf('swr', 19890101, 20071231, file=fullfilename_dt,/nostr)` 
    122135;     was used :: 
    123136; 
     
    142155; 
    143156;        IDL> fullfilename_dt='TropFlux_swr_19890101_20071231_DT.nc' 
    144 ;        IDL> dt=read_ncdf("swr", 19890100, 20071231, file=fullfilename_dt,/nostr) 
     157;        IDL> dt=read_ncdf('swr', 19890100, 20071231, file=fullfilename_dt,/nostr) 
    145158;        IDL> print, 'first time step (should crash with invalid date)', jul2date(time[0]) 
    146159;        first time step (should be 19890101)       19890101. 
    147 ;        IDL> dt=read_ncdf("swr", 19890101, 20071231, file=fullfilename_dt,/nostr) 
     160;        IDL> dt=read_ncdf('swr', 19890101, 20071231, file=fullfilename_dt,/nostr) 
    148161;        IDL> print, 'first time step (should be 19890101)', jul2date(time[0]) 
    149162;        first time step (should be 19890101)       19890102. 
     
    170183; 
    171184;- 
    172 pro TropFlux_swr_BLND_19890101_20091231 
     185function tropflux_swr_blnd $ 
     186         , yyyymmddb $ 
     187         , yyyymmdde 
     188; 
     189compile_opt idl2, strictarrsubs, logical_predicate 
    173190; 
    174191@cm_4cal 
     
    178195@cm_project 
    179196; 
     197; Return to caller if errors 
     198ON_ERROR, 2 
     199; 
     200result = -1 
     201; 
     202usage = 'result = tropflux_swr_blnd(yyyymmddb, yyyymmdde)' 
     203nparam = N_PARAMS() 
     204IF (nparam NE 2) THEN BEGIN 
     205   ras = report(['Incorrect number of arguments.' $ 
     206         + '!C' $ 
     207         + 'Usage : ' + usage]) 
     208   return, result 
     209ENDIF 
     210; 
    180211; test if ${PROJECT_OD} defined 
    181212CASE project_od_env OF 
     
    183214         msg = 'eee : ${PROJECT_OD} is not defined' 
    184215         ras = report(msg) 
    185        STOP 
     216       return, result 
    186217       END 
    187218  ELSE: BEGIN 
     
    198229   msg = 'eee : the directory' + iodirout  + ' is not accessible.' 
    199230   ras = report(msg) 
    200    STOP 
     231   return, result 
    201232ENDIF 
    202233; 
     
    205236    msg = 'eee : the directory' + iodirout  + ' was not found.' 
    206237    ras = report(msg) 
    207     STOP 
     238    return, result 
    208239ENDIF 
    209240; 
    210241; build dt data filename 
    211 filename_dt="TropFlux_swr_19890101_20071231_DT.nc" 
     242filename_dt='TropFlux_swr_' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '_DT.nc' 
    212243; 
    213244; check if this file exists 
     
    218249   msg = 'eee : the file ' + fullfilename_dt + ' was not found.' 
    219250   ras = report(msg) 
    220    STOP 
     251   return, result 
    221252ENDIF 
    222253; 
    223254; build nrt data filename 
    224 filename_nrt="TropFlux_swr_19890101_20091231_NRT.nc" 
     255filename_nrt='TropFlux_swr_' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '_NRT.nc' 
    225256; 
    226257; check if this file exists 
     
    231262   msg = 'eee : the file ' + fullfilename_nrt + ' was not found.' 
    232263   ras = report(msg) 
    233    STOP 
     264   return, result 
    234265ENDIF 
    235266; 
    236267; build wg data filename 
    237 filename_wg="TropFlux_gustiness_19890101_20091231.nc" 
     268filename_wg='TropFlux_gustiness_' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '.nc' 
    238269; 
    239270; check if this file exists 
     
    244275   msg = 'eee : the file ' + fullfilename_wg + ' was not found.' 
    245276   ras = report(msg) 
    246    STOP 
     277   return, result 
    247278ENDIF 
    248279; 
    249280; build output filename 
    250 filename_out = 'TropFlux_swr_19890101_20091231_BLND.nc' 
     281filename_out = 'TropFlux_swr_' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '_BLND.nc' 
    251282fullfilename_out = iodirout + filename_out 
    252283; in order to avoid unexpected overwritten 
    253 IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN 
     284IF ((FILE_TEST(fullfilename_out) EQ 1)  AND (project_overwrite EQ 0)) THEN BEGIN 
    254285   msg = 'eee : the file ' + fullfilename_out  + ' already exists.' 
    255286   ras = report(msg) 
    256    STOP 
     287   return, result 
    257288ENDIF 
    258289; 
    259290initncdf, fullfilename_dt 
    260 dt=read_ncdf("swr", 19890100, 20071231, file=fullfilename_dt,/nostr) 
     291dt=read_ncdf('swr', 19890100, 20071231, file=fullfilename_dt,/nostr) 
    261292print, 'www : should crash with invalide date 19890100' 
    262293help, dt 
     
    265296; 
    266297initncdf, fullfilename_nrt 
    267 nrt=read_ncdf("sw", 20080100, 20100112, file=fullfilename_nrt,/nostr) 
     298nrt=read_ncdf('sw', 20080100, 20100112, file=fullfilename_nrt,/nostr) 
    268299help, nrt 
    269300; 
    270 swr_nrt=read_ncdf("sw", 19880101, 20100112, file=fullfilename_nrt,/nostr) 
     301swr_nrt=read_ncdf('sw', 19880101, 20100112, file=fullfilename_nrt,/nostr) 
    271302; 
    272303swr_dt=[[[dt]],[[nrt]]] 
     
    281312a=((a > 0.) < 1.) 
    282313for jt=0,jpt-1 do begin 
    283     swr_merged(*,*,jt)=swr_dt(*,*,jt)*a(jt)+(1-a(jt))*swr_nrt(*,*,jt) 
     314    swr_merged[*,*,jt]=swr_dt[*,*,jt]*a[jt]+(1-a[jt])*swr_nrt[*,*,jt] 
    284315endfor 
    285316; 
     
    287318time=timegen(7670, units='days', start=julday(1,1,1989,0)) 
    288319jpt=n_elements(time) 
    289 lat=reform(gphit(0,0:jpj-1)) 
    290 lon=reform(glamt(0:jpi-1,0)) 
    291 cda0=string(jul2date(time(0)),format='(i8.8)') 
    292 cda1=string(jul2date(time(jpt-1)),format='(i8.8)') 
     320lat=reform(gphit[0,0:jpj-1]) 
     321lon=reform(glamt[0:jpi-1,0]) 
     322cda0=string(jul2date(time[0]),format='(i8.8)') 
     323cda1=string(jul2date(time[jpt-1]),format='(i8.8)') 
    293324; 
    294325time=time-julday(1,1,1950,00,00) 
  • trunk/src/tropflux_swr_dt.pro

    r170 r174  
    11;+ 
    22; 
    3 ; .. _TropFlux_swr_DT_19890101_20071231.pro: 
    4 ; 
    5 ; ===================================== 
    6 ; TropFlux_swr_DT_19890101_20071231.pro 
    7 ; ===================================== 
     3; =================== 
     4; tropflux_swr_dt.pro 
     5; =================== 
     6; 
     7; .. function:: tropflux_swr_dt(yyyymmddb,yyyymmdde) 
    88; 
    99; DESCRIPTION 
     
    1717; Corrected swr delay on OAFLUX grid 
    1818; is written in 
    19 ; :file:`${PROJECT_OD}/TropFlux_swr_19890101_20071231_DT.nc` 
     19; :file:`${PROJECT_OD}/TropFlux_swr_{yyyymmdd}_{yyyymmdd}_DT.nc` 
    2020; if this file not already exists. 
    2121; 
    22 ; This file will be used by 
    23 ; :ref:`TropFlux_swr_BLND_19890101_20091231.pro`. 
    24 ; 
    2522;     .. graphviz:: 
    2623; 
    27 ;        digraph tropflux_swr_dt_19890101_20071231 { 
     24;        digraph tropflux_swr_dt { 
    2825; 
    2926;           file_in [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/swr_oafluxgrid_1985_2007.nc"]; 
    30 ;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_19890101_20071231_DT.nc"]; 
    31 ; 
    32 ;           tropflux_swr_dt_19890101_20071231 [shape=box, 
     27;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_{yyyymmdd}_{yyyymmdd}_DT.nc"]; 
     28; 
     29;           tropflux_swr_dt [shape=box, 
    3330;           fontname=Courier, 
    3431;           color=blue, 
    35 ;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/TropFlux_swr_DT_19890101_20071231.pro", 
    36 ;           label="${PROJECT}/src/TropFlux_swr_DT_19890101_20071231.pro"]; 
    37 ; 
    38 ;           {file_in}-> {tropflux_swr_dt_19890101_20071231} -> {file_out} 
     32;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/tropflux_swr_dt.pro", 
     33;           label="${PROJECT}/src/tropflux_swr_dt.pro"]; 
     34; 
     35;           {file_in}-> {tropflux_swr_dt} -> {file_out} 
    3936; 
    4037;        } 
     
    4340; ======== 
    4441; 
     42; :ref:`mooring_corrections` 
     43; 
     44; Used by :ref:`tropflux.sh` 
     45; 
    4546; :ref:`project_profile.sh` 
    46 ; 
    47 ; :ref:`mooring_corrections` 
    4847; 
    4948; :ref:`data_in_swr` 
     
    6160; :: 
    6261; 
    63 ;  IDL> .compile TropFlux_swr_DT_19890101_20071231 
    64 ;  IDL> tropflux_swr_dt_19890101_20071231 
     62;  IDL> yyyymmddb = 20000101L 
     63;  IDL> yyyymmdde = 20001231L 
     64;  IDL> result = tropflux_swr_dt(yyyymmddb, yyyymmdde) 
     65;  IDL> print, result 
    6566; 
    6667; TODO 
    6768; ==== 
    6869; 
     70; handlind yyyymmdde > 20071231 
     71; 
     72; first date 19991231 vs yyyymmddb = 20000101L 
     73; 
    6974; NaNf values in ouptut file while 1.e20 in input file !! 
    7075; 
    7176; coding rules 
    72 ; 
    73 ; why compile is needed ? uppercase in file name 
    74 ; 
    75 ; any way change the name to swr_dt_correction_ndcf.pro 
    76 ; to homogenize names of tools 
    7777; 
    7878; use the output of concat_swr.sh to be written. 
    7979; now use swr_oafluxgrid_1985_2007.nc provided by pk 20110811 
     80; stored in :file:`cratos:/usr/lodyc/incas/fplod/tropflux_d/from_pk/stage_0/swr_oafluxgrid_1985_2007.nc` 
    8081; 
    8182; KNOWN ISSUES 
     
    8889; ========== 
    8990; 
    90 ; $Id: TropFlux_swr_DT_19890101_20071231.pro 88 2011-08-19 15:40:14Z pinsard $ 
     91; $Id: tropflux_swr_dt.pro 88 2011-08-19 15:40:14Z pinsard $ 
    9192; 
    9293; $URL$ 
     94; 
     95; - fplod 20120321 
     96; 
     97;   * pro -> func 
     98;   * rename with lower case TropFlux_swr_DT_19890101_20071231.pro become 
     99;     tropflux_swr_dt.pro 
     100;   * taking project_overwite into account 
     101;   * try to add compile_opt seems to be incompatible with ncdf_quickwrite 
     102;   * start to homogenize time handling and netcdf writing 
    93103; 
    94104; - fplod 20110830T135743Z cratos (Linux) 
     
    115125; 
    116126;- 
    117 pro TropFlux_swr_DT_19890101_20071231 
     127function tropflux_swr_dt $ 
     128         , yyyymmddb $ 
     129         , yyyymmdde 
     130; 
     131;++compile_opt idl2, strictarrsubs, logical_predicate 
    118132; 
    119133@cm_4cal 
     
    123137@cm_project 
    124138; 
     139; Return to caller if errors 
     140ON_ERROR, 2 
     141; 
     142result = -1 
     143; 
     144usage = 'result = tropflux_swr_dt(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 
    125153; test if ${PROJECT_OD} defined 
    126154CASE project_od_env OF 
     
    128156         msg = 'eee : ${PROJECT_OD} is not defined' 
    129157         ras = report(msg) 
    130        STOP 
     158       return, result 
    131159       END 
    132160  ELSE: BEGIN 
     
    143171   msg = 'eee : the directory' + iodirout  + ' is not accessible.' 
    144172   ras = report(msg) 
    145    STOP 
     173   return, result 
    146174ENDIF 
    147175; 
     
    150178    msg = 'eee : the directory' + iodirout  + ' was not found.' 
    151179    ras = report(msg) 
    152     STOP 
     180    return, result 
    153181ENDIF 
    154182; 
     
    163191   msg = 'eee : the file ' + fullfilename + ' was not found.' 
    164192   ras = report(msg) 
    165    STOP 
     193   return, result 
    166194ENDIF 
    167195; 
    168196; build output filename 
    169 filename_out = 'TropFlux_swr_19890101_20071231_DT.nc' 
     197filename_out = 'TropFlux_swr_' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '_DT.nc' 
    170198fullfilename_out = iodirout + filename_out 
    171199; in order to avoid unexpected overwritten 
    172 IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN 
     200IF ((FILE_TEST(fullfilename_out) EQ 1)  AND (project_overwrite EQ 0)) THEN BEGIN 
    173201   msg = 'eee : the file ' + fullfilename_out  + ' already exists.' 
    174202   ras = report(msg) 
    175    STOP 
     203   return, result 
    176204ENDIF 
    177205; 
    178206initncdf, filename 
    179207; 
    180 sw=read_ncdf("swr", 19890101, 20071231, file=filename,/nostr) 
     208sw=read_ncdf("swr", yyyymmddb-.5d,yyyymmdde, file=filename,/nostr) 
     209timein=24.d*(time-julday(1,1,1957,0,0,0)) 
     210jptin=n_elements(timein) 
     211da=jul2date(time[0]) 
     212cda0=string(da,format='(i8.8)') 
     213da=jul2date(time[jptin-1]) 
     214cda1=string(da,format='(i8.8)') 
     215print, 'first date ', cda0 
     216print, 'last date ' , cda1 
    181217help, sw 
    182218; 
     
    190226; 
    191227for jt=0,jpt-1 do begin 
    192   jtt=(time(jt)-julday(1,1,yea(jt))) < 364 
    193   swr=reform(sw_mean(*,*)) 
    194   sw_m(*,*,jt)=swr 
    195   sw_bias(*,*,jt)=(((swr-295.4)*18.36/(200.-295.4)) > 0.) < 18.37 
     228  jtt=(time[jt]-julday(1,1,yea[jt])) < 364 
     229  swr=reform(sw_mean[*,*]) 
     230  sw_m[*,*,jt]=swr 
     231  sw_bias[*,*,jt]=(((swr-295.4)*18.36/(200.-295.4)) > 0.) < 18.37 
    196232endfor 
    197233; 
     
    203239; 
    204240; writing field 
    205 cda0=string(jul2date(time(0)),format='(i8.8)') 
    206 cda1=string(jul2date(time(jpt-1)),format='(i8.8)') 
    207 ; 
    208 lat=reform(gphit(0,0:jpj-1)) 
    209 lon=reform(glamt(0:jpi-1,0)) 
     241cda0=string(jul2date(time[0]),format='(i8.8)') 
     242cda1=string(jul2date(time[jpt-1]),format='(i8.8)') 
     243; 
     244lat=reform(gphit[0,0:jpj-1]) 
     245lon=reform(glamt[0:jpi-1,0]) 
    210246time=time-julday(1,1,1950) 
    211247jpt=n_elements(time) 
     
    218254sw_attr={units:'w/m^2',missing_value:1.e20,long_name:'Net Shortwave Radiation',short_name:'swr',axis:'TYX'} 
    219255; 
    220 ncfields = 'swr[longitude,latitude,time]=swr:sw_attr; ' $ 
     256ncfields = 'swr[longitude,latitude,*time]=swr:sw_attr; ' $ 
    221257                      + 'longitude[]=lon:lon_attr; ' $ 
    222258                      + 'latitude[]=lat:lat_attr; ' $ 
    223                       + 'time[*time]=time:time_attr ' $ 
     259                      + 'time[]=timein:time_attr ' $ 
    224260                      + ' @ globattr' 
    225261; 
    226262@ncdf_quickwrite 
    227263; 
     264result = 0 
     265return, result 
     266; 
    228267end 
  • trunk/src/tropflux_swr_nrt.pro

    r170 r174  
    11;+ 
    22; 
    3 ; .. _TropFlux_swr_NRT_19890101_20091231.pro: 
    4 ; 
    5 ; ====================================== 
    6 ; TropFlux_swr_NRT_19890101_20091231.pro 
    7 ; ====================================== 
     3; ==================== 
     4; tropflux_swr_nrt.pro 
     5; ==================== 
     6; 
     7; .. function:: tropflux_swr_nrt(yyyymmddb,yyyymmdde) 
    88; 
    99; DESCRITION 
     
    1212; Correction of swr near real time on OAFLUX grid 
    1313; 
     14; :file:`${PROJECT_OD}/TropFlux_swr_{yyyymmdd}_{yyyymmdd}_DT.nc` 
     15; containing  
    1416; Corrected swr delay on OAFLUX grid 
    1517; has been produced by 
    16 ; :file:`${PROJECT_OD}/TropFlux_swr_19890101_20071231_DT.nc` 
    17 ; 
    18 ; :file:`${PROJECT_OD}/olr_oafluxgrid_30n30s_19890101_20091231.nc` 
    19 ; have been produced ++by pk 
     18; :func:`tropflux_swr_dt`. 
     19; 
     20; :file:`${PROJECT_OD}/olr_oafluxgrid_30n30s_{yyyymmdd}_{yyyymmdd}.nc` 
     21; have been produced 
     22; :func:`interp_olr_30n30s`. 
    2023; 
    2124; Corrected swr near real time on OAFLUX grid 
    2225; ; is written in 
    23 ; :file:`${PROJECT_OD}/TropFlux_swr_19890101_20091231_NRT.nc` 
     26; :file:`${PROJECT_OD}/TropFlux_swr_{yyyymmdd}_{yyyymmdd}_NRT.nc` 
    2427; if this file not already exists. 
    2528; 
    26 ; This file will be used by 
    27 ; :ref:`TropFlux_swr_BLND_19890101_20091231.pro`. 
    28 ; 
    2929;     .. graphviz:: 
    3030; 
    31 ;        digraph tropflux_swr_nrt_19890101_200912311 { 
    32 ; 
    33 ;           file_swr_dt [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_19890101_20071231_DT.nc"]; 
    34 ;           file_olr [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/olr_oafluxgrid_30n30s_19890101_20091231.nc"]; 
    35 ;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_19890101_20091231_NRT.nc"]; 
    36 ; 
    37 ;           tropflux_swr_nrt_19890101_200912311 [shape=box, 
     31;        digraph tropflux_swr_nrt { 
     32; 
     33;           file_swr_dt [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_{yyyymmdd}_{yyyymmdd}_DT.nc"]; 
     34;           file_olr [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/olr_oafluxgrid_30n30s_{yyyymmdd}_{yyyymmdd}.nc"]; 
     35;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_{yyyymmdd}_{yyyymmdd}_NRT.nc"]; 
     36; 
     37;           tropflux_swr_nrt [shape=box, 
    3838;           fontname=Courier, 
    3939;           color=blue, 
    40 ;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/TropFlux_swr_NRT_19890101_200912311.pro", 
    41 ;           label="${PROJECT}/src/TropFlux_swr_NRT_19890101_200912311.pro"]; 
    42 ; 
    43 ;           {file_swr_dt file_olr}-> {tropflux_swr_nrt_19890101_200912311} -> {file_out} 
     40;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/tropflux_swr_nrt.pro", 
     41;           label="${PROJECT}/src/tropflux_swr_nrt.pro"]; 
     42; 
     43;           {file_swr_dt file_olr}-> {tropflux_swr_nrt} -> {file_out} 
    4444;       } 
    4545; 
     
    6464; :: 
    6565; 
    66 ;  IDL> .compile TropFlux_swr_NRT_19890101_20091231 
    67 ;  IDL> tropflux_swr_nrt_19890101_20091231 
     66;  IDL> yyyymmddb = 20000101L 
     67;  IDL> yyyymmdde = 20001231L 
     68;  IDL> result = tropflux_swr_nrt(yyyymmddb, yyyymmdde) 
     69;  IDL> print, result 
    6870; 
    6971; TODO 
    7072; ==== 
    7173; 
     74; handlind yyyymmdde > 20071231 
     75; 
    7276; remove NaNf values in ouptut file (may be not because of this module) 
    7377; 
     
    7579; 
    7680; coding rules 
    77 ; 
    78 ; why compile is needed ? uppercase in file name 
    79 ; 
    80 ; change the name to swr_nrt_correction_ncdf.pro 
    81 ; to homogenize names of tools 
    8281; 
    8382; KNOWN ISSUES 
     
    9089; ========== 
    9190; 
    92 ; $Id: TropFlux_swr_NRT_19890101_20091231.pro 88 2011-08-19 15:40:14Z pinsard $ 
     91; $Id: tropflux_swr_nrt.pro 88 2011-08-19 15:40:14Z pinsard $ 
    9392; 
    9493; $URL$ 
    9594; 
     95; - fplod 20120321 
     96; 
     97;   * pro -> func 
     98;   * rename with lower case TropFlux_swr_NRT_19890101_20091231.pro become 
     99;     tropflux_swr_nrt.pro 
     100;   * taking project_overwite into account 
     101;   * try to add compile_opt seems to be incompatible with ncdf_quickwrite 
     102; 
    96103; - fplod 20110830T135938Z cratos (Linux) 
    97104; 
    98105;   * replace tt by time 
    99 ;   * fill empty time_origin:wq 
     106;   * fill empty time_origin 
    100107; 
    101108; - fplod 20110812T075406Z aedon.locean-ipsl.upmc.fr (Darwin) 
     
    118125; 
    119126;- 
    120 pro TropFlux_swr_NRT_19890101_20091231 
     127function tropflux_swr_nrt $ 
     128         , yyyymmddb $ 
     129         , yyyymmdde 
     130; 
     131compile_opt idl2, strictarrsubs, logical_predicate 
    121132; 
    122133@cm_4cal 
     
    126137@cm_project 
    127138; 
     139; Return to caller if errors 
     140ON_ERROR, 2 
     141; 
     142result = -1 
     143; 
     144usage = 'result = tropflux_swr_nrt(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; 
    128153; test if ${PROJECT_OD} defined 
    129154CASE project_od_env OF 
     
    131156         msg = 'eee : ${PROJECT_OD} is not defined' 
    132157         ras = report(msg) 
    133        STOP 
     158       return, result 
    134159       END 
    135160  ELSE: BEGIN 
     
    145170   msg = 'eee : the directory' + iodirout  + ' is not accessible.' 
    146171   ras = report(msg) 
    147    STOP 
     172   return, result 
    148173ENDIF 
    149174; 
     
    152177    msg = 'eee : the directory' + iodirout  + ' was not found.' 
    153178    ras = report(msg) 
    154     STOP 
     179    return, result 
    155180ENDIF 
    156181; 
    157182; build swr dt data filename 
    158 filename_swr_dt='TropFlux_swr_19890101_20071231_DT.nc' 
     183filename_swr_dt='TropFlux_swr_' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '_DT.nc' 
    159184; 
    160185; check if this file exists 
     
    165190   msg = 'eee : the file ' + fullfilename_swr_dt + ' was not found.' 
    166191   ras = report(msg) 
    167    STOP 
     192   return, result 
    168193ENDIF 
    169194; 
    170195; build olr data filename 
    171 filename_olr='olr_oafluxgrid_30n30s_19890101_20091231.nc' 
     196filename_olr='olr_oafluxgrid_30n30s_' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '.nc' 
    172197; 
    173198; check if this file exists 
     
    178203   msg = 'eee : the file ' + fullfilename_olr + ' was not found.' 
    179204   ras = report(msg) 
    180    STOP 
     205   return, result 
    181206ENDIF 
    182207; 
    183208; build output filename 
    184 filename_out = 'TropFlux_swr_19890101_20091231_NRT.nc' 
     209filename_out = 'TropFlux_swr_' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '_NRT.nc' 
    185210fullfilename_out = iodirout + filename_out 
    186211; in order to avoid unexpected overwritten 
    187 IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN 
     212IF ((FILE_TEST(fullfilename_out) EQ 1)  AND (project_overwrite EQ 0)) THEN BEGIN 
    188213   msg = 'eee : the file ' + fullfilename_out  + ' already exists.' 
    189214   ras = report(msg) 
    190    STOP 
     215   return, result 
    191216ENDIF 
    192217; 
    193218initncdf, fullfilename_swr_dt 
    194 sw=read_ncdf("swr", 19890101, 20071231, file=fullfilename_swr_dt,/nostr) 
    195 ; 
     219sw=read_ncdf("swr", yyyymmddb-.5d, yyyymmdde, file=fullfilename_swr_dt,/nostr) 
    196220swi=sw 
     221timein=24.d*(time-julday(1,1,1957,0,0,0)) 
     222jptin=n_elements(timein) 
     223da=jul2date(timein[0]) 
     224cda0=string(da,format='(i8.8)') 
     225da=jul2date(timein[jptin-1]) 
     226cda1=string(da,format='(i8.8)') 
     227print, 'swr_dt first date ', cda0 
     228print, 'swr_dt last date ' , cda1 
    197229; 
    198230initncdf, fullfilename_olr 
    199 olr=read_ncdf('olr',19890100, 20071231, file=fullfilename_olr,/nost) 
     231olr=read_ncdf('olr', yyyymmddb-.5d, yyyymmdde, file=fullfilename_olr,/nost) 
     232timein=24.d*(time-julday(1,1,1957,0,0,0)) 
     233jptin=n_elements(timein) 
     234da=jul2date(timein[0]) 
     235cda0=string(da,format='(i8.8)') 
     236da=jul2date(timein[jptin-1]) 
     237cda1=string(da,format='(i8.8)') 
     238print, 'olr first date ', cda0 
     239print, 'olr last date ' , cda1 
    200240; 
    201241help, sw, olr 
     
    203243;creating climatology 
    204244; 
    205 ny=(2007-1989)+1 
     245ny=(2007-1989)+1 ;+++ 
    206246nt=365*ny 
    207 olri=total(reform(olr(*,*,0:nt-1),nxt,nyt,365,ny),4)/ny 
    208 swi=total(reform(swi(*,*,0:nt-1),nxt,nyt,365,ny),4)/ny 
     247olri=total(reform(olr[*,*,0:nt-1],nxt,nyt,365,ny),4)/ny 
     248swi=total(reform(swi[*,*,0:nt-1],nxt,nyt,365,ny),4)/ny 
    209249; 
    210250help, olri, swi 
     
    216256olri=[[[olri]],[[olri]],[[olri]]] 
    217257si=size(sw) 
    218 n1=si(1) 
    219 n2=si(2) 
     258n1=si[1] 
     259n2=si[2] 
    220260; 
    221261for j=0,n2-1 do begin 
    222262  for i=0,n1-1 do begin 
    223     x=reform(swi(i,j,*)) 
    224     y=reform(olri(i,j,*)) 
    225     swi(i,j,*)=smooth(x,nsmooth) 
    226     olri(i,j,*)=smooth(y,nsmooth) 
     263    x=reform(swi[i,j,*]) 
     264    y=reform(olri[i,j,*]) 
     265    swi[i,j,*]=smooth(x,nsmooth) 
     266    olri[i,j,*]=smooth(y,nsmooth) 
    227267  endfor 
    228268endfor 
     
    233273; 
    234274initncdf, fullfilename_olr 
    235 olr=read_ncdf('olr', 19890100, 20091231, box=box, file=fullfilename_olr,/nostr) 
     275olr=read_ncdf('olr', yyyymmddb-.5d,yyyymmdde, box=box, file=fullfilename_olr,/nostr) 
     276timein=24.d*(time-julday(1,1,1957,0,0,0)) 
     277jptin=n_elements(timein) 
     278da=jul2date(timein[0]) 
     279cda0=string(da,format='(i8.8)') 
     280da=jul2date(timein[jptin-1]) 
     281cda1=string(da,format='(i8.8)') 
     282print, 'olr 2 first date ', cda0 
     283print, 'olr 2 last date ' , cda1 
     284 
    236285jpt=n_elements(time) 
    237286caldat, time,mon,day,yea 
     
    239288olrm=olr*0. 
    240289for jt=0,jpt-1 do begin 
    241   jtt=(time(jt)-julday(1,1,yea(jt))) < 364 
    242   swm(*,*,jt)=swi(*,*,jtt) 
    243   olrm(*,*,jt)=olri(*,*,jtt) 
     290  jtt=(time[jt]-julday(1,1,yea[jt])) < 364 
     291  swm[*,*,jt]=swi[*,*,jtt] 
     292  olrm[*,*,jt]=olri[*,*,jtt] 
    244293endfor 
    245294; 
     
    250299; 
    251300; writing field 
    252 time=timegen(7670, start=julday(1,1,1989,0), units='days') 
    253 cda0=string(jul2date(time(0)),format='(i8.8)') 
    254 cda1=string(jul2date(time(jpt-1)),format='(i8.8)') 
    255 ; 
    256 lat=reform(gphit(0,0:jpj-1)) 
    257 lon=reform(glamt(0:jpi-1,0)) 
     301time=timegen(7670, start=julday(1,1,1989,0), units='days') ;+++ 
     302cda0=string(jul2date(time[0]),format='(i8.8)') 
     303cda1=string(jul2date(time[jpt-1]),format='(i8.8)') 
     304; 
     305lat=reform(gphit[0,0:jpj-1]) 
     306lon=reform(glamt[0:jpi-1,0]) 
    258307time=time-julday(1,1,1950) 
    259308jpt=n_elements(time) 
     
    266315sw_attr={units:'w/m^2',missing_value:1.e20,long_name:'Net Shortwave Radiation',short_name:'swr',axis:'TYX'} 
    267316; 
    268 ; 
    269317ncfields = 'sw[longitude,latitude,time]=rec:sw_attr; ' $ 
    270318                      + 'longitude[]=lon:lon_attr; ' $ 
     
    275323@ncdf_quickwrite 
    276324; 
     325result = 0 
     326return, result 
     327; 
    277328end 
Note: See TracChangeset for help on using the changeset viewer.