Skip to content

Commit

Permalink
Merge branch 'main' into equipment_extend
Browse files Browse the repository at this point in the history
  • Loading branch information
brickbots committed Feb 2, 2025
2 parents ffa7f54 + bec012a commit 863be7b
Show file tree
Hide file tree
Showing 21 changed files with 489 additions and 156 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ coverage.xml
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
Expand Down
Binary file modified astro_data/pifinder_objects.db
Binary file not shown.
109 changes: 108 additions & 1 deletion default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,121 @@
"chart_reticle": 128,
"chart_constellations": 64,
"solve_pixel": [256, 256],
"active_catalogs": [
"filter.selected_catalogs": [
"NGC",
"M",
"H",
"Str",
"PL",
"RDS"
],
"filter.object_types": [
"Gx",
"OC",
"Gb",
"Nb",
"DN",
"PN",
"C+N",
"Ast",
"Kt",
"***",
"D*",
"*",
"?",
"Pla",
"CM"
],
"filter.constellations": [
"And",
"Ant",
"Aps",
"Aql",
"Aqr",
"Ara",
"Ari",
"Aur",
"Boo",
"CMa",
"CMi",
"CVn",
"Cae",
"Cam",
"Cap",
"Car",
"Cas",
"Cen",
"Cep",
"Cet",
"Cha",
"Cir",
"Cnc",
"Col",
"Com",
"CrA",
"CrB",
"Crt",
"Cru",
"Crv",
"Cyg",
"Del",
"Dor",
"Dra",
"Equ",
"Eri",
"For",
"Gem",
"Gru",
"Her",
"Hor",
"Hya",
"Hyi",
"Ind",
"LMi",
"Lac",
"Leo",
"Lep",
"Lib",
"Lup",
"Lyn",
"Lyr",
"Men",
"Mic",
"Mon",
"Mus",
"Nor",
"Oct",
"Oph",
"Ori",
"Pav",
"Peg",
"Per",
"Phe",
"Pic",
"PsA",
"Psc",
"Pup",
"Pyx",
"Ret",
"Scl",
"Sco",
"Sct",
"Ser",
"Sex",
"Sge",
"Sgr",
"Tau",
"Tel",
"TrA",
"Tri",
"Tuc",
"UMa",
"UMi",
"Vel",
"Vir",
"Vol",
"Vul"
],
"equipment": {
"telescopes": [
{
Expand Down
6 changes: 6 additions & 0 deletions docs/source/user_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,12 @@ The PiFinder provides an easy to use web interface which allows you to:
To access the web interface for the first time, make sure the PiFinder is in Access Point mode (see :ref:`user_guide:settings menu`). This is the default for new PiFinders to make first time set up easier. Using a phone, tablet or computer, connect to the PiFinder's wireless network called PiFinderAP. It's an open network with no password required. Once connected, open your web browser and visit:
``http://pifinder.local``


.. note::
If you are connected to the PiFinderAP network and can't load the PiFinder web interface using
http://pifinder.local try http://10.10.10.1 as some systems may not support the network features
required to resolve local computer names

.. list-table::
:width: 100%

Expand Down
16 changes: 16 additions & 0 deletions python/PiFinder/camera_pi.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ def __init__(self, exposure_time) -> None:
self.camera_type = "imx296"
# maximum analog gain for this sensor
self.gain = 15

if "imx290" in self.camera.camera.id:
self.camera_type = "imx462"
self.gain = 30

self.camType = f"PI {self.camera_type}"
self.initialize()

Expand All @@ -51,6 +56,13 @@ def initialize(self) -> None:
},
raw={"size": (1456, 1088), "format": "R10"},
)
elif self.camera_type == "imx462":
cam_config = self.camera.create_still_configuration(
{
"size": (512, 512),
},
raw={"size": (1920, 1080), "format": "SRGGB12"},
)
else:
# using this smaller scale auto-selects binning on the sensor...
# cam_config = self.camera.create_still_configuration({"size": (512, 512)})
Expand Down Expand Up @@ -78,6 +90,10 @@ def capture(self) -> Image.Image:
raw_capture = raw_capture.copy().view(np.uint16)[:, 184:-184]
# Sensor orientation is different
raw_capture = np.rot90(raw_capture, 2)
elif self.camera_type == "imx462":
# crop to square and resample to 16 bit from 2 8 bit entries
# to get the right FOV, we want a 980 square....
raw_capture = raw_capture.copy().view(np.uint16)[50:-50, 470:-470]
else:
# crop to square and resample to 16 bit from 2 8 bit entries
raw_capture = raw_capture.copy().view(np.uint16)[:, 256:-256]
Expand Down
49 changes: 48 additions & 1 deletion python/PiFinder/catalog_import.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
This module holds various utils
and importers used during setup
and importers used during catalog setup
"""

Expand Down Expand Up @@ -1442,6 +1442,49 @@ def load_ngc_catalog():
insert_catalog_max_sequence("M")


def fix_object_types():
"""
Runs some global queries to normalize object types from various catalogs
"""
logging.info("FIX: Object Types")
conn, db_c = objects_db.get_conn_cursor()

type_mappings = {
"Dark Nebula": "DN",
"* ": "*",
"*?": "?",
"-": "?",
"": "?",
"Bright Nebula": "Nb",
"D*?": "D*",
"Open Cluster": "OC",
"Pl": "PN",
"PD": "PN",
"Supernova Remnant": "Nb",
}

for k, v in type_mappings.items():
db_c.execute(f"update objects set obj_type = '{v}' where obj_type='{k}'")

conn.commit()


def fix_m45():
"""
m45 coordinates are wrong in our NGC source
"""
logging.info("FIX: m45 location")
conn, db_c = objects_db.get_conn_cursor()

db_c.execute(
"update objects set ra=56.85, dec=24.1167 where "
"id = (select object_id from catalog_objects "
"where catalog_code='M' and sequence=45)"
)

conn.commit()


if __name__ == "__main__":
logging.info("starting main")
logger = logging.getLogger()
Expand Down Expand Up @@ -1505,6 +1548,10 @@ def load_ngc_catalog():
load_arp()
load_tlk_90_vars()

# Fix data issues
fix_object_types()
fix_m45()

# Populate the images table
logging.info("Resolving object images...")
resolve_object_images()
Expand Down
40 changes: 39 additions & 1 deletion python/PiFinder/catalogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from PiFinder.composite_object import CompositeObject, MagnitudeObject
import PiFinder.comets as comets
from PiFinder.utils import Timer, comet_file
from PiFinder.config import Config

logger = logging.getLogger("Catalog")

Expand Down Expand Up @@ -94,6 +95,7 @@ def __init__(
object_types: Union[list[str], None] = None,
altitude: int = -1,
observed: str = "Any",
constellations: list[str] = [],
selected_catalogs: list[str] = [],
):
self.shared_state = shared_state
Expand All @@ -104,9 +106,22 @@ def __init__(
self._object_types = object_types
self._altitude = altitude
self._observed = observed
self._constellations = constellations
self._selected_catalogs = set(selected_catalogs)
self.last_filtered_time = 0

def load_from_config(self, config_object: Config):
"""
Loads filter values from configuration object
"""
self._magnitude = config_object.get_option("filter.magnitude")
self._object_types = config_object.get_option("filter.object_types", [])
self._altitude = config_object.get_option("filter.altitude", -1)
self._observed = config_object.get_option("filter.observed", "Any")
self._constellations = config_object.get_option("filter.constellations", [])
self._selected_catalogs = config_object.get_option("filter.selected_catalogs")
self.last_filtered_time = 0

@property
def magnitude(self):
return self._magnitude
Expand Down Expand Up @@ -143,6 +158,15 @@ def observed(self, observed: str):
self._observed = observed
self.dirty_time = time.time()

@property
def constellations(self):
return self._constellations

@constellations.setter
def constellations(self, constellations: list[str]):
self._constellations = constellations
self.dirty_time = time.time()

@property
def selected_catalogs(self):
return self._selected_catalogs
Expand Down Expand Up @@ -183,6 +207,16 @@ def apply_filter(self, obj: CompositeObject):

obj.last_filtered_time = time.time()
self.last_filtered_time = time.time()

# check constellation
if self._constellations:
if obj.const not in self._constellations:
obj.last_filtered_result = False
return False
else:
obj.last_filtered_result = False
return False

# check altitude
if self._altitude != -1 and self.fast_aa:
obj_altitude, _ = self.fast_aa.radec_to_altaz(
Expand All @@ -202,7 +236,11 @@ def apply_filter(self, obj: CompositeObject):
return False

# check type
if self._object_types is not None and obj.obj_type not in self._object_types:
if self._object_types:
if obj.obj_type not in self._object_types:
obj.last_filtered_result = False
return False
else:
obj.last_filtered_result = False
return False

Expand Down
13 changes: 3 additions & 10 deletions python/PiFinder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,16 +440,9 @@ def main(
catalogs: Catalogs = CatalogBuilder().build(shared_state)

# Establish the common catalog filter object
catalogs.set_catalog_filter(
CatalogFilter(
shared_state=shared_state,
magnitude=cfg.get_option("filter.magnitude"),
object_types=cfg.get_option("filter.object_types"),
altitude=cfg.get_option("filter.altitude", -1),
observed=cfg.get_option("filter.observed", "Any"),
selected_catalogs=cfg.get_option("active_catalogs"),
)
)
_new_filter = CatalogFilter(shared_state=shared_state)
_new_filter.load_from_config(cfg)
catalogs.set_catalog_filter(_new_filter)
console.write(" Menus")
console.update()

Expand Down
9 changes: 5 additions & 4 deletions python/PiFinder/obj_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
"OC": "Open Cluster",
"Gb": "Globular",
"Nb": "Nebula",
"Pl": "Planetary",
"DN": "Dark Nebula",
"PN": "Planetary",
"C+N": "Cluster + Neb",
"Ast": "Asterism",
"Kt": "Knot",
"***": "Triple star",
"D*": "Double star",
"* ": "Star",
"? ": "Unkn",
"*": "Star",
"?": "Unkn",
"Pla": "Planet",
"CM": "Comet",
}
Expand All @@ -20,7 +21,7 @@
"OC": "oc",
"Gb": "gc",
"Nb": "neb",
"Pl": "pneb",
"PN": "pneb",
"D*": "dstar",
"***": "dstar",
"Ast": "ast",
Expand Down
3 changes: 2 additions & 1 deletion python/PiFinder/pos_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ def handle_goto_command(shared_state, ra_parsed, dec_parsed):
)
logger.debug("handle_goto_command: Pushing object: %s", obj)
shared_state.ui_state().add_recent(obj)
shared_state.ui_state().set_new_pushto(True)
ui_queue.put("push_object")
return "1"

Expand Down Expand Up @@ -239,7 +240,7 @@ def run_server(shared_state, p_ui_queue, log_queue):
logger.info("SkySafari server started and listening")
while True:
client_socket, address = server_socket.accept()
logger.info("New connection from %s", address)
logger.debug("New connection from %s", address)
handle_client(client_socket, shared_state)
except Exception:
logger.exception("Unexpected server error")
Expand Down
Loading

0 comments on commit 863be7b

Please sign in to comment.