Re: Order of attributes

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Tue Jun 19 2012 - 08:13:46 MDT

Hi Daniel,

I will try to answer this, but Dave or Wei may want to jump in here.

I believe the ordering of the attributes is the reverse of how they are added. This is sort of like "pushing them on the stack", and hence the first one you add is on the bottom of the list because the others get "pushed" on top of it.

Note: this reverse ordering of attributes does not seem to apply when you write attributes to a file. I think Wei or Dave will definitely need to explain that. :-)

I think for now, it's safe to assume the attributes will always be in the reverse order that you add them, although in general, it's not safe to assume any specific ordering.

Is there a reason you need them to be in a specific order? Could you use "sqsort" to sort the attributes first?

--Mary

On Jun 19, 2012, at 3:59 AM, <Daniel.Leuenberger@meteoswiss.ch> <Daniel.Leuenberger@meteoswiss.ch> wrote:

> Dear all,
>
> I’m using NCL 6.0.0 and came across an unexpected behavior in the ordering of attributes of a logical variable:
>
> res_def = True
> res_def@a = 10
> res_def@b = 5
> res_def@c = 8
>
> print(res_def)
>
> res=res_def
>
> print(res)
>
> gives the following:
>
> Variable: res_def
> Type: logical
> Total Size: 4 bytes
> 1 values
> Number of Dimensions: 1
> Dimensions and sizes: [1]
> Coordinates:
> Number Of Attributes: 3
> c : 8
> b : 5
> a : 10
> (0) True
>
>
> Variable: res
> Type: logical
> Total Size: 4 bytes
> 1 values
> Number of Dimensions: 1
> Dimensions and sizes: [1]
> Coordinates:
> Number Of Attributes: 3
> a : 10
> b : 5
> c : 8
> (0) True
>
> 1) Is there a systematic ordering of the attributes of a logical variable?
> 2) Why is the ordering reversed after the definition?
> 3) Why is the ordering reversed when copied to another variable?
>
> In my application the order of the attributes matter, therefore I need to be sure on how they are sorted.
>
> Thanks a lot for your clarification!
>
> Best regards
> Daniel
>
>
> ________________________________________
>
> Daniel Leuenberger
> Numerical Prediction
>
> Federal Department of Home Affairs FDHA
> Federal Office of Meteorology and Climatology MeteoSwiss
>
> Kraehbuehlstrasse 58, P. O. Box 514, CH-8044 Zurich
> Phone +41 44 256 97 10
> Fax +41 44 256 92 78
> daniel.leuenberger@meteoswiss.ch
> www.meteoswiss.admin.ch
>
> _______________________________________________
> 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 Tue Jun 19 08:13:54 2012

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