# Re: Derivative between 2 levels

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Tue, 7 Jul 2009 07:34:57 -0600 (MDT)

On Wed, 1 Jul 2009, Brandon Fisel wrote:

> Hi NCL'ers
>
> I'm attempting to calculate the horizontal wind between two metgrid levels
> (num_metgrid_levels=3 and num_metgrid_levels=4 - 850mb and 700mb). Below is
> a segment of the ncl script performing the calculation:
>
> v_P = f->VV(:,0,(/3,4/),:,:)
> v_P!0 = "record"
> v_P!1 = "num_metgrid_levels"
> v_P!2 = "lat"
> v_P!3 = "lon"
> z_P = f->GHT(:,0,(/3,4/),:,:)
> z_P!0 = "record"
> z_P!1 = "num_metgrid_levels"
> z_P!2 = "lat"
> z_P!3 = "lon"
> v =
> 0.5*(v_P(record|:,num_metgrid_levels|:,lat|0:204,lon|:)+v_P(record|:,num_metgrid_levels|:,lat|
> 1:205,lon|:)) ; get V on mass grid
> v!0 = "record"
> v!1 = "num_metgrid_levels"
> v!2 = "lat"
> v!3 = "lon"
>
> do nt=0,ntimes
> type = "ps"
> suffix = TimeChar(nt,0,:)+""
> print ("Suffix is:" + suffix)
> path = diro+""+prefix+""+suffix
> print ("Path is:" + path)
> wks = gsn_open_wks(type,path)
> fo(nt,:,:) = 2*0.00007292*sin_r(nt,:,:) ; coriolis parameter
> N = 0.011 ; Brunt-Vaisala Freq. s-1
> dVdZ = center_finite_diff (v(record|
> nt,lat|:,lon|:,num_metgrid_levels|:),z_P(record|
> nt,lat|:,lon|:,num_metgrid_levels|:),False,0)
> printVarSummary(dVdZ)
> print ("dVdZ is: " + dVdZ)
> s_BI = (0.31*fo*dVdZ)/N ; Eady Baro. Parameter
>
>
> On the last printVarSummary for the dVdZ, I lose my time coordinate and
> receive an error for the s_BI line:

Brandon,

You lose the time coordinate because whenever you do an operation on
an array that involves a calculation, the metadata is not copied.

However, I don't think this is the problem. I think the problem is
that you are trying to do a calcuation involving arrays of different
sizes.

With the line:

s_BI = (0.31*fo*dVdZ)/N ; Eady Baro. Parameter

"fo" is 3-dimensional, and I believe "dVdZ" is 4-dimensional.

In order to do this kind of calculation, fo and dVdZ have to be
the same dimensionality, or one of them must be a scalar.

You can use the "conform" or "conform_dims" function if
you want to "promote" an array to be the same size as a bigger
array that it is a subset of dimension-wise. See:

--Mary

> fatal:Mul: Dimension size, for dimension number 0, of operands does not
> match, can't continue
>
> fatal:Execute: Error occurred at or near line 107 in file eady_baro.ncl
>
>
> I'm under the impression that this isn't what I want. What am I doing wrong?
>
>
> -------------------------------------------------------------
> Brandon Fisel
>
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Jul 07 2009 - 07:34:57 MDT

This archive was generated by hypermail 2.2.0 : Tue Jul 07 2009 - 11:13:18 MDT