[SciPy-User] AT&T format

Slavin, Jonathan jslavin at cfa.harvard.edu
Fri Mar 10 12:17:25 EST 2017


​Have you looked at the python library struct?  I don't know anything about
the AT&T format but I have been able to read Fortran unformatted data using
it.  It depends on knowing the number of padding bytes on each line, etc.
Anyways, could be useful.

Jon​

On Fri, Mar 10, 2017 at 12:00 PM, <scipy-user-request at python.org> wrote:

> Date: Thu, 09 Mar 2017 08:29:16 -0800
> From: R Schumacher <rays at blue-cove.com>
> To: SciPy Users List <scipy-user at python.org>
> Subject: Re: [SciPy-User] ANN: SciPy 0.19.0
> Message-ID: <201703091630.v29GU0Hf019131 at blue-cove.com>
> Content-Type: text/plain; charset="us-ascii"; Format="flowed"
>
> Excellent.
>
> We are working with DSP32C legacy data, and of course it is not a
> native type. The original C code is no longer available so this is
> our numpy implementation...
> Might there be a "better" method to support the AT&T format?
>
> def dsp32c_to_float(bytes):
>    dsp32c_array = np.frombuffer(bytes, np.int32)
>    signed = dsp32c_array & 0x80000000 > 0
>    exponent = (dsp32c_array & 0x000000ff) << 23
>    mantissa = (dsp32c_array & 0x7fffffff) >> 8
>    mantissa[signed] = 0x80000000 + ~mantissa[signed]
>    ieee_array = exponent + mantissa
>    float_array = ieee_array.view('f')
>    return float_array
>
> Of course if anyone out there has a stashed copy of dsptools.c
> void ieeetodspf( float *x);
> void dspftoieee( float *x);
> http://www.symres.com/files/legacy/mandsp.pdf
> it would go a long way...
>
>



-- 
________________________________________________________
Jonathan D. Slavin                 Harvard-Smithsonian CfA
jslavin at cfa.harvard.edu       60 Garden Street, MS 83
phone: (617) 496-7981       Cambridge, MA 02138-1516
cell: (781) 363-0035             USA
________________________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-user/attachments/20170310/7c8e0c2d/attachment.html>


More information about the SciPy-User mailing list