comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Adding or averaging multiple grid arrays returns all NaNs
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Adding or averaging multiple grid arrays returns all NaNs [message #92731 is a reply to message #92722] Thu, 18 February 2016 09:47 Go to previous messageGo to previous message
Dick Jackson is currently offline  Dick Jackson
Messages: 347
Registered: August 1998
Senior Member
On Wednesday, 17 February 2016 04:34:53 UTC-8, Luke Conibear wrote:
> Hi,
>
> I have a 2D grid array (lon, lat) for each day of my data:
>
> GRID FLOAT = Array[3999, 1999]
>
> This array is dispersed with values and plots to a map nicely.
>
> When I add multiple grids together or average them (as below), every value in the 2D array turns to NaN, so the plot is blank.
>
> TOTAL_GRID FLOAT = Array[3999, 1999]
> total_grid = total_grid + grid
> MEAN_GRID FLOAT = Array[3999, 1999]
> mean_grid = total_grid / n_days
>
> Does anyone know a solution, as looping for every lat and lon cell would be very computationally expensive for my large data set?
>
> Thanks,
> Luke

Hi Luke,

Good question! Am I right that 'NaN' in your data would be treated the same as zero? (It looks like it, since you divide the total by n_days) If so, preparing a "real_grid" from "grid" would work. You could do this before adding grid to total_grid:

grid[Where(Finite(grid, /NAN))] = 0

If you needed to track which grid elements always had NaN, there are ways to handle that too. Let us know if this is sufficient.

--

Cheers,
-Dick

Dick Jackson Software Consulting Inc.
Victoria, BC, Canada
www.d-jackson.com
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Passing an array of color values into polyfill
Next Topic: Summation Image arrays

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:59:59 PDT 2025

Total time taken to generate the page: 0.00445 seconds