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

POCS status store #1264

Merged
merged 10 commits into from
May 12, 2024
Prev Previous commit
Next Next commit
Default all db insert_current to not storing permanently. This could …
…be done better.
wtgee committed May 12, 2024
commit 12b193e59ae30c0a9e8dad5f8d2e29cb7f583bcd
2 changes: 1 addition & 1 deletion src/panoptes/pocs/core.py
Original file line number Diff line number Diff line change
@@ -377,7 +377,7 @@ def is_safe(self, no_warning=False, horizon='observe', ignore=None, park_if_not_
safe = all([v for k, v in is_safe_values.items() if k not in ignore])

# Insert safety reading
self.db.insert_current('safety', is_safe_values)
self.db.insert_current('safety', is_safe_values, store_permanently=False)

if not safe:
if no_warning is False:
98 changes: 49 additions & 49 deletions src/panoptes/pocs/observatory.py
Original file line number Diff line number Diff line change
@@ -351,9 +351,9 @@ def get_observation(self, *args, **kwargs):

# If observation list is empty or a reread is requested
reread_file = (
self.scheduler.has_valid_observations is False or
kwargs.get('read_file', False) or
self.get_config('scheduler.check_file', default=False)
self.scheduler.has_valid_observations is False or
kwargs.get('read_file', False) or
self.get_config('scheduler.check_file', default=False)
)

# This will set the `current_observation`.
@@ -419,13 +419,13 @@ def take_observation(self, blocking: bool = True):
del self.cameras[cam_id]

def process_observation(
self,
compress_fits: Optional[bool] = None,
record_observations: Optional[bool] = None,
make_pretty_images: Optional[bool] = None,
plate_solve: Optional[bool] = None,
upload_image: Optional[bool] = None,
):
self,
compress_fits: Optional[bool] = None,
record_observations: Optional[bool] = None,
make_pretty_images: Optional[bool] = None,
plate_solve: Optional[bool] = None,
upload_image: Optional[bool] = None,
):
"""Process an individual observation.

Performs the following steps:
@@ -496,17 +496,17 @@ def process_observation(
self.logger.debug(f'Compressed {compressed_file_path}')

if record_observations or self.get_config(
'observations.record_observations',
default=False
):
'observations.record_observations',
default=False
):
self.logger.debug(f"Adding current observation to db: {image_id}")
metadata['status'] = 'complete'
self.db.insert_current('observations', metadata)
self.db.insert_current('observations', metadata, store_permanently=False)

if make_pretty_images or self.get_config(
'observations.make_pretty_images',
default=False
):
'observations.make_pretty_images',
default=False
):
try:
image_title = f'{field_name} [{exptime}s] {seq_id}'

@@ -522,8 +522,8 @@ def process_observation(
kwargs=dict(
title=image_title,
link_path=str(link_path)
)
)
)
pretty_process.start()
except Exception as e: # pragma: no cover
self.logger.warning(f'Problem with extracting pretty image: {e!r}')
@@ -572,8 +572,8 @@ def analyze_recent(self):
'd_dec': self.current_offset_info.delta_dec.value,
'magnitude': self.current_offset_info.magnitude.value,
'unit': 'arcsec',
}
)
}, store_permanently=False
)

except error.SolveError:
self.logger.warning("Can't solve field, skipping")
@@ -610,8 +610,8 @@ def upload_exposure(self, exposure_info, bucket_name=None):
file_path=image_path,
bucket_path=bucket_path.as_posix(),
bucket_name=bucket_name
)
)
)

self.logger.debug(f'Uploading {str(image_path)} to {bucket_path} on {bucket_name}')
upload_process.start()
@@ -792,22 +792,22 @@ def close_dome(self):
return self.dome.close()

def take_flat_fields(
self,
which='evening',
alt=None,
az=None,
min_counts=1000,
max_counts=12000,
target_adu_percentage=0.5,
initial_exptime=3.,
min_exptime=0.,
max_exptime=60.,
readout=5.,
camera_list=None,
bias=2048,
max_num_exposures=10,
no_tracking=True
): # pragma: no cover
self,
which='evening',
alt=None,
az=None,
min_counts=1000,
max_counts=12000,
target_adu_percentage=0.5,
initial_exptime=3.,
min_exptime=0.,
max_exptime=60.,
readout=5.,
camera_list=None,
bias=2048,
max_num_exposures=10,
no_tracking=True
): # pragma: no cover
"""Take flat fields.
This method will slew the mount to the given AltAz coordinates(which
should be roughly opposite of the setting sun) and then begin the flat-field
@@ -916,9 +916,9 @@ def take_flat_fields(
# Block until done exposing on all cameras.
flat_field_timer = CountdownTimer(exptime + readout, name='Flat Field Images')
while any(
[cam.is_observing for cam_name, cam in self.cameras.items()
if cam_name in camera_list]
):
[cam.is_observing for cam_name, cam in self.cameras.items()
if cam_name in camera_list]
):
if flat_field_timer.expired():
self.logger.warning(f'{flat_field_timer} expired while waiting for flat fields')
return
@@ -969,7 +969,7 @@ def take_flat_fields(
suggested_exptime = int(
previous_exptime * (target_adu / counts) *
(2.0 ** (sun_direction * (elapsed_time / 180.0))) + 0.5
)
)

