Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #31983

Re: Fast forward-backward (write-read)

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <dwightdhutto@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.010
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; '"""': 0.05; 'ascii': 0.07; 'bytes)': 0.09; 'received:mail-qc0-f174.google.com': 0.09; 'cc:addr:python-list': 0.10; 'stored': 0.10; 'assume': 0.11; '"""\\': 0.16; 'arrays.': 0.16; 'benjamin': 0.16; 'inputs': 0.16; 'numpy': 0.16; 'oct': 0.16; 'processed.': 0.16; 'repetitions': 0.16; 'sequential': 0.16; 'written.': 0.16; 'wrote:': 0.17; 'variables': 0.17; 'input': 0.18; 'written': 0.20; 'import': 0.21; 'finally,': 0.22; 'example': 0.23; 'external': 0.24; 'cc:2**1': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; '---': 0.26; '(e.g.': 0.27; 'question': 0.27; 'message- id:@mail.gmail.com': 0.27; 'thus,': 0.29; 'performing': 0.30; 'file': 0.32; 'print': 0.32; 'ram': 0.33; 'received:google.com': 0.34; 'saved': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'data.': 0.36; "i'll": 0.36; 'subject: (': 0.36; 'october': 0.37; 'being': 0.37; 'rather': 0.37; 'received:209': 0.37; 'received:209.85.216': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'perform': 0.38; 'files': 0.38; 'some': 0.38; 'several': 0.39; 'subject:-': 0.40; 'header:Received:5': 0.40; 'save': 0.61; 'first': 0.61; 'mentioned': 0.63; 'series': 0.63; 'skip:n 10': 0.63; 'reverse': 0.65; 'forward': 0.66; 'manner': 0.74; 'dimensional': 0.84; 'oscar': 0.84; 'subject:Fast': 0.84; 'subject:read': 0.84; 'subject:write': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=s8voWtOHZH6oBYkK+7ZHBxCyAGxqRDGpoXARrE6NPdM=; b=l8NV/YiZJeWS78bwIXBCXzHU5XsRYD/bShfT3+PAPB35CI9NRYZkLzaC6fLUpklA3W 8wrEjqOXE6yCSjp+cVMGSCOoK/zUEm8U3baeFHb1ZoTLqHKThOPen6seX2iVfStCPDxT 5aw7wxIt5CNAI+r6H2/UPVjZueMiuPfLki3zVx52nqyydN14rFE1qrEcDO6uz10aXPLi 3PDrdbZLNeqz5zsK+HgdyXGZqMk97owqzjATrdPD2TjkuvfBNlbQTUqKOkb+kuS2fku2 LKWSuCtlzmFJ9NHUeXvoeI9j+CKJs31s4uytXYbrRhTgNqyIY7hzL20JU/jDrECVbMS5 xZoA==
MIME-Version 1.0
In-Reply-To <CAHVvXxRRSwV=A9Sx6odkpG2wOYwito7=OD6YPatcAutoBuAcgw@mail.gmail.com>
References <5086AA35.4000509@it.uu.se> <CAHVvXxRRSwV=A9Sx6odkpG2wOYwito7=OD6YPatcAutoBuAcgw@mail.gmail.com>
Date Tue, 23 Oct 2012 22:29:09 -0400
Subject Re: Fast forward-backward (write-read)
From David Hutto <dwightdhutto@gmail.com>
To Oscar Benjamin <oscar.j.benjamin@gmail.com>
Content-Type text/plain; charset=ISO-8859-1
Cc "python-list@python.org" <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2708.1351045752.27098.python-list@python.org> (permalink)
Lines 75
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1351045752 news.xs4all.nl 6960 [2001:888:2000:d::a6]:60247
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:31983

Show key headers only | View raw


On Tue, Oct 23, 2012 at 8:06 PM, Oscar Benjamin
<oscar.j.benjamin@gmail.com> wrote:
> On 23 October 2012 15:31, Virgil Stokes <vs@it.uu.se> wrote:
>> I am working with some rather large data files (>100GB) that contain time
>> series data. The data (t_k,y(t_k)), k = 0,1,...,N are stored in ASCII
>> format. I perform various types of processing on these data (e.g. moving
>> median, moving average, and Kalman-filter, Kalman-smoother) in a sequential
>> manner and only a small number of these data need be stored in RAM when
>> being processed. When performing Kalman-filtering (forward in time pass, k =
>> 0,1,...,N) I need to save to an external file several variables (e.g. 11*32
>> bytes) for each (t_k, y(t_k)). These are inputs to the Kalman-smoother
>> (backward in time pass, k = N,N-1,...,0). Thus, I will need to input these
>> variables saved to an external file from the forward pass, in reverse order
>> --- from last written to first written.
>>
>> Finally, to my question --- What is a fast way to write these variables to
>> an external file and then read them in backwards?
>
> You mentioned elsewhere that you are using numpy. I'll assume that the
> data you want to read/write are numpy arrays.

If that is the case always timeit. The following is an example of 3
functions, with repetitions of time that give an average:

import timeit
#3 dimensional matrix
x_dim = -1
y_dim = -1
z_dim = -1
s = """\

x_dim = -1
y_dim = -1
z_dim = -1
dict_1 = {}

for i in xrange(0,6):
	x_dim = 1
	y_dim = 1
	z_dim = 1
	dict_1['%s' % (i) ] = ['x = %i' % (x_dim), 'y = %i' % (y_dim),  'z =
%i' % (z_dim)]

"""

t = """\
import numpy
numpy.array([[ 1.,  0.,  0.],
       [ 0.,  1.,  2.]])
"""

u = """\
list_count = 0
an_array = []
for i in range(0,10):

	if list_count > 3:
		break
	
	if i % 3 != 0:
		an_array.append(i)

	if i % 3 == 0:
		list_count += 1

"""
print timeit.timeit(stmt=s, number=100000)
print timeit.timeit(stmt=t, number=100000)
print timeit.timeit(stmt=u, number=100000)


-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Fast forward-backward (write-read) David Hutto <dwightdhutto@gmail.com> - 2012-10-23 22:29 -0400

csiph-web