Coverage for pesummary/gw/notebook/notebook.py: 18.2%
11 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-12-09 22:34 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2024-12-09 22:34 +0000
1# Licensed under an MIT style license -- see LICENSE.md
3__author__ = ["Charlie Hoy <charlie.hoy@ligo.org>"]
6def psd_plot(
7 read_variable, default_analysis=None, plot_kwargs={}, extra_lines=[],
8 text="As an example, we now plot the PSDs stored in the file"
9):
10 """Return a string containing the function to generate a plot showing the
11 stored PSDs
13 Parameters
14 ----------
15 read_variable: str
16 name of the read object
17 default_analysis: str, optional
18 The analysis PSD that you wish to plot
19 plot_kwargs: dict, optional
20 kwargs for the `.plot()` method.
21 extra_lines: list, optional
22 additional lines to add to the end of the string
23 text: str, optional
24 Markdown text explaining the plot
25 """
26 if default_analysis is None:
27 raise ValueError("Please provide a default analysis to use")
28 kwargs = ", ".join([f"{key}={item}" for key, item in plot_kwargs.items()])
29 string = "psd = {}.psd['{}']\n".format(read_variable, default_analysis)
30 string += "fig = psd.plot({})\n".format(kwargs)
31 string += "\n".join(extra_lines)
32 if text is not None:
33 return [text, string]
34 return [string]