SeismicSource / sourcespec

Earthquake source parameters from P- and S-wave displacement spectra
https://sourcespec.seismicsource.org
Other
50 stars 12 forks source link

Error when generating HTML if map files are missing #29

Closed krisvanneste closed 1 year ago

krisvanneste commented 1 year ago

When requesting HTML output (html_report=True), but without station map (plot_station_map=False), the following error occurs:

  File "C:\Users\kris\Documents\Python\cloned_repos\sourcespec\sourcespec\ssp_html_report.py", line 381, in html_report
    map_mag = [mapfile for mapfile in station_maps if 'map_mag' in mapfile][0]

IndexError: list index out of range

I think similar errors would occur if the spectral plots or boxplots would be missing. I created a patch to fix these problems: html_report_patch.zip

However, when I run this, another error occurs:

  File "C:\Users\kris\Documents\Python\cloned_repos\sourcespec\sourcespec\ssp_html_report.py", line 766, in html_report
    if config.qml_file_out is not None:

  File "C:\Users\kris\Documents\Python\cloned_repos\sourcespec\sourcespec\config.py", line 27, in __getattr__
    raise AttributeError(err) from err

AttributeError: 'qml_file_out'

Here I'm not sure if this is due to my way of running sourcespec. I set options.qml_file = None. According to the code in ssp_qml_output.py, config.qml_file_out should be set to None, but this does not seem to happen. Do you know what is going on here?

krisvanneste commented 1 year ago

OK, I found the problem. The write_qml function was not executed because an error occurred when running write_sqlite because my database still had the version 0 format.

However, I think it's odd that QML output only occurs if a QML input file has been specified. It would be better to have a specific option for that.

krisvanneste commented 1 year ago

I ran into one more problem in the html_report problem, which I also fixed. I combined the fix with the previous one in a new patch, which I include here: patch_html_report2.zip

Finally, HTML report works again!

claudiodsf commented 1 year ago

Hi Kris, thank you for your patch.

Finally, I decided to go all in and refactor ssp_html_report.py (#30).

Please let me know if that works for you.

I'll work later today or tomorrow on the QuakeML output.

claudiodsf commented 1 year ago

Fixed by #30