<div dir="ltr"><div dir="ltr"><div>Hi Dennis,</div><div><br></div><div>Thank you for your answer, but this didn't make difference in the calculations. As I could read in documentation, there is no warning about latitude order.</div><div><br></div><div>Trying more comparisons, I've calculated the wind gradients with <i>grad_latlon_cfd</i> function to get <i>du_dx</i> and <i>dv_dy</i> and the results are the same, as shown below:</div><div><br></div><div><b>For latitude -90</b><br></div><div>(0) du_dx manual du_dx grad funct<br>(0) -32.9238 -32.9175<br>(1) -32.9238 -32.9175<br>(2) -28.8081 -28.8026<br>(3) -28.8081 -28.8026</div><div><br></div><div>(0) dv_dy manual dv_dy grad funct<br>(0) 5.39676e-06 5.39574e-06<br>(1) 5.39676e-06 5.39574e-06<br>(2) 5.39676e-06 5.39574e-06<br>(3) 5.39676e-06 5.39574e-06<br></div><div><br></div><div><b>For latitude -87.5</b></div><div>(0) du_dx manual du_dx grad funct<br>(0) 2.88688e-05 2.88633e-05<br>(1) 2.88688e-05 2.88633e-05<br>(2) 2.47451e-05 2.47403e-05<br>(3) 2.88688e-05 2.88633e-05</div><div><br></div><div>(0) dv_dy manual dv_dy grad funct<br>(0) 2.69839e-06 2.69787e-06<br>(1) 2.51851e-06 2.51803e-06<br>(2) 2.33858e-06 2.33813e-06<br>(3) 2.33861e-06 2.33816e-06</div><div><br></div><div>And below the divergence, but along with the calculation using gradients obtained with <i>grad_latlon_cfd</i>:</div><div><br></div><div><b>For latitude -90</b><br></div><div>(0) div manual div function div grad funct<br>(0) -0.24189 5.72546e-06 -0.235588<br>(1) -0.960165 5.72546e-06 -0.953863<br>(2) 2.43722 5.72546e-06 2.44274<br>(3) 1.71895 5.72546e-06 1.72446</div><div><br></div><div><b>For latitude -87.5</b></div><div>(0) div manual div function div grad funct<br>(0) 4.24092e-06 4.24011e-06 4.23487e-06<br>(1) 4.78015e-06 4.77923e-06 4.77414e-06<br>(2) 1.19561e-06 1.19538e-06 1.19042e-06<br>(3) 6.0385e-06 6.03735e-06 6.03253e-06</div><div><br></div><div>The data used for these calculations has its latitude ordered south-to-north. I think that I'm missing something, but I can't figure it out.<br></div><div><br></div><div>Best regards,</div><div><br></div><div>Mateus</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Em qua, 10 de jul de 2019 às 13:23, Dennis Shea <<a href="mailto:shea@ucar.edu">shea@ucar.edu</a>> escreveu:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">NCEP reanalyses are ordered North-to-South. The function requires South-to-North. Assuming (time,lev,Lat,Lon)<div><br></div><div> V = V(:,:,::-1,:)</div><div> printVarSummary(V)</div><div><br></div><div>Look at the lat coordinate. <br><br><div id="gmail-m_5411981133741331454AppleMailSignature" dir="ltr">Sent from my iPhone</div><div dir="ltr"><br>On Jul 10, 2019, at 8:33 AM, Mateus da Silva Teixeira via ncl-talk <<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a>> wrote:<br><br></div><blockquote type="cite"><div dir="ltr"><div dir="ltr"><div>Hi,</div><div><br></div><div>I'm trying to reproduce with <i>center_finite_difference</i> function the computation of wind divergence, to compare with <i>uv2dv_<span id="gmail-m_5411981133741331454:244.53">cfd</span></i> function. However, I'm getting some strange values for divergence.<br></div><div><br></div><div>For <i><span id="gmail-m_5411981133741331454:244.55">Dv</span>/Dy</i>, I'm using:</div><div><br></div><div><span id="gmail-m_5411981133741331454:244.56">dv</span>_<span id="gmail-m_5411981133741331454:244.57">dy</span> = center_finite_diff_n( v850, lat*g2r, False, 0, 0 )/<span id="gmail-m_5411981133741331454:244.58">rTerra</span><br></div><div><br></div><div>For Du/<span id="gmail-m_5411981133741331454:244.59">Dx</span>, I'm using:</div><div><br></div><div><i><span id="gmail-m_5411981133741331454:244.60">dlon</span> = (<span id="gmail-m_5411981133741331454:244.61">lon</span>(2)-<span id="gmail-m_5411981133741331454:244.62">lon</span>(1))*g2r<br><span id="gmail-m_5411981133741331454:244.63">du</span>_<span id="gmail-m_5411981133741331454:244.64">dx</span> = new( (/<span id="gmail-m_5411981133741331454:244.65">dimsizes</span>(u850)/), <span id="gmail-m_5411981133741331454:244.66">typeof</span>( u850 ), u850@_<span id="gmail-m_5411981133741331454:244.67">FillValue</span> )<br>term3 = new( (/<span id="gmail-m_5411981133741331454:244.68">dimsizes</span>(v850)/), <span id="gmail-m_5411981133741331454:244.69">typeof</span>(v850), v850@_<span id="gmail-m_5411981133741331454:244.70">FillValue</span> )<br>do i = 0, <span id="gmail-m_5411981133741331454:244.71">dimsizes</span>(lat)-1<br> <span id="gmail-m_5411981133741331454:244.72">dx</span> = <span id="gmail-m_5411981133741331454:244.73">rTerra</span> * cos( g2r*lat(i) ) * <span id="gmail-m_5411981133741331454:244.74">dlon</span><br> <span id="gmail-m_5411981133741331454:244.75">du</span>_<span id="gmail-m_5411981133741331454:244.76">dx</span>(i,:) = center_finite_diff( u850(i,:), <span id="gmail-m_5411981133741331454:244.77">dx</span>, True, 0 )</i></div><div><i> term3(i,:) = ( v850(i,:)/<span id="gmail-m_5411981133741331454:244.78">rTerra</span> ) * tan( lat(i)*g2r )<br> end do</i></div><div><i><br></i></div><div>with <i>rTerra</i> being the mean radius of the Earth, and finally, for divergence (using the same equation calculated by <i>uv2dv_cfd</i>):</div><div><br></div><div><i>div = du_dx + dv_dy - term3</i></div><div><br></div><div>With <i>uv2dv_cfd</i>, I'm using:</div><div><br></div><div><i>divV = uv2dv_cfd( u850, v850, lat, lon, 3 )</i></div><div><i><br></i></div><div>Below, a comparison between the results for latitude 90, for both calculations:</div><div><br></div><div>(0) div manual div function<br>(0) -0.435886 8.54325e-07<br>(1) 0.282385 8.54325e-07<br>(2) 0.641552 8.54325e-07<br>(3) 0.640924 8.54325e-07<br>(4) -3.11505 8.54325e-07</div><div>...</div><div>(138) 0.0877819 8.54325e-07<br>(139) 0.806053 8.54325e-07<br>(140) -2.59076 8.54325e-07<br>(141) -1.87243 8.54325e-07<br>(142) 2.96093 8.54325e-07<br>(143) -0.795052 8.54325e-07</div><div><br></div><div>And below, the comparison for latitude 87.5, for both calculations:</div><div><br></div><div>(0) div manual div function<br>(0) 2.54982e-06 2.54933e-06<br>(1) 3.44865e-06 3.44799e-06<br>(2) 4.34874e-06 4.34791e-06<br>(3) 1.30406e-06 1.30381e-06<br>(4) 2.92225e-06 2.9217e-06</div><div>...</div><div>(138) 2.74009e-06 2.73957e-06<br>(139) 1.3016e-06 1.30136e-06<br>(140) 3.98753e-06 3.98678e-06<br>(141) 7.39285e-06 7.39144e-06<br>(142) 2.72861e-06 2.72809e-06<br>(143) 2.54953e-06 2.54905e-06</div><div><br></div><div>I've noted this problem only in the poles and seems to be related with <i>cos</i> function in the computation of gradient of zonal wind over longitude, since it doesn't give zero (or a very small value) for <i>cos(90)</i> or <i>cos(-90).</i></div><div><i></i><br></div><div>I'm using NCEP Reanalysis 1 data and NCL 6.4.0.</div><div><br></div><div>Am I doing something wrong in these calculations?</div><div><br></div><div>Thanks,</div><div><br></div><div>Mateus</div><div><br></div><div><br></div><div><i></i></div><div><i></i></div></div>
</div></blockquote><blockquote type="cite"><div dir="ltr"><span>_______________________________________________</span><br><span>ncl-talk mailing list</span><br><span><a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a></span><br><span>List instructions, subscriber options, unsubscribe:</span><br><span><a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></span></div></blockquote></div></div></blockquote></div></div>