Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
134 commits
Select commit Hold shift + click to select a range
055ba83
Early stage GUI for the CSU currently can import a starlist file and …
NominalAnxiety Jul 14, 2025
f0f3cd7
initial commit
NominalAnxiety Jul 14, 2025
2457760
added a interactive image of the bars that you can select which will …
NominalAnxiety Jul 14, 2025
503e2e6
Added slits that display the star they are opening for and should cha…
NominalAnxiety Jul 14, 2025
ab8a9b8
initial commit
NominalAnxiety Jul 14, 2025
7058de5
made it so that the slit position table should now be able to change …
NominalAnxiety Jul 14, 2025
9d129c9
slightly edited the interactiveslitmask file to take out unneccesary …
NominalAnxiety Jul 15, 2025
66e1bc9
Changed file names and made the files overall easier to read
NominalAnxiety Jul 15, 2025
024c698
made a few changes that were inconsequential
NominalAnxiety Jul 15, 2025
50358cf
Merge branch 'interactive_slit_mask'
NominalAnxiety Jul 16, 2025
02c703b
renamed the slit_mask to be nicer
NominalAnxiety Jul 16, 2025
e052d71
made it so that the interactive slit mask could change the slit posit…
NominalAnxiety Jul 16, 2025
06e2230
Merge branch 'main' into slit_position_table
NominalAnxiety Jul 16, 2025
eeeede3
messed up the merge so this is the last touches on the merge
NominalAnxiety Jul 16, 2025
b3ff0bd
Merge branch 'CaltechOpticalObservatories:main' into main
NominalAnxiety Jul 16, 2025
5f19058
changed the name of the slit postion table file to make it look better
NominalAnxiety Jul 16, 2025
4d81409
the slit position table now interacts with the interactive slit mask …
NominalAnxiety Jul 16, 2025
a785ef7
Merge remote-tracking branch 'origin'
NominalAnxiety Jul 16, 2025
d2a7ae3
updated the GUI layout to use QsizePolicy and updated other functions…
NominalAnxiety Jul 17, 2025
b458ef5
initial commit
NominalAnxiety Jul 18, 2025
8981748
forgot to commit but now I can get the offset from center data (the p…
NominalAnxiety Jul 18, 2025
7529251
added input to the row widget and the slit mask but none of it is act…
NominalAnxiety Jul 18, 2025
051720d
when you press run, it will give a list of stars and show what slit p…
NominalAnxiety Jul 21, 2025
64474d1
fixed bug when selecting items in the interactive slit mask. Changed …
NominalAnxiety Jul 22, 2025
57d2473
changed gitignore slightly so it is less annoying to commit
NominalAnxiety Jul 22, 2025
5827e15
added a green fov box on the slit mask and fixed the x coordinates
NominalAnxiety Jul 22, 2025
a9cff53
Added titles to all the widgets
NominalAnxiety Jul 22, 2025
38c58a0
Everything can be resized by the user on a whim now (most of everything)
NominalAnxiety Jul 23, 2025
54547f3
the slit_mask now scales when the area is changed by the user
NominalAnxiety Jul 23, 2025
15defd3
changed the display to have splitters so that pretty much everything …
NominalAnxiety Jul 23, 2025
65c1f64
changed items to make the code more readable and futureproof
NominalAnxiety Jul 23, 2025
3de4d53
Added titles to all the widgets
NominalAnxiety Jul 22, 2025
9271118
Everything can be resized by the user on a whim now (most of everything)
NominalAnxiety Jul 23, 2025
6aed603
the slit_mask now scales when the area is changed by the user
NominalAnxiety Jul 23, 2025
580e626
changed the display to have splitters so that pretty much everything …
NominalAnxiety Jul 23, 2025
49f553d
fixed error
NominalAnxiety Jul 23, 2025
97a178d
Merge remote-tracking branch 'origin/mask_configurations' into cosmetics
NominalAnxiety Jul 23, 2025
c2dbe4f
fixed error
NominalAnxiety Jul 23, 2025
6d0d229
fixed error
NominalAnxiety Jul 23, 2025
80f6b79
Merge remote-tracking branch 'upstream/main'
NominalAnxiety Jul 24, 2025
7e9e1bc
Merge branch 'main' into cosmetics
NominalAnxiety Jul 24, 2025
bc74295
made the code more readable and added stylesheet file
NominalAnxiety Jul 24, 2025
7ad084e
replacing branch content with the one from my own personal fork
NominalAnxiety Jul 24, 2025
c4c62a3
Merge remote-tracking branch 'temp_remote/main' into slitmaskgui
NominalAnxiety Jul 24, 2025
3d9f666
changed algorithm for slit calculation
NominalAnxiety Jul 24, 2025
fa9666f
merged personal branch
NominalAnxiety Jul 24, 2025
03d2ba5
made a mistake now its all merged
NominalAnxiety Jul 24, 2025
c8bd3c7
fixed small thing
NominalAnxiety Jul 25, 2025
0beb9db
selects stars with only the highest priority for each row (still does…
NominalAnxiety Jul 25, 2025
416e5dd
the slit mask and the rows now interact when you click on them in a c…
NominalAnxiety Jul 25, 2025
1b3b6d9
selecting item in target list now selects the star
NominalAnxiety Jul 25, 2025
2f09c4f
all of the widgets (slitmask,row,targetdisplay) now select each other
NominalAnxiety Jul 25, 2025
eeb3ef5
Merge branch 'slitmaskgui_select_corresponding' into slitmaskgui
NominalAnxiety Jul 25, 2025
dfd41dc
Merge branch 'slitmaskgui_mask_configuration' into slitmaskgui
NominalAnxiety Jul 25, 2025
29910ff
initial commit added two test files that are empty
NominalAnxiety Jul 25, 2025
9fe9468
added more to the test_target inputs (generates a lot of stars now)
NominalAnxiety Jul 25, 2025
66ec3aa
added first test file
NominalAnxiety Jul 28, 2025
990a296
changed the input_targets slightly
NominalAnxiety Jul 28, 2025
df9d4a3
Merge branch 'slitmaskgui' into slitmaskgui_testing
NominalAnxiety Jul 28, 2025
fdeca55
added another test file. test file is for input_targets
NominalAnxiety Jul 28, 2025
fd2de7a
changed file location
NominalAnxiety Jul 28, 2025
ba5e168
added basic info logging to the main app and the mask_gen widget
NominalAnxiety Jul 28, 2025
4905cc9
big commit: selecting different mask configs now changes what is disp…
NominalAnxiety Jul 28, 2025
25957f7
the close button no longer crashes the program and you only save to f…
NominalAnxiety Jul 28, 2025
1cfaaab
updated to make more readable
NominalAnxiety Jul 28, 2025
b210360
Merge branch 'slitmaskgui' into slitmaskgui_mask_config
NominalAnxiety Jul 28, 2025
8325ae2
small changes
NominalAnxiety Jul 29, 2025
0bc6eb5
changed the position of some files
NominalAnxiety Jul 29, 2025
711040a
fixed the connection between all the display widgets
NominalAnxiety Jul 29, 2025
dbd6693
changed up the style a bit
NominalAnxiety Jul 30, 2025
0c2cf3c
changed the style a bit and fixed some bugs
NominalAnxiety Jul 31, 2025
9d43f4c
added the bones for a spectral view for the slit mask
NominalAnxiety Jul 31, 2025
2e3f958
the most alpha version of spectral format ever
NominalAnxiety Jul 31, 2025
06d92ad
fixed major bug and made code more readable
NominalAnxiety Aug 1, 2025
41f1ce7
Merge remote-tracking branch 'origin' into slitmaskgui_wavelength
NominalAnxiety Aug 1, 2025
bbfe882
changed gitignore
NominalAnxiety Aug 1, 2025
38a3663
added parentheses
NominalAnxiety Aug 1, 2025
047a7fc
added a catch and fixed an error in my merge
NominalAnxiety Aug 1, 2025
7b1e795
changed the graphics a bit
NominalAnxiety Aug 1, 2025
4db0645
the slitmask now doesn't stretch but resizes itself when view is changed
NominalAnxiety Aug 1, 2025
0f786be
smoother resizing for all widgets now
NominalAnxiety Aug 1, 2025
a944e1c
changed the mask tab and added a new file for it
NominalAnxiety Aug 4, 2025
8e8810b
center of priority doesn't work
NominalAnxiety Aug 4, 2025
51fad85
can now use center of priority
NominalAnxiety Aug 4, 2025
aba834b
added center of priority and skyview
NominalAnxiety Aug 5, 2025
4be1c1d
added caching (sort of) to the skyview and fixed the slitmask to accu…
NominalAnxiety Aug 5, 2025
f0143f3
added ability to make changes to the slit width and then save those c…
NominalAnxiety Aug 5, 2025
8963adc
fixed small bug that made the open button not work
NominalAnxiety Aug 5, 2025
d21eb20
added some error catching
NominalAnxiety Aug 5, 2025
56ab76d
Added light_mode and dark_mode depending on what the systems settings…
NominalAnxiety Aug 6, 2025
3b8971f
made the comboboxes a lot better
NominalAnxiety Aug 6, 2025
6768d9d
Merge https://github.com/CaltechOpticalObservatories/lris2 into slitm…
NominalAnxiety Aug 7, 2025
ee66b43
moved the starlist file parser to backend
NominalAnxiety Aug 7, 2025
18ecff7
made mask view have gradient bars
NominalAnxiety Aug 14, 2025
799b252
forgot to commit in a while but the wavelength_view is working but no…
NominalAnxiety Aug 15, 2025
a416e47
temporary wavelength view finished
NominalAnxiety Aug 15, 2025
ff96eca
restructured my files
NominalAnxiety Aug 15, 2025
a9ad684
made it change waveband range text when you change the different scenes
NominalAnxiety Aug 15, 2025
068d093
functional wavelength view for blue low res (still has problems)
NominalAnxiety Aug 20, 2025
b36e344
updated the waveband so now it displays all wavebands with no errors …
NominalAnxiety Aug 20, 2025
855630a
added mostly dummy gui widgets that will be for communicating with th…
NominalAnxiety Aug 21, 2025
2e35346
can't get the splitter to not have small amount of space on right sid…
NominalAnxiety Aug 21, 2025
08134c4
slightly changed the button
NominalAnxiety Aug 21, 2025
1ffe34f
there are still errors but its better now (timeout error response to …
NominalAnxiety Aug 25, 2025
135af1d
can get status of bars and moves bars to where they need to be but it…
NominalAnxiety Aug 26, 2025
bac7951
animates the bar positions (nice release)
NominalAnxiety Aug 26, 2025
cf96816
added better messsages when configuring
NominalAnxiety Aug 26, 2025
6b9dc69
updated the mask config widget
NominalAnxiety Aug 27, 2025
33042e0
added docstrings to waveband_view.py to improve clarity
NominalAnxiety Aug 27, 2025
a63e69d
Merge branch 'slitmaskgui_wavelengthview' into slitmaskgui_communication
NominalAnxiety Aug 27, 2025
24148cd
made code more readable
NominalAnxiety Aug 28, 2025
17a3dd9
added requirements.txt for slitmaskgui and a github workflow
NominalAnxiety Aug 28, 2025
936a31a
removed seme uneeded code and fixed a bug
NominalAnxiety Aug 28, 2025
6598f29
updated the tests and added a new one
NominalAnxiety Aug 29, 2025
a82794b
updated logic for slitmask_view
NominalAnxiety Aug 30, 2025
663c179
fixed a bug that would lag out the app when you selected rows in slit…
NominalAnxiety Sep 2, 2025
be67bb4
added to mask_config pytest. made one of the tests a lot faster and a…
NominalAnxiety Sep 2, 2025
3a703ea
added some more tests
NominalAnxiety Sep 2, 2025
63d26b7
updated the tests and added a new file
NominalAnxiety Sep 2, 2025
7996861
removed a comment
NominalAnxiety Sep 3, 2025
d4edd3c
thread that can check if it is connected to the internet or not
NominalAnxiety Sep 3, 2025
864870a
if offline it will display offline on top of window
NominalAnxiety Sep 3, 2025
93f1203
fixed a bug and added offline mode
NominalAnxiety Sep 3, 2025
37dae13
Merge remote-tracking branch 'origin' into slitmaskgui_offline_mode
NominalAnxiety Sep 3, 2025
f389cfe
changed CI
NominalAnxiety Sep 3, 2025
b6f80c5
changed CI
NominalAnxiety Sep 3, 2025
9b970fd
changed CI again
NominalAnxiety Sep 3, 2025
a5b48dd
changed CI and offline mode
NominalAnxiety Sep 3, 2025
dc88531
updated the requirements.txt
NominalAnxiety Sep 3, 2025
643f5c1
deleted a comment for some reason
NominalAnxiety Sep 8, 2025
a5c6bef
CI should now work
NominalAnxiety Sep 8, 2025
9705e92
updated gitignore
NominalAnxiety Sep 8, 2025
cd669b0
forgot that I didn't have this file in this checout
NominalAnxiety Sep 8, 2025
8fcfaa9
removed some comments
NominalAnxiety Sep 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

name: Integration

on:
pull_request

permissions:
contents: read


jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-

- name: Install dependencies
run: |
python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
pip install flake8 pytest Pyqt6 pytest-qt
sudo apt-get update
sudo apt-get install -y libegl1 xvfb
if [ -f slitmaskgui/requirements.txt ]; then pip install -r slitmaskgui/requirements.txt; fi

- name: Lint with flake8
run: |
source .venv/bin/activate
flake8 slitmaskgui/ --count --select=E9,F63,F7,F82 --show-source --statistics --exclude=.venv
flake8 slitmaskgui/ --count --exit-zero --max-complexity=10 --statistics #--max-line-length=120 --exclude=.venv

- name: Test
run: |
source .venv/bin/activate
export QT_QPA_PLATFORM=offscreen
xvfb-run -a python3 -m pytest slitmaskgui/tests/
#test:
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ notes.txt
slitmaskgui/tests/problemchild.json
allfonts.txt
slitmaskgui/tests/testfiles/problemchild.json
gaia_starlist.txt
<<<<<<< HEAD
slitmaskgui/tests/testfiles/look_at_later.json
=======
>>>>>>> c53fca9e73a6906023b2dc175c50be15bb18df13
center_coord_starlist.txt
106 changes: 65 additions & 41 deletions slitmaskgui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#just importing everything for now. When on the final stages I will not import what I don't need
import sys
import random
import logging
logging.basicConfig(
filename="main.log",
Expand All @@ -29,27 +28,27 @@
from slitmaskgui.target_list_widget import TargetDisplayWidget
from slitmaskgui.mask_gen_widget import MaskGenWidget
from slitmaskgui.menu_bar import MenuBar
from slitmaskgui.mask_viewer import interactiveSlitMask, WavelengthView
from slitmaskgui.sky_viewer import SkyImageView
from slitmaskgui.mask_widgets.slitmask_view import interactiveSlitMask
from slitmaskgui.mask_widgets.waveband_view import WavelengthView
from slitmaskgui.mask_widgets.sky_viewer import SkyImageView
from slitmaskgui.mask_configurations import MaskConfigurationsWidget
from slitmaskgui.slit_position_table import SlitDisplay
from slitmaskgui.mask_view_tab_bar import TabBar
from PyQt6.QtCore import Qt, QSize, pyqtSlot
from PyQt6.QtGui import QFontDatabase
from slitmaskgui.mask_widgets.mask_view_tab_bar import TabBar
from slitmaskgui.configure_mode.mode_toggle_button import ShowControllerButton
from slitmaskgui.configure_mode.mask_controller import MaskControllerWidget
from slitmaskgui.configure_mode.csu_display_widget import CsuDisplauWidget
from slitmaskgui.offline_mode import OfflineMode
from PyQt6.QtCore import Qt, pyqtSlot
from PyQt6.QtWidgets import (
QApplication,
QMainWindow,
QVBoxLayout,
QHBoxLayout,
QWidget,
QLabel,
QSizePolicy,
QSplitter,
QLayout,
QTreeWidgetItem,
QTreeWidget,
QTabWidget,
QComboBox
QStackedLayout


)
Expand All @@ -58,21 +57,6 @@
main_logger = logging.getLogger()
main_logger.info("starting logging")

"""
currently use center of priority doesn't work (don't know the problem will diagnose it at some later point)
need to make it so that it doesn't randomly generate a starlist with random priority
add more logging to all the functions
"""

"""
Things to do before launch
photo display of the stars
use center of priority should work
ability to modulate slit width
actually use a starlist instead of generating your own
add logging to everything
ability to state max slit length
"""

class MainWindow(QMainWindow):
def __init__(self):
Expand All @@ -82,19 +66,31 @@ def __init__(self):
self.setMenuBar(MenuBar()) #sets the menu bar
self.update_theme()


#----------------------------definitions---------------------------
main_logger.info("app: doing definitions")

self.connection_status = OfflineMode()
self.start_checking_internet_connection()

mask_config_widget = MaskConfigurationsWidget()
mask_gen_widget = MaskGenWidget()
self.mode_toggle_button = ShowControllerButton()
mask_controller_widget = MaskControllerWidget()
csu_display_widget = CsuDisplauWidget()

self.target_display = TargetDisplayWidget()
self.interactive_slit_mask = interactiveSlitMask()
self.slit_position_table = SlitDisplay()
self.wavelength_view = WavelengthView()
self.sky_view = SkyImageView()
self.mask_tab = TabBar(slitmask=self.interactive_slit_mask,waveview=self.wavelength_view,skyview=self.sky_view)


#------------- stacked layout in mask_tab --------------------
self.slitmask_and_csu_display = QStackedLayout()
self.slitmask_and_csu_display.addWidget(self.interactive_slit_mask)
self.slitmask_and_csu_display.addWidget(csu_display_widget)

self.mask_tab = TabBar(slitmask_layout=self.slitmask_and_csu_display,waveview=self.wavelength_view,skyview=self.sky_view)

#---------------------------------connections-----------------------------
main_logger.info("app: doing connections")
Expand All @@ -104,26 +100,33 @@ def __init__(self):
self.target_display.selected_le_star.connect(self.interactive_slit_mask.get_row_from_star_name)
self.interactive_slit_mask.select_star.connect(self.target_display.select_corresponding)
self.wavelength_view.row_selected.connect(self.interactive_slit_mask.select_corresponding_row)
self.mask_tab.waveview_change.connect(self.wavelength_view.re_initialize_scene)
self.interactive_slit_mask.new_slit_positions.connect(self.mask_tab.initialize_spectral_view)

mask_gen_widget.change_data.connect(self.target_display.change_data)
mask_gen_widget.change_slit_image.connect(self.interactive_slit_mask.change_slit_and_star)
mask_gen_widget.change_slit_image.connect(self.interactive_slit_mask.update_slit_and_star)
mask_gen_widget.change_row_widget.connect(self.slit_position_table.change_data)
mask_gen_widget.send_mask_config.connect(mask_config_widget.update_table)
mask_gen_widget.change_wavelength_data.connect(self.wavelength_view.get_spectra_of_star)
mask_gen_widget.send_mask_config.connect(mask_config_widget.initialize_configuration)

mask_config_widget.change_data.connect(self.target_display.change_data)
mask_config_widget.change_row_widget.connect(self.slit_position_table.change_data)
mask_config_widget.change_slit_image.connect(self.interactive_slit_mask.change_slit_and_star)
mask_config_widget.change_slit_image.connect(self.interactive_slit_mask.update_slit_and_star)
mask_config_widget.reset_scene.connect(self.reset_scene)
mask_config_widget.update_image.connect(self.sky_view.show_image)
mask_config_widget.update_image.connect(self.sky_view.update_image)
mask_config_widget.change_name_above_slit_mask.connect(self.interactive_slit_mask.update_name_center_pa)

#if the data is changed connections
self.slit_position_table.tell_unsaved.connect(mask_config_widget.update_table)
self.slit_position_table.tell_unsaved.connect(mask_config_widget.update_table_to_unsaved)
mask_config_widget.data_to_save_request.connect(self.slit_position_table.data_saved)
self.slit_position_table.data_changed.connect(mask_config_widget.save_data_to_mask)

#sending to csu connections
self.mode_toggle_button.connect_controller_with_config(mask_controller_widget,mask_config_widget)
mask_controller_widget.connect_controller_with_slitmask_display(csu_display_widget)
self.mode_toggle_button.button.clicked.connect(self.mode_toggle_button.on_button_clicked)
self.mode_toggle_button.button.clicked.connect(self.switch_modes)

self.connection_status.current_mode.connect(self.switch_internet_connection_mode)


#-----------------------------------layout-----------------------------
main_logger.info("app: setting up layout")
Expand All @@ -132,6 +135,12 @@ def __init__(self):
main_splitter = QSplitter()
self.splitterV2 = QSplitter()
self.mask_viewer_main = QVBoxLayout()
self.stacked_layout = QStackedLayout()
switcher_widget = QWidget()

self.stacked_layout.addWidget(mask_gen_widget)
self.stacked_layout.addWidget(mask_controller_widget)
switcher_widget.setLayout(self.stacked_layout)

self.interactive_slit_mask.setContentsMargins(0,0,0,0)
self.slit_position_table.setContentsMargins(0,0,0,0)
Expand All @@ -140,28 +149,25 @@ def __init__(self):
mask_config_widget.setMinimumSize(1,1)
mask_gen_widget.setMinimumSize(1,1)


self.splitterV2.addWidget(mask_config_widget)
self.splitterV2.addWidget(mask_gen_widget)
self.splitterV2.addWidget(switcher_widget)
self.splitterV2.addWidget(self.mode_toggle_button)
self.splitterV2.setOrientation(Qt.Orientation.Vertical)
self.splitterV2.setContentsMargins(0,0,0,0)

self.layoutH1.addWidget(self.slit_position_table)#temp_widget2)
self.layoutH1.addWidget(self.slit_position_table)
self.layoutH1.addWidget(self.mask_tab)
# self.layoutH1.addWidget(self.combobox)
self.layoutH1.setSpacing(0)
self.layoutH1.setContentsMargins(9,9,9,9)
widgetH1 = QWidget()
widgetH1.setLayout(self.layoutH1)

self.splitterV1.addWidget(widgetH1)
# self.splitterV1.setCollapsible(0,False)
self.splitterV1.addWidget(self.target_display)
self.splitterV1.setOrientation(Qt.Orientation.Vertical)
self.splitterV1.setContentsMargins(0,0,0,0)

main_splitter.addWidget(self.splitterV1)
# main_splitter.setCollapsible(0,False)
main_splitter.addWidget(self.splitterV2)

self.setCentralWidget(main_splitter)
Expand Down Expand Up @@ -218,6 +224,24 @@ def update_theme(self):
else:
with open("slitmaskgui/dark_mode.qss", "r") as f:
self.setStyleSheet(f.read())

def switch_modes(self):
index = abs(self.stacked_layout.currentIndex()-1)
self.stacked_layout.setCurrentIndex(index)
self.slitmask_and_csu_display.setCurrentIndex(index)
button_text = "Configuration Mode (ON)" if index == 1 else "Configuration Mode (OFF)"
self.mode_toggle_button.button.setText(button_text)

def start_checking_internet_connection(self):
self.connection_status.start_checking_internet_connection()
self.connection_status.start_timer()

def switch_internet_connection_mode(self):
self.sky_view.offline = self.connection_status.offline
self.setWindowTitle(f"LRIS-2 Slit Configuration Tool ({repr(self.connection_status)})")






Expand Down
18 changes: 14 additions & 4 deletions slitmaskgui/backend/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from astropy.coordinates import SkyCoord
import astropy.units as u
import random
import numpy as np


def query_gaia_starlist_rect(ra_center, dec_center, width_arcmin=5, height_arcmin=10, n_stars=100, output_file='gaia_starlist.txt'):
Expand All @@ -24,22 +25,31 @@ def query_gaia_starlist_rect(ra_center, dec_center, width_arcmin=5, height_arcmi
sign, dec_d, dec_m, dec_s = coord.dec.signed_dms
dec_d = sign * dec_d

# parallax = row['parallax'] # in mas
# app_mag = row['phot_g_mean_mag']

# if parallax > 0:
# distance_pc = 1000.0 / parallax
# abs_mag = app_mag - 5 * (np.log10(distance_pc) - 1)
# else:
# abs_mag = float(0)

line = f"{name:<15} {int(ra_h):02d} {int(ra_m):02d} {ra_s:05.2f} {int(dec_d):+03d} {int(dec_m):02d} {abs(dec_s):04.1f} 2000.0 vmag={row['phot_g_mean_mag']:.2f} priority={random.randint(1,2000)}\n"
f.write(line)
# Output center info
print("Starlist Generated")


# Example call — replace RA/Dec with your actual center
run = False
run = False
if run:
ra = "00 42 44.00"
dec = "+41 16 09.00"
ra = "10 20 10.00"
dec = "-10 04 00.10"
query_gaia_starlist_rect(
ra_center=ra, # RA in degrees
dec_center=dec, # Dec in degrees
width_arcmin=5,
height_arcmin=10,
n_stars=104,
output_file='andromeda_galaxy.txt'
output_file='gaia_starlist.txt'
)
24 changes: 7 additions & 17 deletions slitmaskgui/backend/star_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class StarList:
#with auto run you can select if the json is complete or not already
#this means that if you have a complete list of all the stars as if it rand thorough this class, then you can select auto run as false
#then you can use the send functions without doing a bunch of computation
def __init__(self,payload,ra,dec,slit_width=0,pa=0,auto_run=True,use_center_of_priority=False):
def __init__(self,payload,ra=0,dec=0,slit_width=0,pa=0,auto_run=True,use_center_of_priority=False):
self.payload = json.loads(payload)
ra_coord,dec_coord = ra, dec
if use_center_of_priority:
Expand All @@ -61,50 +61,40 @@ def __init__(self,payload,ra,dec,slit_width=0,pa=0,auto_run=True,use_center_of_p

def calc_mask(self,all_stars):
slit_mask = SlitMask(all_stars,center=self.center, slit_width= self.slit_width, pa= self.pa)

return json.loads(slit_mask.return_mask())

def export_mask_config(self,file_path):
# file_path = f'{os.getcwd()}/{mask_name}.json'
with open(file_path,'w') as f:
json.dump(self.payload,f,indent=4)
# return file_path

def send_mask(self, mask_name="untitled"):
return self.payload


def send_target_list(self):
return [[x["name"],x["priority"],x["vmag"],x["ra"],x["dec"],x["center distance"]] for x in self.payload]


def send_interactive_slit_list(self):
#have to convert it to dict {bar_num:(position,star_name)}
#imma just act rn like all the stars are in sequential order
#I am going to have an optimize function that actually gets the right amount of stars with good positions
#its going to also order them by bar
total_pixels = 252

slit_dict = {
i: (obj["x_mm"], obj["bar_id"], obj["name"])
for i, obj in enumerate(self.payload[:72])
obj["bar_id"]: (obj["x_mm"], obj["name"])
for obj in self.payload[:72]
if "bar_id" in obj
}

return slit_dict

def send_list_for_wavelength(self):
old_ra_dec_list = [[x["bar_id"],x["ra"],x["dec"]]for x in self.payload]
ra_dec_list =[]
[ra_dec_list.append(x) for x in old_ra_dec_list if x not in ra_dec_list]
return ra_dec_list

def send_row_widget_list(self):
#the reason why the bar id is plus 1 is to transl
sorted_row_list = sorted(
([obj["bar_id"]+1, obj["x_mm"], obj["slit_width"]]
for obj in self.payload[:72] if "bar_id" in obj),
key=lambda x: x[0]
)
return sorted_row_list

def find_center_of_priority(self):
""" ∑ coordinates * priority
CoP coordinate = ------------------------
Expand Down Expand Up @@ -136,7 +126,7 @@ def generate_skyview(self):
key = (hips, width, height, ra, dec, fov)
if key in HIPS_CACHE:
return HIPS_CACHE[key]

hdulist = hips2fits.query(
hips=hips,
width=width, #in pixels
Expand Down
Loading