[SciPy-User] AT&T format

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[SciPy-User] AT&T format

Slavin, Jonathan
​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.


On Fri, Mar 10, 2017 at 12:00 PM, <[hidden email]> wrote:
Date: Thu, 09 Mar 2017 08:29:16 -0800
From: R Schumacher <[hidden email]>
To: SciPy Users List <[hidden email]>
Subject: Re: [SciPy-User] ANN: SciPy 0.19.0
Message-ID: <[hidden email]>
Content-Type: text/plain; charset="us-ascii"; Format="flowed"


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);
it would go a long way...

Jonathan D. Slavin                 Harvard-Smithsonian CfA
[hidden email]       60 Garden Street, MS 83
phone: (617) 496-7981       Cambridge, MA 02138-1516
cell: (781) 363-0035             USA

SciPy-User mailing list
[hidden email]