Re: Oh what is wrong with WHERE() ? [message #48562] |
Mon, 01 May 2006 10:02  |
news.qwest.net
Messages: 137 Registered: September 2005
|
Senior Member |
|
|
"Sheldon" <shejo284@gmail.com> wrote in message
news:1146327351.938523.112920@e56g2000cwe.googlegroups.com.. .
> Hi Bob,
> IF count_m GE count_p THEN nodata_tot = nodata_m ELSE nodata_tot =
> nodata_p
> The results showed that these two amounts were identical:
> 1443953
> 1443953
Just a thought:
Even though the total is equal, it may be that notdata_m is not
exactly equal to nodata_p.
A short example of what I mean.
p = [0,1,0]
m = [1,0,0]
nodata_p = (where p eq 1, count_p)
nodata_m = (where m eq 1, count_m)
IF count_m GE count_p THEN nodata_tot = nodata_m ELSE nodata_tot =
nodata_p
p[nodata_tot] = 1
m[nodata_tot] = 1
so your results are now:
p = [1,1,0]
m = [1,0,0]
(Hence the missing pixel in p is due to the fact that your 'p' had
a '1' in a place outside of 'nodata_tot'.)
Cheers,
bob
|
|
|
Re: Oh what is wrong with WHERE() ? [message #48567 is a reply to message #48562] |
Sat, 29 April 2006 09:15   |
Liberum
Messages: 48 Registered: September 2005
|
Member |
|
|
Hi Bob,
This is good point that you make and I have thought about this at great
length before. I have to set the arrays m and p to the equal amount of
255, i.e., no data values so as do a good pixel to pixel comparison
over a period of one month. This means that I will do this m and p
comparison about 355 times for one month. Now m and p varies when it
comes to which pixels are valid and which are not. Some times p has all
255 values and the comparison cannot be done.
Now in the checks that I have placed in the program checks of the the
count for 255 in p is greater than the 255 count in m and sets
nodata_tot to the greater number:
IF count_m GE count_p THEN nodata_tot = nodata_m ELSE nodata_tot =
nodata_p
The results showed that these two amounts were identical:
1443953
1443953
This is what I did to solve the problem your pointing out. Yet is does
not work.
The numbers add up until the last where statement where the one pixel
disappears. This is why I am trying now David's approach and using LONG
instead of DOUBLE. Still a pixel disappears :( I think that it is
something about this array as I tried another and it works. The thing
is what? I can shrink the arrays but I will have to exclude some data.
I did just that with the following check (each arrays should only have
the values 255, 1 or 2):
r = where((p EQ 255.0 OR p EQ 1.0 OR p EQ 2.0), check_p,
COMPLEMENT=compp, NCOMPLEMENT=ncompp)
print, 'check_p: ', check_p
IF ncompp GT 0 THEN stop, p[compp]
Yet this test is passed and ncompp is always zero. If I reduce the
array, then what am I looking for in that case? I am lost.
/Sheldon
|
|
|
Re: Oh what is wrong with WHERE() ? [message #48568 is a reply to message #48567] |
Sat, 29 April 2006 08:49   |
news.qwest.net
Messages: 137 Registered: September 2005
|
Senior Member |
|
|
"Sheldon" <shejo284@gmail.com> wrote in message
news:1146322284.261031.55760@e56g2000cwe.googlegroups.com...
...
> m[nodata_tot] = 255.0
> p[nodata_tot] = 255.0
> ; finding the area with real data check
> va_data = WHERE(p EQ 255.0, COMPLEMENT=vdatap, NCOMPLEMENT=chp)
> va_data = WHERE(m EQ 255.0, COMPLEMENT=vdatam, NCOMPLEMENT=chm)
> print, 'chp: ', chp, ' chm: ', chm
...
> chp: 32271 chm: 32272
> /////////////////////////////
>
> What happened to one pixel??
Hi Sheldon,
could you reduce this problem to a very short example?
(and with m and p small enough to actually print out)?
This looks very strange in that you apparently set both m and p
to have the same number of 255s, then get different results from
the where call.. David makes a good point about the folly of
using where for equality to floats, however for this example I don't
think that causes your problem.
Offhand I would say that p already has a single value of 255 that was
not in the indexes described by nodata_tot. Thus you already had a value
for 255 before your line "p[nodata_tot] = 255.0". This line had set
1443953 points to 255, leaving 32272 points that should be other,
however on of those 32272 points in fact had a point equal to 255,
thus leaving the chp value one short at 32721.
Cheers,
bob
PS you should think hard about converting your arrays to integers
before doing any equality test.
|
|
|
|
|
|