Skip to content

Commit

Permalink
Add monitor test
Browse files Browse the repository at this point in the history
  • Loading branch information
robertdstein committed Nov 19, 2022
1 parent a473cd3 commit 81df277
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
6 changes: 4 additions & 2 deletions winterdrp/monitor/base_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def postprocess(self):
if self.postprocess_configurations is not None:

postprocess_config = [ImageLoader(
load_image=self.pipeline.load_raw_image,
load_image=self.pipeline.unpack_raw_image,
input_sub_dir=self.sub_dir,
input_img_dir=str(Path(self.raw_image_directory)).split(self.pipeline_name)[0]
)]
Expand All @@ -292,6 +292,7 @@ def postprocess(self):
self.latest_csv_log = processor.get_output_path()

_, errorstack = self.pipeline.reduce_images(
dataset=Dataset(ImageBatch()),
selected_configurations=protected_key,
catch_all_errors=True
)
Expand Down Expand Up @@ -352,13 +353,14 @@ def process_load_queue(self, q):

is_science = img["OBSCLASS"] == "science"

all_img = ImageBatch([img] + copy.deepcopy(self.cal_images))
all_img = ImageBatch(img) + copy.deepcopy(self.cal_images)

if not is_science:
print(f"Skipping {event.src_path} (calibration image)")
else:
print(f"Reducing {event.src_path} (science image) on thread {threading.get_ident()}")
_, errorstack = self.pipeline.reduce_images(
dataset=Dataset(all_img),
selected_configurations=self.realtime_configurations,
catch_all_errors=True
)
Expand Down
3 changes: 3 additions & 0 deletions winterdrp/pipelines/base_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ def load_raw_image(self, path: str) -> Image:
data, header = self._load_raw_image(path)
return Image(data=data, header=header)

def unpack_raw_image(self, path: str) -> tuple[np.ndarray, astropy.io.fits.Header]:
return self._load_raw_image(path)

@staticmethod
def configure_processors(
processors: list[BaseProcessor],
Expand Down
2 changes: 1 addition & 1 deletion winterdrp/processors/utils/image_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(
self,
input_sub_dir: str = raw_img_sub_dir,
input_img_dir: str = base_raw_dir,
load_image: Callable = open_fits,
load_image: Callable[[str], [np.ndarray, astropy.io.fits.Header]] = open_fits,
*args,
**kwargs
):
Expand Down
4 changes: 1 addition & 3 deletions winterdrp/processors/utils/simulate_realtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,12 @@ def _apply_to_images(

img_path = self.input_img_dir.joinpath(image_name)

logger.info(img_path)

output_path = Path(get_output_dir(
dir_root=self.output_dir_name,
sub_dir=self.night_sub_dir,
output_dir=self.output_dir
))
logger.info(output_path)
logger.debug(f"Copying {img_path} to {output_path}")

if not output_path.exists():
output_path.mkdir(parents=True)
Expand Down

0 comments on commit 81df277

Please sign in to comment.