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

Home » Public Forums » archive » Satellite Swath Overlap
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Satellite Swath Overlap [message #87523] Wed, 12 February 2014 09:14 Go to next message
Chase Calkins is currently offline  Chase Calkins
Messages: 4
Registered: February 2014
Junior Member
Hello Everyone,

I have a couple of files that I overlap on a mapset but when I plot it, the image is overwritten by the latter of each file. A simple set up is essentially like this.

Lat1 = fltarr[36,400]
Lon1 = fltarr[36,400]

Lat2 = fltarr[36,400]
Lon2 = fltarr[36,400]

result1 = fltarr[36,400]
result2 = fltarr[46,400]

cgcontour, result1, Lon1, Lat1, level = findgen(18)/10-.2, /overplot, /cell_fill

MAP_SET, /Continents, limit = [10,70,45,135], /grid, label = 2, latlab = 110, color =1, charsize = 1.9, /noerase

cgcontour, result2, Lon2, Lat2, level = findgen(18)/10-.2, /overplot, /cell_fill

MAP_SET, /Continents, limit = [10,70,45,135], /grid, label = 2, latlab = 110, color =1, charsize = 1.9, /noerase

A picture of what I am experiencing is here.

http://www.vos.noaa.gov/MWL/apr_10/Images/pacific/Fig21P.jpg


I was wanting to know if there is a way IDL can say where the overlap is and average the result between the two files in the overlap section.

Thanks,

Chase
Re: Satellite Swath Overlap [message #87525 is a reply to message #87523] Wed, 12 February 2014 11:26 Go to previous messageGo to next message
Andy Sayer is currently offline  Andy Sayer
Messages: 127
Registered: February 2009
Senior Member
Well, you could try something like this (and assuming result1, result2 are supposed to be the same size and not different like in your code):

missingval=0 ; or whatever indicates no data

nx=n_elements(result1[*,0]) ; get size of x dimension
ny=n_elements(result1[0,*]) ; get size of y dimension

result_averaged=fltarr(36,400) ; array to contain average results

for i=0l,nx-1 do begin
for j=0l,ny-1 do begin ; Loop over cells
if result1[i,j] eq missingval and result2[i,j] eq missingval then result_averaged[i,j] = missingval
if result1[i,j] eq missingval and result2[i,j] ne missingval then result_averaged[i,j] = result2[i,j]
if result1[i,j] ne missingval and result2[i,j] eq missingval then result_averaged[i,j] = result1[i,j]
if result1[i,j] ne missingval and result2[i,j] ne missingval then result_averaged[i,j] = mean([result1[i,j],result2[i,j]])
endfor
endfor

Then do your plotting using result_averaged.

There are probably more efficient ways to code this but I think the above is an easy-to-understand method, if I have understood your problem correctly. Hope this helps!

Andy



On Wednesday, February 12, 2014 12:14:21 PM UTC-5, Chase Calkins wrote:
> Hello Everyone,
>
>
>
> I have a couple of files that I overlap on a mapset but when I plot it, the image is overwritten by the latter of each file. A simple set up is essentially like this.
>
>
>
> Lat1 = fltarr[36,400]
>
> Lon1 = fltarr[36,400]
>
>
>
> Lat2 = fltarr[36,400]
>
> Lon2 = fltarr[36,400]
>
>
>
> result1 = fltarr[36,400]
>
> result2 = fltarr[46,400]
>
>
>
> cgcontour, result1, Lon1, Lat1, level = findgen(18)/10-.2, /overplot, /cell_fill
>
>
>
> MAP_SET, /Continents, limit = [10,70,45,135], /grid, label = 2, latlab = 110, color =1, charsize = 1.9, /noerase
>
>
>
> cgcontour, result2, Lon2, Lat2, level = findgen(18)/10-.2, /overplot, /cell_fill
>
>
>
> MAP_SET, /Continents, limit = [10,70,45,135], /grid, label = 2, latlab = 110, color =1, charsize = 1.9, /noerase
>
>
>
> A picture of what I am experiencing is here.
>
>
>
> http://www.vos.noaa.gov/MWL/apr_10/Images/pacific/Fig21P.jpg
>
>
>
>
>
> I was wanting to know if there is a way IDL can say where the overlap is and average the result between the two files in the overlap section.
>
>
>
> Thanks,
>
>
>
> Chase
Re: Satellite Swath Overlap [message #87527 is a reply to message #87523] Wed, 12 February 2014 12:06 Go to previous messageGo to next message
Phillip Bitzer is currently offline  Phillip Bitzer
Messages: 223
Registered: June 2006
Senior Member
On Wednesday, February 12, 2014 11:14:21 AM UTC-6, Chase Calkins wrote:

>
> I was wanting to know if there is a way IDL can say where the overlap is and average the result between the two files in the overlap section.
>

Well, your example shows the arrays are the same size and cover the same lat/lon, so I would say they "overlap" everywhere (assuming the same thing as Andy about the size of result1/result2).

Let's say you have a missing value (again, building off Andy's example). The non-loop way would be to do something like this:

ind1 = WHERE(result1 EQ missingValue, count1) ;find missing values...
IF count1 NE 0 THEN result1[ind1] = !VALUES.F_NAN ;.. and replace them with NaNs

ind2 = WHERE(result2 EQ missingValue, count2) ;find/replace the missing value in result2 too...
IF count2 NE 0 THEN result2[ind2] = !VALUES.F_NAN

;to find the mean, build a 36x400x2 array, do the mean over the third dimension
resultAvg = MEAN([[[result1]], [[result2]]], dim=3, /NAN) ;avg the results

;find the NaNs; this will be where both arrays have the missing value...
indAvg = WHERE(~FINITE(resultAvg), countAvg)

IF countAvg NE 0 THEN resultAvg[indAvg] = missingValue ;...and put the missing value back

;go plot....

Notice I'm overwriting the original arrays - so you would modify this slightly if this isn't acceptable.

Also, I'm testing for equality between floats, always a precarious affair. You may want to test instead if the difference b/t the results and the missing value is some small number.
Re: Satellite Swath Overlap [message #87528 is a reply to message #87523] Wed, 12 February 2014 13:23 Go to previous message
Chase Calkins is currently offline  Chase Calkins
Messages: 4
Registered: February 2014
Junior Member
Dear Andy,

You are correct on the results array, there are both (36,400) , slip of the finger

However, I think the problem with this, as though it looks right is the problem with the two files.

For example

Lat1(13000), Lon2(13000)
47.7115 106.192

Lat2(13000), Lon2(13000)
47.7185 80.8134

result1(13000), result2(13000)
0.00000 0.101473

So I'm not sure if it's comparing the right Latitude and Longitude when it compares the results. So I'm wondering if I need to line up the index's for it to be correct.

Thanks,

Chase
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: READU: Error encountered reading from file.
Next Topic: How to use cgplot insidecgwindow with mouse.button command

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

Current Time: Wed Oct 08 11:34:11 PDT 2025

Total time taken to generate the page: 0.00405 seconds