Thank you all for your suggestions. I ended up multiplying by 10 and
rounding, while casting the array to an int. Certainly not the most
universal solution, but it worked for my data.
code, for anyone searching for examples:
np.array(np.round((hlspec[:,0]-offset)*10),dtype=np.int)
-Mike
On Sun
2010/3/28 Mike Sarahan :
> I have run into some roundoff problems trying to line up some
> experimental spectra. The x coordinates are given in intervals of 0.1
> units. I read the data in from a text file using np.loadtxt().
I don't know your problem well enough, so the suggestion to use
numpy.
On 27 March 2010 19:38, Mike Sarahan wrote:
> Hi all,
>
> I have run into some roundoff problems trying to line up some
> experimental spectra. The x coordinates are given in intervals of 0.1
> units. I read the data in from a text file using np.loadtxt().
>
> I think Robert's post here explains
Mike Sarahan wrote:
> However, even linspace shows roundoff error:
>
> a=np.linspace(0.0,10.0,endpoint=False)
> b=np.linspace(0.1,10.1,endpoint=False)
> np.sum(a[1:]==b[:-1]) # Gives me 72, no 100
Are you sure equally spaced floating point numbers having this property even
exist? 0.1 does not ha
Hi all,
I have run into some roundoff problems trying to line up some
experimental spectra. The x coordinates are given in intervals of 0.1
units. I read the data in from a text file using np.loadtxt().
I think Robert's post here explains why the problem exists:
http://mail.scipy.org/pipermail/