<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'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>;****************************************************</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("uwind200hPa_1975.nc","r")</div><div>vfile = addfile("vwind200hPa_1975.nc","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">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">https://www.esrl.noaa.gov/psd/data/gridded/data.ncep.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">https://drive.google.com/drive/folders/0B9faET7Bc2o8MmtGS2VJLTB2NE0?usp=sharing</a></div></div></div></div></div></div></div></div></div>
</div>