473,624 Members | 2,453 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

More efficient array processing


Hello,

I'm trying to do the following:

datagrid = numpy.zeros(360 ,180,3,73,20)

But I get an error saying that the dimensions are too large? Is there a
memory issue here?

So, my workaround is this:

numpoint = 73

datagrid = numpy.zeros(360 ,180,3,73,1)

for np in range(numpoint) :
datagrid[:,:,:,np,0] = datagrid[:,:,:,np,0] + concgrid[:,:,:,np,0]

But this is SLOW.. what can I do to increase efficiency here? Is there a way
to create the larger array? The program loops through several days actually,
filling the 5th dimension. Eventually I just sum the 5th dimension anyway
(as done in the loop of the workaround).

Thanks!
john
--
Configuration
``````````````` ```````````
Plone 2.5.3-final,
CMF-1.6.4,
Zope (Zope 2.9.7-final, python 2.4.4, linux2),
Five 1.4.1,
Python 2.4.4 (#1, Jul 3 2007, 22:58:17) [GCC 4.1.1 20070105 (Red Hat
4.1.1-51)],
PIL 1.1.6
Mailman 2.1.9
Postfix 2.4.5
Procmail v3.22 2001/09/10
--
View this message in context: http://www.nabble.com/More-efficient...p20136676.html
Sent from the Python - python-list mailing list archive at Nabble.com.

Oct 23 '08 #1
9 1432
On Thu, 23 Oct 2008 11:11:32 -0700, John [H2O] wrote:
I'm trying to do the following:

datagrid = numpy.zeros(360 ,180,3,73,20)

But I get an error saying that the dimensions are too large? Is there a
memory issue here?
Let's see:

You have: 360 * 180 * 3 * 73 * 20 * 8 bytes
You want: GiB
* 2.1146536
/ 0.47289069

Do you have a 32 bit system? Then 2Â*GiB is too much for a process.

Ciao,
Marc 'BlackJack' Rintsch
Oct 23 '08 #2

Thanks for the clarification.

What is strange though, is that I have several Fortran programs that create
the exact same array srtucture... wouldn't they be restricted to the 2Gb
limit as well?

Thoughts on a more efficient work around?
Marc 'BlackJack' Rintsch wrote:

On Thu, 23 Oct 2008 11:11:32 -0700, John [H2O] wrote:
>I'm trying to do the following:

datagrid = numpy.zeros(360 ,180,3,73,20)

But I get an error saying that the dimensions are too large? Is there a
memory issue here?
Let's see:

You have: 360 * 180 * 3 * 73 * 20 * 8 bytes
You want: GiB
* 2.1146536
/ 0.47289069

Do you have a 32 bit system? Then 2Â*GiB is too much for a process.

Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
--
View this message in context: http://www.nabble.com/More-efficient...p20137263.html
Sent from the Python - python-list mailing list archive at Nabble.com.

Oct 23 '08 #3
On Thu, 23 Oct 2008 11:44:04 -0700, John [H2O] wrote:
What is strange though, is that I have several Fortran programs that
create the exact same array srtucture... wouldn't they be restricted to
the 2Gb limit as well?
They should be. What about the data type of the elements? Any chance
they are just 4 byte floats in your Fortran code i.e. C floats instead of
C doubles like the default in `numpy`?

Ciao,
Marc 'BlackJack' Rintsch
Oct 23 '08 #4

I'm using zeros with type np.float, is there a way to define the data type to
be 4 byte floats?
Marc 'BlackJack' Rintsch wrote:
>
On Thu, 23 Oct 2008 11:44:04 -0700, John [H2O] wrote:
>What is strange though, is that I have several Fortran programs that
create the exact same array srtucture... wouldn't they be restricted to
the 2Gb limit as well?

They should be. What about the data type of the elements? Any chance
they are just 4 byte floats in your Fortran code i.e. C floats instead of
C doubles like the default in `numpy`?

Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list

--
View this message in context: http://www.nabble.com/More-efficient...p20139062.html
Sent from the Python - python-list mailing list archive at Nabble.com.

Oct 23 '08 #5
On Thu, 23 Oct 2008 13:56:22 -0700, John [H2O] wrote:
I'm using zeros with type np.float, is there a way to define the data
type to be 4 byte floats?
Yes:

In [13]: numpy.zeros(5, numpy.float32)
Out[13]: array([ 0., 0., 0., 0., 0.], dtype=float32)

