<div dir="ltr"><div><div><div>Hello,<br><br></div>I am new to NCL and I am trying to plot annual mean climatology for divergent winds (vectors), 
divergence (contours (shading)) and velocity potential (contours (lines)) in a single plot
 using velocities u and v only. I am using two input .nc files f1 and f2, where f1 contains u and v and f2 contains velocity potential.<br>I am trying to plot divergent velocities over velocity potential using the following script:<br><br>begin<br>;*************************************************<br>; open file and read in data: data are on a gaussian grid<br>;*************************************************<br>  f1    = addfile ("ERAI_200uvd_1979-2010_new.nc", "r")<br>  u    = f1->u<br>  v    = f1->v<br>  f2    = addfile ("ERAI_200sfvp_1979-2010_new.nc", "r")<br>  vp    = f2->velopot    <br>;*************************************************<br>; calculate divergence on a gaussian grid<br>;*************************************************<br>  div = uv2dvG_Wrap(u,v)                                        ; u,v ==> divergence  <br>  div@long_name  = "Divergence"<br>  div@units      = "s-1"<br>;*************************************************<br>; calculate velocity potential<br>;*************************************************<br>  ;chi = ilapsG_Wrap ( div , 0)<br>  chi  = new ( dimsizes(vp), double, vp@_FillValue )<br>  chi = (/vp/1e4/)                                                 ; arbitrary scale<br>  copy_VarCoords(vp, chi )    <br>    ;chi@long_name = "velocity potential"<br>  ;chi@units     = "m^2/s" <br>;*************************************************<br>; calculate divergent wind component <br>; --<br>; note: the calculation uses a procedure, so memory <br>; must be preallocated.<br>;*************************************************    <br>  ud    = new ( dimsizes(u), double, u@_FillValue )<br>  vd    = new ( dimsizes(v), double, v@_FillValue )<br><br>  dv2uvg(div,ud,vd) ; div  ==> divergent  wind components<br><br>  copy_VarCoords(u, ud ) <br>  copy_VarCoords(v, vd ) <br>  ud@long_name  = "Zonal Divergent Wind"<br>  ud@units      = u@units<br>  vd@long_name  = "Meridional Divergent Wind"<br>  vd@units      = v@units<br>    <br>    ;udAve = avg(ud(:,:,:,:))<br>    ;vdAve = avg(vd(:,:,:,:))<br>    ;scale    =(/vdAve/udAve/)<br>    ;ud    =    (/scale*ud/)<br><br>    ud = (/ud/1e3/)<br>    vd = (/vd/1e3/)<br>    div = (/div*1e3/)<br><br>    ;UD = month_to_annual(ud, 1)<br>    ;VD = month_to_annual(vd, 1)<br>    ;DIV = month_to_annual(div, 1)<br>    ;CHI = month_to_annual(chi, 1)<br>    <br>    UDavg    =    dim_avg_n_Wrap(ud, (/0,1/))<br>    VDavg    =    dim_avg_n_Wrap(vd, (/0,1/))<br>    DIVavg    =    dim_avg_n_Wrap(div, (/0,1/))<br>    CHIavg    =    dim_avg_n_Wrap(chi, (/0,1/))<br>    CHIavg    =    abs(CHIavg)<br><br>;*************************************************<br>; plot results<br>;*************************************************    <br>  wks  = gsn_open_wks("png","vp_dv_d")             ; send graphics to PNG file<br>  ;cmap = read_colormap_file("GMT_polar")<br>    ;cmap = read_colormap_file("GMT_seis")<br>    cmap = read_colormap_file("cmp_b2r")<br>  nc   = dimsizes(cmap(:,0))<br><br>    res                          = True<br>    res@gsnDraw                                 = False<br>    res@gsnFrame                             = False<br>    cnres1                                        = res<br>    cnres2                                        = res<br>    vcres                                            = res<br><br>  cnres1@cnFillOn           = True               ; color on<br>  cnres1@cnLinesOn          = False              ; turn off contour lines<br>    cnres1@cnFillPalette      = cmap(:nc-4,:)  <br>    cnres1@tiMainString       = "Divergent Winds, Divergence and Velocity Potential"<br>  cnres1@cnLevelSelectionMode     = "ManualLevels"    ; manually set the contour levels with the following 3 resources<br>  cnres1@cnMinLevelValF              = -5.                                ; set the minimum contour level<br>  cnres1@cnMaxLevelValF              = 5.                                ; set the maximum contour level<br>  cnres1@cnLevelSpacingF             = 0.5                                ; set the interval between contours    <br>    cnres1@lbOrientation           = "vertical"<br>    cnres1@lbBoxSeparatorLinesOn = False<br>    cnres1@lbTitleString             = div@long_name<br>    cnres1@lbTitlePosition        = "Left"<br>    cnres1@lbAutoManage             = False<br>    cnres1@lbTitleFontHeightF    = 0.012<br>    ;cnres1@lbLabelStrings =  (/"-5.0","-2.5","0","2.5","5.0"/)<br>    cnres1@mpMinLonF          =   0<br>  cnres1@mpMaxLonF          = 360<br>  cnres1@mpCenterLonF       = 180     ; This is necessary to get the correct map <br>    cnres1@mpMinLatF          = -80<br>  cnres1@mpMaxLatF          = 80<br><br>    vcres@vcRefMagnitudeF     = 10.                 ; make vectors larger<br>  vcres@vcRefLengthF        = 0.05              ; ref vector length<br>  vcres@vcGlyphStyle        = "CurlyVector"      ; turn on curly vectors<br>  vcres@vcMinDistanceF      = 0.012              ; thin the vectors<br>  vcres@vcRefAnnoOrthogonalPosF  = 0        ; Move ref anno into plot<br>    vcres@vcRefAnnoBackgroundColor = "Background"<br>    vcres@vcRefAnnoString2On    = False<br>    ;vcres@vcRefAnnoSide            =    "Left" <br><br>  ;cnres2@gsnCenterString    = "Chi scaled by 1e8"<br>    cnres2@cnFillOn                        = False<br>    cnres2@cnLinesOn                    = True<br>    ;cnres2@mpMinLonF          =   0<br>  ;cnres2@mpMaxLonF          = 360<br>  ;cnres2@mpCenterLonF       = 180     ; This is necessary to get the correct map<br>    cnres2@trGridType                     = "TriangularMesh"<br><br>    plot1 = gsn_csm_vector(wks,UDavg(:,:),VDavg(:,:),vcres)<br>    plot2    = gsn_csm_contour_map_overlay(wks,DIVavg(:,:),CHIavg(:,:),cnres1,cnres2)<br><br>    overlay(plot2,plot1)<br>    <br>    draw(plot2)<br>    frame(wks)<br><br>end<br><br><br></div>I am getting the following warning messages: <br><br>(0)    check_for_y_lat_coord: Warning: Data either does not contain a valid latitude coordinate array or doesn't contain one at all.<br>(0)    A valid latitude coordinate array should have a 'units' attribute equal to one of the following values: <br>(0)        'degrees_north' 'degrees-north' 'degree_north' 'degrees north' 'degrees_N' 'Degrees_north' 'degree_N' 'degreeN' 'degreesN' 'deg north'<br>(0)    check_for_lon_coord: Warning: Data either does not contain a valid longitude coordinate array or doesn't contain one at all.<br>(0)    A valid longitude coordinate array should have a 'units' attribute equal to one of the following values: <br>(0)        'degrees_east' 'degrees-east' 'degree_east' 'degrees east' 'degrees_E' 'Degrees_east' 'degree_E' 'degreeE' 'degreesE' 'deg east'<br><br><br></div>and the plot which is attached to this mail. I think I am getting proper divergence but velocity potential lines are not getting plotted at all and I feel the direction of winds are also wrong. So please help me to get a proper plot without error. I am expecting humble reply from your side. <br><div><br>Thanking you,<br><br></div><div>Vyankatesh Mundhada<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 21, 2018 at 5:40 PM, Vyankatesh Manoj Mundhada <span dir="ltr"><<a href="mailto:vyankatesh@iiserb.ac.in" target="_blank">vyankatesh@iiserb.ac.in</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>Thank you very much. That was really helpful.<br><br></div>Regards,<br></div>Vyankatesh<br></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 21, 2018 at 4:03 PM, Guido Cioni <span dir="ltr"><<a href="mailto:guidocioni@gmail.com" target="_blank">guidocioni@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space">Hi,<div>This error usually pops up when you're doing assignment that delete the original attributes of the variable, including the reference to the coordinate variables. </div><div><br></div><div>I'm just speculating but...could it be this line? </div><span><div><br></div><div><font face="Menlo">    plot1 = gsn_csm_vector_map(wks,0.001*u<wbr>d(0,0,:,:),0.001*vd(0,0,:,:),v<wbr>cres)</font></div><div><br></div></span><div>You are doing <font face="Menlo">0.001*ud(0,0,:,:)</font>, so merely assigning a new variable without copying the attributes.</div><div>You should instead do the scaling first </div><div><br></div><div><font face="Menlo">ud=0.001*ud(:,:,:,:) ; here the attributes are preserved</font></div><div><br></div><div>and then plot <font face="Menlo">ud(0,0,:,:).</font></div><div>Or just a define a new variable based un <font face="Menlo">ud</font> first. </div><div><br></div><div>Let us know whether that works, that's the first thing that comes to my mind. </div><div><br></div><div><br><div><br><blockquote type="cite"><div>On 21. Feb 2018, at 10:20, Vyankatesh Manoj Mundhada <<a href="mailto:vyankatesh@iiserb.ac.in" target="_blank">vyankatesh@iiserb.ac.in</a>> wrote:</div><br class="m_-6586681390938842954m_3346935692996899367Apple-interchange-newline"><div><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">0.001*vd(0,0,:,:)</span></div></blockquote></div><span class="m_-6586681390938842954HOEnZb"><font color="#888888"><br><div>
<div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br class="m_-6586681390938842954m_3346935692996899367Apple-interchange-newline">Guido Cioni</div><div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="http://guidocioni.altervista" target="_blank">http://guidocioni.altervista</a>.o<wbr>rg</div>

</div>
<br></font></span></div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>