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

an other bunch of new functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/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 
Note: See TracChangeset for help on using the changeset viewer.