Re: Fwd: Re.fatal:relhum: The input arrays must have the same dimension sizes

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Thu Jun 21 2012 - 09:06:42 MDT

Please read the int2p_n_Wrap documentation carefully.

http://www.ncl.ucar.edu/Document/Functions/Contributed/int2p_n_Wrap.shtml

The first array is supposed to be the pressure levels that you want to interpolate from. You are passing in "q" which looks to be specific humidity.

The idea behind int2p_n is if you have a variable, "x", that is dimensioned (time x level x lat x lon), and say its levels are represented by a 1D array "p", and you want to interpolate "x" to a different set of levels, say "pnew", you use:

   x2 = int2p_n(p,x,pnew,1,1)

--Mary

On Jun 21, 2012, at 8:48 AM, wei wrote:

>
>
> ---------- Forwarded message ----------
> From: wei <whua27@gmail.com>
> Date: Thu, Jun 21, 2012 at 7:46 PM
> Subject: Re: Re.fatal:relhum: The input arrays must have the same dimension sizes
> To: Mary Haley <haley@ucar.edu>
>
>
> Hi,
> Someone give me help how to solve the problem, the script and error are give below:
> thanks and regards,
>
>
> 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"
>
> begin
>
> a = addfile("anl_p.pres.jma.nc","r")
> a1 = addfile("anl_p.tmp.jma.nc","r")
> a2 = addfile("anl_p.spf.jma.nc","r")
> p = a->pres
> printVarSummary(p)
>
> t = a1->tmp
> printVarSummary(t)
> q = a2->spf
> printVarSummary(q)
> w = q/(1-q)
> w@long_name = "mixing ratio"
> copy_VarCoords(q, w) ; assign coordinates
> w!1 = "wlev"
> wlev = (/0,50,100,150,200,250,300,350,400,450\
> ,500,550,600,650,700,750,800,850,900,950,1000/)
> w = int2p_n_Wrap(q,t, wlev,0,1)
> printVarSummary(w)
> end
>
> Error:
> fatal:int2p_n: If xin and pin have the same number of dimensions, then they must be the same dimension sizes
> fatal:Execute: Error occurred at or near line 11617 in file $NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl
>
> fatal:Execute: Error occurred at or near line 23 in file rh.ncl
>
> Variable: p
> Type: float
> Total Size: 4008960 bytes
> 1002240 values
> Number of Dimensions: 3
> Dimensions and sizes: [time | 24] x [lat | 145] x [lon | 288]
> Coordinates:
> time: [0.5..143.5]
> lat: [90..-90]
> lon: [ 0..358.75]
> Number Of Attributes: 11
> center : Japanese Meteorological Agency - Tokyo (RSMC)
> long_name : Pressure reduced to MSL
> units : Pa
> _FillValue : 1e+20
> level_indicator : 102
> gds_grid_type : 0
> parameter_table_version : 3
> parameter_number : 2
> forecast_time : 0
> forecast_time_units : hours
> initial_time : 07/26/2010 (00:00)
>
> Variable: t
> Type: float
> Total Size: 92206080 bytes
> 23051520 values
> Number of Dimensions: 4
> Dimensions and sizes: [time | 24] x [lev | 23] x [lat | 145] x [lon | 288]
> Coordinates:
> time: [0.5..143.5]
> lev: [0..1000]
> lat: [90..-90]
> lon: [ 0..358.75]
> Number Of Attributes: 11
> center : Japanese Meteorological Agency - Tokyo (RSMC)
> long_name : Temperature
> units : K
> _FillValue : 1e+20
> level_indicator : 100
> gds_grid_type : 0
> parameter_table_version : 3
> parameter_number : 11
> forecast_time : 0
> forecast_time_units : hours
> initial_time : 07/26/2010 (00:00)
>
> Variable: q
> Type: float
> Total Size: 48107520 bytes
> 12026880 values
> Number of Dimensions: 4
> Dimensions and sizes: [time | 24] x [lev | 12] x [lat | 145] x [lon | 288]
> Coordinates:
> time: [0.5..143.5]
> lev: [100..1000]
> lat: [90..-90]
> lon: [ 0..358.75]
> Number Of Attributes: 11
> center : Japanese Meteorological Agency - Tokyo (RSMC)
> long_name : Specific humidity
> units : kg kg^-1
> _FillValue : 1e+20
> level_indicator : 100
> gds_grid_type : 0
> parameter_table_version : 3
> parameter_number : 51
> forecast_time : 0
> forecast_time_units : hours
> initial_time : 07/26/2010 (00:00
>
> On Tue, Jun 19, 2012 at 6:55 PM, Mary Haley <haley@ucar.edu> wrote:
>
>
> Your "t" array is [time | 24] x [lev | 23] x [lat | 145] x [lon | 288]
>
> Your "w" array is [time | 24] x [lev | 12] x [lat | 145] x [lon | 288]
>
> There is no way you can "conform" w to be the same size as t, because they both have the same number of dimensions, but different dimension sizes.
>
> To use "relhum", you first have to get "t" and "w" to be on the same levels. Check out the "int2p_n_Wrap" function for this:
>
> http://www.ncl.ucar.edu/Document/Functions/Contributed/int2p_n_Wrap.shtml
>
>
> --Mary
>
> On Jun 19, 2012, at 3:40 AM, wei wrote:
>
> > Dear Mary,
> > thanks for your support. unfortunately, I could not figure out the problem. Hence, code and print summary including error is given below:
> > thank again
> > ****************************************************************
> > 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"
> >
> > begin
> >
> > a = addfile("anl_p.pres.jma.nc","r")
> > a1 = addfile("anl_p.tmp.jma.nc","r")
> > a2 = addfile("anl_p.spf.jma.nc","r")
> > p = a->pres
> > printVarSummary(p)
> > t = a1->tmp
> > printVarSummary(t)
> > q = a2->spf
> > printVarSummary(q)
> >
> > w = q/(1-q)
> > copy_VarCoords(q,w)
> > printVarSummary(w)
> > rh = relhum (t, w, conform(t,p,(/0,2,3/)))
> > printVarSummary(rh)
> > end
> > ************************************************************
> >
> > Copyright (C) 1995-2011 - All Rights Reserved
> > University Corporation for Atmospheric Research
> > NCAR Command Language Version 6.0.0
> > The use of this software is governed by a License Agreement.
> > See http://www.ncl.ucar.edu/ for more details.
> >
> > Variable: p
> > Type: float
> > Total Size: 4008960 bytes
> > 1002240 values
> > Number of Dimensions: 3
> > Dimensions and sizes: [time | 24] x [lat | 145] x [lon | 288]
> > Coordinates:
> > time: [0.5..143.5]
> > lat: [90..-90]
> > lon: [ 0..358.75]
> > Number Of Attributes: 11
> > center : Japanese Meteorological Agency - Tokyo (RSMC)
> > long_name : Pressure reduced to MSL
> > units : Pa
> > _FillValue : 1e+20
> > level_indicator : 102
> > gds_grid_type : 0
> > parameter_table_version : 3
> > parameter_number : 2
> > forecast_time : 0
> > forecast_time_units : hours
> > initial_time : 07/26/2011 (00:00)
> >
> > Variable: t
> > Type: float
> > Total Size: 92206080 bytes
> > 23051520 values
> > Number of Dimensions: 4
> > Dimensions and sizes: [time | 24] x [lev | 23] x [lat | 145] x [lon | 288]
> > Coordinates:
> > time: [0.5..143.5]
> > lev: [0..1000]
> > lat: [90..-90]
> > lon: [ 0..358.75]
> > Number Of Attributes: 11
> > center : Japanese Meteorological Agency - Tokyo (RSMC)
> > long_name : Temperature
> > units : K
> > _FillValue : 1e+20
> > level_indicator : 100
> > gds_grid_type : 0
> > parameter_table_version : 3
> > parameter_number : 11
> > forecast_time : 0
> > forecast_time_units : hours
> > initial_time : 07/26/2011 (00:00)
> >
> > Variable: q
> > Type: float
> > Total Size: 48107520 bytes
> > 12026880 values
> > Number of Dimensions: 4
> > Dimensions and sizes: [time | 24] x [lev | 12] x [lat | 145] x [lon | 288]
> > Coordinates:
> > time: [0.5..143.5]
> > lev: [100..1000]
> > lat: [90..-90]
> > lon: [ 0..358.75]
> > Number Of Attributes: 11
> > center : Japanese Meteorological Agency - Tokyo (RSMC)
> > long_name : Specific humidity
> > units : kg kg^-1
> > _FillValue : 1e+20
> > level_indicator : 100
> > gds_grid_type : 0
> > parameter_table_version : 3
> > parameter_number : 51
> > forecast_time : 0
> > forecast_time_units : hours
> > initial_time : 07/26/2011 (00:00)
> >
> > Variable: w
> > Type: float
> > Total Size: 48107520 bytes
> > 12026880 values
> > Number of Dimensions: 4
> > Dimensions and sizes: [time | 24] x [lev | 12] x [lat | 145] x [lon | 288]
> > Coordinates:
> > time: [0.5..143.5]
> > lev: [100..1000]
> > lat: [90..-90]
> > lon: [ 0..358.75]
> > Number Of Attributes: 1
> > _FillValue : 1e+20
> > fatal:relhum: The input arrays must have the same dimension sizes
> > fatal:Execute: Error occurred at or near line 20 in file rh.ncl
> >
> >
> > On Mon, Jun 18, 2012 at 8:08 PM, Mary Haley <haley@ucar.edu> wrote:
> > Wei,
> >
> > Your question is confusing. Did you actually fix the conform call? You can't use:
> >
> >
> > rh = relhum (t, w, conform(t,p,1)))
> >
> > Because you are then telling "conform" that the second leftmost dimension of "t" is the exact same size as "p". This is not correct. I think you simply have this reversed. That is, all *but* the second dimension of "t" is equal to p, so you should be using:
> >
> > rh = relhum (t, w, conform(t,p,(/0,2,3/)))
> >
> > This basically says "conform p to be equal to the size of t", and hence conform needs to know what dimensions of "p" are already equal to the dimensions of "t".
> >
> > You then mentioned "q", which has different levels than "t", but you didn't show the code that you had for this. "relhum" is pretty basic: all input arrays must be the same size.
> >
> > --Mary
> >
> >
> > On Jun 18, 2012, at 5:51 AM, wei wrote:
> >
> > > Dear Mary,
> > > Thanks for your response, I have followed your guidance but the problem is still exist. variable t (temperature; 23 level) has four dimension like:
> > > time: [0.5..143.5]
> > > lev: [0..1000]
> > > lat: [90..-90]
> > > lon: [ 0..358.75]
> > > but the levels started from 0 to 1000
> > > and q (specific humidity;12 level) is also four dimension,but the levels started from 100 to 1000:
> > > time: [0.5..143.5]
> > > lev: [100..1000]
> > > lat: [90..-90]
> > > lon: [ 0..358.75]
> > > when I calculated w (mixing ration) it gives the followings output:[time | 24] x [lev | 12] x [lat | 145] x [lon | 288]
> > > but when I used the function : rh = relhum (t, w, conform(t,p,1))) for calculating the RH it gives the following error give below and print variable summary is also given.
> > > According to my idea the problem is level and I do not know how to make the equal level of w and t? Please someone give me help to figure out this problem.
> > > thanks in advance and regards,
> > >
> > >
> > >
> > > On Fri, Jun 15, 2012 at 7:07 PM, Mary Haley <haley@ucar.edu> wrote:
> > >
> > > You need to fix the third argument to conform. The third argument is the list of dimension indexes of the first variable that make up the same dimensions in the second variable.
> > > t is time x lev x lat x lon, and p is time x lat x lon, so the dimensions of t that equal the dimensions of p are (/0,2,3/). This is what you want to use instead of "1".
> > >
> > > --Mary
> > >
> > >
> > > On Jun 15, 2012, at 7:49 AM, wei wrote:
> > >
> > > > Dear all,
> > > > Could anyone give me help how to solve the problem for calculating RH from JRA-25 data.
> > > > thanks and regards,
> > > > wei
> > > > ***********************************************
> > > > p = a->pres
> > > > printVarSummary(p)
> > > > t = a1->tmp
> > > > printVarSummary(t)
> > > > q = a2->spf
> > > > printVarSummary(q)
> > > > w = q/(1-q)
> > > > w!0="time"
> > > > w!1="lev"
> > > > w!2="lat"
> > > > w!3="lon"
> > > > printVarSummary(w)
> > > > rh = relhum (t, w, conform(t,p,1))
> > > > printVarSummary(rh)
> > > > end
> > > > ***********************************************
> > > >
> > > > print Var Summary:
> > > > Variable: p
> > > > Type: float
> > > > Total Size: 4008960 bytes
> > > > 1002240 values
> > > > Number of Dimensions: 3
> > > > Dimensions and sizes: [time | 24] x [lat | 145] x [lon | 288]
> > > > Coordinates:
> > > > time: [0.5..143.5]
> > > > lat: [90..-90]
> > > > lon: [ 0..358.75]
> > > > Number Of Attributes: 11
> > > > center : Japanese Meteorological Agency - Tokyo (RSMC)
> > > > long_name : Pressure reduced to MSL
> > > > units : Pa
> > > > _FillValue : 1e+20
> > > > level_indicator : 102
> > > > gds_grid_type : 0
> > > > parameter_table_version : 3
> > > > parameter_number : 2
> > > > forecast_time : 0
> > > > forecast_time_units : hours
> > > > initial_time : 07/26/2010 (00:00)
> > > >
> > > > Variable: t
> > > > Type: float
> > > > Total Size: 92206080 bytes
> > > > 23051520 values
> > > > Number of Dimensions: 4
> > > > Dimensions and sizes: [time | 24] x [lev | 23] x [lat | 145] x [lon | 288]
> > > > Coordinates:
> > > > time: [0.5..143.5]
> > > > lev: [0..1000]
> > > > lat: [90..-90]
> > > > lon: [ 0..358.75]
> > > > Number Of Attributes: 11
> > > > center : Japanese Meteorological Agency - Tokyo (RSMC)
> > > > long_name : Temperature
> > > > units : K
> > > > _FillValue : 1e+20
> > > > level_indicator : 100
> > > > gds_grid_type : 0
> > > > parameter_table_version : 3
> > > > parameter_number : 11
> > > > forecast_time : 0
> > > > forecast_time_units : hours
> > > > initial_time : 07/26/2010 (00:00)
> > > >
> > > > Variable: q
> > > > Type: float
> > > > Total Size: 48107520 bytes
> > > > 12026880 values
> > > > Number of Dimensions: 4
> > > > Dimensions and sizes: [time | 24] x [lev | 12] x [lat | 145] x [lon | 288]
> > > > Coordinates:
> > > > time: [0.5..143.5]
> > > > lev: [100..1000]
> > > > lat: [90..-90]
> > > > lon: [ 0..358.75]
> > > > Number Of Attributes: 11
> > > > center : Japanese Meteorological Agency - Tokyo (RSMC)
> > > > long_name : Specific humidity
> > > > units : kg kg^-1
> > > > _FillValue : 1e+20
> > > > level_indicator : 100
> > > > gds_grid_type : 0
> > > > parameter_table_version : 3
> > > > parameter_number : 51
> > > > forecast_time : 0
> > > > forecast_time_units : hours
> > > > initial_time : 07/26/2010 (00:00)
> > > >
> > > > Variable: w
> > > > Type: float
> > > > Total Size: 48107520 bytes
> > > > 12026880 values
> > > > Number of Dimensions: 4
> > > > Dimensions and sizes: [time | 24] x [lev | 12] x [lat | 145] x [lon | 288]
> > > > Coordinates:
> > > > Number Of Attributes: 1
> > > > _FillValue : 1e+20
> > > > fatal:conform: The array to be conformed must have the same number of dimensions as indicated by the length of the last argument
> > > > fatal:Execute: Error occurred at or near line 24 in file rh.ncl
> > > > _______________________________________________
> > > > 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
> >
> >
> > _______________________________________________
> > 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

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Jun 21 09:06:54 2012

This archive was generated by hypermail 2.1.8 : Mon Jun 25 2012 - 09:57:23 MDT