Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix loader bugs, change random2 to avoid restarting during testing #158

Merged
merged 1 commit into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions python/PiFinder/catalogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,15 @@ def set_current_object(self, object_number: int, catalog_code: str = ""):
logging.debug(
f"set_current_object: {self.object_tracker=}, {self.designator_tracker=}, {catalog_code=}, {object_number=}, {self.get_current_object()=}"
)

# Make sure this catalog is in the designator tracker
# if not, add it so it can be set
if self.designator_tracker.get(catalog_code) is None:
_c = self.catalogs.get_catalog_by_code(catalog_code)
self.designator_tracker[catalog_code] = CatalogDesignator(
catalog_code, _c.max_sequence
)

self.designator_tracker[catalog_code].set_number(
object_number if object_number else 0
)
Expand Down
11 changes: 5 additions & 6 deletions python/PiFinder/obslist.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import os
from textwrap import dedent
from PiFinder import utils
from PiFinder.catalogs import Names
from PiFinder.catalogs import Names, Catalogs

OBSLIST_DIR = f"{utils.data_dir}/obslists/"

Expand Down Expand Up @@ -49,7 +49,7 @@ def write_list(catalog_objects, name):
index_num += 1


def resolve_object(catalog_numbers, objects):
def resolve_object(catalog_numbers, catalogs: Catalogs):
"""
Takes a list of SkySafari catalog
numbers and tries to find an object
Expand All @@ -65,14 +65,13 @@ def resolve_object(catalog_numbers, objects):
sequence = None

if sequence is not None:
_object = objects.get_object_by_catalog_sequence(catalog, sequence)
_object = catalogs.get_object(catalog, sequence)
if _object:
return _object
print("Failed")
return None


def read_list(names: Names, name):
def read_list(catalogs: Catalogs, name):
"""
Reads a skylist style observing
list. Matches against catalogs
Expand Down Expand Up @@ -112,7 +111,7 @@ def read_list(names: Names, name):
}

# see if we can resolve an object
_object = resolve_object(catalog_numbers, names)
_object = resolve_object(catalog_numbers, catalogs)

if _object:
list_catalog.append(_object)
Expand Down
2 changes: 1 addition & 1 deletion python/PiFinder/ui/locate.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def load_list(self, option):
self.message("No matches")
return False

self.ui_state.set_observing_list(_load_results["catalog"])
self.ui_state.set_observing_list(_load_results["catalog_objects"])
self.ui_state.set_active_list_to_observing_list()
self.target_index = 0
self.ui_state.set_target(self.ui_state.active_list()[self.target_index])
Expand Down
Loading