Open Valdebenit0 opened 20 hours ago
I had a similar issue. You can see it in the closed issues. It was thought to be fixed.
There is a workaround that I used which involves editing the code in sensor1c.py and commenting out the line looking for STACK.
@alangi could you share with me how your sensor1c.py code looks like after editing it? I just commented what you said but I keep getting the same error.
In "def _from_trace_seg2" find the code below
header = trace.stats.seg2
return cls.from_trace(trace,
read_header=False,
nstacks=int(header.STACK),
delay=float(header.DELAY),
x=map_x(float(header.RECEIVER_LOCATION)),
y=map_y(0),
z=0)
delete the line nstacks=int(header.STACK),
Best keep a copy incase it doesn't work. This assumes that you are using seg2 files.
thanks for trying to help me, but I keep getting the same error:
KeyError Traceback (most recent call last) File ~\anaconda3\Lib\site-packages\obspy\core\util\attribdict.py:140, in AttribDict.getattr(self, name, default) 139 try: --> 140 return self.getitem(name, default) 141 except KeyError as e:
File ~\anaconda3\Lib\site-packages\obspy\core\util\attribdict.py:96, in AttribDict.getitem(self, name, default) 95 try: ---> 96 return self.dict[name] 97 except KeyError: 98 # check if we got any default value given at class level
KeyError: 'STACK'
During handling of the above exception, another exception occurred:
AttributeError Traceback (most recent call last) Cell In[92], line 18 16 wavefieldtransforms = [] 17 for fnames in fnames_set: ---> 18 wavefieldtransforms.append(swprocess.Masw.run(fnames=fnames, settings=settings)) 19 end = time.perf_counter() 20 print(f"Elapsed Time (s): {round(end-start,2)}")
File ~\anaconda3\Lib\site-packages\swprocess\masw.py:87, in Masw.run(fnames, settings, map_x, map_y) 83 workflow = Workflow(fnames=fnames, settings=settings, 84 map_x=map_x, map_y=map_y) 86 # Run and return. ---> 87 return workflow.run()
File ~\anaconda3\Lib\site-packages\swprocess\maswworkflows.py:136, in TimeDomainWorkflow.run(self) 135 def run(self): --> 136 self.array = Array1D.from_files(self.fnames, map_x=self.map_x, 137 map_y=self.map_y) 138 self.check() 139 self.trim_offsets()
File ~\anaconda3\Lib\site-packages\swprocess\array1d.py:657, in Array1D.from_files(cls, fnames, map_x, map_y) 655 sensors = [] 656 for trace in stream.traces: --> 657 sensor = Sensor1C.from_trace(trace, map_x=map_x, map_y=map_y) 658 sensors.append(sensor) 660 # Define source
File ~\anaconda3\Lib\site-packages\swprocess\sensor1c.py:118, in Sensor1C.from_trace(cls, trace, read_header, map_x, map_y, nstacks, delay, x, y, z) 116 if read_header: 117 if _format == "SEG2": --> 118 return cls._from_trace_seg2(trace, map_x=map_x, map_y=map_y) 119 elif _format == "SU": 120 return cls._from_trace_su(trace, map_x=map_x, map_y=map_y)
File ~\anaconda3\Lib\site-packages\swprocess\sensor1c.py:151, in Sensor1C._from_trace_seg2(cls, trace, map_x, map_y)
131 """Create a Sensor1C
object form a SEG2-style Trace
object.
132
133 Parameters
(...)
146
147 """
148 header = trace.stats.seg2
149 return cls.from_trace(trace,
150 read_header=False,
--> 151 nstacks=int(header.STACK),
152 delay=float(header.DELAY),
153 x=map_x(float(header.RECEIVER_LOCATION)),
154 y=map_y(0),
155 z=0)
File ~\anaconda3\Lib\site-packages\obspy\core\util\attribdict.py:142, in AttribDict.getattr(self, name, default) 140 return self.getitem(name, default) 141 except KeyError as e: --> 142 raise AttributeError(e.args[0])
AttributeError: STACK
Greetings of the day! I'm running the masw code (I'm using swprocess-v0.3.0), but it happens that when I run the analysis cell I get an error because the file format that my system outputs does not include the STACK object in the header. This creates a problem with sensor1c.py when trying to import the data. How can I do this to process my data? My data is in this link: https://correouss-my.sharepoint.com/:f:/r/personal/evaldebenitoc_correo_uss_cl/Documents/Data%20San%20Pedro?csf=1&web=1&e=l4kZHi
thank you