<div dir="ltr"><div class="gmail_default" style="font-size:small">Lyndz,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">It looks like a simple typo. You have:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default"><div class="gmail_default"><b><font color="#cc0000">sfvp</font></b> = uv2sfvpF(uwnd,vwnd)</div><div class="gmail_default"><b><font color="#cc0000">sfvp</font></b> = (/<b><font color="#990000">sfvp</font></b>/1e6/) ;rescaling by 1e6</div><div class="gmail_default"><br></div><div class="gmail_default">copy_VarCoords(ufile,<font color="#cc0000"><b>vp</b></font>)</div><div class="gmail_default"><br></div><div class="gmail_default"><b><font color="#cc0000">vp</font></b>@long_name = "velocity potential"</div><div class="gmail_default"><b><font color="#cc0000">vp</font></b>@units = "m/s"</div><div class="gmail_default"><br></div><div class="gmail_default">The variable you're computing is called <b><font color="#cc0000">sfvp</font></b>, but then you refer to <b><font color="#cc0000">vp</font></b> after that. Change the two <b><font color="#cc0000">sfvp</font></b> lines to be <b><font color="#cc0000">vp</font></b> instead:</div><div class="gmail_default"><br></div><div class="gmail_default"><div class="gmail_default"><b><font color="#cc0000">vp</font></b> = uv2sfvpF(uwnd,vwnd)</div><div class="gmail_default"><b><font color="#cc0000">vp</font></b> = (/<b><font color="#cc0000">vp</font></b>/1e6/) ;rescaling by 1e6</div><div><br></div><div>--Mary</div><div><br></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 5, 2017 at 1:34 AM, Lyndon Mark Olaguera <span dir="ltr"><<a href="mailto:olagueralyndonmark429@gmail.com" target="_blank">olagueralyndonmark429@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 dir="ltr"><div><div class="m_-8213661668546040251gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Dear All,</div><div><br></div><div>I'm trying to calculate the velocity potential (fixed grid) at 200 hPa from NCEP daily reanalysis data. I am using the uv2sfvpF(u,v) function. </div><div><br></div><div>I am having trouble in saving the output to a netcdf file. How do I save the calculated velocity potential with the same grid coordinates (i.e. same lat order as the original file) as the original file?</div><div><br></div><div>I attached the link of the files that I'm working with and the script in this email.</div><div>I highlight in red the line where I got stuck.</div><div><br></div><div>I'll appreciate any help. </div><div><br></div><div>Many thanks,</div><div><br></div><div>Lyndz</div><div><br></div><div><br></div><div>Here's my script:</div><div><div><br></div><div>;*****************************<wbr>***********************</div><div>;This script calculates the velocity potential</div><div>;Input: U and V wind components</div><div>;*****************************<wbr>***********************</div><div>begin</div><div>ufile = addfile("uwind200hPa_1975.nc",<wbr>"r")</div><div>vfile = addfile("vwind200hPa_1975.nc",<wbr>"r")</div><div>uwnd = ufile->uwnd(:,:,::-1,:) ;sort coordinates usinf ::-1</div><div>printVarSummary(uwnd)</div><div><br></div><div>vwnd = vfile->vwnd(:,:,::-1,:) ;sort coordinates using ::-1</div><div>printVarSummary(vwnd)</div><div><br></div><div>sfvp = uv2sfvpF(uwnd,vwnd)</div><div>sfvp = (/sfvp/1e6/) ;rescaling by 1e6</div><div><br></div><div><b><font color="#ff0000">copy_VarCoords(ufile,vp)</font></b></div><div><br></div><div>vp@long_name = "velocity potential"</div><div>vp@units = "m/s"</div></div><div><div>ncdf = addfile("<a href="http://test.nc" target="_blank">test.nc</a>" ,"c") ; open output netCDF file</div><div><br></div><div>fAtt = True ; assign file attributes</div><div>fAtt@title = "Velocity Potential"</div><div>fAtt@source_file = "<a href="https://www.esrl.noaa.gov/psd/data/gridded/data.ncep.reanalysis.pressure.html" target="_blank">https://www.esrl.noaa.gov/<wbr>psd/data/gridded/data.ncep.<wbr>reanalysis.pressure.html</a>"</div><div>fAtt@Conventions = "None"</div><div>fAtt@creation_date = systemfunc ("date")</div><div>fileattdef( ncdf, fAtt ) ; copy file attributes</div><div><br></div><div>ncdf->vp = vp</div><div>end</div></div><div><br></div><div><br></div><div>Here's the link to the files:</div><div><br></div><div><a href="https://drive.google.com/drive/folders/0B9faET7Bc2o8MmtGS2VJLTB2NE0?usp=sharing" target="_blank">https://drive.google.com/<wbr>drive/folders/<wbr>0B9faET7Bc2o8MmtGS2VJLTB2NE0?<wbr>usp=sharing</a></div></div></div></div></div></div></div></div></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>