Re: error about array rearrangement

From: <brownrig_at_nyahnyahspammersnyahnyah>
Date: Thu Dec 19 2013 - 22:17:28 MST

Hi Maria, Yi-Chih,

The self reassignment issue (for lack of a better phrase) you've
uncovered does indeed seem counterintuitive and undesirable from a
programming language perspective; I'll file a ticket to track this
issue. In the meantime, it sounds like there are a couple of
work-arounds (?)

Thanks for indentifying and reporting this!

Rick

On Thu, 19 Dec 2013 18:15:31 -0700
  mgehne@ucar.edu wrote:
> I was thinking about that today and it seems that you can't use the
>reassign
> operator with the same variable on both sides.
>
> So if you have variables A(time,lat,lon) and B = A you can use the
> reassignment
> operator without issues to change B to
>
> B := A(lat|:,lon|:,time|:)
>
> But if you try to redefine A by doing that you get an error message:
>
> A := A(lat|:,lon|:,time|:)
>
> (see attached script)
>
> It seems that the "A := " causes A to be deleted from memory, which
>then
> means
> A is not defined. Hence the error message.
>
> Maybe that reassignment of the same variable is something useful to
>have
> for a
> future NCL release? Although you can always use the original
>variable with
> coordinate
> subscripting to change to dimension order when you need it.
>
> Maria
>
>
>> Hello Maria,
>>
>> I used ":=" before so my current version of NCL support the
>>function.
>> I used a do loop to get around this error. But yet I don't
>>understand
>> why
>> subscription rearrangement or ":=" was not working.
>>
>> Best,
>>
>> Yi-Chih
>>
>>
>> On Fri, Dec 20, 2013 at 1:39 AM, <mgehne@ucar.edu> wrote:
>>
>>> You may not have the latest version of ncl so the ":=" may not work
>>>for
>>> you. You can try defining a new array and then deleting the old one.
>>>
>>> temp = dpcp(lat|:,lon|:,month|:)
>>> delete(dpcp)
>>> dpcp = temp
>>> delete(temp)
>>>
>>> Maria
>>>
>>>
>>> > Hello Maria,
>>> >
>>> > Thanks much for the suggestion. But the result is as follows
>>> after I
>>> > gave "dpcp := dpcp(lat|:,lon|:,month|:)". Any thought?
>>> >
>>> > fatal:["Execute.c":7270]:performASSIGN_VAR_VAR_OP: dpcp is
>>>undefined
>>> > fatal:["Execute.c":8128]:Execute: Error occurred at or near line
>>>96 in
>>> > file
>>> > regrEnso.ncl
>>> >
>>> > Thanks,
>>> >
>>> > Yi-Chih
>>> >
>>> >
>>> > On Thu, Dec 19, 2013 at 1:53 PM, <mgehne@ucar.edu> wrote:
>>> >
>>> >> Hi Yi-Chih,
>>> >>
>>> >> try replacing your line
>>> >> dp(lat|:,lon|:,month|:) = dpcp(month|:,lat|:,lon|:)
>>> >> with
>>> >> dpcp := dpcp(lat|:,lon|:,month|:)
>>> >>
>>> >> This changes the order of dimensions of dpcp to match the order
>>>of
>>> >> dimensions of dp.
>>> >>
>>> >> I hope this helps,
>>> >> Maria
>>> >>
>>> >>
>>> >> > Hello,
>>> >> >
>>> >> > I am trying to rearrange the array dpcp by
>>> >> "dp(lat|:,lon|:,month|:) =
>>> >> > dpcp(month|:,lat|:,lon|:)". The dimensions of dpcp and dp are
>>>as
>>> >> follows.
>>> >> > I believe the command would be working; but it ended up an
>>>error
>>> >> message
>>> >> > "fatal:Dimension size mismatch, dimension (0) of left hand side
>>> >> reference
>>> >> > does not have the same size as the right hand side reference
>>>after
>>> >> > subscripting." I wonder what was the problem with the command?
>>> >> >
>>> >> > Thanks much,
>>> >> >
>>> >> > Yi-Chih
>>> >> >
>>> >> > #####
>>> >> > Variable: dpcp
>>> >> > Type: float
>>> >> > Total Size: 19968 bytes
>>> >> > 4992 values
>>> >> > Number of Dimensions: 3
>>> >> > Dimensions and sizes: [month | 4] x [lat | 24] x [lon | 52]
>>> >> > Coordinates:
>>> >> > month: [5..8]
>>> >> > lat: [-28.75..28.75]
>>> >> > lon: [31.25..158.75]
>>> >> > Number Of Attributes: 17
>>> >> > _FillValue : -9.96921e+36
>>> >> > parent_stat : Mean
>>> >> > statistic : Mean
>>> >> > level_desc : Surface
>>> >> > dataset : GPCP Version 2.2 Combined Precipitation Dataset
>>> >> > var_desc : Precipitation
>>> >> > least_significant_digit : 2
>>> >> > precision : 32767
>>> >> > missing_value : -9.96921e+36
>>> >> > actual_range : ( 0, 9.985388e+29 )
>>> >> > scale_factor : 1
>>> >> > add_offset : 0
>>> >> > units : mm/day
>>> >> > valid_range : ( 0, 100 )
>>> >> > long_name : Average Monthly Rate of Precipitation
>>> >> > time_op_ncl : Climatology: 26 years
>>> >> > info : function clmMonLLT: contributed.ncl
>>> >> >
>>> >> > Variable: dp
>>> >> > Type: float
>>> >> > Total Size: 19968 bytes
>>> >> > 4992 values
>>> >> > Number of Dimensions: 3
>>> >> > Dimensions and sizes: [lat | 24] x [lon | 52] x [month | 4]
>>> >> > Coordinates:
>>> >> > Number Of Attributes: 1
>>> >> > _FillValue : 9.96921e+36
>>> >> > fatal:Dimension size mismatch, dimension (0) of left hand side
>>> >> reference
>>> >> > does not have the same size as the right hand side reference
>>>after
>>> >> > subscripting.
>>> >> > fatal:["Execute.c":8128]:Execute: Error occurred at or near
>>>line
>>> 114
>>> >> in
>>> >> > file regrEnso.ncl
>>> >> >
>>> >> > #####
>>> >> > dpcp= pcpE - pcpm
>>> >> > copy_VarMeta(pcpm,dpcp)
>>> >> > printVarSummary(dpcp)
>>> >> >
>>> >> > dp!0= "lat"
>>> >> > dp!1= "lon"
>>> >> > dp!2= "month"
>>> >> > printVarSummary(dp)
>>> >> > dpcp= dim_standardize_n_Wrap(dpcp, 0, 0)
>>> >> > dp(lat|:,lon|:,month|:) = dpcp(month|:,lat|:,lon|:)
>>> >> > rc = regCoef(index,dp) ; rc(nlat,nlon)
>>> >> > _______________________________________________
>>> >> > 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 Dec 19 22:17:38 2013

This archive was generated by hypermail 2.1.8 : Mon Jan 06 2014 - 13:02:22 MST