X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 04 May 2004 04:41 AM by  anon
Progamming puzzle with Meteorological Data
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:8
New Member


--
04 May 2004 04:41 AM
    I have three arrays of size npts=42164. They are LON, LAT and DATA. They contain meteorological data over the ocean. I need to transform the DATA array from one-dimension to two, but need to do it quickly (i.e. no "do loops"). LON and LAT contain the longitude and latitude of the nth point. Data contains some variable, say sea surface temperature. Note that the arrays only have valid data over the oceans and not over land (that's the catch). So what I need is the following: Using info in LON and LAT, transform DATA[npts] -> DATA2[nlon,nlat], where nlon=360 and nlat=180 (Global coverage). This could easily be done with loops, but it is much too slow. I need some way to make this transformation very quickly. Thanks to anyone willing to help out. David Wolff NASA GSFC

    Deleted User



    New Member


    Posts:
    New Member


    --
    04 May 2004 04:41 AM
    Greetings: There is no direct way to transform a mixed matrix into a fixed grid without some sort of test of check inside a loop. FOR i = 0, n_elements(data) DO data2[lon[i], lat[i]]=data[i], assuming lon and lat are integer indices that match the [360, 180] requirements. However, it did occur to me that the reason you need speed is that you are doing this repeatedly. In the case where all the lat-lon sets are unchanging, and the only difference is the values of the data, there is a speedier solution for all but the first data input. What you do is create an index table that translates each DATA value to the index location of DATA2. Then, DATA2[table[0,*]] = DATA[table[1,*] for all subsequent values. Hope this helps. D. Klotter
    You are not authorized to post a reply.