kartikmandar commited on
Commit
401231c
·
1 Parent(s): 861276f

add readthedocs documentation and sphinx builder

Browse files
.gitignore CHANGED
@@ -3,3 +3,4 @@
3
  __pycache__/
4
  files/loaded-data/
5
  .vscode/
 
 
3
  __pycache__/
4
  files/loaded-data/
5
  .vscode/
6
+ docs/build/
.readthedocs.yaml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: 2
2
+
3
+ build:
4
+ os: "ubuntu-22.04"
5
+ tools:
6
+ python: "3.11"
7
+
8
+ python:
9
+ install:
10
+ - requirements: docs/requirements.txt
11
+ - method: pip
12
+ path: .
13
+
14
+ sphinx:
15
+ configuration: docs/source/conf.py
16
+
17
+ formats:
18
+ - pdf
19
+ - epub
docs/Makefile ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Minimal makefile for Sphinx documentation
2
+ #
3
+
4
+ # You can set these variables from the command line, and also
5
+ # from the environment for the first two.
6
+ SPHINXOPTS ?=
7
+ SPHINXBUILD ?= sphinx-build
8
+ SOURCEDIR = source
9
+ BUILDDIR = build
10
+
11
+ # Put it first so that "make" without argument is like "make help".
12
+ help:
13
+ @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14
+
15
+ .PHONY: help Makefile
16
+
17
+ # Catch-all target: route all unknown targets to Sphinx using the new
18
+ # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19
+ %: Makefile
20
+ @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
docs/make.bat ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @ECHO OFF
2
+
3
+ pushd %~dp0
4
+
5
+ REM Command file for Sphinx documentation
6
+
7
+ if "%SPHINXBUILD%" == "" (
8
+ set SPHINXBUILD=sphinx-build
9
+ )
10
+ set SOURCEDIR=source
11
+ set BUILDDIR=build
12
+
13
+ %SPHINXBUILD% >NUL 2>NUL
14
+ if errorlevel 9009 (
15
+ echo.
16
+ echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17
+ echo.installed, then set the SPHINXBUILD environment variable to point
18
+ echo.to the full path of the 'sphinx-build' executable. Alternatively you
19
+ echo.may add the Sphinx directory to PATH.
20
+ echo.
21
+ echo.If you don't have Sphinx installed, grab it from
22
+ echo.https://www.sphinx-doc.org/
23
+ exit /b 1
24
+ )
25
+
26
+ if "%1" == "" goto help
27
+
28
+ %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29
+ goto end
30
+
31
+ :help
32
+ %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33
+
34
+ :end
35
+ popd
docs/requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ sphinx
2
+ sphinx-rtd-theme
3
+ sphinx-autodoc-typehints
4
+ stingray
docs/source/DataLoading.rst ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ DataLoading package
2
+ ===================
3
+
4
+ Submodules
5
+ ----------
6
+
7
+ DataLoading.DataIngestion module
8
+ --------------------------------
9
+
10
+ .. automodule:: modules.DataLoading.DataIngestion
11
+ :members:
12
+ :undoc-members:
13
+ :show-inheritance:
14
+
15
+ Module contents
16
+ ---------------
17
+
18
+ .. automodule:: modules.DataLoading
19
+ :members:
20
+ :undoc-members:
21
+ :show-inheritance:
docs/source/Home.rst ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Home package
2
+ ============
3
+
4
+ Submodules
5
+ ----------
6
+
7
+ Home.HomeContent module
8
+ -----------------------
9
+
10
+ .. automodule:: modules.Home.HomeContent
11
+ :members:
12
+ :undoc-members:
13
+ :show-inheritance:
14
+
15
+ Module contents
16
+ ---------------
17
+
18
+ .. automodule:: modules.Home
19
+ :members:
20
+ :undoc-members:
21
+ :show-inheritance:
docs/source/QuickLook.rst ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ QuickLook package
2
+ =================
3
+
4
+ Submodules
5
+ ----------
6
+
7
+ QuickLook.AverageCrossSpectrum module
8
+ -------------------------------------
9
+
10
+ .. automodule:: modules.QuickLook.AverageCrossSpectrum
11
+ :members:
12
+ :undoc-members:
13
+ :show-inheritance:
14
+
15
+ QuickLook.AveragePowerSpectrum module
16
+ -------------------------------------
17
+
18
+ .. automodule:: modules.QuickLook.AveragePowerSpectrum
19
+ :members:
20
+ :undoc-members:
21
+ :show-inheritance:
22
+
23
+ QuickLook.Bispectrum module
24
+ ---------------------------
25
+
26
+ .. automodule:: modules.QuickLook.Bispectrum
27
+ :members:
28
+ :undoc-members:
29
+ :show-inheritance:
30
+
31
+ QuickLook.CrossSpectrum module
32
+ ------------------------------
33
+
34
+ .. automodule:: modules.QuickLook.CrossSpectrum
35
+ :members:
36
+ :undoc-members:
37
+ :show-inheritance:
38
+
39
+ QuickLook.LightCurve module
40
+ ---------------------------
41
+
42
+ .. automodule:: modules.QuickLook.LightCurve
43
+ :members:
44
+ :undoc-members:
45
+ :show-inheritance:
46
+
47
+ QuickLook.PowerColors module
48
+ ----------------------------
49
+
50
+ .. automodule:: modules.QuickLook.PowerColors
51
+ :members:
52
+ :undoc-members:
53
+ :show-inheritance:
54
+
55
+ QuickLook.PowerSpectrum module
56
+ ------------------------------
57
+
58
+ .. automodule:: modules.QuickLook.PowerSpectrum
59
+ :members:
60
+ :undoc-members:
61
+ :show-inheritance:
62
+
63
+ Module contents
64
+ ---------------
65
+
66
+ .. automodule:: modules.QuickLook
67
+ :members:
68
+ :undoc-members:
69
+ :show-inheritance:
docs/source/conf.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Configuration file for the Sphinx documentation builder.
2
+ #
3
+ # For the full list of built-in configuration values, see the documentation:
4
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html
5
+
6
+ # -- Project information -----------------------------------------------------
7
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
8
+
9
+ import os
10
+ import sys
11
+ sys.path.insert(0, os.path.abspath('../../'))
12
+
13
+ project = 'Stingray Explorer'
14
+ copyright = '2024, Kartik Mandar'
15
+ author = 'Kartik Mandar'
16
+ release = '0.1'
17
+
18
+ # -- General configuration ---------------------------------------------------
19
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
20
+
21
+ extensions = [
22
+ 'sphinx.ext.autodoc',
23
+ 'sphinx.ext.napoleon', # For Google-style docstrings
24
+ 'sphinx.ext.viewcode', # Adds links to source code
25
+ 'sphinx.ext.autosummary', # Generate summaries automatically
26
+ ]
27
+ autosummary_generate = True # Enables automatic summary generation
28
+
29
+
30
+ templates_path = ['_templates']
31
+ exclude_patterns = []
32
+
33
+
34
+
35
+ # -- Options for HTML output -------------------------------------------------
36
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
37
+
38
+ html_theme = 'sphinx_rtd_theme'
39
+ html_static_path = ['_static']
docs/source/index.rst ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .. StingrayExplorer documentation master file, created by
2
+ sphinx-quickstart on Fri Nov 8 15:00:39 2024.
3
+ You can adapt this file completely to your liking, but it should at least
4
+ contain the root `toctree` directive.
5
+
6
+ StingrayExplorer documentation
7
+ ==============================
8
+
9
+ Add your content using ``reStructuredText`` syntax. See the
10
+ `reStructuredText <https://www.sphinx-doc.org/en/master/usage/restructuredtext/index.html>`_
11
+ documentation for details.
12
+
13
+
14
+ .. toctree::
15
+ :maxdepth: 2
16
+ :caption: Contents:
17
+
18
+ modules
19
+ DataLoading
20
+ Home
21
+ QuickLook
22
+
23
+ Indices and tables
24
+ ==================
25
+
26
+ * :ref:`genindex`
27
+ * :ref:`modindex`
28
+ * :ref:`search`
docs/source/modules.rst ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ modules
2
+ =======
3
+
4
+ .. toctree::
5
+ :maxdepth: 4
6
+
modules/DataLoading/__init__.py ADDED
File without changes
modules/Home/__init__.py ADDED
File without changes
modules/QuickLook/PowerSpectrum.py CHANGED
@@ -42,6 +42,8 @@ colors = [
42
  "#9edae5",
43
  ]
