kartikmandar commited on
Commit
85b4f7a
·
1 Parent(s): 5810784

layout fix for eventlist operations, add lightcurve property multiselect

Browse files
Files changed (1) hide show
  1. modules/QuickLook/EventList.py +135 -74
modules/QuickLook/EventList.py CHANGED
@@ -49,7 +49,6 @@ def create_warning_handler():
49
  return warning_handler
50
 
51
 
52
-
53
  """ Header Section """
54
 
55
 
@@ -83,7 +82,9 @@ def create_eventlist_header(
83
  >>> header.heading.value
84
  'Data Ingestion and creation'
85
  """
86
- home_heading_input = pn.widgets.TextInput(name="Heading", value="QuickLook EventList")
 
 
87
  return MainHeader(heading=home_heading_input)
88
 
89
 
@@ -266,9 +267,7 @@ def create_event_list(
266
  except ValueError as ve:
267
  warning_handler.warn(str(ve), category=ValueError)
268
  output_box_container[:] = [
269
- create_eventlist_output_box(
270
- "An error occurred: Please check your inputs."
271
- )
272
  ]
273
  except Exception as e:
274
  warning_handler.warn(str(e), category=RuntimeError)
@@ -623,6 +622,16 @@ def create_eventlist_operations_tab(
623
  event_list_properties_box = pn.pane.Markdown(
624
  "**Select an EventList to view its properties.**"
625
  )
 
 
 
 
 
 
 
 
 
 
626
 
627
  deadtime_input = pn.widgets.FloatInput(
628
  name="Deadtime", value=0.01, step=0.001, start=0.001, end=10000.0
@@ -754,6 +763,25 @@ def create_eventlist_operations_tab(
754
  )
755
 
756
  event_list_properties_box.object = "\n".join(properties)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
757
 
758
  # Callback: Apply Deadtime
759
  def apply_deadtime_callback(event):
@@ -788,9 +816,7 @@ def create_eventlist_operations_tab(
788
 
789
  # Update the output box with results
790
  if results:
791
- output_box_container[:] = [
792
- create_eventlist_output_box("\n".join(results))
793
- ]
794
  else:
795
  output_box_container[:] = [
796
  create_eventlist_output_box("No event lists processed.")
@@ -1279,9 +1305,7 @@ def create_eventlist_operations_tab(
1279
  )
1280
 
1281
  # Update output container with results
1282
- output_box_container[:] = [
1283
- create_eventlist_output_box("\n".join(results))
1284
- ]
1285
 
1286
  except Exception as e:
1287
  error_message = (
@@ -1292,6 +1316,7 @@ def create_eventlist_operations_tab(
1292
 
1293
  # Assign callbacks to buttons
1294
  multi_event_list_select.param.watch(update_event_list_properties, "value")
 
1295
  apply_deadtime_button.on_click(apply_deadtime_callback)
1296
  convert_pi_button.on_click(convert_pi_callback)
1297
  filter_energy_button.on_click(filter_energy_callback)
@@ -1304,70 +1329,107 @@ def create_eventlist_operations_tab(
1304
  # Layout for the tab
1305
  tab_content = pn.Column(
1306
  pn.pane.Markdown("# EventList Operations"),
1307
- pn.Row(
1308
  multi_event_list_select,
1309
  event_list_properties_box,
 
 
 
1310
  ),
1311
  pn.Column(
1312
- pn.pane.Markdown("## Apply Deadtime"),
1313
- pn.Row(
1314
- pn.Column(
1315
- deadtime_input, deadtime_inplace_checkbox, apply_deadtime_button
1316
- )
1317
- ),
1318
- pn.pane.Markdown("## Convert PI to Energy"),
1319
- pn.Row(
1320
- pn.Column(rmf_file_input, rmf_newEventList_checkbox, convert_pi_button)
1321
- ),
1322
- pn.pane.Markdown("## Filter by Energy Range"),
1323
- pn.Row(
1324
- pn.Column(
1325
- energy_range_input,
1326
- filterEnergy_inplace_checkbox,
1327
- filterEnergy_use_pi_checkbox,
1328
- filter_energy_button,
1329
- )
1330
- ),
1331
- pn.pane.Markdown("## Compute Color Evolution"),
1332
- pn.Row(
1333
- pn.Column(
1334
- energy_ranges_input,
1335
- segment_size_input,
1336
- color_use_pi_checkbox,
1337
- compute_color_button,
1338
- )
1339
- ),
1340
- pn.pane.Markdown("## Get Energy Mask"),
1341
- pn.Row(
1342
- pn.Column(
1343
- energy_mask_input,
1344
- energy_mask_use_pi_checkbox,
1345
- get_energy_mask_button,
1346
- )
1347
- ),
1348
- pn.pane.Markdown("## Compute Intensity Evolution"),
1349
- pn.Row(
1350
- pn.Column(
1351
- intensity_energy_range_input,
1352
- intensity_segment_size_input,
1353
- intensity_use_pi_checkbox,
1354
- compute_intensity_button,
1355
- )
1356
- ),
1357
- pn.pane.Markdown("## Join EventLists"),
1358
- pn.Row(
1359
- pn.Column(
1360
- join_strategy_select,
1361
- join_button,
1362
- )
1363
- ),
1364
- pn.pane.Markdown("## Sort EventLists"),
1365
- pn.Row(
1366
- pn.Column(
1367
- sort_inplace_checkbox,
1368
- sort_button,
1369
- )
1370
- ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1371
  ),
1372
  pn.pane.Markdown("<br/>"),
1373
  )
@@ -1382,7 +1444,7 @@ def create_eventlist_main_area(
1382
  plots_container,
1383
  help_box_container,
1384
  footer_container,
1385
- float_panel_container,
1386
  ):
1387
  """
1388
  Create the main area for the data loading tab, including all sub-tabs.
@@ -1425,7 +1487,6 @@ def create_eventlist_main_area(
1425
  return MainArea(tabs_content=tabs_content)
1426
 
1427
 
1428
-
1429
  def create_eventlist_help_area():
1430
  """
1431
  Create the help area for the data loading tab.
@@ -1653,4 +1714,4 @@ def create_eventlist_plots_area():
1653
  >>> isinstance(plots_area, PlotsContainer)
1654
  True
1655
  """
1656
- return PlotsContainer()
 
49
  return warning_handler
50
 
51
 
 
52
  """ Header Section """
53
 
54
 
 
82
  >>> header.heading.value
83
  'Data Ingestion and creation'
84
  """
85
+ home_heading_input = pn.widgets.TextInput(
86
+ name="Heading", value="QuickLook EventList"
87
+ )
88
  return MainHeader(heading=home_heading_input)
89
 
90
 
 
267
  except ValueError as ve:
268
  warning_handler.warn(str(ve), category=ValueError)
269
  output_box_container[:] = [
270
+ create_eventlist_output_box("An error occurred: Please check your inputs.")
 
 
271
  ]
272
  except Exception as e:
273
  warning_handler.warn(str(e), category=RuntimeError)
 
622
  event_list_properties_box = pn.pane.Markdown(
623
  "**Select an EventList to view its properties.**"
624
  )
625
+
626
+ multi_light_curve_select = pn.widgets.MultiSelect(
627
+ name="Select Light Curve(s)",
628
+ options={name: i for i, (name, lc) in enumerate(loaded_light_curve)},
629
+ size=8,
630
+ )
631
+
632
+ light_curve_properties_box = pn.pane.Markdown(
633
+ "**Select a LightCurve to view its properties.**"
634
+ )
635
 
636
  deadtime_input = pn.widgets.FloatInput(
637
  name="Deadtime", value=0.01, step=0.001, start=0.001, end=10000.0
 
763
  )
764
 
765
  event_list_properties_box.object = "\n".join(properties)
766
+
767
+ # Callback to update the lightcurve properties box
768
+ def update_light_curve_properties(event):
769
+ selected_indices = multi_light_curve_select.value
770
+ if not selected_indices:
771
+ light_curve_properties_box.object = "**No LightCurve selected.**"
772
+ return
773
+
774
+ properties = []
775
+ for selected_index in selected_indices:
776
+ light_curve_name, light_curve = loaded_light_curve[selected_index]
777
+ properties.append(
778
+ f"### LightCurve: {light_curve_name}\n"
779
+ f"- **Counts**: {light_curve.counts}\n"
780
+ f"- **Time Span**: {light_curve.time[0]:.2f} - {light_curve.time[-1]:.2f}\n"
781
+ f"- **Time Resolution**: {light_curve.dt:.2f}\n"
782
+ )
783
+
784
+ light_curve_properties_box.object = "\n".join(properties)
785
 
786
  # Callback: Apply Deadtime
787
  def apply_deadtime_callback(event):
 
816
 
817
  # Update the output box with results
818
  if results:
819
+ output_box_container[:] = [create_eventlist_output_box("\n".join(results))]
 
 
820
  else:
821
  output_box_container[:] = [
822
  create_eventlist_output_box("No event lists processed.")
 
1305
  )
1306
 
1307
  # Update output container with results
1308
+ output_box_container[:] = [create_eventlist_output_box("\n".join(results))]
 
 
1309
 
1310
  except Exception as e:
1311
  error_message = (
 
1316
 
1317
  # Assign callbacks to buttons
1318
  multi_event_list_select.param.watch(update_event_list_properties, "value")
1319
+ multi_light_curve_select.param.watch(update_light_curve_properties, "value")
1320
  apply_deadtime_button.on_click(apply_deadtime_callback)
1321
  convert_pi_button.on_click(convert_pi_callback)
1322
  filter_energy_button.on_click(filter_energy_callback)
 
1329
  # Layout for the tab
1330
  tab_content = pn.Column(
1331
  pn.pane.Markdown("# EventList Operations"),
1332
+ pn.FlexBox(
1333
  multi_event_list_select,
1334
  event_list_properties_box,
1335
+ multi_light_curve_select,
1336
+ light_curve_properties_box,
1337
+ flex_direction="row",
1338
  ),
1339
  pn.Column(
1340
+ pn.FlexBox(
1341
+ pn.FlexBox(
1342
+ pn.Column(
1343
+ pn.pane.Markdown("## Apply Deadtime"),
1344
+ deadtime_input,
1345
+ deadtime_inplace_checkbox,
1346
+ apply_deadtime_button,
1347
+ width=400,
1348
+ height=300,
1349
+ ),
1350
+ pn.Column(
1351
+ pn.pane.Markdown("## Convert PI to Energy"),
1352
+ rmf_file_input,
1353
+ rmf_newEventList_checkbox,
1354
+ convert_pi_button,
1355
+ width=400,
1356
+ height=300,
1357
+ ),
1358
+ flex_direction="row",
1359
+ flex_wrap="nowrap",
1360
+ align_items="flex-start",
1361
+ justify_content="flex-start",
1362
+ gap="50px",
1363
+ ),
1364
+ pn.FlexBox(
1365
+ pn.Column(
1366
+ pn.pane.Markdown("## Filter by Energy Range"),
1367
+ energy_range_input,
1368
+ filterEnergy_inplace_checkbox,
1369
+ filterEnergy_use_pi_checkbox,
1370
+ filter_energy_button,
1371
+ width=400,
1372
+ height=300,
1373
+ ),
1374
+ pn.Column(
1375
+ pn.pane.Markdown("## Compute Color Evolution"),
1376
+ energy_ranges_input,
1377
+ segment_size_input,
1378
+ color_use_pi_checkbox,
1379
+ compute_color_button,
1380
+ width=400,
1381
+ height=300,
1382
+ ),
1383
+ pn.Column(
1384
+ pn.pane.Markdown("## Get Energy Mask"),
1385
+ energy_mask_input,
1386
+ energy_mask_use_pi_checkbox,
1387
+ get_energy_mask_button,
1388
+ width=400,
1389
+ height=300,
1390
+ ),
1391
+ flex_direction="row",
1392
+ flex_wrap="nowrap",
1393
+ align_items="flex-start",
1394
+ justify_content="flex-start",
1395
+ gap="50px",
1396
+ ),
1397
+ pn.FlexBox(
1398
+ pn.Column(
1399
+ pn.pane.Markdown("## Compute Intensity Evolution"),
1400
+ intensity_energy_range_input,
1401
+ intensity_segment_size_input,
1402
+ intensity_use_pi_checkbox,
1403
+ compute_intensity_button,
1404
+ width=400,
1405
+ height=300,
1406
+ ),
1407
+ pn.Column(
1408
+ pn.pane.Markdown("## Join EventLists"),
1409
+ join_strategy_select,
1410
+ join_button,
1411
+ width=400,
1412
+ height=300,
1413
+ ),
1414
+ pn.Column(
1415
+ pn.pane.Markdown("## Sort EventLists"),
1416
+ sort_inplace_checkbox,
1417
+ sort_button,
1418
+ width=400,
1419
+ height=300,
1420
+ ),
1421
+ flex_direction="row",
1422
+ flex_wrap="nowrap",
1423
+ align_items="flex-start",
1424
+ justify_content="flex-start",
1425
+ gap="50px",
1426
+ ),
1427
+ flex_direction="row",
1428
+ flex_wrap="wrap",
1429
+ align_items="center",
1430
+ justify_content="center",
1431
+
1432
+ )
1433
  ),
1434
  pn.pane.Markdown("<br/>"),
1435
  )
 
1444
  plots_container,
1445
  help_box_container,
1446
  footer_container,
1447
+ float_panel_container,
1448
  ):
1449
  """
1450
  Create the main area for the data loading tab, including all sub-tabs.
 
1487
  return MainArea(tabs_content=tabs_content)
1488
 
1489
 
 
1490
  def create_eventlist_help_area():
1491
  """
1492
  Create the help area for the data loading tab.
 
1714
  >>> isinstance(plots_area, PlotsContainer)
1715
  True
1716
  """
1717
+ return PlotsContainer()