[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Correlate and NAN

Why not simply perform the correlation on a subset of the larger arrays,
that portion with the NaNs removed?  Something like:

indices = [ where( finite(dataset1) eq 1 ), where( finite(dataset2) eq 2
) ]

common_indices = indices( UNIQ(indices, sort(indices)) )

Result  = CORRELATE( dataset1(common_indices), dataset2(common_indices)

Ben Tupper wrote:
> Hello,
> I have two datasets that I would like to correlate using the CORRELATE
> function.  Each dataset has some members flagged as NANs; the NANs are
> not neccessarily coincident.   The online documentation makes no mention
> of NAN-handling, but the procedure in the lib directory indicates (see
> modifications history) that it handles NANs (although there is no
> keyword for it).  It doesn't really handle NANs the way I expect it
> to.   For example, repeated calls to the TOTAL function don't set the
> keyword NAN, so TOTAL doesn't check for NANs.
> I'm not sure if it is reasonable to involve NANs in a correlation... but
> it seems reasonable to request that the routine ignore NANs in the input
> arguments.
> Is there a simple solution to this NAN-jam?
> Thanks,
> Ben
> --
> Ben Tupper
> Bigelow Laboratory for Ocean Sciences
> 180 McKown Point Rd.
> W. Boothbay Harbor, ME 04575
> btupper@bigelow.org

Andrew Loughe =====================================================
NOAA/OAR/FSL/AD   R/FS5  |  email: loughe@fsl.noaa.gov
325 Broadway             |  wwweb: www-ad.fsl.noaa.gov/users/loughe
Boulder, CO  80305-3328  |  phone: 303-497-6211   fax: 303-497-6301