473,320 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

A way to more efficiently process arrays

I am a bit of a newbie to python, and would like a little advice on how to more efficiently process arrays.

I work a lot with satellite data, and have opened and read two binary images into separate 2-D arrays using numarray.fromfile. What I want to do is is test each pixel in each image for various conditions, and depending on which condition the pixel value meets, write a number to a third array which is "empty" (contains pixels whose values are 0).

Up until now I have been using a sequence of numarray.choose statements to test specific conditions. E.g.:

numarray.choose(numarray.greater(array1,0.70),(arr ay3,array2))
numarray.choose(numarray.less_equal(array2,0.30),( array3,array2))...etc...

[If array1 > 0.7 then pixel in array3 takes value of corresponding pixel in array2; If array2 <= 0.30 then pixel in array 3 takes value of array2].

However, how could I code the above if I wanted to test for BOTH conditions to be true (i.e. I want to assign pixels in array3 a specific value IF (and only if) the corresponding pixels in array1 > 0.7 AND array2 <= 0.30)??

Thanks in advance,

Andrew
Oct 13 '05 #1
0 1672

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: Klaus Neuner | last post by:
Hello, I need to gather information that is contained in various files. Like so: file1: ===================== foo : 1 2 bar : 2 4
3
by: Mark van Heeswijk | last post by:
Probably a very basic question but i'm new to c++ What's the most efficient (mem) way to copy string 'a' to string 'b'? Now i do: char a; char* b; // length not known...could be 1000...
3
by: maadhuu | last post by:
hello I have a problem and it is something like this . I have 5 static arrays in one class called S1 ,S2 ....S5(all 2 D arrays). Now , I want to access some number of elements in each one of the...
9
by: AtariPete | last post by:
Hi all, My scenario is as follows: * Receive a base 1 array (index starts at 1 instead of 0) of data from a COM component . * Need to pass this array to a .net component that requires its...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.