From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>

Date: Tue Aug 13 2013 - 15:10:54 MDT

Date: Tue Aug 13 2013 - 15:10:54 MDT

Rather than:

L = sum((Qv1*dx_1)+Qu2*dy+(Qv2*dx_2)+Qu1*dy)

The 'x' and 'y' paths are not the same size.

Do a printVarSummary(...) of each term to verify.

That is what led to the error.

===

You should add each track separately.

Arrays dimensioned: [12] x [32] x [lon | 144] x [lat | 73]

Qu1 = Quu(:,:,{270},{60:80}) * dy ; (:,:,:)

Qu2 = Quu(:,:,{357},{60:80}) * dy

Qv1 = Qvv(:,:,{270:357},{60})* dx_1

Qv2 = Qvv(:,:,{270:357},{80})* dx_2

L1 = dim_sum_n(Qv1, 2) ; left->right

L2 = dim_sum_n(Qu2, 2) ; up

L3 = dim_sum_n(Qv2, 2) : right->left

L4 = dim_sum_n(Qu1, 2) ; down

L = L1 + L2+ L3 + L4 ; L(12,32)

==================================================

ine integration: answer = SUM[q(i)*dlen(i)]

For a rectilinear grid and traversing in a counter-clockwise manner:

<= left

+ + + + 60

+ + 50

| ^

down + + lat | 40

up

+ + 30

+ + + + 20

lon =>

130 140 150 160

Q(time,lev,lat,lon)

Here is a crude approach for a rectilinear grid.

This assumes dx is he same at each latitude and dy

is constant

Q1 = dim_sum_n( Q(:,:,{20},{130:160})*dx({20}), 2) ; left->right

Q2 = dim_sum_n( Q(:,:,{20:60},{160}) *dy) , 2) ; up

Q3 = dim_sum_n( Q(:,:,{60},{130:160})*dx(60) , 2) : right->left

Q4 = dim_sum_n( Q(:,:,{20:60},{130}) *dy) , 2) ; down

QQ = Q1 + Q2+ Q3 + Q4 ; QQ(ntime,lev)

Circulation: U(time,lev,lat,lon), V(time,lev,lat,lon)

C1 = dim_sum_n( U(:,:,{20},{130:160})*dx({20}, 2) ; right->left

C2 = dim_sum_n( V(:,:,{20:60},{160}) *dy) , 2) ; up

C3 = dim_sum_n( U(:,:,{60},{130:160})*dx(60) , 2) : left->right

C4 = dim_sum_n( V(:,:,{20:60},{130}) *dy) , 2) ; down

C = C1 + C2+ C3 + C4 ; C(ntime)

On 8/13/13 2:07 PM, Bithi De wrote:

*> Hi,
*

*> Thanks Dennis for the reply.
*

*> Let me explain my question clearly.
*

*>
*

*> * I have rectilinear grid.
*

*> * I have U-component and V-component at each grid point , with print
*

*> variable summary like this: (where 12= no. of months and 32= no. of
*

*> years)
*

*>
*

*> Variable: Qvv
*

*> Type: float
*

*> Total Size: 16146432 bytes
*

*> 4036608 values
*

*> Number of Dimensions: 4
*

*> Dimensions and sizes: [12] x [32] x [lon | 144] x [lat | 73]
*

*> Coordinates:
*

*> lon: [ 0..357.5]
*

*> lat: [90..-90]
*

*> Number Of Attributes: 1
*

*> _FillValue : 9.96921e+36
*

*>
*

*>
*

*> Variable: Quu
*

*> Type: float
*

*> Total Size: 16146432 bytes
*

*> 4036608 values
*

*> Number of Dimensions: 4
*

*> Dimensions and sizes: [12] x [32] x [lon | 144] x [lat | 73]
*

*> Coordinates:
*

*> lon: [ 0..357.5]
*

*> lat: [90..-90]
*

*> Number Of Attributes: 1
*

*> _FillValue : 9.96921e+36
*

*>
*

*>
*

*>
*

*> * I want to calculate line integration along the east, west boundary
*

*> of an area for u component and line integration along the south and
*

*> north boundary of an area for v component.
*

*> I tried like the following:
*

*>
*

*> re = 6.37122e06
*

*> rad = 4.0* atan(1.0) / 180.0
*

*> con = re * rad
*

*> clat = cos(lat * rad) ; cosine of latitude
*

*>
*

*> dlon = (lon(2) - lon(1))
*