Ciao,
Marc 'BlackJack' Rintsch
Oct 23 '08 #6
John [H2O] wrote:
I'm using zeros with type np.float, is there a way to define the data type to
be 4 byte floats?
np.float32. np.float is not part of the numpy API. It's just Python's builtin
float type which corresponds to C doubles.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Oct 23 '08 #7
On Thu, 23 Oct 2008 11:44:04 -0700 (PDT), "John [H2O]"
<wa******@gmail .comwrote:
>
Thanks for the clarification.

What is strange though, is that I have several Fortran programs that create
the exact same array srtucture... wouldn't they be restricted to the 2Gb
limit as well?
Depends on lot of things, as Mark has hinted.
But, why are you rewriting fortran subroutines to py ? Expecially for
this kind of array processing.

And, if it's no secret, would you mind telling what do you need an
array of that size for ?
I cannot think of many uses that would require an array of that size
and that many dimensions, which couldn't be rewritten in a more
efficient manner, to several smaller arrays.
--
Ivan

>
Thoughts on a more efficient work around?

Oct 23 '08 #8
On Fri, 24 Oct 2008 00:32:11 +0200, Ivan Reborin
<ir******@delet e.this.gmail.co mwrote:
>On Thu, 23 Oct 2008 11:44:04 -0700 (PDT), "John [H2O]"
<wa******@gmai l.comwrote:
>>
Thanks for the clarification.

What is strange though, is that I have several Fortran programs that create
the exact same array srtucture... wouldn't they be restricted to the 2Gb
limit as well?

Depends on lot of things, as Mark has hinted.
*Marc*

Apologies.

--
Ivan
Oct 23 '08 #9
On Oct 23, 8:11*pm, "John [H2O]" <washa...@gmail .comwrote:
datagrid = numpy.zeros(360 ,180,3,73,20)
On a 32 bit system, try this instead:

datagrid = numpy.zeros((36 0,180,3,73,20), dtype=numpy.flo at32)

(if you can use single precision that is.)




Oct 24 '08 #10

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

Similar topics

5
1581
by: Bosconian | last post by:
I need to make an associated array (all with the same key name) using values from another array. Is there a more efficient way to doing this in one pass (instead of looping)? I'm always looking to learn something new. :-) -------------------------------------------------------------------- $fields = array('username', 'passwd', 'firstname', 'lastname', 'email');
303
17572
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b. Yahoo store was originally written in Lisp. c. Emacs The issues with these will probably come up, so I might as well mention them myself (which will also make this a more balanced
21
3909
by: Rabbit63 | last post by:
Hi: I want to show a set of records in the database table on the clicnt browser. I have two ways to do this (writen in JScript): 1.The first way is: <% var sql = "select firstname from table1"; var obj=new ActiveXObject("ADODB.Recordset");
25
2914
by: CodeCracker | last post by:
Problem details below: I have few items(simple values or objects) to be put into an array and I implement it through a set rather than just an array of items. This is because every time I get a new item I have to look into the Set whether it is there or not. Depending on whether it is there or not I have to respond differntly. Since it is easy to search into a Set rather than a number of if statement which will compare each of the...
3
1883
by: Ted Miller | last post by:
Hi folks, I've got an unmanaged routine I'm pinvoking to. It takes a pointer to an array of 3 pointers to bytes, typed as byte**. public static extern void foo(byte **p3pb); unsafe { byte pB = new byte;
2
1553
by: booksnore | last post by:
..eh I was stuck thinking up a subject title for this post for a while.. So I am processing a really big file (scary big). Each record is fixed length, I need to test conditions on certain fields in the record. At the moment the most efficient way I've found to process the data is a series of nested if/else statements so like below. My question is does anyone know of a better way to process this kind of logic. I can't use a switch...
15
3089
by: Macca | last post by:
Hi, My app needs to potentially store a large number of custom objects and be able to iterate through them quickly. I was wondering which data structure would be the most efficient to do this,a hashtable or a generic list. Is using enumerators to iterate through the data structure a good idea? I'd appreciate any suggesstions or advice,
19
2603
by: Matthias Truxa | last post by:
Hello, can anyone confirm the existence of the following effects which I'd consider being a critical bug in msxml according to w3c's xpath specs? The Spec says: "The parent, ancestor, ancestor-or-self, preceding, and preceding-sibling axes are reverse axes" http://www.w3.org/TR/2005/CR-xpath20-20051103/#doc-xpath-ReverseAxis
4
5655
by: | last post by:
Hi all, I want to create a method that does the following: 1) Programmatically instantiate a new XmlDataSource control 2) For each file in a named directory, make a "FileSystemItem" element 3) On each FileSystemItem Element, make two child nodes, one with the file name, one with the file size. ie. <filesystemitems> <filesystemitem>
0
8240
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8175
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8680
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8625
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8336
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8482
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6111
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5565
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.