From: Bold Khan <gkhan100_at_nyahnyahspammersnyahnyah>

Date: Sun Dec 19 2010 - 16:35:11 MST

Date: Sun Dec 19 2010 - 16:35:11 MST

Hi. Understand.

I am still getting an error. The function does not like what I am

using for "r" (or dX, second part of command) although I don't see

what else to use...

dX = radius*cos(radian*lat)*dlon

do nl=0,nlat-1

dvdx(nl,:) = center_finite_diff_n (v(nl,:), dX, False, 0, 0)

end do

Did I have it written correctly the first time?

-Bold

[ 06:23:38 ] > ncl tester.ncl

Copyright (C) 1995-2010 - All Rights Reserved

University Corporation for Atmospheric Research

NCAR Command Language Version 5.2.1

The use of this software is governed by a License Agreement.

See http://www.ncl.ucar.edu/ for more details.

Variable: v

Type: float

Total Size: 27156 bytes

6789 values

Number of Dimensions: 2

Dimensions and sizes: [lat | 73] x [lon | 93]

Coordinates:

lat: [-19.5..34.5]

lon: [-34.5..34.5]

Number Of Attributes: 13

lev : 700

lonFlip : longitude coordinate variable has been reordered via lonFlip

initial_time : 09/02/2006 (00:00)

forecast_time_units : hours

forecast_time : 0

parameter_number : 132

parameter_table_version : 128

gds_grid_type : 0

level_indicator : 109

_FillValue : 1e+20

units : m s**-1

long_name : V velocity

center : European Center for Medium-Range Weather Forecasts (RSMC)

Variable: dX

Type: float

Total Size: 292 bytes

73 values

Number of Dimensions: 1

Dimensions and sizes: [73]

Coordinates:

fatal:center_finite_diff_n: r must either be a scalar, a 1D array the

same length as the dim-th dimemsion of q, or the same size as q

fatal:Execute: Error occurred at or near line 32 in file tester.ncl

Variable: dY

Type: float

Total Size: 4 bytes

1 values

Number of Dimensions: 1

Dimensions and sizes: [1]

Coordinates:

(0)

(0) min=-999 max=-999

[ 06:24:14 ] >

!!!!!!!!!!! CODE

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"

;;; some contants

pi = 4.0*atan(1.0)

radian = pi/180.0

radius = 6370949.0

FILEIN = "era_uv.nc"

;;;;;;;;

a = addfile(FILEIN,"r")

U=a->U

u=U(0,{700},:,:)

V=a->V

v=V(0,{700},:,:)

printVarSummary(v)

lat = a->lat

lon = a->lon

nlat = dimsizes(lat)

mlon = dimsizes(lon)

dlon = (max(lon)-min(lon))/(mlon-1)

dlat = (max(lat)-min(lat))/(nlat-1)

; Arrays

dvdx = new ( (/nlat,mlon/), typeof(v), v@_FillValue)

dudy = new ( (/nlat,mlon/), typeof(v), v@_FillValue)

; Calculate dv/dx & du/dy with loops

dX = radius*cos(radian*lat)*dlon ; array dX[*] because lat[*]

printVarSummary(dX)

do nl=0,nlat-1

dvdx(nl,:) = center_finite_diff_n (v(nl,:), dX, False, 0, 0)

end do

dY = radius*radian*dlat

printVarSummary(dY)

do ml=0,mlon-1

dudy(:,ml) = center_finite_diff_n (v(:,ml), dY, False, 0, 0)

end do

vor = dvdx - dudy

printMinMax(vor,True)

On Sun, Dec 19, 2010 at 5:40 PM, Dennis Shea <shea@ucar.edu> wrote:

*> dX = radius*cos(radian*lat)*dlon ; array dX[*] because lat[*]
*

*>
*

*> do nl=0,nlat-1
*

*> dvdx(nl,:) = center_finite_diff_n (v(nl,:), dX, False, 0, 0)
*

*> end do
*

*>
*

*> dY = radius*radian*dlat
*

*>
*

*> do ml=0,mlon-1
*

*> dudy(:,ml) = center_finite_diff_n (v(:,ml), dY, False, 0, 0)
*

*> end do
*

*>
*

*> Essentially the same as in fortran 90, Matlab,....
*

*>
*

*>
*

*> On 12/19/10 3:28 PM, Bold Khan wrote:
*

*>>
*

*>> Dennis, Thank you! This was an oversight on my part. I made this
*

*>> correction.
*

*>> So the script, the way it's written, works. But I am not sure if its
*

*>> actually right. I don't feel that it is.
*

