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