Skip to content

Commit

Permalink
Move TESS analysis settings widget out of notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
mwcraig committed Nov 25, 2024
1 parent 960c025 commit ee2bef1
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 222 deletions.
77 changes: 75 additions & 2 deletions stellarphot/gui_tools/photometry_widget_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,90 @@

import ipywidgets as ipw
from ccdproc import ImageFileCollection
from ipyautoui.custom import FileChooser

from stellarphot import PhotometryData
from stellarphot.settings import (
PhotometryApertures,
PhotometryFileSettings,
ui_generator,
)
from stellarphot.settings.custom_widgets import Spinner

__all__ = ["PhotometrySettings"]
__all__ = ["TessAnalysisInputControls", "PhotometrySettingsOLDBAD"]


class PhotometrySettings:
class TessAnalysisInputControls(ipw.VBox):
"""
A class to hold the widgets for choosing TESS input
"""

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
hidden = ipw.Layout(display="none")

self.phot_chooser = FileChooser(filter_pattern=["*.csv", "*.fits", "*.ecsv"])
self._fits_openr = ipw.VBox(
children=[
ipw.HTML(value="<h3>Select your photometry/flux file</h3>"),
self.phot_chooser,
]
)
self.tic_file_chooser = FileChooser(filter_pattern=["*.json"])
fits_openr2 = ipw.VBox(
children=[
ipw.HTML(value="<h3>Select your TESS info file</h3>"),
self.tic_file_chooser,
],
layout=hidden,
)
self._passband = ipw.Dropdown(
description="Ccoose Filter",
options=["gp", "ip"],
disabled=True,
layout=hidden,
)

spinner = Spinner(message="<h4>Loading photometry...</h4>")

self.phot_data = None

def update_filter_list(_):
spinner.start()
self.phot_data = PhotometryData.read(self.phot_chooser.value)
passband_data = self.phot_data["passband"]
fits_openr2.layout.display = "flex"
self._passband.layout.display = "flex"
self._passband.options = sorted(set(passband_data))
self._passband.disabled = False
self._passband.value = self._passband.options[0]
spinner.stop()

self.phot_chooser.observe(update_filter_list, names="_value")
self.children = [self._fits_openr, spinner, fits_openr2, self._passband]

@property
def tic_info_file(self):
p = Path(self.tic_file_chooser.value)
selected_file = p.name
if not selected_file:
raise ValueError("No TIC info json file selected")
return p

@property
def photometry_data_file(self):
p = Path(self.phot_chooser.value)
selected_file = p.name
if not selected_file:
raise ValueError("No photometry data file selected")
return p

@property
def passband(self):
return self._passband.value


class PhotometrySettingsOLDBAD:
"""
A class to hold the widgets for photometry settings.
Expand Down
Loading

0 comments on commit ee2bef1

Please sign in to comment.