hvasbath / beat

Bayesian Earthquake Analysis Tool
GNU General Public License v3.0
128 stars 42 forks source link

AttributeError: 'numpy.ndarray' object has no attribute 'tmin' #113

Closed eugenialocchi closed 1 year ago

eugenialocchi commented 1 year ago

**Hi,

I'm trying to do the kinematic model of an event with M = 5.5, using local data. For the goemetry mode i didn't have any problem to plot waveform fits. When the ffi mode was finished and then I'm going to plot the waveform fits I have this error:**

beat - INFO Loading problem ... config - INFO All hierarchicals ok! config - INFO All hyperparameters ok! config - INFO All priors ok! models - INFO ... Initialising Distribution Optimizer ...

models - INFO Analysing problem ... models - INFO ---------------------

seismic - INFO Loading seismic data for event 0 from: /home/locchi/events/FFI_CAMPOTOSTO/seismic_data.pkl seismic - INFO Initialising seismic wavemap for "any_P" ... heart - INFO Consistent number of datasets and targets in any_P_0 wavemap! heart - INFO Number of seismic datasets for wavemap: any_P_0: 30

seismic - INFO Fault(s) discretized to 1.0 [km] patches. seismic - INFO Preparing data of "any_P_0" for optimization heart - INFO Did not find custom arrival times. heart - INFO Using theoretical arrival times for "any_P_0" models - INFO Using "none" regularization ... plotting.seismic - INFO Drawing Waveform fits ... backend - INFO Loading multitrace from /home/locchi/events/FFICAMPOTOSTO/ffi/stage-1 plotting.seismic - INFO FFI waveform fit, using reference source ... seismic - INFO Loading SeismicGFLibrary seismic_uparr_any_P_0_0 seismic - INFO Loading SeismicGFLibrary seismic_uperp_any_P_00 Traceback (most recent call last): File "/home/locchi/anaconda3/envs/beat/bin/beat", line 8, in sys.exit(main()) File "/home/locchi/anaconda3/envs/beat/lib/python3.9/site-packages/beat/apps/beat.py", line 2396, in main globals()["command" + command](args) File "/home/locchi/anaconda3/envs/beat/lib/python3.9/site-packages/beat/apps/beat.py", line 1910, in command_plot plotting.plots_catalog[plot](problem, po) File "/home/locchi/anaconda3/envs/beat/lib/python3.9/site-packages/beat/plotting/seismic.py", line 1114, in draw_seismic_fits event_figs = seismic_fits(problem, stage, po) File "/home/locchi/anaconda3/envs/beat/lib/python3.9/site-packages/beat/plotting/seismic.py", line 719, in seismic_fits bresults = composite.assemble_results( File "/home/locchi/anaconda3/envs/beat/lib/python3.9/site-packages/beat/models/seismic.py", line 482, in assemble_results taper = at.get_pyrocko_taper(float(obs_tr.tmin - at.a)) AttributeError: 'numpy.ndarray' object has no attribute 'tmin'

**The seismic data are the same of geometry mode, with same taper but different filter!!

How can I fix this error?? Could it be an error due to numpy or pyrocko?

I have numpy 1.22.4, numpy-base 1.21.5, pyrocko 2022.06.10

Thanks**

hvasbath commented 1 year ago

Dear Eugenia,

this error is really puzzling. Apparently, at least some of your observed traces are numpy arrays instead of pyrocko.trace.Trace objects. You can try loading your seismic_data.pkl through beat.utility.load_objects("seismic_data.pkl"). Please inspect your traces there and make sure that they are all in the correct format. Although, if that wasnt the case there should have been an error earlier in the loading, which is why it is puzzling...

Hannes

eugenialocchi commented 1 year ago

Hi Hannes,

I checked my traces and they are all a beat.heart.SeismicDataset object.

The stranger thing is that I used the same seismic_data.pkl for the geometry mode and I didn't have this error...

hvasbath commented 1 year ago

Thanks for checking again! I think I found the issue. Now I still do not understand why it still works in my test-case. I will keep you updated. Today evening I will have time to run more checks.

hvasbath commented 1 year ago

Dear Eugenia, Thanks again for posting that I was able to finally reproduce it. I created a branch where https://github.com/hvasbath/beat/tree/ffi_kin_fix I fixed the issue. Now locally on my computer it fixed the issue, but it would be good if you try also on your case, before we merge that. Please see here: https://pyrocko.org/beat/docs/current/updating.html#testing-development-features for how to install particular git branches that are different from the standeard installation. In this case the "$feature_branch_name" would be "ffi_kin_fix". Please let me know if this solves the issue for you.

eugenialocchi commented 1 year ago

Thanks for help!! So now I'm going to try for my case, I will let you know as soon as I have results!!

eugenialocchi commented 1 year ago

Hi Hannes,

Finally the problem is solved using the new branch!!!

Thank you very much!!!

hvasbath commented 1 year ago

Thats good news! Thanks for testing! So I will collect few other changes for a new release.

hvasbath commented 1 year ago

New release 1.2.3 is out where this is fixed. Closing.