[obspy-users] SAC write file not working on X86 32-bit operating systems?

Tycho Aussie tychoaussie at gmail.com
Fri Jul 31 17:14:16 CEST 2015

Good morning,
While doing some training, we attempted to install our calibration project
onto the engineer's laptop. While we all use 64 bit versions of windows,
this computer has the 32 bit version. We installed Anaconda as well as
Obspy for 32-bit systems. Unfortunately the code fails when trying to write
SAC files. Here's an excerpt of my python code, and the resulting error.
This error does not occur when running 64 bit operating system.

This code works for 64 bit operating systems but fails on the 32 bit
operating system of Obspy.

    for i in range(0,4): # Build each channel
        t = SacIO()
        b = np.arange(len(stack),dtype=np.float32)   #   Establishes the
size of the datastream
        for n in range(len(stack)):        #   Load the array with
time-history data
            b[n] = np.float32(stack[n][i+1]) #   Convert the measurement
from counts to volts.

             #                     set the SAC header values
        t.SetHvalue('scale',1.00) # Set the scale for each channel. This
one is important to declare.
        t.SetHvalue('delta', Delta)
        t.SetHvalue('nzsec', St_time.tm_sec)
        t.SetHvalue('nzmsec', int(Frac_second*1000))
        t.SetHvalue('idep',4) # 4 = units of velocity (in Volts)
                              # Dependent variable choices: (1)unknown,
                              # (3)velocity(nm/sec), (4)velocity(volts),
                              # (5)nm/sec/sec
        t.SetHvalue('kinst',comment[i-1])       # Instrument type
        t.SetHvalue('knetwk','CSV2SAC ')         # Network designator
        t.SetHvalue('kuser0',units[i-1])        # Place the system of units
into the user text field 0
        sacfile = outfile+"_{}.sac".format(Channel[i])
        print "The name of the sacfile is '{0}'".format(sacfile)
        print " File successfully written: {0}".format(sacfile)

The name of the sacfile is 'c:\seismo\working\SM3_newcoil\00000011_CH0.sac'
Traceback (most recent call last):
  File "c:\Anaconda\sigscript\dat2sac.py", line 282, in <module>
  File "c:\Anaconda\sigscript\dat2sac.py", line 259, in main
  File "c:\Anaconda\sigscript\dat2sac.py", line 218, in convert
  File "c:\Anaconda\sigscript\dat2sac.py", line 201, in csv2sac
io.py", line 865, in WriteSacBinary
    raise SacIOError(msg, e)
obspy.sac.sacio.SacIOError: (u'Cannot write SAC-buffer to file: ',
r("'str' object has no attribute 'write'",))

Can anyone help me figure out why it's failing, and how I can fix it?
Because many of the networks in central Asia are still using a 32-bit
operating system, I need to get around this problem.

- Dan Burk, Michigan State University.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.swapbytes.de/pipermail/obspy-users/attachments/20150731/802d7a62/attachment.html>

More information about the obspy-users mailing list