Skip to content

Commit

Permalink
Merge pull request #53 from winter-telescope/prebuiltcache
Browse files Browse the repository at this point in the history
Add Prebuiltcache Processor
  • Loading branch information
robertdstein authored Jul 29, 2022
2 parents c5a95c2 + f7264fb commit 5231a66
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 7 deletions.
19 changes: 19 additions & 0 deletions winterdrp/processors/base_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,25 @@ def make_image(
raise NotImplementedError


class ProcessorPremadeCache(ProcessorWithCache, ABC):

def __init__(
self,
master_image_path: str,
*args,
**kwargs
):
super().__init__(*args, **kwargs)
self.master_image_path = master_image_path

def get_cache_path(
self,
images: list[np.ndarray],
headers: list[astropy.io.fits.Header],
) -> str:
return self.master_image_path


class BaseCandidateGenerator(BaseProcessor, ImageHandler, ABC):

@classmethod
Expand Down
8 changes: 6 additions & 2 deletions winterdrp/processors/bias.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
import logging
from winterdrp.processors.base_processor import ProcessorWithCache
from winterdrp.processors.base_processor import ProcessorWithCache, ProcessorPremadeCache
from collections.abc import Callable
import astropy.io.fits
from winterdrp.processors.utils.image_selector import select_from_images
Expand Down Expand Up @@ -63,4 +63,8 @@ def make_image(
logger.info(f'Median combining {n_frames} biases')
master_bias = np.nanmedian(biases, axis=2)

return master_bias, headers[0]
return master_bias, headers[0]


class MasterBiasCalibrator(ProcessorPremadeCache, BiasCalibrator):
pass
6 changes: 5 additions & 1 deletion winterdrp/processors/dark.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import logging
import pandas as pd
from collections.abc import Callable
from winterdrp.processors.base_processor import ProcessorWithCache
from winterdrp.processors.base_processor import ProcessorWithCache, ProcessorPremadeCache
from winterdrp.paths import base_name_key
from winterdrp.processors.utils.image_selector import select_from_images

Expand Down Expand Up @@ -70,3 +70,7 @@ def make_image(
master_dark = np.nanmedian(darks, axis=2)

return master_dark, headers[0]


class MasterDarkCalibrator(ProcessorPremadeCache, DarkCalibrator):
pass
5 changes: 3 additions & 2 deletions winterdrp/processors/flat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import numpy as np
import logging
import sys
from winterdrp.processors.base_processor import ProcessorWithCache
from winterdrp.processors.base_processor import ProcessorWithCache, ProcessorPremadeCache
from winterdrp.processors.utils.image_selector import select_from_images
from collections.abc import Callable
from winterdrp.paths import latest_save_key, flat_frame_key
Expand Down Expand Up @@ -103,7 +103,8 @@ def select_sky_flat(
) -> tuple[list[np.ndarray], list[astropy.io.fits.Header]]:
return select_from_images(images, headers, header_key="obsclass", target_values="science")


class MasterFlatCalibrator(ProcessorPremadeCache, FlatCalibrator):
pass
# class OldSkyFlatCalibrator(SkyFlatCalibrator):
#
# def select_cache_images(
Expand Down
5 changes: 3 additions & 2 deletions winterdrp/processors/sky.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pandas as pd
from collections.abc import Callable
from astropy.time import Time
from winterdrp.processors.base_processor import ProcessorWithCache
from winterdrp.processors.base_processor import ProcessorWithCache, ProcessorPremadeCache
from winterdrp.processors.flat import SkyFlatCalibrator
from winterdrp.paths import cal_output_dir, saturate_key

Expand Down Expand Up @@ -42,7 +42,8 @@ def _apply_to_images(

return images, headers


class MasterSkyCalibrator(ProcessorPremadeCache, NightSkyMedianCalibrator):
pass
# class OldNightSkyMedianCalibrator(
# NightSkyMedianCalibrator,
# OldSkyFlatCalibrator
Expand Down

0 comments on commit 5231a66

Please sign in to comment.