[obspy-users] (TSPA) Re: Problem reading css format

Maccarthy, Jonathan K jkmacc at lanl.gov
Thu Apr 20 08:24:48 CEST 2017


Feel free to email me directly with any questions.


From: obspy-users-bounces at lists.swapbytes.de <obspy-users-bounces at lists.swapbytes.de> on behalf of Yochai Ben Horin <yochai at ndc.soreq-ndc.gov.il>
Sent: Thursday, April 20, 2017 12:09:28 AM
To: users at obspy.org
Subject: Re: [obspy-users] (TSPA) Re: Problem reading css format

Dear Jon,

Thanks for your replay, I'm still in the trying to import the pisces project into my python and to operate it.


From: obspy-users-bounces at lists.swapbytes.de [mailto:obspy-users-bounces at lists.swapbytes.de] On Behalf Of Maccarthy, Jonathan K
Sent: Friday, April 14, 2017 5:51 PM
To: users at obspy.org
Subject: [obspy-users] (TSPA) Re: Problem reading css format

Hi Yochai,

s3 is a weird 3-byte integer type that numpy doesn't natively support.  I've looked into ways to coax it into a 4-byte integer type, and found a snippet from a SciPy issue that may help (pasted below): https://github.com/scipy/scipy/issues/1930.  It's for multi-dimensional arrays, but could probably be modified for 1D arrays.  If this doesn't do what you want, the Pisces project (I'm an author) can read CSS s3 type: https://github.com/jkmacc-LANL/pisces/blob/master/pisces/io/readwaveform.py#L30.

If you're able to do this using just the snippet, please let me know.  I'd be curious how it works for you.


data = numpy.fromfile(fid, dtype='u1', count=size) # first read byte per byte

a = numpy.empty((len(data)/3, 4), dtype=`u1`)

a[:, :3] = data.reshape((-1, 3))

a[:, 3:] = (a[:, 3 - 1:3] >> 7) * 255

data = a.view('<i4').reshape(a.shape[:-1])

On Apr 14, 2017, at 2:18 AM, Yochai Ben Horin <yochai at ndc.soreq-ndc.gov.il<mailto:yochai at ndc.soreq-ndc.gov.il>> wrote:


I'm trying to read data in CSS format, the data is stored as s3 which is one of the allowed data formats in CSS. I'm getting an error regarding the s3, with data in t4 the program work OK.
Any suggestions?

Cheers Yochai
obspy-users mailing list
obspy-users at lists.swapbytes.de<mailto:obspy-users at lists.swapbytes.de>

This footnote confirms that this email message has been scanned by
PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.swapbytes.de/pipermail/obspy-users/attachments/20170420/c154b66a/attachment-0001.html>

More information about the obspy-users mailing list