<div dir="ltr"><div>Hi Mike,<br><br></div>Maybe a minus sign in the 2nd argument of atan2? <br><div><br>Given your:<br><br><p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures">; a b c</span></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures">; d e f</span></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures">; g h i<br></span></p><p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></p><p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">dzdx = ( (c + 2*f + i) - (a + 2*d + g))/dx</p><p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">----</p><p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">dzdy = ( (a + 2*b + c) - (g + 2*h + i))/dy</p><p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></p><p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">or, maybe, not sure of sign convention<br></p><p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></p><p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">dzdy = ( (g + 2*h + i) - (a + 2*b + c))/dy</p><p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">----<br></p><p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">Your code may need a minus sign before the 2nd argument:<br></p><p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></p><p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">aspect = <span style="font-variant-ligatures:no-common-ligatures">57.29578*atan2(dzdy,-dzdx)   ; <=== minus sign ???</span></p><p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures"><br></span></p><p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">if (aspect.lt.0) then</span></p><p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">    aspect = 90 - aspect</span></p><p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">end if</span></p><p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures"><br></span></p><p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">------------------<br></span></p><p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br><span style="font-variant-ligatures:no-common-ligatures"><span style="font-variant-ligatures:no-common-ligatures">if (aspect(jj,ii).le.0.) then</span>
</span></p><p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures"><span class="gmail-m_919916421783336330gmail-m_-4762187390746946064Apple-converted-space">       
</span>aspect(jj,ii)=90.-aspect(jj,ii<wbr>)</span></p><p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">end if<br></span></p><p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">--<br></span></p><p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures"><br></span></p><p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">If you use a minus sign, maybe you do not need other 'if' blocks?<br></span></p><p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures"></span></p></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 12, 2018 at 3:27 PM, Michael Notaro <span dir="ltr"><<a href="mailto:mnotaro@wisc.edu" target="_blank">mnotaro@wisc.edu</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 id="m_-8038621355348424374divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif" dir="ltr">
<p style="margin-top:0;margin-bottom:0">I used the following to compute terrain aspect based</p>
<p style="margin-top:0;margin-bottom:0">on elevation.  But it seems the values are possibly not</p>
<p style="margin-top:0;margin-bottom:0">quite right, since they disagree with another aspect </p>
<p style="margin-top:0;margin-bottom:0">dataset I have.  Does anyone see something wrong below?</p>
<p style="margin-top:0;margin-bottom:0">Michael</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures">ny=dims(0)</span></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures">nx=dims(1)</span></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures">aspect=new((/ny,nx/),"float")</span></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures">aspect@_FillValue=-999.</span></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures">aspect=-999.</span></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255);min-height:19px">
<span style="font-variant-ligatures:no-common-ligatures"></span><br>
</p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures">; a b c</span></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures">; d e f</span></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures">; g h i</span></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255);min-height:19px">
<span style="font-variant-ligatures:no-common-ligatures"></span><br>
</p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures">do ii=1,nx-2</span></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures"><span class="m_-8038621355348424374Apple-converted-space"> 
</span>do jj=1,ny-2</span></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures"><span class="m_-8038621355348424374Apple-converted-space">   
</span>if (.not.ismissing(elev(jj,ii))) then</span></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures"><span class="m_-8038621355348424374Apple-converted-space">     
</span>a=elevation(jj+1,ii-1)</span></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures"><span class="m_-8038621355348424374Apple-converted-space">     
</span>b=elevation(jj+1,ii)</span></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures"><span class="m_-8038621355348424374Apple-converted-space">     
</span>c=elevation(jj+1,ii+1)</span></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures"><span class="m_-8038621355348424374Apple-converted-space">     
</span>d=elevation(jj,ii-1)</span></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures"><span class="m_-8038621355348424374Apple-converted-space">     
</span>e=elevation(jj,ii)</span></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures"><span class="m_-8038621355348424374Apple-converted-space">     
</span>f=elevation(jj,ii+1)</span></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures"><span class="m_-8038621355348424374Apple-converted-space">     
</span>g=elevation(jj-1,ii-1)</span></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures"><span class="m_-8038621355348424374Apple-converted-space">     
</span>h=elevation(jj-1,ii)</span></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures"><span class="m_-8038621355348424374Apple-converted-space">     
</span>i=elevation(jj-1,ii+1)</span></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures"><span class="m_-8038621355348424374Apple-converted-space">     
</span>dzdx=((a+2.*d+g)-(c+2.*f+i))/(<wbr>8.*800.) ; 800 m PRISM</span></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures"><span class="m_-8038621355348424374Apple-converted-space">     
</span>dzdy=((g+2.*h+i)-(a+2.*b+c))/(<wbr>8.*800.)</span></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures"><span class="m_-8038621355348424374Apple-converted-space">     
</span>aspect(jj,ii)=57.29578*atan2(<wbr>dzdy,dzdx)</span></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures"><span class="m_-8038621355348424374Apple-converted-space">     
</span>if (aspect(jj,ii).le.0.) then</span></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures"><span class="m_-8038621355348424374Apple-converted-space">       
</span>aspect(jj,ii)=90.-aspect(jj,<wbr>ii)</span></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures"><span class="m_-8038621355348424374Apple-converted-space">     
</span>else if (aspect(jj,ii).gt.90.) then</span></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures"><span class="m_-8038621355348424374Apple-converted-space">       
</span>aspect(jj,ii)=360.-aspect(jj,<wbr>ii)+90.</span></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures"><span class="m_-8038621355348424374Apple-converted-space">     
</span>else</span></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures"><span class="m_-8038621355348424374Apple-converted-space">       
</span>aspect(jj,ii)=90.-aspect(jj,<wbr>ii)</span></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures"><span class="m_-8038621355348424374Apple-converted-space">     
</span>end if</span></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures"><span class="m_-8038621355348424374Apple-converted-space">     
</span>end if</span></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures"><span class="m_-8038621355348424374Apple-converted-space">   
</span>end if</span></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures"><span class="m_-8038621355348424374Apple-converted-space"> 
</span>end do</span></p>
<p style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<span style="font-variant-ligatures:no-common-ligatures">end do</span></p><span class="HOEnZb"><font color="#888888">
<br>
<p></p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<div id="m_-8038621355348424374Signature">
<div id="m_-8038621355348424374divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255);font-family:Calibri,Arial,Helvetica,sans-serif,Helvetica,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
Michael Notaro<br>
<div>Associate Director<br>
</div>
<div>Nelson Institute Center for Climatic Research<br>
</div>
<div>University of Wisconsin-Madison<br>
</div>
<div>Phone: <a href="tel:(608)%20261-1503" value="+16082611503" target="_blank">(608) 261-1503</a><br>
</div>
<div>Email: <a href="mailto:mnotaro@wisc.edu" target="_blank">mnotaro@wisc.edu</a><br>
</div>
</div>
</div>
</font></span></div>
</div>

<br>______________________________<wbr>_________________<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" rel="noreferrer" target="_blank">http://mailman.ucar.edu/<wbr>mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>