self.logger.info(f"Suggested exptime for {cam_name}: {suggested_exptime:.02f}")

@@ -985,7 +985,7 @@ def take_flat_fields(
self.logger.info(
f"Suggested exposure time greater than max, "
f"stopping flat fields for {cam_name}"
)
)
camera_list.remove(cam_name)

self.logger.debug(f"Checking for saturation on short exposure on {cam_name}")
@@ -1005,13 +1005,13 @@ def take_flat_fields(
return

def _create_flat_field_observation(
self,
alt=70, # degrees
az=None,
field_name='FlatField',
flat_time=None,
initial_exptime=5
):
self,
alt=70, # degrees
az=None,
field_name='FlatField',
flat_time=None,
initial_exptime=5
):
"""Small convenience wrapper to create a flat-field Observation.
Flat-fields are specified by AltAz coordinates so this method is just a helper
to look up the current RA-Dec coordinates based on the unit's location and
2 changes: 1 addition & 1 deletion src/panoptes/pocs/sensor/power.py
Original file line number Diff line number Diff line change
@@ -242,7 +242,7 @@ def record(self, collection_name: str = None):
recent_values = self.readings

collection_name = collection_name or self.arduino_board_name
self.db.insert_current(collection_name, recent_values)
self.db.insert_current(collection_name, recent_values, store_permanently=False)

return recent_values

4 changes: 2 additions & 2 deletions src/panoptes/pocs/sensor/remote.py
Original file line number Diff line number Diff line change
@@ -55,11 +55,11 @@ def capture(self, store_result: bool = True) -> dict:
sensor_data['date'] = current_time(flatten=True)

if store_result and len(sensor_data) > 0:
self.db.insert_current(self.sensor_name, sensor_data)
self.db.insert_current(self.sensor_name, sensor_data, store_permanently=False)

# Make a separate power entry
if 'power' in sensor_data:
self.db.insert_current('power', sensor_data['power'])
self.db.insert_current('power', sensor_data['power'], store_permanently=False)

self.logger.debug(f'Remote data: {sensor_data}')

2 changes: 1 addition & 1 deletion src/panoptes/pocs/sensor/weather.py
Original file line number Diff line number Diff line change
@@ -58,7 +58,7 @@ def record(self):
"""Record the rolling mean of the power readings in the database."""
recent_values = self.weather_station.get_reading()

self.db.insert_current(self.collection_name, recent_values)
self.db.insert_current(self.collection_name, recent_values, store_permanently=False)

return recent_values