Re: Extracting unique values in an array (integer) ?

From: Christian Pagé <page.christian_at_nyahnyahspammersnyahnyah>
Date: Wed, 5 Mar 2008 09:36:11 +0100

Hi Mary,

I think I didn't explain correctly what I want to achieve.

Let a vector of time (udunits in hours since), with daily data.
I convert it to year, month, day, etc arrays using ut_calendar.
I would like to know how many years I have... but I cannot use the dimension
of years since I will have 365/366 values of each year for complete years,
and less than that for incomplete years.

Example :
I have these two vectors with the same dimensions, years and months as
follows.
years = 1990 1990 1990 1990 1991 1991 1991 1991
month = 09 10 11 12 01 02 03 04

I want to know how many unique years I have in the years vector, which would
be equal to 2 in that example.
It would be the same functionality as the sort -u | wc -l command in
unix.

Many thanks

Christian

2008/3/5, Mary Haley <haley_at_ucar.edu>:
>
> Hi Christian,
>
> I have a weird connection at the moment and can't get to our web
> pages, but I believe what you want is a function Dennis wrote called
> generate_unique_indices.
>
> See:
>
>
>
> http://www.ncl.ucar.edu/Document/Functions/Contributed/generate_unique_indices.shtml
>
>
> --Mary
>
>
>
>
> On Tue, 4 Mar 2008, [ISO-8859-1] Christian Pagé wrote:
>
> > Hi everyone,
> >
> > I searched without success...
> > I was wondering if there already exists a function in NCL to extract
> unique
> > values in an integer array ?
> >
> > Many thanks,
> >
> > --
> > Christian Pagé
> >
Received on Wed Mar 05 2008 - 01:36:11 MST

This archive was generated by hypermail 2.2.0 : Thu Mar 13 2008 - 17:22:54 MDT