<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif">Mira, </div><div class="gmail_default" style="font-family:verdana,sans-serif">Alex's suggestion works and a lot of code in NCL uses the same method to copy metadata between variables. </div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">For a more explicit route, when you subtract variables and define a new variable at the same time the metadata is not carried over to the new variable. Look at your printVarSummary of diff_u there is no information attached to the variable. </div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">Alex's approach will copy over all the metadata, therefore some data (e.g. longname) will be incorrect. diff_u longname should now be something more like "DJF Zonal Wind difference at sigma level 0.995". Though for plotting all NCL needs is coordinates information. </div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">Therefore based on your original script, I'd add 2 lines as below.</div><div class="gmail_default" style="font-family:verdana,sans-serif"><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:13px">diff_u = uAvgTime_hi - uAvgTime_lo</span><br style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:13px"><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:13px">diff_v = vAvgTime_hi - vAvgTime_lo</span><br></div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">copy_VarCoords(<span style="color:rgb(0,0,0);font-size:13px;font-family:arial,sans-serif">uAvgTime_hi, diff_u)</span></div><div class="gmail_default" style="font-family:verdana,sans-serif">copy_VarCoords(v<span style="font-size:13px;color:rgb(0,0,0);font-family:arial,sans-serif">AvgTime_hi, diff_v)</span><span style="color:rgb(0,0,0);font-size:13px;font-family:arial,sans-serif"><br></span></div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">This will copy the latitude and longitude information to the new variables, so NCL will know where to plot the data. <br></div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">Alan.</div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 9 June 2015 at 16:42, <span dir="ltr"><<a href="mailto:mberdahl@envsci.rutgers.edu" target="_blank">mberdahl@envsci.rutgers.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Alex,<br>
I just tried and the spacing looks to be right now! Thanks very much! The<br>
only thing I don't understand what you mean is to change the long names.<br>
Thanks!<br>
Mira<br>
<div class="HOEnZb"><div class="h5"><br>
> Mira,<br>
><br>
> I don’t know the example pages well so I can’t really point to a specific<br>
> code example but usually lat and lon are stored in your netcdf file just<br>
> like every other variable.<br>
><br>
> Here is a way we can cheat the system as long as your lats/lons don’t<br>
> change (logically easier but not exactly proper).<br>
><br>
> You should be able to set diff_u = uAvgTime_hi so that all of the metadata<br>
> is copied over to the new variable. The issue with this is you would need<br>
> to change long names and other stuff for completeness. After you do that<br>
> you can do you subtraction and all the metadata should remain with the<br>
> variable: diff_u = uAvgTime_hi - uAvgTime_lo. Similarly done for diff_v.<br>
><br>
> Not the clean way of doing it but I’m not the best when pulling variables<br>
> using the named dimension convention, i.e. specifying the lat/lon ranges.<br>
> Maybe one of the NCAR folks can provide some insight to using that way.<br>
><br>
> This way however should get you what you need with regards to lats/lons<br>
> being associated with your data and hopefully get your plot working.<br>
><br>
> Hope that helps,<br>
> -Alex<br>
><br>
><br>
> On Jun 9, 2015, at 1:34 PM, <a href="mailto:mberdahl@envsci.rutgers.edu">mberdahl@envsci.rutgers.edu</a> wrote:<br>
><br>
>><br>
>> Hi Alex,<br>
>> Thanks for the suggestion. I was wondering if it had anything to do<br>
>> with<br>
>> that. When you say pull the lat Lon, I'm not exactly sure what you mean<br>
>> to do. Do you have an example to point me to?<br>
>> Thanks!<br>
>> Mira<br>
>>> Mira,<br>
>>><br>
>>> You have lost your lats/lons in the subtraction. It may have something<br>
>>> to<br>
>>> do with that. You might want to pull them in at the beginning and then<br>
>>> associate them with diff_u and diff_v using:<br>
>>><br>
>>> diff_u@lon2d = lon<br>
>>> diff_u@lat2d = lat<br>
>>><br>
>>> diff_v@lon2d = lon<br>
>>> diff_v@lat2d = lat<br>
>>><br>
>>> Just pull the lats and lons on the same subsection that you are pulling<br>
>>> u/v.<br>
>>><br>
>>> -Alex<br>
>>><br>
>>> On Mon, Jun 8, 2015 at 9:30 PM, <<a href="mailto:mberdahl@envsci.rutgers.edu">mberdahl@envsci.rutgers.edu</a>> wrote:<br>
>>><br>
>>>> Hi Alex,<br>
>>>> I changed it so the vectors were appropriately sized. I just tried<br>
>>>> the<br>
>>>> script with removing the second Magnitude definition and the spacing<br>
>>>> is<br>
>>>> still the same. Any other thoughts?<br>
>>>> Mira<br>
>>>>> Mira,<br>
>>>>><br>
>>>>> Why did you change vcres@vcRefMagnitudeF = 10.0 to<br>
>>>> vcres@vcRefMagnitudeF<br>
>>>> =<br>
>>>>> 1.0 after the first 2 plots were made? This is likely what is<br>
>>>>> causing<br>
>>>> the<br>
>>>>> difference.<br>
>>>>><br>
>>>>> -Alex<br>
>>>>><br>
>>>>> On Mon, Jun 8, 2015 at 8:12 PM, <<a href="mailto:mberdahl@envsci.rutgers.edu">mberdahl@envsci.rutgers.edu</a>> wrote:<br>
>>>>><br>
>>>>>> Hi all,<br>
>>>>>> I have a 3 panel plot which shows the winds over a region. The<br>
>>>>>> first<br>
>>>>>> two<br>
>>>>>> panels show averages for selected years, and the third panel shows<br>
>>>> the<br>
>>>>>> difference between the top 2 panels. My problem is that the spacing<br>
>>>> of<br>
>>>>>> wind vectors is much denser in the first two plots than the third<br>
>>>>>> "difference" plot. Is there a reason why the grid spacing would<br>
>>>>>> suddenly<br>
>>>>>> be different (more sparse) when displaying the difference of two<br>
>>>>>> wind<br>
>>>>>> fields? The sizes (dimensions) of the u and v fields remain the<br>
>>>>>> same<br>
>>>>>> for<br>
>>>>>> each panel.<br>
>>>>>> My script and the VarSummaries for some of the variables are below.<br>
>>>>>> I will try to attach the pdf of the figure here if possible.<br>
>>>>>> Thanks very much for any help.<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>
>>>>>> ; to take the average over the first dimensions (time)<br>
>>>>>> ;uAvgTime = dim_avg_n_Wrap(u,0)<br>
>>>>>> ;vAvgTime = dim_avg_n_Wrap(v,0)<br>
>>>>>><br>
>>>>>> ;printVarSummary(vAvgTime)<br>
>>>>>> ;printVarSummary(uAvgTime)<br>
>>>>>><br>
>>>>>> ; calculate speed from u and v components<br>
>>>>>> ;speed = sqrt(uAvgTime^2+vAvgTime^2)<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>
>>>>>> ; from the matlab script i wrote: findExtremeYrs, i pulled out the<br>
>>>>>> extreme<br>
>>>>>> years (> or < 1std) that i want to average and plot here.<br>
>>>>>><br>
>>>>>> ; for ans = 4 (NAO)<br>
>>>>>> ; yearList_hi = 1973 1975 1983 1989 1995<br>
>>>>>> 2000 2007 2012<br>
>>>>>> ; yearList_lo = 1963 1964 1965 1969 1977<br>
>>>>>> 1979 1996 1997 2010 2011<br>
>>>>>><br>
>>>>>> ; ans = 5 (pressure)<br>
>>>>>> ;yearList_hi = 1963 1965 1968 1969 1970<br>
>>>>>> 1971 1977 1997 2006 2011<br>
>>>>>> ;yearList_lo = 1973 1989 1990 1991 1995<br>
>>>>>> 1999 2000 2007 2012<br>
>>>>>><br>
>>>>>> ;ans = 7 (longitude of IL)<br>
>>>>>> ;yearList_hi =1966 1967 1968 1969 1974<br>
>>>>>> 1975 1983 1994 1995 2005<br>
>>>>>> ;yearList_lo =1963 1964 1985 1987 1991<br>
>>>>>> 1992 1996 2002 2003 2006 2009<br>
>>>>>><br>
>>>>>><br>
>>>>>> ; this data starts at 1948 (this is index 0), so 1953=5, 1963=10<br>
>>>>>> etc.<br>
>>>>>><br>
>>>>>> uDJF_NAO_lo = uDJF((/10,11,12,16,24,26,43,44,57,58/),:,:)<br>
>>>>>> uDJF_NAO_hi = uDJF((/20,22,30,36,42,47,54,59/),:,:)<br>
>>>>>><br>
>>>>>> vDJF_NAO_lo = vDJF((/10,11,12,16,24,26,43,44,57,58/),:,:)<br>
>>>>>> vDJF_NAO_hi = vDJF((/20,22,30,36,42,47,54,59/),:,:)<br>
>>>>>><br>
>>>>>> uAvgTime_hi = dim_avg_n_Wrap(uDJF_NAO_hi,0)<br>
>>>>>> uAvgTime_lo = dim_avg_n_Wrap(uDJF_NAO_lo,0)<br>
>>>>>><br>
>>>>>> printVarSummary(uAvgTime_hi)<br>
>>>>>> printVarSummary(uAvgTime_lo)<br>
>>>>>><br>
>>>>>> vAvgTime_hi = dim_avg_n_Wrap(vDJF_NAO_hi,0)<br>
>>>>>> vAvgTime_lo = dim_avg_n_Wrap(vDJF_NAO_lo,0)<br>
>>>>>><br>
>>>>>> printVarSummary(vAvgTime_hi)<br>
>>>>>> printVarSummary(vAvgTime_lo)<br>
>>>>>><br>
>>>>>><br>
>>>>>><br>
>>>>>> ;************************************************<br>
>>>>>> ; create plot<br>
>>>>>> ;************************************************<br>
>>>>>> wks = gsn_open_wks("eps","Panel_NAO") ; open a ps file<br>
>>>>>> plot = new(3,graphic) ; create a plot<br>
>>>>>> array<br>
>>>>>><br>
>>>>>> vcres = True<br>
>>>>>> vcres@gsnDraw = False ; dont draw<br>
>>>>>> vcres@gsnFrame = False ; dont advance frame<br>
>>>>>> vcres@cnInfoLabelOn = False ; trn off cn info<br>
>>>> label<br>
>>>>>><br>
>>>>>> vcres = True ; plot mods desired<br>
>>>>>> vcres@gsnAddCyclic = False ; has to do with<br>
>>>>>> wrapping<br>
>>>>>> the longitude at 0/360<br>
>>>>>> vcres@vcRefAnnoOrthogonalPosF = -1.0 ; move ref vector up<br>
>>>>>> vcres@vcRefMagnitudeF = 10.0 ; define vector ref<br>
>>>> mag<br>
>>>>>> vcres@vcRefLengthF = 0.045 ; define length of<br>
>>>> vec<br>
>>>>>> ref<br>
>>>>>> vcres@vcGlyphStyle = "CurlyVector" ; turn on curly<br>
>>>> 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<br>
>>>>>> boundaries<br>
>>>>>> vcres@mpGeophysicalLineColor = "Navy" ; color of cont.<br>
>>>>>> outlines<br>
>>>>>> vcres@mpGeophysicalLineThicknessF = 1.5 ; thickness of<br>
>>>> 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>
>>>>>> diff_u = uAvgTime_hi - uAvgTime_lo<br>
>>>>>> diff_v = vAvgTime_hi - vAvgTime_lo<br>
>>>>>><br>
>>>>>> printVarSummary(diff_u)<br>
>>>>>> printVarSummary(diff_v)<br>
>>>>>><br>
>>>>>> vcres@gsnLeftString = "DJF High NAO"<br>
>>>>>> plot(0) = gsn_csm_vector_map_ce(wks,uAvgTime_hi,vAvgTime_hi,vcres)<br>
>>>>>><br>
>>>>>> vcres@gsnLeftString = "DJF Low NAO"<br>
>>>>>> plot(1) = gsn_csm_vector_map_ce(wks,uAvgTime_lo,vAvgTime_lo,vcres)<br>
>>>>>><br>
>>>>>><br>
>>>>>> vcres@vcRefMagnitudeF = 1.0 ; define vector ref<br>
>>>> mag<br>
>>>>>> vcres@vcRefLengthF = 0.045 ; define length of<br>
>>>> vec<br>
>>>>>> ref<br>
>>>>>> vcres@gsnLeftString = "Difference of High - Low"<br>
>>>>>> plot(2) = gsn_csm_vector_map_ce(wks, diff_u, diff_v,vcres)<br>
>>>>>><br>
>>>>>> ;************************************************<br>
>>>>>> ; create panel<br>
>>>>>> ;************************************************<br>
>>>>>> resP = True ; modify the panel<br>
>>>> plot<br>
>>>>>> resP@txString = "NAO"<br>
>>>>>> gsn_panel(wks,plot,(/3,1/),resP) ; now draw as one<br>
>>>> plot<br>
>>>>>><br>
>>>>>><br>
>>>>>><br>
>>>>>> end<br>
>>>>>><br>
>>>>>><br>
>>>>>><br>
>>>>>> OUTPUT<br>
>>>>>> *******************************************************<br>
>>>>>> Variable: vAvgTime_hi<br>
>>>>>> Type: float<br>
>>>>>> Total Size: 2736 bytes<br>
>>>>>> 684 values<br>
>>>>>> Number of Dimensions: 2<br>
>>>>>> Dimensions and sizes: [lat | 19] x [lon | 36]<br>
>>>>>> Coordinates:<br>
>>>>>> lat: [45..90]<br>
>>>>>> lon: [270..357.5]<br>
>>>>>> Number Of Attributes: 17<br>
>>>>>> NMO : 0<br>
>>>>>> _FillValue : -9.96921e+36<br>
>>>>>> actual_range : ( -15.43516, 19.79167 )<br>
>>>>>> parent_stat : Other<br>
>>>>>> statistic : Mean<br>
>>>>>> level_desc : Surface<br>
>>>>>> dataset : CDC Derived NCEP Reanalysis Products<br>
>>>>>> var_desc : v-wind<br>
>>>>>> least_significant_digit : 1<br>
>>>>>> precision : 2<br>
>>>>>> missing_value : -9.96921e+36<br>
>>>>>> scale_factor : 1<br>
>>>>>> add_offset : 0<br>
>>>>>> units : m/s<br>
>>>>>> valid_range : ( -102.2, 102.2 )<br>
>>>>>> long_name : DJF: Monthly Mean Meridional Wind at sigma level<br>
>>>> 0.995<br>
>>>>>> average_op_ncl : dim_avg_n over dimension(s): time<br>
>>>>>><br>
>>>>>> Variable: vAvgTime_lo<br>
>>>>>> Type: float<br>
>>>>>> Total Size: 2736 bytes<br>
>>>>>> 684 values<br>
>>>>>> Number of Dimensions: 2<br>
>>>>>> Dimensions and sizes: [lat | 19] x [lon | 36]<br>
>>>>>> Coordinates:<br>
>>>>>> lat: [45..90]<br>
>>>>>> lon: [270..357.5]<br>
>>>>>> Number Of Attributes: 17<br>
>>>>>> NMO : 0<br>
>>>>>> _FillValue : -9.96921e+36<br>
>>>>>> actual_range : ( -15.43516, 19.79167 )<br>
>>>>>> parent_stat : Other<br>
>>>>>> statistic : Mean<br>
>>>>>> level_desc : Surface<br>
>>>>>> dataset : CDC Derived NCEP Reanalysis Products<br>
>>>>>> var_desc : v-wind<br>
>>>>>> least_significant_digit : 1<br>
>>>>>> precision : 2<br>
>>>>>> missing_value : -9.96921e+36<br>
>>>>>> scale_factor : 1<br>
>>>>>> add_offset : 0<br>
>>>>>> units : m/s<br>
>>>>>> valid_range : ( -102.2, 102.2 )<br>
>>>>>> long_name : DJF: Monthly Mean Meridional Wind at sigma level<br>
>>>> 0.995<br>
>>>>>> average_op_ncl : dim_avg_n over dimension(s): time<br>
>>>>>><br>
>>>>>><br>
>>>>>> Variable: diff_u<br>
>>>>>> Type: float<br>
>>>>>> Total Size: 2736 bytes<br>
>>>>>> 684 values<br>
>>>>>> Number of Dimensions: 2<br>
>>>>>> Dimensions and sizes: [19] x [36]<br>
>>>>>> Coordinates:<br>
>>>>>> Number Of Attributes: 1<br>
>>>>>> _FillValue : -9.96921e+36<br>
>>>>>><br>
>>>>>> Variable: diff_v<br>
>>>>>> Type: float<br>
>>>>>> Total Size: 2736 bytes<br>
>>>>>> 684 values<br>
>>>>>> Number of Dimensions: 2<br>
>>>>>> Dimensions and sizes: [19] x [36]<br>
>>>>>> Coordinates:<br>
>>>>>> Number Of Attributes: 1<br>
>>>>>> _FillValue : -9.96921e+36<br>
>>>>>><br>
>>>>>><br>
>>>>>><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>
>>>>>><br>
>>>>><br>
>>>><br>
>>>><br>
>>>><br>
>>><br>
>><br>
>><br>
><br>
><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>
</div></div></blockquote></div><br></div>