;*******************************************
; Create daily averages
;*******************************************
    ntJump  = 8
    x       = x3(::ntJump,:,:)       ; trick: create array with meta
    printVarSummary(x)               ; values will be overwritten with 
averages
    ntStrt  = 0
    ntLast  = ntJump-1
    do nt=0,NTIM-1,8                                            ; 
dim_avg_n v5.1.1
       x(nt/8,:,:) = (/ dim_avg_n(x(ntStrt:ntLast,:,:), 0) /)   ; 
(/.../) ignore meta
    end do
    x_at_info_tag     = "daily average"
DJ Rasmussen wrote:
> Hello,
>
> I have been trying to compute daily averages from 3 hourly data for an 
> entire year and have been having trouble getting NCL to correctly do the 
> calculations.  My code runs with out errors, but it still plots all 1095 
> 3 hours times for the entire year.  I apologize for not having any 
> Fortran coding experience, but I think I am getting closer to getting 
> this to work correctly.  I have received some assistance to get to this 
> point, but after playing with my code for a while, I am stuck again at 
> square one.  I have stripped it of calculating both components just to 
> keep it simple.
>
> Below is my NCL filedump and my NCL code.
>
> I am using NCL v5.1.1, the latest version.
>
> Here is my filedump:
>
> filename:       uas_CRCM_2038010103
> path:   uas_CRCM_2038010103.nc
>    file global attributes:
>       Conventions : CF-1.0
>       institution : Ouranos (Ouranos, Montreal, PQ, Canada)
>       source : CRCM(2006):atmosphere:CRCMv4.2.0(50km,29levels):sea 
> ice:AMIPII:land:CLASSv2.7
>       project_id : NARCCAP
>       realization : 1
>       experiment_id : 2038-2070 climate simulation using CGCM3 member #4 
> (mc_abv experiment)
>       experiment_id2 : Ouranos operational simulation afs
>       contact1 : Sebastien Biner
>       contact2 : biner.sebastien_at_ouranos.ca
>       contact3 : 550 Sherbrooke Ouest, 19e etage, Montreal, PQ, H3A 1B9, 
> Canada
>       contact4 : tel : (514)282.6464 poste 263
>       history : Tue Feb  3 19:51:48 2009: ncrename -a 
> conventions,Conventions table2/uas_CRCM_2038010103.nc
> Mon Dec 15 19:49:09 2008: ncatted -a experiment_id,global,m,c,2038-2070 
> climate simulation using CGCM3 member #4 (mc_abv experiment) 
> 4_NETCDF_FINAUX/uas_CRCM_2038010103.nc
> created 24/04/2004 by Ton Nom (netCDF3.6.1 udunits1.12.4)
>       table_id : Table 2
>    dimensions:
>       ncl_scalar = 1
>       xc = 140
>       yc = 115
>       time = 8760  // unlimited
>    variables:
>       double level ( ncl_scalar )
>          units :        m
>          long_name :    height
>          axis : Z
>          positive :     up
>          coordinate_defines :   point
>          actual_range : ( 10, 10 )
>  
>       double yc ( yc )
>          units :        m
>          long_name :    y-coordinate of polar_stereographic projection
>          standard_name :        projection_y_coordinate
>          axis : Y
>          coordinate_defines :   point
>          actual_range : (  0, 5700000 )
>  
>       double xc ( xc )
>          units :        m
>          long_name :    x-coordinate of polar_stereographic projection
>          standard_name :        projection_x_coordinate
>          axis : X
>          coordinate_defines :   point
>          actual_range : (  0, 6950000 )
>  
>       double time ( time )
>          long_name :    time
>          calendar :     365_day
>          standard_name :        time
>          axis : T
>          units :        days since 2038-01-01 00:00:0.0
>          delta_t :      0000-00-00 03:00:00
>          coordinate_defines :   point
>          actual_range : ( 0.125, 1095 )
>  
>       double lon ( yc, xc )
>          units :        degrees_east
>          long_name :    longitude
>          standard_name :        longitude
>          axis : X
>          actual_range : ( 199.8962, 326.4349 )
>  
>       double lat ( yc, xc )
>          units :        degrees_north
>          long_name :    latitude
>          standard_name :        latitude
>          axis : Y
>          actual_range : ( 20.60496, 73.2522 )
>  
>       character polar_stereographic ( ncl_scalar )
>          straight_vertical_longitude_from_pole :         263
>          standard_parallel :      60
>          false_easting :        3450000
>          false_northing :       7450000
>          latitude_of_projection_origin :          90
>          grid_mapping_name :    polar_stereographic
>          resolution_at_standard_parallel :      50000
>          earth_radius : 6371000
>  
>       float uas ( time, yc, xc )
>          units :        m s-1
>          type : instantaneaous
>          long_name :    Zonal Surface Wind Speed
>          standard_name :        eastward_wind 
>          missing_value :        1e+20
>          _FillValue :   1e+20
>          actual_range : ( -38.31223, 37.18084 )
>          add_offset :    0
>          scale_factor :  1
>          coordinates :  lon lat level
>          grid_mapping : polar_stereographic
>          level_desc :   10 m
>          grid_desc :    polar_stereographic
>
> The NCL code:
>
> ;*********************************************************************
> ; Calculate the Daily Average
> ;*********************************************************************
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>
> begin
>
> ;************************************************************
> ; open files and read in desired variables
> ;************************************************************
>
>   CtmDir = "/home/rasmussen/NARCCAP/"
>   appl   = "uas_CRCM_2038010103"
>   f      = addfile(CtmDir+appl+".nc","r")
>   arr_u      = f->uas
>
> ;************************************************************
> ; compute daily averages for u wind components
> ;************************************************************
>
> dimarr_u=dimsizes(arr_u)
> ntim=dimarr_u(0)
> nlat=dimarr_u(1)
> nlon=dimarr_u(2)
>
>
> ;for u...
>     nave = 8
>     opt  = 0
>     avg_u  = runave_Wrap(arr_u(xc|:,yc|:,time|:), nave, opt) ; Average 
> every 8 data points for u comp.
>
>
> delete(arr_u)
> fin_avg_u=avg_u(time|0::8,yc|:,xc|:)    ;take first time and last time 
> and step by 8 to get daily averages.
> delete(avg_u)
>
>   name      = "AvgWnd2038_CRCM"
>   type      = "pdf"
>   wks       = gsn_open_wks(type,name)  
>
> res                        = True               ; plot mods desired
>
> res_at_tiMainString      = "Daily Average Wind Speeds"
> res_at_tiXAxisString = "Day of Year 2035-2040"
> res_at_tiYAxisString = "Wind Speed ms-1"
> res_at_trXMaxF           =  365         ; axis max
> res_at_trXMinF           = 0                  ; axis min
> res_at_tmYRLabelsOn         = False        ; turn on right axis labels
> res_at_tmYUseLeft           = False          ; don't use any left settings
> res_at_tmYRAutoPrecision    = False          ; no auto precisioun
> res_at_gsnPaperOrientation  = True
> res_at_gsnMaximize          = True
> res_at_tmYRPrecision        = 4        ; set the precision 
>
>
>   plot = gsn_csm_y(wks,fin_avg_u(:,42,23),res)  ;plot desired grid point 
> with time averages.
>
> end
>
>
>   
-- ====================================================== Dennis J. Shea tel: 303-497-1361 | P.O. Box 3000 fax: 303-497-1333 | Climate Analysis Section | Climate & Global Dynamics Div. | National Center for Atmospheric Research | Boulder, CO 80307 | USA email: shea 'at' ucar.edu | ====================================================== _______________________________________________ ncl-talk mailing list List instructions, subscriber options, unsubscribe: http://mailman.ucar.edu/mailman/listinfo/ncl-talkReceived on Thu Jul 02 2009 - 11:53:51 MDT
This archive was generated by hypermail 2.2.0 : Tue Jul 07 2009 - 11:13:18 MDT