Spaces:
Running
Running
Commit ·
9d73992
1
Parent(s): 13a1ba6
update docs
Browse files- docs/source/DataLoading.rst +4 -0
- docs/source/Home.rst +4 -0
- docs/source/QuickLook.rst +16 -0
- docs/source/conf.py +11 -4
- modules/DataLoading/DataIngestion.py +174 -9
docs/source/DataLoading.rst
CHANGED
|
@@ -11,6 +11,8 @@ DataLoading.DataIngestion module
|
|
| 11 |
:members:
|
| 12 |
:undoc-members:
|
| 13 |
:show-inheritance:
|
|
|
|
|
|
|
| 14 |
|
| 15 |
Module contents
|
| 16 |
---------------
|
|
@@ -19,3 +21,5 @@ Module contents
|
|
| 19 |
:members:
|
| 20 |
:undoc-members:
|
| 21 |
:show-inheritance:
|
|
|
|
|
|
|
|
|
| 11 |
:members:
|
| 12 |
:undoc-members:
|
| 13 |
:show-inheritance:
|
| 14 |
+
:special-members: __init__, __call__ # Include special methods like __init__
|
| 15 |
+
:inherited-members: # Shows inherited methods in classes
|
| 16 |
|
| 17 |
Module contents
|
| 18 |
---------------
|
|
|
|
| 21 |
:members:
|
| 22 |
:undoc-members:
|
| 23 |
:show-inheritance:
|
| 24 |
+
:special-members: __init__, __call__ # Include special methods like __init__
|
| 25 |
+
:inherited-members: # Shows inherited methods in classes
|
docs/source/Home.rst
CHANGED
|
@@ -11,6 +11,8 @@ Home.HomeContent module
|
|
| 11 |
:members:
|
| 12 |
:undoc-members:
|
| 13 |
:show-inheritance:
|
|
|
|
|
|
|
| 14 |
|
| 15 |
Module contents
|
| 16 |
---------------
|
|
@@ -19,3 +21,5 @@ Module contents
|
|
| 19 |
:members:
|
| 20 |
:undoc-members:
|
| 21 |
:show-inheritance:
|
|
|
|
|
|
|
|
|
| 11 |
:members:
|
| 12 |
:undoc-members:
|
| 13 |
:show-inheritance:
|
| 14 |
+
:special-members: __init__, __call__ # Include special methods like __init__
|
| 15 |
+
:inherited-members: # Shows inherited methods in classes
|
| 16 |
|
| 17 |
Module contents
|
| 18 |
---------------
|
|
|
|
| 21 |
:members:
|
| 22 |
:undoc-members:
|
| 23 |
:show-inheritance:
|
| 24 |
+
:special-members: __init__, __call__ # Include special methods like __init__
|
| 25 |
+
:inherited-members: # Shows inherited methods in classes
|
docs/source/QuickLook.rst
CHANGED
|
@@ -11,6 +11,8 @@ QuickLook.AverageCrossSpectrum module
|
|
| 11 |
:members:
|
| 12 |
:undoc-members:
|
| 13 |
:show-inheritance:
|
|
|
|
|
|
|
| 14 |
|
| 15 |
QuickLook.AveragePowerSpectrum module
|
| 16 |
-------------------------------------
|
|
@@ -19,6 +21,8 @@ QuickLook.AveragePowerSpectrum module
|
|
| 19 |
:members:
|
| 20 |
:undoc-members:
|
| 21 |
:show-inheritance:
|
|
|
|
|
|
|
| 22 |
|
| 23 |
QuickLook.Bispectrum module
|
| 24 |
---------------------------
|
|
@@ -27,6 +31,8 @@ QuickLook.Bispectrum module
|
|
| 27 |
:members:
|
| 28 |
:undoc-members:
|
| 29 |
:show-inheritance:
|
|
|
|
|
|
|
| 30 |
|
| 31 |
QuickLook.CrossSpectrum module
|
| 32 |
------------------------------
|
|
@@ -35,6 +41,8 @@ QuickLook.CrossSpectrum module
|
|
| 35 |
:members:
|
| 36 |
:undoc-members:
|
| 37 |
:show-inheritance:
|
|
|
|
|
|
|
| 38 |
|
| 39 |
QuickLook.LightCurve module
|
| 40 |
---------------------------
|
|
@@ -43,6 +51,8 @@ QuickLook.LightCurve module
|
|
| 43 |
:members:
|
| 44 |
:undoc-members:
|
| 45 |
:show-inheritance:
|
|
|
|
|
|
|
| 46 |
|
| 47 |
QuickLook.PowerColors module
|
| 48 |
----------------------------
|
|
@@ -51,6 +61,8 @@ QuickLook.PowerColors module
|
|
| 51 |
:members:
|
| 52 |
:undoc-members:
|
| 53 |
:show-inheritance:
|
|
|
|
|
|
|
| 54 |
|
| 55 |
QuickLook.PowerSpectrum module
|
| 56 |
------------------------------
|
|
@@ -59,6 +71,8 @@ QuickLook.PowerSpectrum module
|
|
| 59 |
:members:
|
| 60 |
:undoc-members:
|
| 61 |
:show-inheritance:
|
|
|
|
|
|
|
| 62 |
|
| 63 |
Module contents
|
| 64 |
---------------
|
|
@@ -67,3 +81,5 @@ Module contents
|
|
| 67 |
:members:
|
| 68 |
:undoc-members:
|
| 69 |
:show-inheritance:
|
|
|
|
|
|
|
|
|
| 11 |
:members:
|
| 12 |
:undoc-members:
|
| 13 |
:show-inheritance:
|
| 14 |
+
:special-members: __init__, __call__ # Include special methods like __init__
|
| 15 |
+
:inherited-members: # Shows inherited methods in classes
|
| 16 |
|
| 17 |
QuickLook.AveragePowerSpectrum module
|
| 18 |
-------------------------------------
|
|
|
|
| 21 |
:members:
|
| 22 |
:undoc-members:
|
| 23 |
:show-inheritance:
|
| 24 |
+
:special-members: __init__, __call__ # Include special methods like __init__
|
| 25 |
+
:inherited-members: # Shows inherited methods in classes
|
| 26 |
|
| 27 |
QuickLook.Bispectrum module
|
| 28 |
---------------------------
|
|
|
|
| 31 |
:members:
|
| 32 |
:undoc-members:
|
| 33 |
:show-inheritance:
|
| 34 |
+
:special-members: __init__, __call__ # Include special methods like __init__
|
| 35 |
+
:inherited-members: # Shows inherited methods in classes
|
| 36 |
|
| 37 |
QuickLook.CrossSpectrum module
|
| 38 |
------------------------------
|
|
|
|
| 41 |
:members:
|
| 42 |
:undoc-members:
|
| 43 |
:show-inheritance:
|
| 44 |
+
:special-members: __init__, __call__ # Include special methods like __init__
|
| 45 |
+
:inherited-members: # Shows inherited methods in classes
|
| 46 |
|
| 47 |
QuickLook.LightCurve module
|
| 48 |
---------------------------
|
|
|
|
| 51 |
:members:
|
| 52 |
:undoc-members:
|
| 53 |
:show-inheritance:
|
| 54 |
+
:special-members: __init__, __call__ # Include special methods like __init__
|
| 55 |
+
:inherited-members: # Shows inherited methods in classes
|
| 56 |
|
| 57 |
QuickLook.PowerColors module
|
| 58 |
----------------------------
|
|
|
|
| 61 |
:members:
|
| 62 |
:undoc-members:
|
| 63 |
:show-inheritance:
|
| 64 |
+
:special-members: __init__, __call__ # Include special methods like __init__
|
| 65 |
+
:inherited-members: # Shows inherited methods in classes
|
| 66 |
|
| 67 |
QuickLook.PowerSpectrum module
|
| 68 |
------------------------------
|
|
|
|
| 71 |
:members:
|
| 72 |
:undoc-members:
|
| 73 |
:show-inheritance:
|
| 74 |
+
:special-members: __init__, __call__ # Include special methods like __init__
|
| 75 |
+
:inherited-members: # Shows inherited methods in classes
|
| 76 |
|
| 77 |
Module contents
|
| 78 |
---------------
|
|
|
|
| 81 |
:members:
|
| 82 |
:undoc-members:
|
| 83 |
:show-inheritance:
|
| 84 |
+
:special-members: __init__, __call__ # Include special methods like __init__
|
| 85 |
+
:inherited-members: # Shows inherited methods in classes
|
docs/source/conf.py
CHANGED
|
@@ -19,13 +19,20 @@ release = '0.1'
|
|
| 19 |
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
|
| 20 |
|
| 21 |
extensions = [
|
| 22 |
-
'sphinx.ext.autodoc',
|
| 23 |
-
'sphinx.ext.napoleon',
|
| 24 |
-
'sphinx.ext.
|
| 25 |
-
'sphinx.ext.
|
|
|
|
| 26 |
]
|
|
|
|
| 27 |
autosummary_generate = True # Enables automatic summary generation
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
templates_path = ['_templates']
|
| 31 |
exclude_patterns = []
|
|
|
|
| 19 |
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
|
| 20 |
|
| 21 |
extensions = [
|
| 22 |
+
'sphinx.ext.autodoc', # Main extension for auto-documentation
|
| 23 |
+
'sphinx.ext.napoleon', # Supports Google/NumPy style docstrings
|
| 24 |
+
'sphinx.ext.autosummary', # Generates summary tables for modules/classes
|
| 25 |
+
'sphinx.ext.viewcode', # Adds links to highlighted source code
|
| 26 |
+
'sphinx.ext.intersphinx', # Links to documentation of external libraries
|
| 27 |
]
|
| 28 |
+
|
| 29 |
autosummary_generate = True # Enables automatic summary generation
|
| 30 |
|
| 31 |
+
intersphinx_mapping = {
|
| 32 |
+
'python': ('https://docs.python.org/3', None),
|
| 33 |
+
'numpy': ('https://numpy.org/doc/stable/', None),
|
| 34 |
+
'scipy': ('https://docs.scipy.org/doc/scipy/', None),
|
| 35 |
+
}
|
| 36 |
|
| 37 |
templates_path = ['_templates']
|
| 38 |
exclude_patterns = []
|
modules/DataLoading/DataIngestion.py
CHANGED
|
@@ -29,13 +29,19 @@ loaded_data_path = os.path.join(os.getcwd(), "files", "loaded-data")
|
|
| 29 |
os.makedirs(loaded_data_path, exist_ok=True)
|
| 30 |
|
| 31 |
|
| 32 |
-
# Create a warning handler
|
| 33 |
def create_warning_handler():
|
| 34 |
"""
|
| 35 |
Create an instance of WarningHandler and redirect warnings to this custom handler.
|
| 36 |
|
| 37 |
Returns:
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
"""
|
| 40 |
warning_handler = WarningHandler()
|
| 41 |
warnings.showwarning = warning_handler.warn
|
|
@@ -57,8 +63,22 @@ def create_loadingdata_header(
|
|
| 57 |
"""
|
| 58 |
Create the header for the data loading section.
|
| 59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
Returns:
|
| 61 |
MainHeader: An instance of MainHeader with the specified heading.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
"""
|
| 63 |
home_heading_input = pn.widgets.TextInput(
|
| 64 |
name="Heading", value="Data Ingestion and creation"
|
|
@@ -78,6 +98,11 @@ def create_loadingdata_output_box(content):
|
|
| 78 |
|
| 79 |
Returns:
|
| 80 |
OutputBox: An instance of OutputBox with the specified content.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
"""
|
| 82 |
return OutputBox(output_content=content)
|
| 83 |
|
|
@@ -94,6 +119,11 @@ def create_loadingdata_warning_box(content):
|
|
| 94 |
|
| 95 |
Returns:
|
| 96 |
WarningBox: An instance of WarningBox with the specified content.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
"""
|
| 98 |
return WarningBox(warning_content=content)
|
| 99 |
|
|
@@ -120,6 +150,21 @@ def load_event_data(
|
|
| 120 |
output_box_container (OutputBox): The container for output messages.
|
| 121 |
warning_box_container (WarningBox): The container for warning messages.
|
| 122 |
warning_handler (WarningHandler): The handler for warnings.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
"""
|
| 124 |
if not file_selector.value:
|
| 125 |
output_box_container[:] = [
|
|
@@ -148,7 +193,7 @@ def load_event_data(
|
|
| 148 |
filenames.extend(
|
| 149 |
[
|
| 150 |
os.path.basename(path).split(".")[0]
|
| 151 |
-
for path in file_paths[len(filenames)
|
| 152 |
]
|
| 153 |
)
|
| 154 |
if len(formats) < len(file_paths):
|
|
@@ -213,6 +258,21 @@ def save_loaded_files(
|
|
| 213 |
output_box_container (OutputBox): The container for output messages.
|
| 214 |
warning_box_container (WarningBox): The container for warning messages.
|
| 215 |
warning_handler (WarningHandler): The handler for warnings.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
"""
|
| 217 |
if not loaded_event_data:
|
| 218 |
output_box_container[:] = [
|
|
@@ -315,6 +375,21 @@ def delete_selected_files(
|
|
| 315 |
output_box_container (OutputBox): The container for output messages.
|
| 316 |
warning_box_container (WarningBox): The container for warning messages.
|
| 317 |
warning_handler (WarningHandler): The handler for warnings.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 318 |
"""
|
| 319 |
if not file_selector.value:
|
| 320 |
output_box_container[:] = [
|
|
@@ -367,6 +442,19 @@ def preview_loaded_files(
|
|
| 367 |
warning_box_container (WarningBox): The container for warning messages.
|
| 368 |
warning_handler (WarningHandler): The handler for warnings.
|
| 369 |
time_limit (int): The number of time entries to preview.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 370 |
"""
|
| 371 |
preview_data = []
|
| 372 |
|
|
@@ -412,6 +500,7 @@ def preview_loaded_files(
|
|
| 412 |
warning_handler.warnings.clear()
|
| 413 |
|
| 414 |
|
|
|
|
| 415 |
def clear_loaded_files(event, output_box_container, warning_box_container):
|
| 416 |
"""
|
| 417 |
Clear all loaded event data files and light curves from memory.
|
|
@@ -420,6 +509,20 @@ def clear_loaded_files(event, output_box_container, warning_box_container):
|
|
| 420 |
event: The event object triggering the function.
|
| 421 |
output_box_container (OutputBox): The container for output messages.
|
| 422 |
warning_box_container (WarningBox): The container for warning messages.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 423 |
"""
|
| 424 |
global loaded_event_data, loaded_light_curve
|
| 425 |
event_data_cleared = False
|
|
@@ -449,7 +552,6 @@ def clear_loaded_files(event, output_box_container, warning_box_container):
|
|
| 449 |
warning_box_container[:] = [create_loadingdata_warning_box("No warnings.")]
|
| 450 |
|
| 451 |
|
| 452 |
-
|
| 453 |
def create_event_list(
|
| 454 |
event,
|
| 455 |
times_input,
|
|
@@ -476,6 +578,20 @@ def create_event_list(
|
|
| 476 |
output_box_container (OutputBox): The container for output messages.
|
| 477 |
warning_box_container (WarningBox): The container for warning messages.
|
| 478 |
warning_handler (WarningHandler): The handler for warnings.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 479 |
"""
|
| 480 |
# Clear previous warnings
|
| 481 |
warning_handler.warnings.clear()
|
|
@@ -567,6 +683,20 @@ def simulate_event_list(
|
|
| 567 |
output_box_container (OutputBox): The container for output messages.
|
| 568 |
warning_box_container (WarningBox): The container for warning messages.
|
| 569 |
warning_handler (WarningHandler): The handler for warnings.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 570 |
"""
|
| 571 |
# Clear previous warnings
|
| 572 |
warning_handler.warnings.clear()
|
|
@@ -632,7 +762,12 @@ def create_loading_tab(output_box_container, warning_box_container, warning_hand
|
|
| 632 |
warning_handler (WarningHandler): The handler for warnings.
|
| 633 |
|
| 634 |
Returns:
|
| 635 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 636 |
"""
|
| 637 |
file_selector = pn.widgets.FileSelector(
|
| 638 |
os.getcwd(), only_files=True, name="Select File", show_hidden=True
|
|
@@ -778,7 +913,12 @@ def create_event_list_tab(output_box_container, warning_box_container, warning_h
|
|
| 778 |
warning_handler (WarningHandler): The handler for warnings.
|
| 779 |
|
| 780 |
Returns:
|
| 781 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 782 |
"""
|
| 783 |
times_input = pn.widgets.TextInput(
|
| 784 |
name="Photon Arrival Times", placeholder="e.g., 0.5, 1.1, 2.2, 3.7"
|
|
@@ -845,7 +985,12 @@ def create_simulate_event_list_tab(
|
|
| 845 |
warning_handler (WarningHandler): The handler for warnings.
|
| 846 |
|
| 847 |
Returns:
|
| 848 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 849 |
"""
|
| 850 |
simulation_title = pn.pane.Markdown("# Simulating Event Lists")
|
| 851 |
time_slider = pn.widgets.IntSlider(
|
|
@@ -914,11 +1059,21 @@ def create_loadingdata_main_area(
|
|
| 914 |
Create the main area for the data loading tab, including all sub-tabs.
|
| 915 |
|
| 916 |
Args:
|
| 917 |
-
|
| 918 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 919 |
|
| 920 |
Returns:
|
| 921 |
MainArea: An instance of MainArea with all the necessary tabs for data loading.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 922 |
"""
|
| 923 |
warning_handler = create_warning_handler()
|
| 924 |
tabs_content = {
|
|
@@ -947,6 +1102,11 @@ def create_loadingdata_help_area():
|
|
| 947 |
|
| 948 |
Returns:
|
| 949 |
HelpBox: An instance of HelpBox with the help content.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 950 |
"""
|
| 951 |
help_content = LOADING_DATA_HELP_BOX_STRING
|
| 952 |
return HelpBox(help_content=help_content, title="Help Section")
|
|
@@ -958,5 +1118,10 @@ def create_loadingdata_plots_area():
|
|
| 958 |
|
| 959 |
Returns:
|
| 960 |
PlotsContainer: An instance of PlotsContainer with the plots for the data loading tab.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 961 |
"""
|
| 962 |
return PlotsContainer()
|
|
|
|
| 29 |
os.makedirs(loaded_data_path, exist_ok=True)
|
| 30 |
|
| 31 |
|
|
|
|
| 32 |
def create_warning_handler():
|
| 33 |
"""
|
| 34 |
Create an instance of WarningHandler and redirect warnings to this custom handler.
|
| 35 |
|
| 36 |
Returns:
|
| 37 |
+
WarningHandler: An instance of WarningHandler to handle warnings.
|
| 38 |
+
|
| 39 |
+
Side effects:
|
| 40 |
+
Overrides the default warning handler with a custom one.
|
| 41 |
+
|
| 42 |
+
Example:
|
| 43 |
+
>>> warning_handler = create_warning_handler()
|
| 44 |
+
>>> warning_handler.warn("Test warning", category=RuntimeWarning)
|
| 45 |
"""
|
| 46 |
warning_handler = WarningHandler()
|
| 47 |
warnings.showwarning = warning_handler.warn
|
|
|
|
| 63 |
"""
|
| 64 |
Create the header for the data loading section.
|
| 65 |
|
| 66 |
+
Args:
|
| 67 |
+
header_container: The container for the header.
|
| 68 |
+
main_area_container: The container for the main content area.
|
| 69 |
+
output_box_container: The container for the output messages.
|
| 70 |
+
warning_box_container: The container for warning messages.
|
| 71 |
+
plots_container: The container for plots.
|
| 72 |
+
help_box_container: The container for the help section.
|
| 73 |
+
footer_container: The container for the footer.
|
| 74 |
+
|
| 75 |
Returns:
|
| 76 |
MainHeader: An instance of MainHeader with the specified heading.
|
| 77 |
+
|
| 78 |
+
Example:
|
| 79 |
+
>>> header = create_loadingdata_header(header_container, main_area_container, ...)
|
| 80 |
+
>>> header.heading.value
|
| 81 |
+
'Data Ingestion and creation'
|
| 82 |
"""
|
| 83 |
home_heading_input = pn.widgets.TextInput(
|
| 84 |
name="Heading", value="Data Ingestion and creation"
|
|
|
|
| 98 |
|
| 99 |
Returns:
|
| 100 |
OutputBox: An instance of OutputBox with the specified content.
|
| 101 |
+
|
| 102 |
+
Example:
|
| 103 |
+
>>> output_box = create_loadingdata_output_box("File loaded successfully.")
|
| 104 |
+
>>> output_box.output_content
|
| 105 |
+
'File loaded successfully.'
|
| 106 |
"""
|
| 107 |
return OutputBox(output_content=content)
|
| 108 |
|
|
|
|
| 119 |
|
| 120 |
Returns:
|
| 121 |
WarningBox: An instance of WarningBox with the specified content.
|
| 122 |
+
|
| 123 |
+
Example:
|
| 124 |
+
>>> warning_box = create_loadingdata_warning_box("Invalid file format.")
|
| 125 |
+
>>> warning_box.warning_content
|
| 126 |
+
'Invalid file format.'
|
| 127 |
"""
|
| 128 |
return WarningBox(warning_content=content)
|
| 129 |
|
|
|
|
| 150 |
output_box_container (OutputBox): The container for output messages.
|
| 151 |
warning_box_container (WarningBox): The container for warning messages.
|
| 152 |
warning_handler (WarningHandler): The handler for warnings.
|
| 153 |
+
|
| 154 |
+
Side effects:
|
| 155 |
+
- Modifies the global `loaded_event_data` list.
|
| 156 |
+
- Updates the output and warning containers with messages.
|
| 157 |
+
|
| 158 |
+
Exceptions:
|
| 159 |
+
- Displays exceptions in the output box if file loading fails.
|
| 160 |
+
|
| 161 |
+
Restrictions:
|
| 162 |
+
- Requires that the number of formats matches the number of files unless default format is used.
|
| 163 |
+
|
| 164 |
+
Example:
|
| 165 |
+
>>> load_event_data(event, file_selector, filename_input, format_input, format_checkbox, ...)
|
| 166 |
+
>>> len(loaded_event_data)
|
| 167 |
+
1 # Assuming one file was loaded
|
| 168 |
"""
|
| 169 |
if not file_selector.value:
|
| 170 |
output_box_container[:] = [
|
|
|
|
| 193 |
filenames.extend(
|
| 194 |
[
|
| 195 |
os.path.basename(path).split(".")[0]
|
| 196 |
+
for path in file_paths[len(filenames):]
|
| 197 |
]
|
| 198 |
)
|
| 199 |
if len(formats) < len(file_paths):
|
|
|
|
| 258 |
output_box_container (OutputBox): The container for output messages.
|
| 259 |
warning_box_container (WarningBox): The container for warning messages.
|
| 260 |
warning_handler (WarningHandler): The handler for warnings.
|
| 261 |
+
|
| 262 |
+
Side effects:
|
| 263 |
+
- Saves files to disk in the specified formats.
|
| 264 |
+
- Updates the output and warning containers with messages.
|
| 265 |
+
|
| 266 |
+
Exceptions:
|
| 267 |
+
- Displays exceptions in the warning box if file saving fails.
|
| 268 |
+
|
| 269 |
+
Restrictions:
|
| 270 |
+
- Requires that the number of filenames and formats matches the number of loaded files unless default format is used.
|
| 271 |
+
|
| 272 |
+
Example:
|
| 273 |
+
>>> save_loaded_files(event, filename_input, format_input, format_checkbox, ...)
|
| 274 |
+
>>> os.path.exists('/path/to/saved/file.hdf5')
|
| 275 |
+
True # Assuming the file was saved successfully
|
| 276 |
"""
|
| 277 |
if not loaded_event_data:
|
| 278 |
output_box_container[:] = [
|
|
|
|
| 375 |
output_box_container (OutputBox): The container for output messages.
|
| 376 |
warning_box_container (WarningBox): The container for warning messages.
|
| 377 |
warning_handler (WarningHandler): The handler for warnings.
|
| 378 |
+
|
| 379 |
+
Side effects:
|
| 380 |
+
- Deletes files from the file system.
|
| 381 |
+
- Updates the output and warning containers with messages.
|
| 382 |
+
|
| 383 |
+
Exceptions:
|
| 384 |
+
- Displays exceptions in the warning box if file deletion fails.
|
| 385 |
+
|
| 386 |
+
Restrictions:
|
| 387 |
+
- Cannot delete `.py` files for safety reasons.
|
| 388 |
+
|
| 389 |
+
Example:
|
| 390 |
+
>>> delete_selected_files(event, file_selector, warning_box_container, output_box_container, warning_handler)
|
| 391 |
+
>>> os.path.exists('/path/to/deleted/file')
|
| 392 |
+
False # Assuming the file was deleted successfully
|
| 393 |
"""
|
| 394 |
if not file_selector.value:
|
| 395 |
output_box_container[:] = [
|
|
|
|
| 442 |
warning_box_container (WarningBox): The container for warning messages.
|
| 443 |
warning_handler (WarningHandler): The handler for warnings.
|
| 444 |
time_limit (int): The number of time entries to preview.
|
| 445 |
+
|
| 446 |
+
Side Effects:
|
| 447 |
+
Updates the output and warning containers with preview information.
|
| 448 |
+
|
| 449 |
+
Exceptions:
|
| 450 |
+
Captures exceptions and displays them in the warning box.
|
| 451 |
+
|
| 452 |
+
Restrictions:
|
| 453 |
+
None.
|
| 454 |
+
|
| 455 |
+
Example:
|
| 456 |
+
>>> preview_loaded_files(event, output_box_container, warning_box_container, warning_handler)
|
| 457 |
+
"Event List - my_event_list:\nTimes (first 10): [0.1, 0.2, ...]\nMJDREF: 58000"
|
| 458 |
"""
|
| 459 |
preview_data = []
|
| 460 |
|
|
|
|
| 500 |
warning_handler.warnings.clear()
|
| 501 |
|
| 502 |
|
| 503 |
+
|
| 504 |
def clear_loaded_files(event, output_box_container, warning_box_container):
|
| 505 |
"""
|
| 506 |
Clear all loaded event data files and light curves from memory.
|
|
|
|
| 509 |
event: The event object triggering the function.
|
| 510 |
output_box_container (OutputBox): The container for output messages.
|
| 511 |
warning_box_container (WarningBox): The container for warning messages.
|
| 512 |
+
|
| 513 |
+
Side effects:
|
| 514 |
+
- Clears the global `loaded_event_data` and `loaded_light_curve` lists.
|
| 515 |
+
- Updates the output and warning containers with messages.
|
| 516 |
+
|
| 517 |
+
Exceptions:
|
| 518 |
+
- None.
|
| 519 |
+
|
| 520 |
+
Restrictions:
|
| 521 |
+
- None.
|
| 522 |
+
|
| 523 |
+
Example:
|
| 524 |
+
>>> clear_loaded_files(event, output_box_container, warning_box_container)
|
| 525 |
+
"Loaded event files have been cleared."
|
| 526 |
"""
|
| 527 |
global loaded_event_data, loaded_light_curve
|
| 528 |
event_data_cleared = False
|
|
|
|
| 552 |
warning_box_container[:] = [create_loadingdata_warning_box("No warnings.")]
|
| 553 |
|
| 554 |
|
|
|
|
| 555 |
def create_event_list(
|
| 556 |
event,
|
| 557 |
times_input,
|
|
|
|
| 578 |
output_box_container (OutputBox): The container for output messages.
|
| 579 |
warning_box_container (WarningBox): The container for warning messages.
|
| 580 |
warning_handler (WarningHandler): The handler for warnings.
|
| 581 |
+
|
| 582 |
+
Side effects:
|
| 583 |
+
- Creates a new EventList object and adds it to `loaded_event_data`.
|
| 584 |
+
- Updates the output and warning containers with messages.
|
| 585 |
+
|
| 586 |
+
Exceptions:
|
| 587 |
+
- Displays exceptions in the warning box if event list creation fails.
|
| 588 |
+
|
| 589 |
+
Restrictions:
|
| 590 |
+
- Requires photon arrival times and MJDREF to be provided.
|
| 591 |
+
|
| 592 |
+
Example:
|
| 593 |
+
>>> create_event_list(event, times_input, energy_input, pi_input, gti_input, mjdref_input, name_input, ...)
|
| 594 |
+
"Event List created successfully!"
|
| 595 |
"""
|
| 596 |
# Clear previous warnings
|
| 597 |
warning_handler.warnings.clear()
|
|
|
|
| 683 |
output_box_container (OutputBox): The container for output messages.
|
| 684 |
warning_box_container (WarningBox): The container for warning messages.
|
| 685 |
warning_handler (WarningHandler): The handler for warnings.
|
| 686 |
+
|
| 687 |
+
Side effects:
|
| 688 |
+
- Creates a simulated EventList object and adds it to `loaded_event_data`.
|
| 689 |
+
- Updates the output and warning containers with messages.
|
| 690 |
+
|
| 691 |
+
Exceptions:
|
| 692 |
+
- Displays exceptions in the warning box if simulation fails.
|
| 693 |
+
|
| 694 |
+
Restrictions:
|
| 695 |
+
- Requires a unique name for the simulated event list.
|
| 696 |
+
|
| 697 |
+
Example:
|
| 698 |
+
>>> simulate_event_list(event, time_slider, count_slider, dt_input, name_input, method_selector, ...)
|
| 699 |
+
"Event List simulated successfully!"
|
| 700 |
"""
|
| 701 |
# Clear previous warnings
|
| 702 |
warning_handler.warnings.clear()
|
|
|
|
| 762 |
warning_handler (WarningHandler): The handler for warnings.
|
| 763 |
|
| 764 |
Returns:
|
| 765 |
+
Column: A Panel Column containing the widgets and layout for the loading tab.
|
| 766 |
+
|
| 767 |
+
Example:
|
| 768 |
+
>>> tab = create_loading_tab(output_box_container, warning_box_container, warning_handler)
|
| 769 |
+
>>> isinstance(tab, pn.Column)
|
| 770 |
+
True
|
| 771 |
"""
|
| 772 |
file_selector = pn.widgets.FileSelector(
|
| 773 |
os.getcwd(), only_files=True, name="Select File", show_hidden=True
|
|
|
|
| 913 |
warning_handler (WarningHandler): The handler for warnings.
|
| 914 |
|
| 915 |
Returns:
|
| 916 |
+
Column: A Panel Column containing the widgets and layout for the event list creation tab.
|
| 917 |
+
|
| 918 |
+
Example:
|
| 919 |
+
>>> tab = create_event_list_tab(output_box_container, warning_box_container, warning_handler)
|
| 920 |
+
>>> isinstance(tab, pn.Column)
|
| 921 |
+
True
|
| 922 |
"""
|
| 923 |
times_input = pn.widgets.TextInput(
|
| 924 |
name="Photon Arrival Times", placeholder="e.g., 0.5, 1.1, 2.2, 3.7"
|
|
|
|
| 985 |
warning_handler (WarningHandler): The handler for warnings.
|
| 986 |
|
| 987 |
Returns:
|
| 988 |
+
Column: A Panel Column containing the widgets and layout for the event list simulation tab.
|
| 989 |
+
|
| 990 |
+
Example:
|
| 991 |
+
>>> tab = create_simulate_event_list_tab(output_box_container, warning_box_container, warning_handler)
|
| 992 |
+
>>> isinstance(tab, pn.Column)
|
| 993 |
+
True
|
| 994 |
"""
|
| 995 |
simulation_title = pn.pane.Markdown("# Simulating Event Lists")
|
| 996 |
time_slider = pn.widgets.IntSlider(
|
|
|
|
| 1059 |
Create the main area for the data loading tab, including all sub-tabs.
|
| 1060 |
|
| 1061 |
Args:
|
| 1062 |
+
header_container: The container for the header.
|
| 1063 |
+
main_area_container: The container for the main content area.
|
| 1064 |
+
output_box_container (OutputBox): The container for output messages.
|
| 1065 |
+
warning_box_container (WarningBox): The container for warning messages.
|
| 1066 |
+
plots_container: The container for plots.
|
| 1067 |
+
help_box_container: The container for the help section.
|
| 1068 |
+
footer_container: The container for the footer.
|
| 1069 |
|
| 1070 |
Returns:
|
| 1071 |
MainArea: An instance of MainArea with all the necessary tabs for data loading.
|
| 1072 |
+
|
| 1073 |
+
Example:
|
| 1074 |
+
>>> main_area = create_loadingdata_main_area(header_container, main_area_container, ...)
|
| 1075 |
+
>>> isinstance(main_area, MainArea)
|
| 1076 |
+
True
|
| 1077 |
"""
|
| 1078 |
warning_handler = create_warning_handler()
|
| 1079 |
tabs_content = {
|
|
|
|
| 1102 |
|
| 1103 |
Returns:
|
| 1104 |
HelpBox: An instance of HelpBox with the help content.
|
| 1105 |
+
|
| 1106 |
+
Example:
|
| 1107 |
+
>>> help_area = create_loadingdata_help_area()
|
| 1108 |
+
>>> isinstance(help_area, HelpBox)
|
| 1109 |
+
True
|
| 1110 |
"""
|
| 1111 |
help_content = LOADING_DATA_HELP_BOX_STRING
|
| 1112 |
return HelpBox(help_content=help_content, title="Help Section")
|
|
|
|
| 1118 |
|
| 1119 |
Returns:
|
| 1120 |
PlotsContainer: An instance of PlotsContainer with the plots for the data loading tab.
|
| 1121 |
+
|
| 1122 |
+
Example:
|
| 1123 |
+
>>> plots_area = create_loadingdata_plots_area()
|
| 1124 |
+
>>> isinstance(plots_area, PlotsContainer)
|
| 1125 |
+
True
|
| 1126 |
"""
|
| 1127 |
return PlotsContainer()
|