<div dir="ltr">Dear Sir Jeff,<div><br></div><div>Thank you for this wonderful explanation. You are a genius!</div><div><br></div><div>I have one last question regarding the sign of the output attached in this email.</div><div><br></div><div><div>Here&#39;s the script that I am using.</div><div><br></div><div>&#39;sdfopen <a href="http://pentad_ensmean_shum_1981-2010.nc">pentad_ensmean_shum_1981-2010.nc</a>&#39;</div><div>&#39;sdfopen ../uwind/pentad/<a href="http://pentad_ensmean_uwind_1981-2010.nc">pentad_ensmean_uwind_1981-2010.nc</a>&#39;</div><div>&#39;sdfopen ../vwind/pentad/<a href="http://pentad_ensmean_vwind_1981-2010.nc">pentad_ensmean_vwind_1981-2010.nc</a>&#39;</div></div><div><div>&#39;set dfile 1&#39;</div><div>&#39;define q=shum(z=3)&#39;</div><div>&#39;set dfile 2&#39;</div><div>&#39;define u=uwnd(z=3)&#39;</div><div>&#39;set dfile 3&#39;</div><div>&#39;define v=vwnd(z=3)&#39;</div><div>&#39;color -0.2 0.2 0.02 -kind blue-&gt;white-&gt;red&#39;</div><div><br></div><div><b>&#39;define mconv=(-1)*hdivg(u*q,v*q)*1e6&#39;</b></div><div><br></div><div><br></div><div>&#39;set lat -5 45&#39;</div><div>&#39;set lon 80 180&#39;</div><div>&#39;d mconv&#39;</div><div>&#39;xcbar -fs 2&#39;</div><div><br></div><div>*overlay 850mb winds</div><div>&#39;set gxout vector&#39;</div><div>&#39;set arrscl 0.3 10&#39;</div><div>&#39;d u;v&#39;</div></div><div><br></div><div><br></div><div>Question:</div><div><br></div><div>1. I overlayed the 850 mb winds over the calculated MFC, but the results do not match. I&#39;m not sure if I understand this correctly.</div><div>From the defined mconv equation, negative values should correspond to &quot;convergence&quot;, while positive values should correspond to &quot;divergence&quot;.</div><div>But in the attached image, positive values are seen over areas of convergence. Is the correct equation for the MFC above should contain -1 or this depends on the situation?</div><div><br></div><div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><font face="comic sans ms, sans-serif"><b><u>Lyndon Mark P. Olaguera</u></b></font><div><br></div></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Sat, Jan 28, 2017 at 2:53 PM, Jeff Duda <span dir="ltr">&lt;<a href="mailto:jeffduda319@gmail.com" target="_blank">jeffduda319@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div><div><div>Lyndon,<br></div>Absolutely. I calclulate MFC frequently. Use cdiff. But before I give the full explanation, I should note that your formula already gives the full MFC field. hdivg(q*u,q*v) should include the advection term. You can verify this by comparing that formula to those below that I will give you.<br><br></div>The trick with this is to define your grid spacing before doing anything else. While your model integration may use a fixed grid spacing (whether in degrees or linear distance or otherwise), if you use a control file to display the data, and if it includes XDEF and YDEF entries, then the grid on which your data are calculated may differ from that on which the model was integrated, so you can&#39;t use your scalar grid spacing value in that case. You can define your data grid spacing using trigonometry. The equations to calculate that are<br><br></div>dx = Re * cos(lat) * cdiff(lon,x)<br></div>dy = Re * cdiff(lat,y)<br><br></div>In the above equations, Re is the radius of the earth, and you need to make sure to convert between radians and degrees. Grads functions assume inputs are in radians and also output in radians. However, the lat and lon fields are in degrees, so convert. Both formulas are also instances of the arc length formula for a circle, which assumes the angle is in radians. So basically, convert everything to radians in those equations.<br><br></div>Once you have those terms, you have all the fields you need (assuming you have mixing ratio and wind components defined on the same grid already):<br><br></div>advection term = -u * cdiff(q,x) / dx - v * cdiff(q,y) / dy<br></div>convergence term = q*hdivg(u,v)<br><br></div>To verify that the advection term is already contained in hdivg(q*u,q*v), it should suffice to display <br></div>hdivg(q*u,q*v) - q * hdivg(u,v)<br></div>This field should match the advection term field above. You can also display <br>hdivg(q*u,q*v) - q * hdivg(u,v) - [  -u * cdiff(q,x) / dx - v * cdiff(q,y) / dy] and it should be 0.<br><br></div>I might be wrong about this since the divergence operator in spherical coordinates includes an additional term to represent convergence for purely meridional wind, so you may want to crack open a dynamics textbook and find what that term is and include it in here somewhere. Either way, I hope this helps.<br><br></div>Jeff Duda<br></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="gmail-h5">On Fri, Jan 27, 2017 at 11:35 PM, Lyndon Mark Olaguera <span dir="ltr">&lt;<a href="mailto:olagueralyndonmark429@gmail.com" target="_blank">olagueralyndonmark429@gmail.<wbr>com</a>&gt;</span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div class="gmail-h5"><div dir="ltr">Dear All,<div><br></div><div>I&#39;m trying to calculate the moisture flux convergence using the following commands:</div><div><br></div><div><div>*At 850 mbĀ </div><div><br></div><div>&#39;set dfile 1&#39;</div><div>&#39;define q=shum(z=3)&#39;</div><div><br></div><div>&#39;set dfile 2&#39;</div><div>&#39;define u=uwnd(z=3)&#39;</div><div><br></div><div>&#39;set dfile 3&#39;</div><div>&#39;define v=vwnd(z=3)&#39;</div><div><br></div><div>&#39;color -0.2 0.2 0.02 -kind blue-&gt;white-&gt;red&#39;<br></div><div>&#39;define mconv=(1)*hdivg(u*q,v*q)*1e6&#39;</div><div><br></div><div>According to this link, I have to add the advection term.</div><div><br></div><div><a href="http://www.spc.noaa.gov/publications/banacos/mfc-sls.pdf" target="_blank">http://www.spc.noaa.gov/public<wbr>ations/banacos/mfc-sls.pdf</a></div><div><br></div><div><img src="cid:ii_159e390675f5b588" alt="Inline image 1" style="margin-right: 0px;" height="134" width="406"><br></div><div><br></div><div>Question:</div><div><br></div><div>1. Is there a way to do this in grads?</div><div>2. Or is there a function in GRADS that can calculate partial derivatives?</div><div><br></div><div>I&#39;ll appreciate any help.</div><div><br></div><div>Best,</div><div><br></div><div><div class="gmail-m_3939538811372423368m_274993068877275854gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><font face="comic sans ms, sans-serif"><b><u>Lyndon Mark P. Olaguera</u></b></font><div><br></div></div></div></div></div></div></div></div></div></div>
</div></div>
<br></div></div>______________________________<wbr>_________________<br>
gradsusr mailing list<br>
<a href="mailto:gradsusr@gradsusr.org" target="_blank">gradsusr@gradsusr.org</a><br>
<a href="http://gradsusr.org/mailman/listinfo/gradsusr" rel="noreferrer" target="_blank">http://gradsusr.org/mailman/li<wbr>stinfo/gradsusr</a><br>
<br></blockquote></div><span class="gmail-HOEnZb"><font color="#888888"><br><br clear="all"><br>-- <br><div class="gmail-m_3939538811372423368gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Jeff Duda<br>Post-doctoral research fellow<br>University of Oklahoma School of Meteorology<br></div></div></div></div></div>
</font></span></div>
<br>______________________________<wbr>_________________<br>
gradsusr mailing list<br>
<a href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</a><br>
<a href="http://gradsusr.org/mailman/listinfo/gradsusr" rel="noreferrer" target="_blank">http://gradsusr.org/mailman/<wbr>listinfo/gradsusr</a><br>
<br></blockquote></div><br></div></div></div>