473,498 Members | 1,218 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

2d array slicing problem

jeg
dear all,

i'm an astronomer working with 2d images -- 2d numarrays. i have a
script which basically does some operations on some images, and one of
the first steps is to find a galaxy on an image (at, say, a known x,y
coord), and create a sub-image by slicing out part of the larger array
to create a more managable smaller one (e.g. 50x50 pixels from a
1000x1000 array).

i was running this fine under python 2.3.4, but due to the slowness of
my machine, moved to a speedy 64-bit linux box running version 2.4.2.
arrays were no longer being sliced in the correct way, for example:

B = A[3:7,6:10]

generates different Bs if i run an identical script on the same image
on the different machines.

note: we deal with FITS format images, which are read into numarrays
using the pyfits.py module. does anyone know any obvious reason this
should be happening?

many thanks if you can help,

jim

Oct 7 '05 #1
4 2891
jeg wrote:
dear all,

i'm an astronomer working with 2d images -- 2d numarrays. i have a
script which basically does some operations on some images, and one of
the first steps is to find a galaxy on an image (at, say, a known x,y
coord), and create a sub-image by slicing out part of the larger array
to create a more managable smaller one (e.g. 50x50 pixels from a
1000x1000 array).

i was running this fine under python 2.3.4, but due to the slowness of
my machine, moved to a speedy 64-bit linux box running version 2.4.2.
arrays were no longer being sliced in the correct way, for example:

B = A[3:7,6:10]

generates different Bs if i run an identical script on the same image
on the different machines.

note: we deal with FITS format images, which are read into numarrays
using the pyfits.py module. does anyone know any obvious reason this
should be happening?


Not without having the data and the machines in front of me. You'll get
better luck asking on numarray's mailing list.

--
Robert Kern
rk***@ucsd.edu

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter

Oct 7 '05 #2
Do you have a simple program that demonstrates the problem?

I have an x86 machine with Python 2.3, and an x86_64 machine with Python 2.4
available. I wrote a simple test program which performs a slice operation,
but it behaves the same on both platforms.

Here's the program:
#------------------------------------------------------------------------
import numarray, sys, os
print "python: ", sys.version_info
print "numarray:", numarray.__version__
print "CPU: ", os.uname()[-1]

n = numarray.arange(10)
o = numarray.outerproduct(n,n)
p = o[3:7,6:10].copy()
q = numarray.outerproduct([3,4,5,6], [6,7,8,9])
print "Success: ", numarray.alltrue(p.ravel() == q.ravel())
#------------------------------------------------------------------------

Here are the two results I gathered:

python: (2, 4, 1, 'final', 0)
numarray: 1.3.3
CPU: x86_64
Success: True

python: (2, 3, 2, 'final', 0)
numarray: 0.9
CPU: i686
Success: 1

Jeff

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFDRsYYJd01MZaTXX0RAq35AJ477QdItft2GAaL+Elmqt bEE8fHQQCgpjpO
Vl4i9wURTugz61Xfo5Puc1w=
=X7lq
-----END PGP SIGNATURE-----

Oct 7 '05 #3
jeg
thanks, i ran it -- the only difference i got was the numarray version:
1.1.1 on the 686, and 1.3.3 on the 64bit... but i wouldn't have thought
that would make too much difference.

Oct 7 '05 #4
Tune Kamae (sent by Nabble.com) wrote:
I am thinking to upgrade my desktop to 64bit cpu with 16GB memory to handle
large astronomical images and data. I wonder if
1) the latest numarry (besides 2d slicing) has been tested with one or more
64 bit CPU and Linux distributions
Certainly.
2) with 64 bit address space, will numarray be able to handle larger arrays
and matrices (many 3d-arrays 100x100x100 and matrices 50k x 50k)?
(with 32 bit CPU I was limited by the memory.)

I would appreciate knowing about your experience.


You'll probably want to ask on the appropriate mailing list[1], but
since you ask here, I will say that there are limitations that prevent
numarray from fully utilizing 64-bit systems. numarray uses the Python
buffer interface which is addressed by 32-bit integers even on 64-bit
platforms[2]. There has been some work on numarray's replacement,
scipy_core, to address this deficiency, but more work needs to be done
and more volunteers with 64-bit systems are needed. 100x100x100 arrays
should work with numarray; 50000x50000 perhaps not. You could always try
and let us know.

[1] http://lists.sourceforge.net/lists/l...mpy-discussion
[2] http://permalink.gmane.org/gmane.com...c.general/2690

--
Robert Kern
ro*********@gmail.com

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter

Nov 27 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1858
by: beliavsky | last post by:
Suppose I define a trivial class composed of x and y coordinates and create a Numeric array of instances of that class. class xy: def __init__(self,x=0.0,y=0.0): self.x = x self.y = y def...
7
8301
by: LutherRevisited | last post by:
I'm wanting to do something with a list that is basically a 2 dimensional array. I'm not so good with lists so can someone give me an example of how I might implement this in Python? thanks.
2
1587
by: Yun Mao | last post by:
Hi python gurus, I have some questions when I'm using python numeric: 1. When I do v = u, it seems u and v still point to the same memory. e.g. When I do v=0, u will be zero out as well....
9
4763
by: justanotherguy63 | last post by:
Hi, I am designing an application where to preserve the hierachy and for code substitability, I need to pass an array of derived class object in place of an array of base class object. Since I...
10
3738
by: amparikh | last post by:
Ok, my question is not about Virtual destructors and why, but more on the significance. Generally we have a virtual destructor in the base class ( and inadvertently in the derived class) so that...
17
15813
by: Jon Slaughter | last post by:
I'm having a little trouble understanding what the slicing problem is. In B.S.'s C++ PL3rdEd he says "Becayse the Employee copy functions do not know anything about Managers, only the Employee...
17
3540
by: baibaichen | last post by:
i have written some code to verify how to disable slicing copy according C++ Gotchas item 30 the follow is my class hierarchy, and note that B is abstract class!! class B { public: explicit...
3
2239
by: Louis Caron | last post by:
I am facing the following problem: - I have to build a const array containing functions pointers - the indexes for this array are generated automatically by a tool (not my property) How do I...
2
4683
by: Rahul | last post by:
Hi Everyone, I was working around object slicing (pass by value) and was wondering how it is specified in the standard, class A { }; class B: public A
0
7124
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7200
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7375
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5460
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4586
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3090
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1416
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
651
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.