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

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Wed Jun 27 2012 - 10:31:23 MDT

Wei,

You need to use int2p_n to interpolate your "w" values to be on the same level as your original "t" array (the one dimensioned [time | 24] x [lev | 23] x [lat | 145] x [lon | 288]).

I imagine it would look something like this:
  
   linlog = -1 ; the "-1" allows for extrapolation of levels outside the range of t&lev.
   t_new = int2p_n(t&lev, t, w&lev, linlog, 1)

At this point, I believe t_new should be the same size as "w", because the level dimension of "t" will have been replaced with the level dimension of "w".

You can then use t_new in the relhum call.

--Mary

On Jun 25, 2012, at 7:53 AM, wei wrote:

> Hi,
> Sorry for a mistakeI tried to make the level of t to the level of w but it is not ture,in printVarSummary the level is 0:100, but I need from 0:1000.
> thx
>
>
> ---------- Forwarded message ----------
> From: wei <whua27@gmail.com>
> Date: Mon, Jun 25, 2012 at 11:23 AM
> Subject: Re: Fwd: Re.fatal:relhum: The input arrays must have the same dimension sizes
> To: Dennis Shea <shea@ucar.edu>
> Cc: ncl-talk@ucar.edu
>
>
> Dear Dennis and Mary,
> Thanks a lot for your kind support. I don't know the way is right or wrong, however, I have solved the problem just adding something like this:
> dimt = dimsizes(t)
> dimw = dimsizes(w)
> if (dimsizes(dimt) .ne. dimsizes(dimw)) then
> print("w: rank of t .ne. rank of w")
> exit
> end if
> ; w = new (dimsizes(t), typeof(t))
> ; w(:,0:11,:,:) = (/w/)
> copy_VarCoords(t,w)
> w@long_name = "mixing ratio"
> ; w@units = "..."
>
> printVarSummary(w)
> rh = relhum (t, w, conform(t,p,(/0,2,3/)))
> printVarSummary(rh)
> end
>
> thanks again and best regards,
> wei
> *************************************************
> PrintVarSummary:
>
> Variable: t
> 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..23.5]
> lev: [0..100]
>
> 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..23.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:
> time: [0.5..23.5]
> lev: [0..100]
> lat: [90..-90]
> lon: [ 0..358.75]
> Number Of Attributes: 2
> long_name : mixing ratio
> _FillValue : 1e+20
>
> Variable: rh
>
> Type: float
> Total Size: 48107520 bytes
> 12026880 values
> Number of Dimensions: 4
> Dimensions and sizes: [24] x [12] x [145] x [288]
>
> Coordinates:
> Number Of Attributes: 1
> _FillValue : 1e+20
>
>
> On Fri, Jun 22, 2012 at 3:14 AM, Dennis Shea <shea@ucar.edu> wrote:
> This is offline.
>
> You can ftp small samples of the files you have below.
> If they are not small, then use the netCDF operator 'ncrcat'
> or 'ncks' to make them small.
>
> ncrcat -d time,0 anl_p.pres.jma.nc anl_p.pres.jma.t0.nc
> ncrcat -d time,0 anl_p.tmp.jma.nc anl_p.tmp.jma.t0.nc
> ncrcat -d time,0 anl_p.spf.jma.nc anl_p.spf.jma.t0.nc
>
> Then ftp the files to
>
> ftp ftp.cgd.ucar.edu
> anonymous
> <use your email address for the password>
> cd incoming
> put anl_p.pres.jma.t0.nc
> put anl_p.tmp.jma.t0.nc
> put anl_p.spf.jma.t0.nc
> quit
>
> After successful transfer, send email to with the following information:
>
> The names of the files after you have successfully completed the transfer.
>
> The version of NCL you are running (ncl -V).
> The type of system you are on (uname -a).
>
>
> On 6/21/12 8:48 AM, wei wrote:
>
>
> ---------- Forwarded message ----------
> From: *wei* <whua27@gmail.com <mailto: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 <mailto: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 <http://anl_p.pres.jma.nc>","r")
> a1 = addfile("anl_p.tmp.jma.nc <http://anl_p.tmp.jma.nc>","r")
> a2 = addfile("anl_p.spf.jma.nc <http://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
> <mailto: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 <http://anl_p.pres.jma.nc>","r")
> > a1 = addfile("anl_p.tmp.jma.nc <http://anl_p.tmp.jma.nc>","r")
> > a2 = addfile("anl_p.spf.jma.nc <http://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
> <mailto: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
> <mailto: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

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Jun 27 10:31:34 2012

This archive was generated by hypermail 2.1.8 : Fri Jun 29 2012 - 15:46:14 MDT