*>> May I have a little conceptual help?
*

*>>
*

*>> If I want to calculate vorticity: (i.e. rv = (dv/dy) - (du/dx)
*

*>> Do dv/dx and dvdy need to be in the same loop or can they be
*

*>> separate as I have done?
*

*>> And, since I yearn to be an efficient NCLer, and avoid do loops where
*

*>> possible, is there a way not
*

*>> to use loops for this calculation?
*

*>>
*

*>> Again, thank you for your time.
*

*>> Still trying to wrap my brain around this.
*

*>> -Bold
*

*>>
*

*>>
*

*>> 05:12:16 ]> ncl tester.ncl
*

*>> Copyright (C) 1995-2010 - All Rights Reserved
*

*>> University Corporation for Atmospheric Research
*

*>> NCAR Command Language Version 5.2.1
*

*>> The use of this software is governed by a License Agreement.
*

*>> See http://www.ncl.ucar.edu/ for more details.
*

*>> (0)
*

*>> (0) min=-4.3992e-05 max=4.80107e-05
*

*>>
*

*>> CODE
*

*>>
*

*>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
*

*>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
*

*>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
*

*>> ;======================== some contants
*

*>> pi = 4.0*atan(1.0)
*

*>> radian = pi/180.0
*

*>> radius = 6370949.0
*

*>> FILEIN = "era_uv.nc"
*

*>> ;======================== Read in file and variables
*

*>> a = addfile(FILEIN,"r")
*

*>> U=a->U
*

*>> u=U(0,{700},:,:)
*

*>> V=a->V
*

*>> v=V(0,{700},:,:)
*

*>>
*

*>> lat = a->lat
*

*>> lon = a->lon
*

*>> nlat = dimsizes(lat)
*

*>> mlon = dimsizes(lon)
*

*>> dlon = (max(lon)-min(lon))/(mlon-1)
*

*>> dlat = (max(lat)-min(lat))/(nlat-1)
*

*>> ;===================================== Arrays
*

*>> dvdx = new ( (/nlat,mlon/), typeof(v), v@_FillValue)
*

*>> dudy = new ( (/nlat,mlon/), typeof(v), v@_FillValue)
*

*>> ;===================================== loops
*

*>> do nl=0,nlat-1
*

*>> dX = radius*cos(radian*lat(nl))*dlon
*

*>> dvdx(nl,:) = center_finite_diff_n (v(nl,:), dX, False, 0, 0)
*

*>> end do
*

*>> do ml=0,mlon-1
*

*>> dY = radius*radian*dlat
*

*>> dudy(:,ml) = center_finite_diff_n (v(:,ml), dY, False, 0, 0)
*

*>> end do
*

*>> vor = dvdx - dudy
*

*>>
*

*>> printMinMax(vor,True)
*

*>>
*

*>>
*

*>>
*

*>> On Sun, Dec 19, 2010 at 4:44 PM, Dennis Shea<shea@ucar.edu> wrote:
*

*>>>
*

*>>> You did not define the variables correctly.
*

*>>>
*

*>>> You created the following arrays
*

*>>>
*

*>>>> dvdx = new ( (/nlat,mlon/), typeof(v), v@_FillValue)
*

*>>>> dudx = new ( (/nlat,mlon/), typeof(v), v@_FillValue)
*

*>>>
*

*>>> Then you used
*

*>>>
*

*>>>> dvdx(nl,:) = center_finite_diff_n (v(nl,:), dX, False, 0, 0)
*

*>>>
*

*>>> :
*

*>>>>
*

*>>>> dudy(:,ml) = center_finite_diff_n (v(:,ml), dY, False, 0, 1)
*

*>>>
*

*>>> Where did you preallocate space for dudy??
*

*>>> The error messages told you exactly what the problem is:
*

*>>>
*

*>>>> fatal:Undefined identifier: (dudy) is undefined, can't continue
*

*>>>> fatal:Execute: Error occurred at or near line 30 in file tester.ncl
*

*>>>>
*

*>>>> fatal:Variable (dudy) is undefined
*

*>>>> fatal:Execute: Error occurred at or near line 33 in file tester.ncl
*

*>>>>
*

*>>>> fatal:Variable (vor) is undefined
*

*>>>
*

*>>> vor is undefined because the dudy is undefined
*

*>>>
*

*>>> ==
*

*>>>
*

*>>> I think waht you want is:
*

*>>>
*

*>>> dudy = new ( (/nlat,mlon/), typeof(v), v@_FillValue)
*

*>>>
*

*>>>
*

