[ncl-talk] averaging over non-consecutive, user-inputted times
Walter Kolczynski
walter.kolczynski at noaa.gov
Thu Jun 4 20:26:02 MDT 2015
Mira,
If you want to pass in a literal array to subset, you need to use (/ ...
/), not just parenthesis.
uDJF_NAO_lo = uDJF((/10,11,12,16,24,26,43,44,57,58/),:,:)
- Walter
On 04-Jun-15 22:05, mberdahl at envsci.rutgers.edu wrote:
> Hi all,
>
> I have downloaded NCEP reanalysis winds (u and v), each with dimensions
> [time x lat x long]. The data runs from 1948 - current. I take the DJF
> seasonal average first. Next, I am trying to take an average of
> user-inputted, non-consecutive years. So for example, I'd like to take
> the average over, say, 1958, 1967, 1999 and 2001. I have used
> dim_avg_n_wrap to do averages before, but as far as I can see I can only
> choose a range of consecutive years with this. Is there a simple way to
> do this? Also, I manually convert the years to indices, but not sure
> that's the way to go.
>
> My code and some of the VarSummaries are copied here. I run into an error
> when trying to make a list of years at line 43
> (uDJF_NAO_lo = uDJF((10,11,12,16,24,26,43,44,57,58),:,:))
>
> Thanks!
> Mira
>
>
>
> ;****************************************************
> 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"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
> ;************************************************
> begin
> ;************************************************
> ; read in netCDF file
> ;************************************************
> a = addfile("uwnd.mon.mean.nc","r")
> print(a)
> b = addfile("vwnd.mon.mean.nc","r")
>
> ;************************************************
> ; read in zonal [u] and meridional [v] winds (July)
> ;************************************************
>
> u = a->uwnd(0:803,{45:90},{270:357.5})
> v = b->vwnd(0:803,{45:90},{270:357.5}) ; Get u, v, time (1),level
> (1000hpa),latitude(-90:90) and longitude(0:360) data.
>
> printVarSummary(u)
> printVarSummary(v)
>
> ; Calculate the seasonal averages.
> uDJF = month_to_season(u, "DJF")
> vDJF = month_to_season(v, "DJF")
>
> printVarSummary(uDJF)
> printVarSummary(vDJF)
>
> ; I want to average over these years.
> ; yearList_lo = 1963 1964 1965 1969 1977
> 1979 1996 1997 2010 2011
> ; this data starts at 1948 (this is index 0), so 1953=5, 1963=10 etc.
>
> uDJF_NAO_lo = uDJF((10,11,12,16,24,26,43,44,57,58),:,:)
>
>
> ;************************************************
> ; create plot
> ;************************************************
> wks = gsn_open_wks("ps","vector_") ; open a ps file
>
> vcres = True ; plot mods desired
> vcres at gsnAddCyclic = False;
> vcres at gsnFrame = False ; so we can draw time stamp
> vcres at vcRefAnnoOrthogonalPosF = -1.0 ; move ref vector up
> vcres at vcRefMagnitudeF = 10.0 ; define vector ref mag
> vcres at vcRefLengthF = 0.045 ; define length of vec ref
> vcres at vcGlyphStyle = "CurlyVector" ; turn on curly vectors
> vcres at vcMinDistanceF = 0.017
>
> ;************************************************
> ; Choose a subregion
> ;************************************************
> vcres at mpFillOn = False ; turn off gray fill
> vcres at mpOutlineBoundarySets = "National" ; turn on country boundaries
> vcres at mpGeophysicalLineColor = "Navy" ; color of cont. outlines
> vcres at mpGeophysicalLineThicknessF = 1.5 ; thickness of outlines
>
> vcres at mpMaxLatF = 90 ;maximum latitude
> vcres at mpMinLatF = 45 ;minimum latitude
> vcres at mpMaxLonF = 357.5 ;maximum longitude
> vcres at mpMinLonF = 270 ;minimum longitude
>
> vector = gsn_csm_vector_map_ce(wks,uAvgTime,vAvgTime,vcres)
>
> frame (wks)
> end
>
>
>
>
>
> *************************************************************
>
> Converted to chunked, deflated non-packed NetCDF4 2014/09
> title : monthly mean uwnd.sig995 from the NCEP Reanalysis
> dimensions:
> lat = 73
> lon = 144
> time = 808 // unlimited
> variables:
> float lat ( lat )
> units : degrees_north
> actual_range : ( 90, -90 )
> long_name : Latitude
> standard_name : latitude
> axis : Y
>
> float lon ( lon )
> units : degrees_east
> long_name : Longitude
> actual_range : ( 0, 357.5 )
> standard_name : longitude
> axis : X
>
> double time ( time )
> long_name : Time
> delta_t : 0000-01-00 00:00:00
> prev_avg_period : 0000-00-01 00:00:00
> standard_name : time
> axis : T
> units : hours since 1800-01-01 00:00:0.0
> actual_range : ( 1297320, 1886808 )
>
> float uwnd ( time, lat, lon )
> long_name : Monthly Mean Zonal Wind at sigma level 0.995
> valid_range : ( -102.2, 102.2 )
> units : m/s
> add_offset : 0
> scale_factor : 1
> missing_value : -9.96921e+36
> precision : 2
> least_significant_digit : 1
> var_desc : u-wind
> dataset : CDC Derived NCEP Reanalysis Products
> level_desc : Surface
> statistic : Mean
> parent_stat : Other
> actual_range : ( -18.83935, 18.80581 )
> _FillValue : -9.96921e+36
>
>
> Variable: u
> Type: float
> Total Size: 2199744 bytes
> 549936 values
> Number of Dimensions: 3
> Dimensions and sizes: [time | 804] x [lat | 19] x [lon | 36]
> Coordinates:
> time: [1297320..1883904]
> lat: [45..90]
> lon: [270..357.5]
> Number Of Attributes: 15
> long_name : Monthly Mean Zonal Wind at sigma level 0.995
> valid_range : ( -102.2, 102.2 )
> units : m/s
> add_offset : 0
> scale_factor : 1
> missing_value : -9.96921e+36
> precision : 2
> least_significant_digit : 1
> var_desc : u-wind
> dataset : CDC Derived NCEP Reanalysis Products
> level_desc : Surface
> statistic : Mean
> parent_stat : Other
> actual_range : ( -18.83935, 18.80581 )
> _FillValue : -9.96921e+36
>
> Variable: v
> Type: float
> Total Size: 2199744 bytes
> 549936 values
> Number of Dimensions: 3
> Dimensions and sizes: [time | 804] x [lat | 19] x [lon | 36]
> Coordinates:
> time: [1297320..1883904]
> lat: [45..90]
> lon: [270..357.5]
> Number Of Attributes: 15
> long_name : Monthly Mean Meridional Wind at sigma level 0.995
> valid_range : ( -102.2, 102.2 )
> units : m/s
> add_offset : 0
> scale_factor : 1
> missing_value : -9.96921e+36
> precision : 2
> least_significant_digit : 1
> var_desc : v-wind
> dataset : CDC Derived NCEP Reanalysis Products
> level_desc : Surface
> statistic : Mean
> parent_stat : Other
> actual_range : ( -15.43516, 19.79167 )
> _FillValue : -9.96921e+36
>
> Variable: uDJF
> Type: float
> Total Size: 183312 bytes
> 45828 values
> Number of Dimensions: 3
> Dimensions and sizes: [time | 67] x [lat | 19] x [lon | 36]
> Coordinates:
> time: [1297320..1875888]
> lat: [45..90]
> lon: [270..357.5]
> Number Of Attributes: 16
> long_name : DJF: Monthly Mean Zonal Wind at sigma level 0.995
> valid_range : ( -102.2, 102.2 )
> units : m/s
> add_offset : 0
> scale_factor : 1
> missing_value : -9.96921e+36
> precision : 2
> least_significant_digit : 1
> var_desc : u-wind
> dataset : CDC Derived NCEP Reanalysis Products
> level_desc : Surface
> statistic : Mean
> parent_stat : Other
> actual_range : ( -18.83935, 18.80581 )
> _FillValue : -9.96921e+36
> NMO : 0
>
> Variable: vDJF
> Type: float
> Total Size: 183312 bytes
> 45828 values
> Number of Dimensions: 3
> Dimensions and sizes: [time | 67] x [lat | 19] x [lon | 36]
> Coordinates:
> time: [1297320..1875888]
> lat: [45..90]
> lon: [270..357.5]
> Number Of Attributes: 16
> long_name : DJF: Monthly Mean Meridional Wind at sigma level 0.995
> valid_range : ( -102.2, 102.2 )
> units : m/s
> add_offset : 0
> scale_factor : 1
> missing_value : -9.96921e+36
> precision : 2
> least_significant_digit : 1
> var_desc : v-wind
> dataset : CDC Derived NCEP Reanalysis Products
> level_desc : Surface
> statistic : Mean
> parent_stat : Other
> actual_range : ( -15.43516, 19.79167 )
> _FillValue : -9.96921e+36
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
--
Walter Kolczynski, Jr.
Global Ensemble Team
NOAA/NWS/NCEP/EMC (via I.M. Systems Group)
(301) 683-3781
More information about the ncl-talk
mailing list