44
 
 
 
45
  # Create a warning handler
46
  def create_warning_handler():
47
  warning_handler = WarningHandler()
@@ -228,6 +230,62 @@ def create_powerspectrum_tab(
228
  else:
229
  return plot
230
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
  def create_dataframe_panes(df, title):
232
  return pn.FlexBox(
233
  pn.pane.Markdown(f"**{title}**"),
@@ -258,12 +316,13 @@ def create_powerspectrum_tab(
258
 
259
  def rebin_powerspectrum(ps):
260
  rebin_size = rebin_size_input.value
261
-
262
  if linear_rebin_checkbox.value:
263
  # Perform linear rebinning
264
  rebinned_ps = ps.rebin(rebin_size, method="mean")
265
  return rebinned_ps
266
  elif log_rebin_checkbox.value:
 
267
  # Perform logarithmic rebinning
268
  rebinned_ps = ps.rebin_log(f=rebin_size)
269
  return rebinned_ps
@@ -347,7 +406,7 @@ def create_powerspectrum_tab(
347
  "Power": rebinned_ps.power,
348
  })
349
  rebinned_label = f"Rebinned {event_list_name} (dt={dt}, norm={norm})"
350
- rebinned_plot_hv = create_holoviews_plots(rebinned_df, rebinned_label, dt, norm)
351
 
352
  # Check if the user wants to plot rebin with the original
353
  if rebin_with_original_checkbox.value:
 
42
  "#9edae5",
43
  ]
44
 
45
+ log_binned = False
46
+
47
  # Create a warning handler
48
  def create_warning_handler():
49
  warning_handler = WarningHandler()
 
230
  else:
231
  return plot
232
 
233
+ def create_rebinned_holoviews_plots(df, label, dt, norm, color_key=None, log_binned=False):
234
+ """
235
+ Create a HoloViews plot for rebinned power spectrum data.
236
+
237
+ Parameters:
238
+ df (pd.DataFrame): DataFrame containing rebinned frequency and power values.
239
+ label (str): Label for the plot.
240
+ dt (float): Time binning parameter.
241
+ norm (str): Normalization parameter.
242
+ color_key (str, optional): Color key for the plot.
243
+ log_binned (bool): If True, applies a logarithmic scale to the x-axis.
244
+
245
+ Returns:
246
+ hv.Overlay or hv.DynamicMap: The generated HoloViews plot.
247
+ """
248
+ # Create the initial plot from the DataFrame
249
+ plot = df.hvplot(x="Frequency", y="Power", shared_axes=False, label=label)
250
+
251
+ # Check if color_key is provided for individual plot colors
252
+ if color_key:
253
+ if rasterize_checkbox.value:
254
+ return hd.rasterize(
255
+ plot,
256
+ aggregator=hd.ds.mean("Power"),
257
+ color_key=color_key,
258
+ line_width=3,
259
+ pixel_ratio=2,
260
+ ).opts(
261
+ tools=["hover"],
262
+ cmap=[color_key],
263
+ width=600,
264
+ height=600,
265
+ colorbar=True,
266
+ logx=log_binned # Apply log scale only if log_binned is True
267
+ )
268
+ else:
269
+ return plot.opts(logx=log_binned) # Apply log scale only if log_binned is True
270
+ else:
271
+ if rasterize_checkbox.value:
272
+ return hd.rasterize(
273
+ plot,
274
+ aggregator=hd.ds.mean("Power"),
275
+ line_width=3,
276
+ pixel_ratio=2,
277
+ ).opts(
278
+ tools=["hover"],
279
+ width=600,
280
+ height=600,
281
+ cmap="Viridis",
282
+ colorbar=True,
283
+ logx=log_binned # Apply log scale only if log_binned is True
284
+ )
285
+ else:
286
+ return plot.opts(logx=log_binned) # Apply log scale only if log_binned is True
287
+
288
+
289
  def create_dataframe_panes(df, title):
290
  return pn.FlexBox(
291
  pn.pane.Markdown(f"**{title}**"),
 
316
 
317
  def rebin_powerspectrum(ps):
318
  rebin_size = rebin_size_input.value
319
+ log_binned = False # Initialize flag for logarithmic rebinning
320
  if linear_rebin_checkbox.value:
321
  # Perform linear rebinning
322
  rebinned_ps = ps.rebin(rebin_size, method="mean")
323
  return rebinned_ps
324
  elif log_rebin_checkbox.value:
325
+ log_binned = True # Set flag to indicate log rebinning
326
  # Perform logarithmic rebinning
327
  rebinned_ps = ps.rebin_log(f=rebin_size)
328
  return rebinned_ps
 
406
  "Power": rebinned_ps.power,
407
  })
408
  rebinned_label = f"Rebinned {event_list_name} (dt={dt}, norm={norm})"
409
+ rebinned_plot_hv = create_rebinned_holoviews_plots(rebinned_df, rebinned_label, dt, norm, log_binned=log_binned)
410
 
411
  # Check if the user wants to plot rebin with the original
412
  if rebin_with_original_checkbox.value:
modules/QuickLook/__init__.py ADDED
File without changes