Skip to content

Commit

Permalink
Link to supplementary files and plots in the HTML report
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiodsf committed Oct 9, 2024
1 parent e86f562 commit 58f0a28
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Copyright (c) 2011-2024 Claudio Satriano <[email protected]>

## unreleased

### Input/output

- Link to supplementary files and plots in the HTML report

### Processing

- New config parameter `refine_theoretical_arrivals` to refine the
Expand Down
1 change: 1 addition & 0 deletions sourcespec/html_report_template/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ <h2>Files</h2>
</td>
</tr>
{QUAKEML_FILE_LINK}
{SUPPLEMENTARY_FILE_LINKS}
</tbody>
</table>
</div> <!-- dontprint -->
Expand Down
6 changes: 6 additions & 0 deletions sourcespec/html_report_template/supplementary_file_links.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<tr>
<th scope="row">Supplementary files and plots:</th>
<td>
{SUPPLEMENTARY_FILES}
</td>
</tr>
25 changes: 25 additions & 0 deletions sourcespec/ssp_html_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,29 @@ def _add_downloadable_files_to_html(config, templates, replacements):
'{QUAKEML_FILE_LINK}': quakeml_file_link
})

suppl_file_list = [
os.path.basename(fig) for fig in config.figures['traces_raw']
]
suppl_file_list += [
os.path.basename(fig) for fig in config.figures['spectra_weight']
]
supplementary_files = ''.join(
f'<a href="{suppl_file}">{suppl_file}</a></br>\n'
for suppl_file in suppl_file_list
)
if supplementary_files:
with open(
templates.supplementary_file_links_html, encoding='utf-8'
) as fp:
supplementary_file_links = fp.read()
supplementary_file_links = supplementary_file_links\
.replace('{SUPPLEMENTARY_FILES}', supplementary_files)
else:
supplementary_file_links = ''
replacements.update({
'{SUPPLEMENTARY_FILE_LINKS}': supplementary_file_links
})


class HTMLtemplates:
"""Class to hold paths to HTML templates."""
Expand All @@ -987,6 +1010,8 @@ def __init__(self):
template_dir, 'station_table_row.html')
self.quakeml_file_link_html = os.path.join(
template_dir, 'quakeml_file_link.html')
self.supplementary_file_links_html = os.path.join(
template_dir, 'supplementary_file_links.html')


def _cleanup_html(text):
Expand Down

0 comments on commit 58f0a28

Please sign in to comment.