<div dir="ltr"><div><div class="gmail_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&#39;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&#39;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&#39;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&#39;s my script:</div><div><div><br></div><div>;****************************************************</div><div>;This script calculates the velocity potential</div><div>;Input: U and V wind components</div><div>;****************************************************</div><div>begin</div><div>ufile = addfile(&quot;uwind200hPa_1975.nc&quot;,&quot;r&quot;)</div><div>vfile = addfile(&quot;vwind200hPa_1975.nc&quot;,&quot;r&quot;)</div><div>uwnd = ufile-&gt;uwnd(:,:,::-1,:)     ;sort coordinates usinf ::-1</div><div>printVarSummary(uwnd)</div><div><br></div><div>vwnd = vfile-&gt;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 = &quot;velocity potential&quot;</div><div>vp@units     = &quot;m/s&quot;</div></div><div><div>ncdf = addfile(&quot;<a href="http://test.nc">test.nc</a>&quot; ,&quot;c&quot;)  ; open output netCDF file</div><div><br></div><div>fAtt               = True            ; assign file attributes</div><div>fAtt@title         = &quot;Velocity Potential&quot;</div><div>fAtt@source_file   =  &quot;<a href="https://www.esrl.noaa.gov/psd/data/gridded/data.ncep.reanalysis.pressure.html">https://www.esrl.noaa.gov/psd/data/gridded/data.ncep.reanalysis.pressure.html</a>&quot;</div><div>fAtt@Conventions   = &quot;None&quot;</div><div>fAtt@creation_date = systemfunc (&quot;date&quot;)</div><div>fileattdef( ncdf, fAtt )            ; copy file attributes</div><div><br></div><div>ncdf-&gt;vp = vp</div><div>end</div></div><div><br></div><div><br></div><div>Here&#39;s the link to the files:</div><div><br></div><div><a href="https://drive.google.com/drive/folders/0B9faET7Bc2o8MmtGS2VJLTB2NE0?usp=sharing">https://drive.google.com/drive/folders/0B9faET7Bc2o8MmtGS2VJLTB2NE0?usp=sharing</a></div></div></div></div></div></div></div></div></div>
</div>