*> dlat = (lat(2) - lat(1))
*

*> dx = con * dlon * clat ; dx at each latitude
*

*> dy = con * dlat ; dy is constant
*

*>
*

*>
*

*> dx1 = conform(Quu,dx,3)
*

*> dx1!3 = "lat"
*

*> dx1!2 = "lon"
*

*> dx1&lat = lat
*

*> dx1&lon = lon
*

*> printVarSummary(dx1)
*

*> printVarSummary(dy)
*

*>
*

*>
*

*> ;***********************************************************************************
*

*> ; transport across the boundary of the region
*

*> ;***********************************************************************************
*

*>
*

*> Qu1 = Quu(:,:,{270},{60:80}) ;quu component value across east
*

*> boundary at longitude 270
*

*> printVarSummary (Qu1)
*

*>
*

*> Qu2 = Quu(:,:,{357},{60:80}) ;quu component value across west
*

*> boundary at longitude 357.5
*

*> printVarSummary (Qu2)
*

*>
*

*> Qv1 = Qvv(:,:,{270:357},{60}) ;Qvv component across
*

*> south boundary at latitude 60
*

*> Qv2 = Qvv(:,:,{270:357},{80}) ;Qvv component across
*

*> north boundary at latitude 80
*

*> printVarSummary (Qv1)
*

*>
*

*> printVarSummary (Qv2)
*

*>
*

*>
*

*> dx_1=dx1(:,:,{270:357},{60})
*

*> dx_2=dx1(:,:,{270:357},{80})
*

*> printVarSummary (dx_1)
*

*> printVarSummary (dx_2)
*

*>
*

*> L = sum((Qv1*dx_1)+Qu2*dy+(Qv2*dx_2)+Qu1*dy)
*

*>
*

*> For calculating L, I am getting an error like this:
*

*> fatal:Plus: Dimension size, for dimension number 2, of operands does
*

*> not match, can't continue
*

*>
*

*> Did I calculate dx and dy in wrong way? What should be the right approach?
*

*> Thanks for your time.
*

*> Bithi
*

*>
*

*>
*

*> On 8/12/13, Dennis Shea <shea@ucar.edu> wrote:
*

*>> Hi Bithi,
*

*>>
*

*>> This is offline. Respond to ncl-talk@ucar.edu only
*

*>>
*

*>> I hesitate to answer because I am very busy and I do
*

*>> not have a lot of time to answer ncl-talk questions.
*

*>>
*

*>> What type of grid do you have? rectilinear or curvilinear?
*

*>>
*

*>> What have *you* tried? We at ncl-talk sometimes feel people
*

*>> want us to write the code for them. We do not have the time.
*

*>>
*

*>>
*

*>>
*

*>> <= left
*

*>>
*

*>> + + + + 60
*

*>>
*

*>> + + 50
*

*>> |
*

*>> down + + lat up 40
*

*>>
*

*>> + + 30
*

*>>
*

*>> + + + + 20
*

*>>
*

*>> lon =>
*

*>>
*

*>> 130 140 150 160
*

*>>
*

*>> You have U and V at each grid point. Usually, you must go
*

*>> counter clockwise around for the circulation theorm.
*

*>>
*

*>> U(time,lat,lon), V(time,lat,lon)
*

*>>
*

*>> Here is a crude approach for a rectilinear grid.
*

*>>
*

*>>
*

*>> C = sum( U(:,{20},{130:160})*dx({20}) \
*

*>> +V(:,{20:60},{160}) *dy) \
*

*>> +U(:,{60},{130:160})*dx(60) \
*

*>> +V(:,{20:60},{130}) +dy )
*

*>>
*

*>> C(ntim)
*

*>>
*

*>>
*

*>> Please ask your advisor or a colleague.
*

*>>
*

*>>
*

*>> On 8/9/13 6:02 PM, Bithi De wrote:
*

*>>> Hi All,
*

*>>> Is it possible to calculate line integration using NCL? I need to
*

*>>> calculate line integration along each boundary of an area.
*

*>>>
*

*>>> Thanks .
*

*>>> Bithi
*

*>>>
*

*>>
*

*>
*

*>
*

_______________________________________________

ncl-talk mailing list

List instructions, subscriber options, unsubscribe:

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

Received on Tue Aug 13 15:10:37 2013

*
This archive was generated by hypermail 2.1.8
: Wed Aug 14 2013 - 18:35:09 MDT
*