kartikmandar commited on
Commit
2725f44
·
1 Parent(s): edbaaaf

format help string in data ingestion

Browse files
modules/DataLoading/DataIngestion.py CHANGED
@@ -6,6 +6,7 @@ from stingray import Lightcurve
6
  import warnings
7
  import os
8
  import stat
 
9
  from bokeh.models import Tooltip
10
  from utils.globals import loaded_event_data
11
  from utils.DashboardClasses import (
@@ -18,7 +19,7 @@ from utils.DashboardClasses import (
18
  Footer,
19
  )
20
  import param
21
-
22
 
23
  # Path to the topmost directory for loaded-data
24
  loaded_data_path = os.path.join(os.getcwd(), "files", "loaded-data")
@@ -26,6 +27,7 @@ loaded_data_path = os.path.join(os.getcwd(), "files", "loaded-data")
26
  # Create the loaded-data directory if it doesn't exist
27
  os.makedirs(loaded_data_path, exist_ok=True)
28
 
 
29
  # Custom warning handler
30
  class WarningHandler:
31
  def __init__(self):
@@ -74,7 +76,11 @@ def load_event_data(
74
  warning_handler,
75
  ):
76
  if not file_selector.value:
77
- output_box_container[:] = [create_loadingdata_output_box("No file selected. Please select a file to upload.")]
 
 
 
 
78
  return
79
 
80
  file_paths = file_selector.value
@@ -100,14 +106,22 @@ def load_event_data(
100
  ]
101
  )
102
  if len(formats) < len(file_paths):
103
- output_box_container[:] = [create_loadingdata_output_box("Please specify formats for all files or check the default format option.")]
 
 
 
 
104
  return
105
 
106
  try:
107
  loaded_files = []
108
  for file_path, file_name, file_format in zip(file_paths, filenames, formats):
109
  if any(file_name == event[0] for event in loaded_event_data):
110
- output_box_container[:] = [create_loadingdata_output_box(f"A file with the name '{file_name}' already exists in memory. Please provide a different name.")]
 
 
 
 
111
  return
112
 
113
  event_list = EventList.read(file_path, file_format)
