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

Lyndon Mark Olaguera olagueralyndonmark429 at gmail.com
Thu Jan 5 18:54:46 MST 2017


Dear Sir Dennis,

Many thanks for the suggestion.

I still have one question though:

According to the ncl page:


*The returned array will be dimensioned 2 x dimsizes
<http://www.ncl.ucar.edu/Document/Functions/Built-in/dimsizes.shtml>(u),
where the 0-th element of the leftmost dimension contains the stream
function and the 1-th element of the leftmost dimension contains the
velocity potential (both in ascending latitude order)*

If I understand this correctly, I should be adding this line in the script
to save only the calculated velocity potential?

*sfvp = sfvp(1,:,:,:)*


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)

*sfvp = sfvp(1,:,:,:)*

sfvp = sfvp/1e6                  ;rescaling by 1e6

*copy_VarCoords(uwnd,sfvp)*

sfvp at long_name = "velocity potential"
sfvp at units     = "m/s"
ncdf = addfile("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"
fAtt at Conventions   = "None"
fAtt at creation_date = systemfunc ("date")
fileattdef( ncdf, fAtt )            ; copy file attributes

ncdf->sfvp = sfvp
end


Many thanks for the help.

*Lyndz*




On Fri, Jan 6, 2017 at 10:23 AM, "김창환" <blueedu at korea.kr> wrote:

> Hi,
>
>
>
> Why don't you use "*sfvp* = *sfvp */ 1e6" instead of "*sfvp* = (/*sfvp*
> /1e6/)"?
>
> and* vp* = (/*vp*/1e6/) => *vp* = *vp*/1e6
>
>
>
> Changhwan.
> --------- 원본 메일 ---------
>
> *보낸사람* : Lyndon Mark Olaguera <olagueralyndonmark429 at gmail.com>
> *받는사람* : Mary Haley <haley at ucar.edu>
> *참조* : "ncl-talk at ucar.edu" <ncl-talk at ucar.edu>
> *받은날짜* : 2017년 Jan 6일(Fri) 10:12:36
> *제목* : Re: [ncl-talk] Calculating Velocity Potential (problem with saving
> output)
>
> Dear Mary,
>
> I corrected my script but I still encounter the following errors:
>
> fatal:Subscript out of range, error in subscript #0
> fatal:An error occurred reading dfrom
> fatal:["Execute.c":8575]:Execute: Error occurred at or near line 190 in
> file /usr/local/ncl-6.3.0/lib/ncarg/nclscripts/csm/contributed.ncl
> fatal:["Execute.c":8575]:Execute: Error occurred at or near line 20 in
> file chi.ncl
>
>
> Line 20 in the script is the copy_VarCoords(ufile,*vp*).
>
> Any suggestions to properly output this?
>
> Many thanks,
>
> *Lyndz*
>
> On Fri, Jan 6, 2017 at 12:39 AM, Mary Haley <haley at ucar.edu> wrote:
>
>> Lyndz,
>>
>> It looks like a simple typo.  You have:
>>
>> *sfvp* = uv2sfvpF(uwnd,vwnd)
>> *sfvp* = (/*sfvp*/1e6/)                   ;rescaling by 1e6
>>
>> copy_VarCoords(ufile,*vp*)
>>
>> *vp*@long_name = "velocity potential"
>> *vp*@units     = "m/s"
>>
>> The variable you're computing is called *sfvp*, but then you refer to
>> *vp* after that. Change the two *sfvp* lines to be *vp* instead:
>>
>> *vp* = uv2sfvpF(uwnd,vwnd)
>> *vp* = (/*vp*/1e6/)                   ;rescaling by 1e6
>>
>> --Mary
>>
>>
>> On Thu, Jan 5, 2017 at 1:34 AM, Lyndon Mark Olaguera <
>> olagueralyndonmark429 at gmail.com> wrote:
>>
>>> Dear All,
>>>
>>> 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.
>>>
>>> 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?
>>>
>>> I attached the link of the files that I'm working with and the script in
>>> this email.
>>> I highlight in red the line where I got stuck.
>>>
>>> I'll appreciate any help.
>>>
>>> Many thanks,
>>>
>>> Lyndz
>>>
>>>
>>> Here's my script:
>>>
>>> ;****************************************************
>>> ;This script calculates the velocity potential
>>> ;Input: U and V wind components
>>> ;****************************************************
>>> begin
>>> ufile = addfile("uwind200hPa_1975.nc","r")
>>> vfile = addfile("vwind200hPa_1975.nc","r")
>>> uwnd = ufile->uwnd(:,:,::-1,:)     ;sort coordinates usinf ::-1
>>> printVarSummary(uwnd)
>>>
>>> vwnd = vfile->vwnd(:,:,::-1,:)     ;sort coordinates using ::-1
>>> printVarSummary(vwnd)
>>>
>>> sfvp = uv2sfvpF(uwnd,vwnd)
>>> sfvp = (/sfvp/1e6/)                   ;rescaling by 1e6
>>>
>>> *copy_VarCoords(ufile,vp)*
>>>
>>> vp at long_name = "velocity potential"
>>> vp at units     = "m/s"
>>> ncdf = addfile("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/ps
>>> d/data/gridded/data.ncep.reanalysis.pressure.html"
>>> fAtt at Conventions   = "None"
>>> fAtt at creation_date = systemfunc ("date")
>>> fileattdef( ncdf, fAtt )            ; copy file attributes
>>>
>>> ncdf->vp = vp
>>> end
>>>
>>>
>>> Here's the link to the files:
>>>
>>> https://drive.google.com/drive/folders/0B9faET7Bc2o8MmtGS2VJ
>>> LTB2NE0?usp=sharing
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170106/2dd8a7a0/attachment.html 


More information about the ncl-talk mailing list