Changeset 165


Ignore:
Timestamp:
03/19/12 17:22:36 (12 years ago)
Author:
pinsard
Message:

interp_erai_msl i now a function

Location:
trunk
Files:
4 edited
1 moved

Legend:

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

    r157 r165  
    99.. 
    1010.. pb with math directives on aedon : probably some latex installation pb 
     11.. 
     12.. ref to tropflux.sh covering the 3 last steps 
     13.. 
    1114.. 
    1215.. EVOLUTIONS 
     
    100103 - :ref:`interp_erai_lwr_1989_2009.pro` 
    101104 - :ref:`interp_erai_sst_1989_2009.pro` 
    102  - :ref:`interp_erai_msl_1989_2009.pro` 
     105 - :func:`interp_erai_msl.pro` 
    103106 - :func:`interp_erai_t2m` 
    104107 - :ref:`interp_erai_ws_1989_2009.pro` 
  • trunk/src/d2m_to_q2m_erai.pro

    r155 r165  
    7575; 
    7676; :ref:`interp_erai_dewt_1989_2009.pro` 
    77 ; :ref:`interp_erai_msl_1989_2009.pro` 
     77; :func:`interp_erai_msl` 
    7878; :func:`interp_erai_t2m` 
    7979; 
  • trunk/src/interp_erai_msl.pro

    r163 r165  
    11;+ 
    22; 
    3 ; .. _interp_erai_msl_1989_2009.pro: 
    4 ; 
    5 ; ============================= 
    6 ; interp_erai_msl_1989_2009.pro 
    7 ; ============================= 
     3; =================== 
     4; interp_erai_msl.pro 
     5; =================== 
     6; 
     7; .. function:: interp_erai_msl(yyyymmddb,yyyymmdde) 
    88; 
    99; DESCRIPTION 
     
    2626; Interpolated msl 
    2727; is written in 
    28 ; :file:`${PROJECT_OD}/erai_msl_19890101_20091231_oafluxgrid.nc` 
     28; :file:`${PROJECT_OD}/erai_msl_{yyyymmdd}_{yyyymmdd}_oafluxgrid.nc` 
    2929; if this file not already exists. 
    3030; 
    3131; This output file 
    32 ; :file:`${PROJECT_OD}/erai_msl_19890101_20091231_oafluxgrid.nc` 
     32; :file:`${PROJECT_OD}/erai_msl_{yyyymmdd}_{yyyymmdd}_oafluxgrid.nc` 
    3333; must be processed after by 
    3434; :ref:`d2m_to_q2m_erai.pro`. 
     
    4242;     .. graphviz:: 
    4343; 
    44 ;        digraph interp_erai_msl_1989_2009 { 
     44;        digraph interp_erai_msl { 
    4545; 
    4646;           file_in [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/20c3m_erai_msl_TROP_1989_2009.nc"]; 
    4747;           mask [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/mask_oaflux_30N30S.nc"]; 
    48 ;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_msl_19890101_20091231_oafluxgrid.nc"]; 
    49 ; 
    50 ;           interp_erai_msl_1989_2009 [shape=box, 
     48;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_msl_{yyyymmdd}_{yyyymmdd}_oafluxgrid.nc"]; 
     49; 
     50;           interp_erai_msl [shape=box, 
    5151;           fontname=Courier, 
    5252;           color=blue, 
    53 ;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/interp_erai_msl_1989_2009.pro", 
    54 ;           label="${PROJECT}/src/interp_erai_msl_1989_2009.pro"]; 
    55 ; 
    56 ;           {file_in mask} -> {interp_erai_msl_1989_2009} -> {file_out} 
     53;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/interp_erai_msl.pro", 
     54;           label="${PROJECT}/src/interp_erai_msl.pro"]; 
     55; 
     56;           {file_in mask} -> {interp_erai_msl} -> {file_out} 
    5757; 
    5858;        } 
     
    6464; 
    6565; :ref:`project_profile.sh` 
     66; 
     67; Used by :ref:`tropflux.sh` 
    6668; 
    6769; :func:`report <saxo:report>` 
     
    8284; 
    8385;  IDL> .compile file_interp 
    84 ;  IDL> interp_erai_msl_1989_2009 
     86;  IDL> yyyymmddb = 20000101 
     87;  IDL> yyyymmdde = 20000302 
     88;  IDL> result = interp_erai_msl(yyyymmddb, yyymmdde) 
     89;  IDL> print, result 
    8590; 
    8691; TODO 
    8792; ==== 
    8893; 
    89 ; use real output of :ref:`compute_erai_daily_region_2d.sh`. 
     94; use real output of :ref:`compute_erai_daily_region_2d.sh` 
     95; 
     96; get_erai.py + grib to netcdf conversion 
    9097; 
    9198; msl_attr={units:'milibars' .. millibar at least, hPa will be probably 
    9299; more SI 
    93100; 
    94 ; why 19880101,20100930 as dates 
     101; why 19880101,20100930 as dates in read_ncdf. 
     102; now (20120319) should be yyyymmddb and yyymmdde but desastrous side effect 
    95103; 
    96104; first step time 14245.5 (days since 1950-01-01 00:00:00) : correct ? 
     
    105113; ========== 
    106114; 
    107 ; $Id: interp_erai_msl_1989_2009.pro 88 2011-08-19 15:40:14Z pinsard $ 
     115; $Id: interp_erai_msl.pro 88 2011-08-19 15:40:14Z pinsard $ 
    108116; 
    109117; $URL$ 
     118; 
     119; - fplod 20120319 
     120; 
     121;   * taking project_overwite into account 
     122;   * pro -> function 
    110123; 
    111124; - pinsard 2011-08-23T09:09:16Z loholt1.ipsl.polytechnique.fr (Linux) 
     
    131144; 
    132145;- 
    133 pro interp_erai_msl_1989_2009 
     146function interp_erai_msl $ 
     147         , yyyymmddb $ 
     148         , yyyymmdde 
     149; 
     150;++compile_opt idl2, strictarrsubs, logical_predicate 
    134151; 
    135152@cm_4cal 
     
    139156@cm_project 
    140157; 
     158; Return to caller if errors 
     159ON_ERROR, 2 
     160; 
     161result = -1 
     162; 
     163usage = 'result = interp_erai_msl(yyyymmddb, yyyymmdde) 
     164nparam = N_PARAMS() 
     165IF (nparam NE 2) THEN BEGIN 
     166   ras = report(['Incorrect number of arguments.' $ 
     167   + '!C' $ 
     168   + 'Usage : ' + usage]) 
     169   return, result 
     170ENDIF 
     171; 
    141172; check for input directory 
    142173; 
     
    146177     msg = 'eee : ${PROJECT_ID} is not defined' 
    147178     ras = report(msg) 
    148      STOP 
     179     return, result 
    149180           END 
    150181 ELSE: BEGIN 
     
    160191   msg = 'eee : the directory' + iodirin  + ' is not accessible.' 
    161192   ras = report(msg) 
    162    STOP 
     193   return, result 
    163194ENDIF 
    164195; 
     
    173204   msg = 'eee : the file ' + fullfilename_msk + ' was not found.' 
    174205   ras = report(msg) 
    175    STOP 
     206   return, result 
    176207ENDIF 
    177208; 
     
    186217   msg = 'eee : the file ' + fullfilename + ' was not found.' 
    187218   ras = report(msg) 
    188    STOP 
     219   return, result 
    189220ENDIF 
    190221; 
     
    194225         msg = 'eee : ${PROJECT_OD} is not defined' 
    195226         ras = report(msg) 
    196        STOP 
     227       return, result 
    197228       END 
    198229  ELSE: BEGIN 
     
    209240    msg = 'eee : the directory' + iodirout  + ' was not found.' 
    210241    ras = report(msg) 
    211     STOP 
     242    return, result 
    212243ENDIF 
    213244; 
    214245; build output filename 
    215 filename_out = 'erai_msl_19890101_20091231_oafluxgrid.nc' 
     246filename_out = 'erai_msl_' +  string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '_oafluxgrid.nc' 
    216247fullfilename_out = iodirout + filename_out 
    217248; in order to avoid unexpected overwritten 
    218 IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN 
     249IF ((FILE_TEST(fullfilename_out) EQ 1)  AND (project_overwrite EQ 0)) THEN BEGIN 
    219250   msg = 'eee : the file ' + fullfilename_out  + ' already exists.' 
    220251   ras = report(msg) 
    221    STOP 
     252   return, result 
    222253ENDIF 
    223254; 
    224255initncdf, fullfilename 
    225256domdef 
    226 latin=reform(gphit(0,*)) 
    227 lonin=reform(glamt(*,0)) 
    228 print, 'lat grid ',min(latin),max(latin),latin(1)-latin(0) 
    229 print, 'lon grid ',min(lonin),max(lonin),lonin(1)-lonin(0) 
     257latin=reform(gphit[0,*]) 
     258lonin=reform(glamt[*,0]) 
     259print, 'lat grid ',min(latin),max(latin),latin[1]-latin[0] 
     260print, 'lon grid ',min(lonin),max(lonin),lonin[1]-lonin[0] 
     261;++mslin=read_ncdf("msl",yyyymmddb,yyymmdde,file=fullfilename,/nostr) 
    230262mslin=read_ncdf("msl",19880101,20100930,file=fullfilename,/nostr) 
     263; 
    231264; 
    232265timein=time 
    233266jptin=jpt 
    234 tab=mslin(*,*,0) 
     267tab=mslin[*,*,0] 
    235268mskin=glamt*0.+1. 
    236269; 
    237270initncdf, fullfilename_msk 
    238271domdef 
    239 latout=reform(gphit(0,*)) 
    240 lonout=reform(glamt(*,0)) 
    241 print, 'lat grid ',min(latout),max(latout),latout(1)-latout(0) 
    242 print, 'lon grid ',min(lonout),max(lonout),lonout(1)-lonout(0) 
     272latout=reform(gphit[0,*]) 
     273lonout=reform(glamt[*,0]) 
     274print, 'lat grid ',min(latout),max(latout),latout[1]-latout[0] 
     275print, 'lon grid ',min(lonout),max(lonout),lonout[1]-lonout[0] 
    243276mskout=read_ncdf("msk", file=fullfilename_msk,/nostr) 
    244277; 
     
    252285        msg = 'eee : ' + units + ' unknown' 
    253286        ras = report(msg) 
    254         STOP 
     287        return, result 
    255288    END 
    256289ENDCASE 
     
    261294for jt=0,jptin-1 do begin 
    262295  ; ++ print, 'Interpolation jt=',jt,' / ',jptin-1 
    263   tab=reform(mslin(*,*,jt)) 
    264   mslout(*,*,jt)=call_interp2d(tab,lonin,latin,mskin $ 
     296  tab=reform(mslin[*,*,jt]) 
     297  mslout[*,*,jt]=call_interp2d(tab,lonin,latin,mskin $ 
    265298      , lonout,latout,method='bilinear' $ 
    266299      , OUTMASK_IND=mskout, SET_OUTMSKVAL=mskout) 
    267   mslout(*,*,jt)=mslout(*,*,jt)*mskout+(1.-mskout)*1.e20 
     300  mslout[*,*,jt]=mslout[*,*,jt]*mskout+(1.-mskout)*1.e20 
    268301endfor 
    269302; 
    270303initncdf, fullfilename_msk 
    271304time=timegen(jptin, start=julday(1,1,1989,0), units='days') 
    272 cda0=string(jul2date(time(0)),format='(i8.8)') 
     305cda0=string(jul2date(time[0]),format='(i8.8)') 
    273306cda1=string(jul2date(time(jpt-1)),format='(i8.8)') 
    274307timein=time-julday(1,1,1950,00,00) 
  • trunk/src/interp_erai_t2m.pro

    r164 r165  
    55; =================== 
    66; 
    7 ; .. function interp_erai_t2m(yyyymmddb,yyyymmdde) 
     7; .. function:: interp_erai_t2m(yyyymmddb,yyyymmdde) 
    88; 
    99; DESCRIPTION 
     
    6161; 
    6262; :ref:`interpolate_data` 
     63; 
     64; Used by :ref:`tropflux.sh` 
    6365; 
    6466; :ref:`project_profile.sh` 
     
    260262         + '!C' $ 
    261263         + 'Usage : ' + usage]) 
    262    return, -1 
     264   return, result 
    263265ENDIF 
    264266 
  • trunk/src/tropflux.sh

    r164 r165  
    6161# 
    6262# You already used :ref:`get_erai.sh` to get ERAI data, etc., 
    63 # during [20060801, 20060802[ and you want to produce NetCDF files:: 
    64 # 
    65 #   $ tropflux.sh -b 20060801 -e 20060802 
     63# during [20000101, 20000302[ and you want to produce NetCDF files:: 
     64# 
     65#   $ tropflux.sh -b 20000101 -e 20000302 
    6666# 
    6767# A more global example:: 
     
    8989# 
    9090# Use : 
    91 # :func:`oaflux_mask_30n30s`, :func:`inter_erai_t2m`, etc. 
     91# :func:`oaflux_mask_30n30s`, :func:`interp_erai_t2m`,  
     92# :func:`interp_erai_msl`, etc. 
    9293# 
    9394# Next step : +validation ++ comparison 
     
    114115# 
    115116#   * add project_overwrite usage 
     117#   * handling error of inter_erai_msl (now function) 
    116118# 
    117119# - pinsard 20120306 
     
    162164# default 
    163165debug=0 
    164 yyyymmddb=20060420 
    165 yyyymmdde=20060420 
     166yyyymmddb=20000101 
     167yyyymmdde=20000302 
    166168# 
    167169minargcount=4 
     
    296298;interp_erai_dewt_1989_2009 
    297299;interp_erai_lwr_1989_2009 
    298 ;interp_erai_msl_1989_2009 
     300result = interp_erai_msl(${yyyymmddb}, ${yyyymmdde}) 
     301IF result < 0 THEN BEGIN 
     302   msg = 'eee : pb after interp_erai_msl' + string(result) 
     303   err = report(msg) 
     304   exit 
     305ENDIF 
    299306;interp_erai_sst_1989_2009 
    300307result = interp_erai_t2m(${yyyymmddb}, ${yyyymmdde}) 
Note: See TracChangeset for help on using the changeset viewer.