Skip to content
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/deploy_gcp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
version: '>= 416.0.0'
- id: 'build_docker_and_push'
run: |-
mkdir -p ./astrometry_data/ && gsutil -m cp -n gs://astrometry_data/* ./astrometry_data/
mkdir -p ./astrometry_data/ && gcloud storage rsync gs://astrometry_data/ ./astrometry_data/ --recursive --verbosity=info --delete-unmatched-destination-objects
docker image prune -f && docker buildx prune -f && docker container prune -f
docker buildx build --platform linux/amd64 -t ${{ vars.AR_URL }}/${{ vars.IMAGE_NAME }} .
docker tag ${{ vars.AR_URL }}/${{ vars.IMAGE_NAME }} ${{ vars.AR_URL }}/${{ vars.IMAGE_NAME }}:${{ github.sha }}
Expand Down
2 changes: 1 addition & 1 deletion Camera/AbstractCamera.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def get_calibration_directory(self,
"calibrations",
calibration_name,
self.uid)
if calibration_name == "dark":
if calibration_name in ["dark", "offset"]:
if temperature is None:
temperature = self.get_temperature()
image_dir = os.path.join(
Expand Down
19 changes: 0 additions & 19 deletions Camera/IndiASICamera290MMMini.py

This file was deleted.

18 changes: 13 additions & 5 deletions Camera/IndiAbstractCamera.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ def __init__(self, serv_time, config=None, connect_on_create=True):

def park(self):
self.logger.debug(f"Parking camera {self.camera_name}")
self.focuser.park()
if self.focuser:
self.focuser.park_focuser()
# if self.filter_wheel:
# self.filter_wheel.park_filterwheel()
self.deinitialize_working_conditions()
self.disconnect()
self.stop_indi_server()
Expand All @@ -37,7 +40,10 @@ def park(self):
def unpark(self):
self.logger.debug(f"Unparking camera {self.camera_name} with a reset-like behaviour")
self.park()
self.focuser.unpark()
if self.focuser:
self.focuser.unpark_focuser()
# if self.filter_wheel:
# self.filter_wheel.unpark_filterwheel()
self.start_indi_server()
self.start_indi_driver()
self.connect(connect_device=True)
Expand Down Expand Up @@ -89,10 +95,12 @@ def initialize_working_conditions(self):
self.logger.debug(f"Camera {self.camera_name} successfully initialized to working conditions")

def deinitialize_working_conditions(self):
if self.is_initialized:
self.logger.debug(f"Camera {self.camera_name} deinitializing from working conditions")
self.logger.debug(f"Camera {self.camera_name} deinitializing from working conditions")
if self._is_initialized:
self.set_cooling_off()
self.logger.debug(f"Camera {self.camera_name} successfully deinitialized")
else:
self.logger.debug(f"Camera {self.camera_name} No need to deinit, as camera was not in initialized state")
self.logger.debug(f"Camera {self.camera_name} successfully deinitialized")

def take_exposure(self, exposure_time, filename, *args, **kwargs):
"""
Expand Down
57 changes: 31 additions & 26 deletions Camera/IndiCamera.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(self, logger=None, config=None, connect_on_create=True):
autofocus_merit_function="half_flux_radius",
focuser=dict(
module="IndiFocuser",
focuser_name="Focuser Simulator",
device_name="Focuser Simulator",
port="/dev/ttyUSB0",
focus_range=dict(
min=1,
Expand Down Expand Up @@ -82,17 +82,17 @@ def __init__(self, logger=None, config=None, connect_on_create=True):
self.connect()

# Specific initialization
self.pointing_seconds = float(config['pointing_seconds'])
self.pointing_seconds = float(config.get('pointing_seconds',5))
self.default_exp_time_sec = config.get('default_exp_time_sec', 5)
self.default_gain = config.get('default_gain', 50)
self.default_offset = config.get('default_offset', 30)
self.adjust_center_x = float(config['adjust_center_x'])
self.adjust_center_y = float(config['adjust_center_y'])
self.adjust_roi_search_size = int(config['adjust_roi_search_size'])
self.adjust_pointing_seconds = float(config['adjust_pointing_seconds'])
self.autofocus_seconds = float(config['autofocus_seconds'])
self.autofocus_roi_size = int(config['autofocus_roi_size'])
self.autofocus_merit_function = config['autofocus_merit_function']
self.adjust_center_x = float(config.get('adjust_center_x',500))
self.adjust_center_y = float(config.get('adjust_center_y',500))
self.adjust_roi_search_size = int(config.get('adjust_roi_search_size',50))
self.adjust_pointing_seconds = float(config.get('adjust_pointing_seconds',5))
self.autofocus_seconds = float(config.get('autofocus_seconds',5))
self.autofocus_roi_size = config.get('autofocus_roi_size', None)
self.autofocus_merit_function = config.get("autofocus_merit_function", "half_flux_radius")
self._setup_focuser(config, connect_on_create)
self._setup_filter_wheel(config, connect_on_create)

Expand All @@ -115,7 +115,6 @@ def _setup_focuser(self, config, connect_on_create):
focuser = load_module('Focuser.'+focuser_name)
#TODO TN, we need to better handle optional connection of focuser
self.focuser = getattr(focuser, focuser_name)(
logger=None,
config=cfg,
connect_on_create=connect_on_create)
except Exception as e:
Expand Down Expand Up @@ -199,7 +198,7 @@ def shoot_async(self):
def get_remaining_exposure_time(self):
return self.get_number('CCD_EXPOSURE')['CCD_EXPOSURE_VALUE']

def get_thumbnail(self, exp_time_sec, thumbnail_size):
def get_thumbnail(self, exp_time_sec, thumbnail_size=None):
"""
There are 4 cases:
-ccd size is even, thumb size is even
Expand All @@ -215,26 +214,28 @@ def get_thumbnail(self, exp_time_sec, thumbnail_size):
2.5-2.5 = 0 ok
2.5-1.5 = 1 ok
"""
sensor_size = self.get_sensor_size()
thumbnail_size = min(thumbnail_size, sensor_size["CCD_MAX_X"])
thumbnail_size = min(thumbnail_size, sensor_size["CCD_MAX_Y"])
center_x = sensor_size["CCD_MAX_X"] / 2
center_y = sensor_size["CCD_MAX_Y"] / 2
left_most = np.floor(center_x - thumbnail_size / 2)
top_most = np.floor(center_y - thumbnail_size / 2)
roi = {'X': left_most, 'Y': top_most, 'WIDTH': thumbnail_size,
'HEIGHT': thumbnail_size}
self.logger.debug(f"Setting camera {self.name} roi to {roi}")
self.set_roi(roi)
if thumbnail_size is not None:
sensor_size = self.get_sensor_size()
thumbnail_size = min(thumbnail_size, sensor_size["CCD_MAX_X"])
thumbnail_size = min(thumbnail_size, sensor_size["CCD_MAX_Y"])
center_x = sensor_size["CCD_MAX_X"] / 2
center_y = sensor_size["CCD_MAX_Y"] / 2
left_most = np.floor(center_x - thumbnail_size / 2)
top_most = np.floor(center_y - thumbnail_size / 2)
roi = {'X': left_most, 'Y': top_most, 'WIDTH': thumbnail_size,
'HEIGHT': thumbnail_size}
self.logger.debug(f"Setting camera {self.name} roi to {roi}")
self.set_roi(roi)
old_exp_time_sec = self.exp_time_sec
self.exp_time_sec = exp_time_sec
self.shoot_async()
self.synchronize_with_image_reception()
fits = self.get_received_image()
roi = {'X': 0, 'Y': 0, 'WIDTH': sensor_size["CCD_MAX_X"],
'HEIGHT': sensor_size["CCD_MAX_Y"]}
self.logger.debug(f"Resetting camera {self.name} roi to {roi}")
self.set_roi(roi)
if thumbnail_size is not None:
roi = {'X': 0, 'Y': 0, 'WIDTH': sensor_size["CCD_MAX_X"],
'HEIGHT': sensor_size["CCD_MAX_Y"]}
self.logger.debug(f"Resetting camera {self.name} roi to {roi}")
self.set_roi(roi)
self.exp_time_sec = old_exp_time_sec
return fits

Expand Down Expand Up @@ -300,6 +301,7 @@ def set_temperature(self, temperature):
if isinstance(temperature, u.Quantity):
temperature = temperature.to(u.deg_C).value
if np.isfinite(temperature):
self.logger.debug(f"Camera {self.device_name} setting temperature to {temperature}")
self.set_number('CCD_TEMPERATURE',
{'CCD_TEMPERATURE_VALUE': temperature},
sync=True, timeout=1200)
Expand All @@ -308,6 +310,9 @@ def set_cooling_on(self):
# No sync, because that's the way it works on indi for the CCD_COOLER property, it stays yellow in the interface
self.set_switch('CCD_COOLER', ['COOLER_ON'], sync=False)

def get_cooling_power(self):
self.get_number("CCD_COOLER_POWER")["CCD_COOLER_VALUE"]

def set_cooling_off(self):
self.set_switch('CCD_COOLER', ['COOLER_OFF'], sync=True, timeout=self.timeout)

Expand Down
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ RUN mkdir -p $HOME/projects/astrometry.net \
# Now Download astrometry.net index files -- This needs to be moved when gsutil is updated
# RUN pyenv install 3.11 \
# && pyenv global 3.11 \
# && gsutil -m cp gs://astrometry_data/* /usr/local/astrometry/data/ \
# && gcloud storage rsync gs://astrometry_data/ /usr/local/astrometry/data/ --recursive --verbosity=info --delete-unmatched-destination-objects \
# && pyenv global $PYTHON_VERSION
#RUN mv /opt/remote_observatory/astrometry_data/* /usr/local/astrometry/data/
USER root
Expand Down Expand Up @@ -255,13 +255,15 @@ RUN for i in indi-duino libasi indi-asi libplayerone indi-playerone indi-shelyak
# Dependencies to build phd2 from sources
USER root
RUN apt-get --assume-yes --quiet install --no-install-recommends \
libeigen3-dev \
libopencv-dev \
libwxgtk3.2-dev

USER $USERNAME
RUN --mount=type=cache,target=$HOME/.cache,uid=$USERID \
mkdir -p $HOME/projects/phd2 \
&& git -C $HOME/.cache/phd2/ fetch || retry -t 8 -d 10 git clone https://github.com/gnthibault/phd2.git $HOME/.cache/phd2/ \
&& cd $HOME/.cache/phd2/ && git checkout master && cp -r --parents ./* $HOME/projects/phd2/ \
&& cd $HOME/.cache/phd2/ && git checkout thibault/fix_find_star && cp -r --parents ./* $HOME/projects/phd2/ \
&& mkdir -p $HOME/projects/build/phd2 \
&& cd $HOME/projects/build/phd2 \
&& cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_SYSTEM_PROCESSOR=$BARCH $HOME/projects/phd2 \
Expand Down
Loading