[ncl-talk] Calculating Velocity Potential (problem with saving output)

Alan Brammer abrammer at albany.edu
Fri Jan 6 10:32:37 MST 2017


> On 5 Jan 2017, at 20:54, Lyndon Mark Olaguera <olagueralyndonmark429 at gmail.com> wrote:
> 
> sfvp = sfvp(1,:,:,:)

This won’t in NCL.  NCL won’t dynamically change the size of an existing variable.  

You can (assuming you’re using a recent version of NCL) however use the := notation, which will effectively redefine the sfvp variable.  e.g.  sfvp := sfvp(1,:,:,:)
Then the rest of your script should work as expected.  

Though for the sake of having variable names that make sense I would do as below. 



begin
ufile = addfile("uwind200hPa_1975.nc","r")       ;single level(200hPa) only
vfile = addfile("vwind200hPa_1975.nc","r")        ;single level(200hPa) only

uwnd = ufile->uwnd(:,0,::-1,:)     ;sort coordinates usinf ::-1
printVarSummary(uwnd)

vwnd = vfile->vwnd(:,0,::-1,:)     ;sort coordinates using ::-1
printVarSummary(vwnd)

sfvp = uv2sfvpF(uwnd,vwnd)

vp = sfvp(1,:,:,:)

vp = vp/1e6                  ;rescaling by 1e6

copy_VarCoords(uwnd,vp)
vp at long_name = "velocity potential"
vp at units     = "m/s”
printVarSummary(vp)

ncdf = addfile("test.nc <http://test.nc/>" ,"c")  ; open output netCDF file

fAtt               = True            ; assign file attributes
fAtt at title         = "Velocity Potential"
fAtt at source_file   =  "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>"
fAtt at Conventions   = "None"
fAtt at creation_date = systemfunc ("date")
fileattdef( ncdf, fAtt )            ; copy file attributes

ncdf->sfvp = vp
end

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170106/f79fbdbd/attachment.html 


More information about the ncl-talk mailing list