*>>> On 12/19/10 12:55 PM, Bold Khan wrote:
*

*>>>>
*

*>>>> Dear ncl users,
*

*>>>> Could I have some help? I am still learning ncl.
*

*>>>> I am getting confused with using the center_finite_diff_n command to
*

*>>>> calculate relative vorticity (RV) with non-cyclic data.
*

*>>>> I want to calculate (RV) using center_finite_diff_n, instead of just
*

*>>>> resorting to using the uv2vr_cfd command that is available, because I
*

*>>>> want to calculate RV and then shear vorticity separately.
*

*>>>> I am following example 6 at
*

*>>>>
*

*>>>>
*

*>>>> http://www.ncl.ucar.edu/Document/Functions/Built-in/center_finite_diff_n.shtml.
*

*>>>>
*

*>>>> 1) Do dv/dx and dvdy need to be in the same loop or can they be
*

*>>>> separate as I have done?
*

*>>>> 2) Since we want to try and avoid do loops in ncl, is there a way not
*

*>>>> to use loops for this calculation
*

*>>>> Any amount of advice, would be greatly appreciated.
*

*>>>> Sincerely,
*

*>>>> Bold
*

*>>>>
*

*>>>>
*

*>>>> [ 02:42:16 ]> ncl tester.ncl
*

*>>>> Copyright (C) 1995-2010 - All Rights Reserved
*

*>>>> University Corporation for Atmospheric Research
*

*>>>> NCAR Command Language Version 5.2.1
*

*>>>> The use of this software is governed by a License Agreement.
*

*>>>> See http://www.ncl.ucar.edu/ for more details.
*

*>>>> fatal:Undefined identifier: (dudy) is undefined, can't continue
*

*>>>> fatal:Execute: Error occurred at or near line 30 in file tester.ncl
*

*>>>>
*

*>>>> fatal:Variable (dudy) is undefined
*

*>>>> fatal:Execute: Error occurred at or near line 33 in file tester.ncl
*

*>>>>
*

*>>>> fatal:Variable (vor) is undefined
*

*>>>> fatal:Execute: Error occurred at or near line 35 in file tester.ncl
*

*>>>>
*

*>>>> [ 02:48:25 ]>
*

*>>>>
*

*>>>>
*

*>>>>
*

*>>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
*

*>>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
*

*>>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
*

*>>>> ;;; some contants
*

*>>>> pi = 4.0*atan(1.0)
*

*>>>> radian = pi/180.0
*

*>>>> radius = 6370949.0
*

*>>>> FILEIN = "era_uv.nc"
*

*>>>> ;=========================variables
*

*>>>> a = addfile(FILEIN,"r")
*

*>>>> U=a->U
*

*>>>> u=U(0,{700},:,:)
*

*>>>> V=a->V
*

*>>>> v=V(0,{700},:,:)
*

*>>>>
*

*>>>> lat = a->lat
*

*>>>> lon = a->lon
*

*>>>> nlat = dimsizes(lat)
*

*>>>> mlon = dimsizes(lon)
*

*>>>> dlon = (max(lon)-min(lon))/(mlon-1)
*

*>>>> dlat = (max(lat)-min(lat))/(nlat-1)
*

*>>>> ; Arrays
*

*>>>> dvdx = new ( (/nlat,mlon/), typeof(v), v@_FillValue)
*

*>>>> dudx = new ( (/nlat,mlon/), typeof(v), v@_FillValue)
*

*>>>> ; loops
*

*>>>> do nl=0,nlat-1
*

*>>>> dX = radius*cos(radian*lat(nl))*dlon
*

*>>>> dvdx(nl,:) = center_finite_diff_n (v(nl,:), dX, False, 0, 0)
*

*>>>> end do
*

*>>>> do ml=0,mlon-1
*

*>>>> dY = radius*radian*dlat
*

*>>>> dudy(:,ml) = center_finite_diff_n (v(:,ml), dY, False, 0, 1)
*

*>>>> end do
*

*>>>> vor = dvdx - dudy
*

*>>>>
*

*>>>> printMinMax(vor,True)
*

*>>>> _______________________________________________
*

*>>>> ncl-talk mailing list
*

*>>>> List instructions, subscriber options, unsubscribe:
*

*>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
*

*>>>
*

*>
*

_______________________________________________

ncl-talk mailing list

List instructions, subscriber options, unsubscribe:

http://mailman.ucar.edu/mailman/listinfo/ncl-talk

Received on Sun Dec 19 16:35:20 2010

*
This archive was generated by hypermail 2.1.8
: Wed Dec 22 2010 - 16:10:23 MST
*