@@ -115,13 +129,19 @@ def load_event_data(
115
  loaded_files.append(
116
  f"File '{file_path}' loaded successfully as '{file_name}' with format '{file_format}'."
117
  )
118
- output_box_container[:] = [create_loadingdata_output_box("\n".join(loaded_files))]
 
 
119
  if warning_handler.warnings:
120
- warning_box_container[:] = [create_loadingdata_warning_box("\n".join(warning_handler.warnings))]
 
 
121
  else:
122
  warning_box_container[:] = [create_loadingdata_warning_box("No warnings.")]
123
  except Exception as e:
124
- output_box_container[:] = [create_loadingdata_output_box(f"An error occurred: {e}")]
 
 
125
 
126
  # Clear the warnings after displaying them
127
  warning_handler.warnings.clear()
@@ -137,7 +157,9 @@ def save_loaded_files(
137
  warning_handler,
138
  ):
139
  if not loaded_event_data:
140
- output_box_container[:] = [create_loadingdata_output_box("No files loaded to save.")]
 
 
141
  return
142
 
143
  filenames = (
@@ -155,13 +177,23 @@ def save_loaded_files(
155
  formats = ["hdf5" for _ in range(len(loaded_event_data))]
156
 
157
  if len(filenames) < len(loaded_event_data):
158
- output_box_container[:] = [create_loadingdata_output_box("Please specify names for all loaded files.")]
 
 
159
  return
160
  if len(filenames) != len(loaded_event_data):
161
- output_box_container[:] = [create_loadingdata_output_box("Please ensure that the number of names matches the number of loaded files.")]
 
 
 
 
162
  return
163
  if len(formats) < len(loaded_event_data):
164
- output_box_container[:] = [create_loadingdata_output_box("Please specify formats for all loaded files or check the default format option.")]
 
 
 
 
165
  return
166
 
167
  saved_files = []
@@ -172,7 +204,11 @@ def save_loaded_files(
172
  if os.path.exists(
173
  os.path.join(loaded_data_path, f"{file_name}.{file_format}")
174
  ):
175
- output_box_container[:] = [create_loadingdata_output_box(f"A file with the name '{file_name}' already exists. Please provide a different name.")]
 
 
 
 
176
  return
177
 
178
  save_path = os.path.join(loaded_data_path, f"{file_name}.{file_format}")
@@ -187,13 +223,19 @@ def save_loaded_files(
187
  f"File '{file_name}' saved successfully to '{save_path}'."
188
  )
189
 
190
- output_box_container[:] = [create_loadingdata_output_box("\n".join(saved_files))]
 
 
191
  if warning_handler.warnings:
192
- warning_box_container[:] = [create_loadingdata_warning_box("\n".join(warning_handler.warnings))]
 
 
193
  else:
194
- warning_box_container[:] = [create_loadingtab_warning_box("No warnings.")]
195
  except Exception as e:
196
- warning_box_container[:] = [create_loadingdata_warning_box(f"An error occurred while saving files: {e}")]
 
 
197
 
198
  # Clear the warnings after displaying them
199
  warning_handler.warnings.clear()
@@ -207,7 +249,11 @@ def delete_selected_files(
207
  warning_handler,
208
  ):
209
  if not file_selector.value:
210
- output_box_container[:] = [create_loadingdata_output_box("No file selected. Please select a file to delete.")]
 
 
 
 
211
  return
212
 
213
  file_paths = file_selector.value
@@ -228,7 +274,9 @@ def delete_selected_files(
228
  deleted_files.append(f"An error occurred while deleting '{file_path}': {e}")
229
  output_box_container[:] = [create_loadingdata_output_box("\n".join(deleted_files))]
230
  if warning_handler.warnings:
231
- warning_box_container[:] = [create_loadingdata_warning_box("\n".join(warning_handler.warnings))]
 
 
232
  else:
233
  warning_box_container[:] = [create_loadingdata_warning_box("No warnings.")]
234
 
@@ -243,7 +291,9 @@ def preview_loaded_files(
243
  time_limit=10,
244
  ):
245
  if not loaded_event_data:
246
- output_box_container[:] = [create_loadingdata_output_box("No files loaded to preview.")]
 
 
247
  return
248
 
249
  preview_data = []
@@ -257,12 +307,159 @@ def preview_loaded_files(
257
  warning_handler.warn(str(e), category=RuntimeWarning)
258
 
259
  if preview_data:
260
- output_box_container[:] = [create_loadingdata_output_box("\n\n".join(preview_data))]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
261
  else:
262
- output_box_container[:] = [create_loadingdata_output_box("No valid files loaded for preview.")]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
263
 
264
  if warning_handler.warnings:
265
- warning_box_container[:] = [create_loadingdata_warning_box("\n".join(warning_handler.warnings))]
 
 
266
  else:
267
  warning_box_container[:] = [create_loadingdata_warning_box("No warnings.")]
268
 
@@ -393,13 +590,128 @@ def create_loading_tab(output_box_container, warning_box_container, warning_hand
393
  return tab_content
394
 
395
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
396
  def create_loadingdata_main_area(output_box, warning_box):
397
  warning_handler = create_warning_handler()
398
  tabs_content = {
399
- "Loading": create_loading_tab(
400
  output_box_container=output_box,
401
  warning_box_container=warning_box,
402
  warning_handler=warning_handler,
403
- )
 
 
 
 
 
 
 
 
 
 
404
  }
405
  return MainArea(tabs_content=tabs_content)
 
 
 
 
 
 
 
6
  import warnings
7
  import os
8
  import stat
9
+ import numpy as np
10
  from bokeh.models import Tooltip
11
  from utils.globals import loaded_event_data
12
  from utils.DashboardClasses import (
 
19
  Footer,
20
  )
21
  import param
22
+ from utils.strings import LOADING_DATA_HELP_BOX_STRING
23
 
24
  # Path to the topmost directory for loaded-data
25
  loaded_data_path = os.path.join(os.getcwd(), "files", "loaded-data")
 
27
  # Create the loaded-data directory if it doesn't exist
28
  os.makedirs(loaded_data_path, exist_ok=True)
29
 
30
+
31
  # Custom warning handler
32
  class WarningHandler:
33
  def __init__(self):
 
76
  warning_handler,
77
  ):
78
  if not file_selector.value:
79
+ output_box_container[:] = [
80
+ create_loadingdata_output_box(
81
+ "No file selected. Please select a file to upload."
82
+ )
83
+ ]
84
  return
85
 
86
  file_paths = file_selector.value
 
106
  ]
107
  )
108
  if len(formats) < len(file_paths):
109
+ output_box_container[:] = [
110
+ create_loadingdata_output_box(
111
+ "Please specify formats for all files or check the default format option."
112
+ )
113
+ ]
114
  return
115
 
116
  try:
117
  loaded_files = []
118
  for file_path, file_name, file_format in zip(file_paths, filenames, formats):
119
  if any(file_name == event[0] for event in loaded_event_data):
120
+ output_box_container[:] = [
121
+ create_loadingdata_output_box(
122
+ f"A file with the name '{file_name}' already exists in memory. Please provide a different name."
123
+ )
124
+ ]
125
  return
126
 
127
  event_list = EventList.read(file_path, file_format)
 
129
  loaded_files.append(
130
  f"File '{file_path}' loaded successfully as '{file_name}' with format '{file_format}'."
131
  )
132
+ output_box_container[:] = [
133
+ create_loadingdata_output_box("\n".join(loaded_files))
134
+ ]
135
  if warning_handler.warnings:
136
+ warning_box_container[:] = [
137
+ create_loadingdata_warning_box("\n".join(warning_handler.warnings))
138
+ ]
139
  else:
140
  warning_box_container[:] = [create_loadingdata_warning_box("No warnings.")]
141
  except Exception as e:
142
+ output_box_container[:] = [
143
+ create_loadingdata_output_box(f"An error occurred: {e}")
144
+ ]
145
 
146
  # Clear the warnings after displaying them
147
  warning_handler.warnings.clear()
 
157
  warning_handler,
158
  ):
159
  if not loaded_event_data:
160
+ output_box_container[:] = [
161
+ create_loadingdata_output_box("No files loaded to save.")
162
+ ]
163
  return
164
 
165
  filenames = (
 
177
  formats = ["hdf5" for _ in range(len(loaded_event_data))]
178
 
179
  if len(filenames) < len(loaded_event_data):
180
+ output_box_container[:] = [
181
+ create_loadingdata_output_box("Please specify names for all loaded files.")
182
+ ]
183
  return
184
  if len(filenames) != len(loaded_event_data):
185
+ output_box_container[:] = [
186
+ create_loadingdata_output_box(
187
+ "Please ensure that the number of names matches the number of loaded files."
188
+ )
189
+ ]
190
  return
191
  if len(formats) < len(loaded_event_data):
192
+ output_box_container[:] = [
193
+ create_loadingdata_output_box(
194
+ "Please specify formats for all loaded files or check the default format option."
195
+ )
196
+ ]
197
  return
198
 
199
  saved_files = []
 
204
  if os.path.exists(
205
  os.path.join(loaded_data_path, f"{file_name}.{file_format}")
206
  ):
207
+ output_box_container[:] = [
208
+ create_loadingdata_output_box(
209
+ f"A file with the name '{file_name}' already exists. Please provide a different name."
210
+ )
211
+ ]
212
  return
213
 
214
  save_path = os.path.join(loaded_data_path, f"{file_name}.{file_format}")
 
223
  f"File '{file_name}' saved successfully to '{save_path}'."
224
  )
225
 
226
+ output_box_container[:] = [
227
+ create_loadingdata_output_box("\n".join(saved_files))
228
+ ]
229
  if warning_handler.warnings:
230
+ warning_box_container[:] = [
231
+ create_loadingdata_warning_box("\n".join(warning_handler.warnings))
232
+ ]
233
  else:
234
+ warning_box_container[:] = [create_loadingdata_warning_box("No warnings.")]
235
  except Exception as e:
236
+ warning_box_container[:] = [
237
+ create_loadingdata_warning_box(f"An error occurred while saving files: {e}")
238
+ ]
239
 
240
  # Clear the warnings after displaying them
241
  warning_handler.warnings.clear()
 
249
  warning_handler,
250
  ):
251
  if not file_selector.value:
252
+ output_box_container[:] = [
253
+ create_loadingdata_output_box(
254
+ "No file selected. Please select a file to delete."
255
+ )
256
+ ]
257
  return
258
 
259
  file_paths = file_selector.value
 
274
  deleted_files.append(f"An error occurred while deleting '{file_path}': {e}")
275
  output_box_container[:] = [create_loadingdata_output_box("\n".join(deleted_files))]
276
  if warning_handler.warnings:
277
+ warning_box_container[:] = [
278
+ create_loadingdata_warning_box("\n".join(warning_handler.warnings))
279
+ ]
280
  else:
281
  warning_box_container[:] = [create_loadingdata_warning_box("No warnings.")]
282
 
 
291
  time_limit=10,
292
  ):
293
  if not loaded_event_data:
294
+ output_box_container[:] = [
295
+ create_loadingdata_output_box("No files loaded to preview.")
296
+ ]
297
  return
298
 
299
  preview_data = []
 
307
  warning_handler.warn(str(e), category=RuntimeWarning)
308
 
309
  if preview_data:
310
+ output_box_container[:] = [
311
+ create_loadingdata_output_box("\n\n".join(preview_data))
312
+ ]
313
+ else:
314
+ output_box_container[:] = [
315
+ create_loadingdata_output_box("No valid files loaded for preview.")
316
+ ]
317
+
318
+ if warning_handler.warnings:
319
+ warning_box_container[:] = [
320
+ create_loadingdata_warning_box("\n".join(warning_handler.warnings))
321
+ ]
322
+ else:
323
+ warning_box_container[:] = [create_loadingdata_warning_box("No warnings.")]
324
+
325
+ warning_handler.warnings.clear()
326
+
327
+
328
+ def create_event_list(
329
+ event,
330
+ times_input,
331
+ energy_input,
332
+ gti_input,
333
+ mjdref_input,
334
+ name_input,
335
+ output_box_container,
336
+ warning_box_container,
337
+ warning_handler,
338
+ ):
339
+ # Clear previous warnings
340
+ warning_handler.warnings.clear()
341
+ warnings.resetwarnings()
342
+
343
+ try:
344
+ if not times_input.value or not mjdref_input.value:
345
+ output_box_container[:] = [
346
+ create_loadingdata_output_box(
347
+ "Please enter Photon Arrival Times and MJDREF."
348
+ )
349
+ ]
350
+ return
351
+
352
+ times = [float(t) for t in times_input.value.split(",")]
353
+ mjdref = float(mjdref_input.value)
354
+ energy = (
355
+ [float(e) for e in energy_input.value.split(",")]
356
+ if energy_input.value
357
+ else None
358
+ )
359
+ gti = (
360
+ [
361
+ [float(g) for g in interval.split()]
362
+ for interval in gti_input.value.split(";")
363
+ ]
364
+ if gti_input.value
365
+ else None
366
+ )
367
+
368
+ if name_input.value:
369
+ name = name_input.value
370
+ if any(name == event[0] for event in loaded_event_data):
371
+ output_box_container[:] = [
372
+ create_loadingdata_output_box(
373
+ f"A file with the name '{name}' already exists in memory. Please provide a different name."
374
+ )
375
+ ]
376
+ return
377
+ else:
378
+ name = f"event_list_{len(loaded_event_data)}"
379
+
380
+ event_list = EventList(times, energy=energy, gti=gti, mjdref=mjdref)
381
+
382
+ loaded_event_data.append((name, event_list))
383
+
384
+ output_box_container[:] = [
385
+ create_loadingdata_output_box(
386
+ f"Event List created successfully!\nSaved as: {name}\nTimes: {event_list.time}\nMJDREF: {event_list.mjdref}\nGTI: {event_list.gti}\nEnergy: {event_list.energy if energy else 'Not provided'}"
387
+ )
388
+ ]
389
+ except ValueError as ve:
390
+ warning_handler.warn(str(ve), category=ValueError)
391
+ except Exception as e:
392
+ warning_handler.warn(str(e), category=RuntimeError)
393
+
394
+ if warning_handler.warnings:
395
+ warning_box_container[:] = [
396
+ create_loadingdata_warning_box("\n".join(warning_handler.warnings))
397
+ ]
398
  else:
399
+ warning_box_container[:] = [create_loadingdata_warning_box("No warnings.")]
400
+
401
+ warning_handler.warnings.clear()
402
+
403
+
404
+ def simulate_event_list(
405
+ event,
406
+ time_slider,
407
+ count_slider,
408
+ dt_input,
409
+ name_input,
410
+ method_selector,
411
+ output_box_container,
412
+ warning_box_container,
413
+ warning_handler,
414
+ ):
415
+ # Clear previous warnings
416
+ warning_handler.warnings.clear()
417
+ warnings.resetwarnings()
418
+
419
+ try:
420
+ if not name_input.value:
421
+ output_box_container[:] = [
422
+ create_loadingdata_output_box(
423
+ "Please provide a name for the simulated event list."
424
+ )
425
+ ]
426
+ return
427
+
428
+ if any(name_input.value == event[0] for event in loaded_event_data):
429
+ output_box_container[:] = [
430
+ create_loadingdata_output_box(
431
+ f"A file with the name '{name_input.value}' already exists in memory. Please provide a different name."
432
+ )
433
+ ]
434
+ return
435
+
436
+ times = np.arange(time_slider.value)
437
+ counts = np.floor(np.random.rand(time_slider.value) * count_slider.value)
438
+ dt = dt_input.value
439
+ lc = Lightcurve(times, counts, dt=dt, skip_checks=True)
440
+
441
+ if method_selector.value == "Standard Method":
442
+ event_list = EventList.from_lc(lc)
443
+ else:
444
+ event_list = EventList()
445
+ event_list.simulate_times(lc)
446
+
447
+ name = name_input.value
448
+ loaded_event_data.append((name, event_list))
449
+
450
+ output_box_container[:] = [
451
+ create_loadingdata_output_box(
452
+ f"Event List simulated successfully!\nSaved as: {name}\nTimes: {event_list.time}\nCounts: {counts}"
453
+ )
454
+ ]
455
+
456
+ except Exception as e:
457
+ warning_handler.warn(str(e), category=RuntimeError)
458
 
459
  if warning_handler.warnings:
460
+ warning_box_container[:] = [
461
+ create_loadingdata_warning_box("\n".join(warning_handler.warnings))
462
+ ]
463
  else:
464
  warning_box_container[:] = [create_loadingdata_warning_box("No warnings.")]
465
 
 
590
  return tab_content
591
 
592
 
593
+ def create_event_list_tab(output_box_container, warning_box_container, warning_handler):
594
+ output = pn.widgets.TextAreaInput(
595
+ name="Output", value="", disabled=True, height=200
596
+ )
597
+ warning_output = pn.widgets.TextAreaInput(
598
+ name="Warnings", value="", disabled=True, height=200
599
+ )
600
+
601
+ times_input = pn.widgets.TextInput(
602
+ name="Photon Arrival Times", placeholder="e.g., 0.5, 1.1, 2.2, 3.7"
603
+ )
604
+ mjdref_input = pn.widgets.TextInput(name="MJDREF", placeholder="e.g., 58000.")
605
+ energy_input = pn.widgets.TextInput(
606
+ name="Energy (optional)", placeholder="e.g., 0., 3., 4., 20."
607
+ )
608
+ gti_input = pn.widgets.TextInput(
609
+ name="GTIs (optional)", placeholder="e.g., 0 4; 5 10"
610
+ )
611
+ name_input = pn.widgets.TextInput(
612
+ name="Event List Name", placeholder="e.g., my_event_list"
613
+ )
614
+ create_button = pn.widgets.Button(name="Create Event List", button_type="primary")
615
+
616
+ create_button.on_click(
617
+ lambda event: create_event_list(
618
+ event,
619
+ times_input,
620
+ energy_input,
621
+ gti_input,
622
+ mjdref_input,
623
+ name_input,
624
+ output_box_container,
625
+ warning_box_container,
626
+ warning_handler,
627
+ )
628
+ )
629
+
630
+ tab_content = pn.Column(
631
+ pn.pane.Markdown("# Create Event List"),
632
+ times_input,
633
+ mjdref_input,
634
+ energy_input,
635
+ gti_input,
636
+ name_input,
637
+ create_button,
638
+ )
639
+ return tab_content
640
+
641
+
642
+ def create_simulate_event_list_tab(
643
+ output_box_container, warning_box_container, warning_handler
644
+ ):
645
+
646
+ simulation_title = pn.pane.Markdown("# Simulating Event Lists")
647
+ time_slider = pn.widgets.IntSlider(
648
+ name="Number of Time Bins", start=1, end=10000, value=10
649
+ )
650
+ count_slider = pn.widgets.IntSlider(
651
+ name="Max Counts per Bin", start=1, end=10000, value=5
652
+ )
653
+ dt_input = pn.widgets.FloatSlider(
654
+ name="Delta Time (dt)", start=0.0001, end=10000.0, step=0.001, value=1.0
655
+ )
656
+ method_selector = pn.widgets.Select(
657
+ name="Method", options=["Standard Method", "Inverse CDF Method"]
658
+ )
659
+ sim_name_input = pn.widgets.TextInput(
660
+ name="Simulated Event List Name", placeholder="e.g., my_sim_event_list"
661
+ )
662
+ simulate_button = pn.widgets.Button(
663
+ name="Simulate Event List", button_type="primary"
664
+ )
665
+
666
+ simulate_button.on_click(
667
+ lambda event: simulate_event_list(
668
+ event,
669
+ time_slider,
670
+ count_slider,
671
+ dt_input,
672
+ sim_name_input,
673
+ method_selector,
674
+ output_box_container,
675
+ warning_box_container,
676
+ warning_handler,
677
+ )
678
+ )
679
+
680
+ tab_content = pn.Column(
681
+ simulation_title,
682
+ time_slider,
683
+ count_slider,
684
+ dt_input,
685
+ method_selector,
686
+ sim_name_input,
687
+ simulate_button,
688
+ )
689
+ return tab_content
690
+
691
+
692
  def create_loadingdata_main_area(output_box, warning_box):
693
  warning_handler = create_warning_handler()
694
  tabs_content = {
695
+ "Load Event List": create_loading_tab(
696
  output_box_container=output_box,
697
  warning_box_container=warning_box,
698
  warning_handler=warning_handler,
699
+ ),
700
+ "Create Event List": create_event_list_tab(
701
+ output_box_container=output_box,
702
+ warning_box_container=warning_box,
703
+ warning_handler=warning_handler,
704
+ ),
705
+ "Simulate Event List": create_simulate_event_list_tab(
706
+ output_box_container=output_box,
707
+ warning_box_container=warning_box,
708
+ warning_handler=warning_handler,
709
+ ),
710
  }
711
  return MainArea(tabs_content=tabs_content)
712
+
713
+
714
+ def create_loadingdata_help_area():
715
+ help_content = LOADING_DATA_HELP_BOX_STRING
716
+ return HelpBox(help_content=help_content, title="Help Section")
717
+
modules/Home/HomeContent.py CHANGED
@@ -10,14 +10,14 @@ from utils.DashboardClasses import (
10
  )
11
  from utils.strings import (
12
  HOME_HEADER_STRING,
13
- WELCOME_MESSAGE_STRING,
14
- FOOTER_STRING,
15
- STINGRAY_TAB_STRING,
16
- HOLOVIZ_TAB_STRING,
17
- DASHBOARD_TAB_STRING,
18
- OUTPUT_BOX_STRING,
19
- WARNING_BOX_STRING,
20
- HELP_BOX_STRING,
21
  )
22
 
23
  """ Header Section """
@@ -33,9 +33,9 @@ def create_home_header():
33
 
34
  """ Main Area Section """
35
  def create_home_main_area():
36
- tab1_content = pn.pane.Markdown(STINGRAY_TAB_STRING)
37
- tab2_content = pn.pane.Markdown(HOLOVIZ_TAB_STRING)
38
- tab3_content = pn.pane.Markdown(DASHBOARD_TAB_STRING)
39
 
40
  tabs_content = {
41
  "What's Stingray?": tab1_content,
@@ -47,11 +47,11 @@ def create_home_main_area():
47
 
48
  """ Output Box Section """
49
  def create_home_output_box():
50
- return OutputBox(output_content=OUTPUT_BOX_STRING)
51
 
52
  """ Warning Box Section """
53
  def create_home_warning_box():
54
- return WarningBox(warning_content=WARNING_BOX_STRING)
55
 
56
  """ Plots Area Section """
57
  def create_home_plots_area():
@@ -69,7 +69,7 @@ def create_home_plots_area():
69
 
70
  """ Help Area Section """
71
  def create_home_help_area():
72
- help_content = HELP_BOX_STRING
73
  return HelpBox(help_content=help_content, title="Help Section")
74
 
75
  """ Footer Section """
 
10
  )
11
  from utils.strings import (
12
  HOME_HEADER_STRING,
13
+ HOME_WELCOME_MESSAGE_STRING,
14
+ HOME_FOOTER_STRING,
15
+ HOME_STINGRAY_TAB_STRING,
16
+ HOME_HOLOVIZ_TAB_STRING,
17
+ HOME_DASHBOARD_TAB_STRING,
18
+ HOME_OUTPUT_BOX_STRING,
19
+ HOME_WARNING_BOX_STRING,
20
+ HOME_HELP_BOX_STRING,
21
  )
22
 
23
  """ Header Section """
 
33
 
34
  """ Main Area Section """
35
  def create_home_main_area():
36
+ tab1_content = pn.pane.Markdown(HOME_STINGRAY_TAB_STRING)
37
+ tab2_content = pn.pane.Markdown(HOME_HOLOVIZ_TAB_STRING)
38
+ tab3_content = pn.pane.Markdown(HOME_DASHBOARD_TAB_STRING)
39
 
40
  tabs_content = {
41
  "What's Stingray?": tab1_content,
 
47
 
48
  """ Output Box Section """
49
  def create_home_output_box():
50
+ return OutputBox(output_content=HOME_OUTPUT_BOX_STRING)
51
 
52
  """ Warning Box Section """
53
  def create_home_warning_box():
54
+ return WarningBox(warning_content=HOME_WARNING_BOX_STRING)
55
 
56
  """ Plots Area Section """
57
  def create_home_plots_area():
 
69
 
70
  """ Help Area Section """
71
  def create_home_help_area():
72
+ help_content = HOME_HELP_BOX_STRING
73
  return HelpBox(help_content=help_content, title="Help Section")
74
 
75
  """ Footer Section """
utils/sidebar.py CHANGED
@@ -15,6 +15,7 @@ from modules.DataLoading.DataIngestion import (
15
  create_loadingdata_main_area,
16
  create_loadingdata_output_box,
17
  create_loadingdata_warning_box,
 
18
  )
19
  from modules.QuickLook.LightCurve import create_quicklook_lightcurve_header
20
  from assets.icons.svg import HOME_ICON_SVG, LOAD_DATA_ICON_SVG
@@ -71,6 +72,7 @@ def create_sidebar(main_area, header, footer, output_box, warning_box, help_box)
71
  main_area[:] = [create_loadingdata_main_area(output_box, warning_box)]
72
  output_box[:] = [create_home_output_box()]
73
  warning_box[:] = [create_home_warning_box()]
 
74
 
75
  load_data_button.on_click(load_data)
76
 
 
15
  create_loadingdata_main_area,
16
  create_loadingdata_output_box,
17
  create_loadingdata_warning_box,
18
+ create_loadingdata_help_area,
19
  )
20
  from modules.QuickLook.LightCurve import create_quicklook_lightcurve_header
21
  from assets.icons.svg import HOME_ICON_SVG, LOAD_DATA_ICON_SVG
 
72
  main_area[:] = [create_loadingdata_main_area(output_box, warning_box)]
73
  output_box[:] = [create_home_output_box()]
74
  warning_box[:] = [create_home_warning_box()]
75
+ help_box[:] = [create_loadingdata_help_area()]
76
 
77
  load_data_button.on_click(load_data)
78
 
utils/strings.py CHANGED
@@ -4,7 +4,7 @@ HOME_HEADER_STRING = """
4
  <h1>Welcome to the Stingray Explorer Dashboard</h1>
5
  """
6
 
7
- WELCOME_MESSAGE_STRING = """
8
  <div>
9
  <p>This dashboard is designed to provide a comprehensive toolset for X-ray astronomy data analysis. Here are the main features:</p>
10
  <ul>
@@ -63,7 +63,7 @@ WELCOME_MESSAGE_STRING = """
63
  </div>
64
  """
65
 
66
- FOOTER_STRING = """
67
  <div>
68
  <p>Stingray Explorer Dashboard</p>
69
  <p>&copy; 2021 Kartik Mandar</p>
@@ -73,7 +73,7 @@ FOOTER_STRING = """
73
 
74
  # Tabs in Main Area of Home Page
75
 
76
- STINGRAY_TAB_STRING = """
77
  <h2> Stingray: Next-Generation Spectral Timing </h2>
78
 
79
  ![Stingray-logo](../assets/images/stingray_logo_minimised.png)
@@ -130,7 +130,7 @@ Windows uses an internal 32-bit representation for int. This might create numeri
130
  <br></br>
131
  """
132
 
133
- HOLOVIZ_TAB_STRING = """
134
  <h2> High-level tools to simplify visualization in Python </h2>
135
 
136
  ![HoloViz-logo](../assets/images/holoviz_logo_minimised.png)
@@ -185,7 +185,7 @@ HoloViz tools provide extensive support for Jupyter notebooks, as well as for st
185
  <br/>
186
  """
187
 
188
- DASHBOARD_TAB_STRING = """
189
  <h2> Stingray Explorer </h2>
190
 
191
  ![Stingray-Explorer-logo](../assets/images/stingray_explorer_minimised.png)
@@ -195,18 +195,149 @@ This dashboard is designed to provide a comprehensive toolset for X-ray astronom
195
  <br/>
196
  """
197
 
198
- OUTPUT_BOX_STRING = """
199
  This is the output container. It will display the output of the analysis tools.
200
  It may contain what EventLists are made, what lightcurves are generated, what power spectra are calculated, etc. It can also be used to preview the loaded EventList.
201
  """
202
 
203
 
204
- WARNING_BOX_STRING = """
205
  This is the warning container. It will display any warnings or errors that occur during the analysis process.
206
  """
207
 
208
- HELP_BOX_STRING = """
209
  This is the helpbox container. It will display any help or documentation for the analysis tools.
210
  It will also have links to the documentation and tutorials for the tools.
211
  And have a brief description of the physics behind the analysis.
212
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  <h1>Welcome to the Stingray Explorer Dashboard</h1>
5
  """
6
 
7
+ HOME_WELCOME_MESSAGE_STRING = """
8
  <div>
9
  <p>This dashboard is designed to provide a comprehensive toolset for X-ray astronomy data analysis. Here are the main features:</p>
10
  <ul>
 
63
  </div>
64
  """
65
 
66
+ HOME_FOOTER_STRING = """
67
  <div>
68
  <p>Stingray Explorer Dashboard</p>
69
  <p>&copy; 2021 Kartik Mandar</p>
 
73
 
74
  # Tabs in Main Area of Home Page
75
 
76
+ HOME_STINGRAY_TAB_STRING = """
77
  <h2> Stingray: Next-Generation Spectral Timing </h2>
78
 
79
  ![Stingray-logo](../assets/images/stingray_logo_minimised.png)
 
130
  <br></br>
131
  """
132
 
133
+ HOME_HOLOVIZ_TAB_STRING = """
134
  <h2> High-level tools to simplify visualization in Python </h2>
135
 
136
  ![HoloViz-logo](../assets/images/holoviz_logo_minimised.png)
 
185
  <br/>
186
  """
187
 
188
+ HOME_DASHBOARD_TAB_STRING = """
189
  <h2> Stingray Explorer </h2>
190
 
191
  ![Stingray-Explorer-logo](../assets/images/stingray_explorer_minimised.png)
 
195
  <br/>
196
  """
197
 
198
+ HOME_OUTPUT_BOX_STRING = """
199
  This is the output container. It will display the output of the analysis tools.
200
  It may contain what EventLists are made, what lightcurves are generated, what power spectra are calculated, etc. It can also be used to preview the loaded EventList.
201
  """
202
 
203
 
204
+ HOME_WARNING_BOX_STRING = """
205
  This is the warning container. It will display any warnings or errors that occur during the analysis process.
206
  """
207
 
208
+ HOME_HELP_BOX_STRING = """
209
  This is the helpbox container. It will display any help or documentation for the analysis tools.
210
  It will also have links to the documentation and tutorials for the tools.
211
  And have a brief description of the physics behind the analysis.
212
  """
213
+
214
+
215
+ # This section contains strings used in the DataIngestion.py
216
+
217
+ LOADING_DATA_HELP_BOX_STRING = """
218
+ <h2> Loading Tab </h2>
219
+
220
+ ### Functionality
221
+ The "Loading" tab allows you to load, save, delete, and preview event data files. Here is a detailed explanation of each component and its functionality:
222
+
223
+ - **File Selector**: Select files to load into the event data list.
224
+ - **Enter File Names**: Specify custom names for the loaded files. If left blank, the names will be derived from the file paths.
225
+ - **Enter Formats**: Specify the formats of the files being loaded. If left blank, the default format is used.
226
+ - **Use default format**: Check this to use the default format ('ogip' for loading and 'hdf5' for saving).
227
+ - **Load Event Data**: Load the selected files into the event data list.
228
+ - **Save Loaded Data**: Save the loaded event data files to the specified directory.
229
+ - **Delete Selected Files**: Delete the selected files from the file system.
230
+ - **Preview Loaded Files**: Preview the contents of the loaded event data files.
231
+
232
+ ### Precautions
233
+ - Ensure the file contains at least a 'time' column when loading event data.
234
+ - When specifying custom names or formats, ensure that the number of names/formats matches the number of files selected.
235
+ - Deleting files with the ".py" extension is not allowed to prevent accidental deletion of script files.
236
+
237
+ ### Examples
238
+ #### Loading an Event List
239
+ ```python
240
+ from stingray import EventList
241
+ ev = EventList.read('events.fits', 'ogip')
242
+ print(ev.time)
243
+ ```
244
+
245
+ ### Saving an Event List
246
+ ```python
247
+ ev.write("events.hdf5", "hdf5")
248
+ ```
249
+
250
+ ## Creation Tab
251
+
252
+ ### Functionality
253
+
254
+ The "Creation" tab allows you to create new event lists or simulate event lists from light curves. Here is a detailed explanation of each component and its functionality:
255
+
256
+ - **Photon Arrival Times**: Enter photon arrival times in seconds from a reference MJD.
257
+ - **MJDREF**: Enter the MJD reference for the photon arrival times.
258
+ - **Energy (optional)**: Enter the energy values associated with the photons.
259
+ - **GTIs (optional)**: Enter the Good Time Intervals (GTIs) for the event list.
260
+ - **Event List Name**: Specify a name for the new event list.
261
+ - **Create Event List**: Create a new event list with the specified parameters.
262
+
263
+ ### Simulation of Event Lists
264
+
265
+ - **Number of Time Bins**: Specify the number of time bins for the simulation.
266
+ - **Max Counts per Bin**: Specify the maximum counts per bin.
267
+ - **Delta Time (dt)**: Specify the delta time for the light curve.
268
+ - **Method**: Choose between "Standard Method" and "Inverse CDF Method" for simulating event lists.
269
+ - **Simulated Event List Name**: Specify a name for the simulated event list.
270
+ - **Simulate Event List**: Simulate an event list using the specified parameters.
271
+
272
+ ### Precautions
273
+
274
+ - Ensure that photon arrival times and MJDREF are provided when creating an event list.
275
+ - When simulating event lists, ensure that the provided parameters (e.g., number of time bins, max counts per bin) are reasonable to avoid excessively large or small event lists.
276
+
277
+ ### Examples
278
+
279
+ #### Creating an Event List
280
+
281
+ ```python
282
+ from stingray import EventList
283
+ times = [0.5, 1.1, 2.2, 3.7]
284
+ mjdref = 58000.
285
+ energy = [0., 3., 4., 20.]
286
+ gti = [[0, 4]]
287
+ ev = EventList(times, gti=gti, energy=energy, mjdref=mjdref)
288
+ print(ev.time)
289
+ ```
290
+
291
+ #### Simulating an Event List from a Light Curve
292
+ ```python
293
+ from stingray import EventList, Lightcurve
294
+ times = np.arange(3)
295
+ counts = np.floor(np.random.rand(3) * 5)
296
+ lc = Lightcurve(times, counts, skip_checks=True, dt=1.)
297
+ ev = EventList.from_lc(lc)
298
+ print(ev.time)
299
+ ```
300
+
301
+ ## Stingray Documentation References
302
+
303
+ ### Creating EventList from Photon Arrival Times
304
+
305
+ ```python
306
+ from stingray import EventList
307
+ times = [0.5, 1.1, 2.2, 3.7]
308
+ mjdref = 58000.
309
+ ev = EventList(times, mjdref=mjdref)
310
+ print(ev.time)
311
+ ```
312
+
313
+ ### Transforming a Lightcurve into an EventList
314
+ ```python
315
+ from stingray import EventList, Lightcurve
316
+ times = np.arange(3)
317
+ counts = np.floor(np.random.rand(3) * 5)
318
+ lc = Lightcurve(times, counts, skip_checks=True, dt=1.)
319
+ ev = EventList.from_lc(lc)
320
+ print(ev.time)
321
+ ```
322
+
323
+ ### Simulating EventList from Lightcurve
324
+ ```python
325
+ from stingray import EventList, Lightcurve
326
+ times = np.arange(50)
327
+ counts = np.floor(np.random.rand(50) * 50000)
328
+ lc = Lightcurve(times, counts, skip_checks=True, dt=1.)
329
+ ev = EventList()
330
+ ev.simulate_times(lc)
331
+ print(ev.time)
332
+ ```
333
+
334
+ ### Loading and Writing EventList Objects
335
+ ```python
336
+ from stingray import EventList
337
+ ev = EventList.read('events.fits', 'ogip')
338
+ ev.write("events.hdf5", "hdf5")
339
+ ```
340
+
341
+ <br/>
342
+
343
+ """