[SciPy-user] partially reading a file...

Sebastian Haase haase@msg.ucsf....
Wed Aug 6 14:06:42 CDT 2008


On Wed, Aug 6, 2008 at 8:14 PM, Travis E. Oliphant
<oliphant@enthought.com> wrote:
> fred wrote:
>> Travis E. Oliphant a écrit :
>>
>>
>>> Absolutely memory mapping still applies --- it's a perfect application
>>> for it.  But, you will probably need a 64-bit system.
>>>
>> No problem.
>>
>>
>>> Memory mapping is how the OS handles "virtual memory" which uses disk
>>> space to increase main memory.  You are just using that idea directly
>>> with a memory mapped file.
>>>
>> Ok.
>> Thanks for the hint.
>>
>>
>
> More directly:
>
> Use numpy.memmap --- look at the docstring for example use and help on
> all the arguments available.  But, something like this (untested):
>
> a = numpy.memmap(<filename>, mode='r', dtype=float, shape=(nx,ny,nz))
> b = a[:nx/4,:ny/4,:nz/4]
> b.tofile(<somefilename>)
>
Hi,
We should already get used to using "//" instead "/" if we want the
result to be integer:
So that is:
> b = a[:nx//4,:ny//4,:nz//4]

... I'm just trying to advertise the 'future' (py3.0 or today: 'python
-Qnew' ) so-called "true division"-feature ....

Cheers,
Sebastian Haase


More information about the SciPy-user mailing list