예제 #1
0
    def __init__(self, telescope: Union[str, ITelescope], camera: Union[str, ICamera],
                 filters: Union[str, IFilters], flat_fielder: Union[dict, FlatFielder],
                 log_file: str = None, *args, **kwargs):
        """Initialize a new flat fielder.

        Args:
            telescope: Name of ITelescope.
            camera: Name of ICamera.
            filters: Name of IFilters, if any.
            pointing: Pointing to use.
            log_file: Name of file to store flat field log in.
        """
        Module.__init__(self, *args, **kwargs)

        # store telescope, camera, and filters
        self._telescope = telescope
        self._camera = camera
        self._filters = filters
        self._abort = threading.Event()

        # flat fielder
        self._flat_fielder = get_object(flat_fielder, FlatFielder, vfs=self.vfs,
                                        observer=self.observer, callback=self.callback)

        # init log file
        self._publisher = None if log_file is None else CsvPublisher(log_file)
예제 #2
0
    def __init__(self, telescope: Union[str, ITelescope], camera: Union[str, ICamera],
                 target_pixel: Tuple = None, attempts: int = 5, tolerance: float = 1,
                 max_offset: float = 120, log_file: str = None, *args, **kwargs):
        """Create a new base acquisition.

        Args:
            telescope: Name of ITelescope.
            camera: Name of ICamera.
            target_pixel: (x, y) tuple of pixel that the star should be positioned on. If None, center of image is used.
            attempts: Number of attempts before giving up.
            tolerance: Tolerance in position to reach in arcsec.
            max_offset: Maximum offset to move in arcsec.
            log_file: Name of file to write log to.
        """
        Module.__init__(self, *args, **kwargs)

        # store telescope and camera
        self._telescope = telescope
        self._camera = camera

        # store
        self._target_pixel = target_pixel
        self._attempts = attempts
        self._tolerance = tolerance
        self._max_offset = max_offset

        # init log file
        self._publisher = CsvPublisher(log_file)

        # init camera settings mixin
        CameraSettingsMixin.__init__(self, *args, **kwargs)
예제 #3
0
    def __init__(self,
                 log_file: Optional[str] = None,
                 log_absolute: bool = False,
                 **kwargs: Any):
        Object.__init__(self, **kwargs)

        # init log file
        self._publisher = None if log_file is None else CsvPublisher(log_file)
        self._log_absolute = log_absolute
예제 #4
0
    def __init__(self,
                 camera: Union[str, ICamera],
                 telescope: Union[str, ITelescope],
                 offsets: Union[dict, BaseGuidingOffset],
                 max_offset: float = 30,
                 max_exposure_time: float = None,
                 min_interval: float = 0,
                 max_interval: float = 600,
                 separation_reset: float = None,
                 pid: bool = False,
                 log_file: str = None,
                 *args,
                 **kwargs):
        """Initializes a new science frame auto guiding system.

        Args:
            telescope: Telescope to use.
            offsets: Auto-guider to use
            max_offset: Max offset in arcsec to move.
            max_exposure_time: Maximum exposure time in sec for images to analyse.
            min_interval: Minimum interval in sec between two images.
            max_interval: Maximum interval in sec between to consecutive images to guide.
            separation_reset: Min separation in arcsec between two consecutive images that triggers a reset.
            pid: Whether to use a PID for guiding.
            log_file: Name of file to write log to.
        """
        Module.__init__(self, *args, **kwargs)

        # store
        self._camera = camera
        self._telescope = telescope
        self._enabled = False
        self._max_offset = max_offset
        self._max_exposure_time = max_exposure_time
        self._min_interval = min_interval
        self._max_interval = max_interval
        self._separation_reset = separation_reset
        self._pid = pid
        self._loop_closed = False

        # headers of last and of reference image
        self._last_header = None
        self._ref_header = None

        # create auto-guiding system
        self._guiding_offset = get_object(offsets, BaseGuidingOffset)

        # init log file
        self._publisher = None if log_file is None else CsvPublisher(log_file)
예제 #5
0
    def __init__(
        self,
        exposure_time: float,
        target_pixel: Optional[Tuple[float, float]] = None,
        attempts: int = 5,
        tolerance: float = 1,
        max_offset: float = 120,
        log_file: Optional[str] = None,
        **kwargs: Any,
    ):
        """Create a new acquisition.

        Args:
            exposure_time: Default exposure time.
            target_pixel: (x, y) tuple of pixel that the star should be positioned on. If None, center of image is used.
            attempts: Number of attempts before giving up.
            tolerance: Tolerance in position to reach in arcsec.
            max_offset: Maximum offset to move in arcsec.
            log_file: Name of file to write log to.
        """
        BasePointing.__init__(self, **kwargs)

        # store
        self._default_exposure_time = exposure_time
        self._is_running = False
        self._target_pixel = target_pixel
        self._attempts = attempts
        self._tolerance = tolerance * u.arcsec
        self._max_offset = max_offset * u.arcsec

        # init log file
        self._publisher = CsvPublisher(
            log_file) if log_file is not None else None

        # init camera settings mixin
        CameraSettingsMixin.__init__(self, **kwargs)
예제 #6
0
    def __init__(self,
                 focuser: str = None,
                 weather: str = None,
                 interval: int = 300,
                 temperatures: dict = None,
                 model: str = None,
                 coefficients: dict = None,
                 update: bool = False,
                 log_file: str = None,
                 min_measurements: int = 10,
                 enabled: bool = True,
                 temp_sensor: str = 'average.temp',
                 default_filter: str = None,
                 filter_offsets: dict = None,
                 filter_wheel: str = None,
                 *args,
                 **kwargs):
        """Initialize a focus model.

        Args:
            focuser: Name of focuser.
            weather: Name of weather station.
            interval: Interval for setting focus or None, if no regular setting of focus is required.
            model: Focus model to use.
            coefficients: Coefficients in model, mainly used when updating it.
            update: Whether to update the model on new focus values.
            log_file: Path to file containing all focus measurements.
            min_measurements: Minimum number of measurements to update model.
            enabled: If False, no focus is set.
            temp_sensor: Name of sensor at weather station to provide ambient temperature.
            default_filter: Name of default filter. If None, filters are ignored.
            filter_offsets: Offsets for different filters. If None, they are not modeled.
            filter_wheel: Name of filter wheel module to use for fetching filter before setting focus.
        """
        Module.__init__(self, *args, **kwargs)

        # check import
        import lmfit

        # add thread func
        if interval is not None and interval > 0:
            self._add_thread_func(self._run_thread, True)

        # store
        self._focuser = focuser
        self._weather = weather
        self._interval = interval
        self._temperatures = temperatures = {} if temperatures is None else temperatures
        self._focuser_ready = True
        self._coefficients = {} if coefficients is None else coefficients
        self._update_model = update
        self._min_measurements = min_measurements
        self._enabled = enabled
        self._temp_station, sensor = temp_sensor.split('.')
        self._temp_sensor = IWeather.Sensors(sensor)
        self._default_filter = default_filter
        self._filter_offsets = filter_offsets
        self._filter_wheel = filter_wheel
        log.info('Going to fetch temperature from sensor %s at station %s.',
                 self._temp_sensor, self._temp_station)

        # model
        parser = Parser()
        log.info('Parsing model: %s', model)
        self._model = parser.parse(model)

        # coefficients
        if self._coefficients is not None and len(self._coefficients) > 0:
            log.info(
                'Found coefficients: %s', ', '.join([
                    '%s=%.3f' % (k, v) for k, v in self._coefficients.items()
                ]))

        # variables
        variables = self._model.variables()
        for c in self._coefficients.keys():
            variables.remove(c)
        log.info('Found variables: %s', ', '.join(variables))

        # init log file
        self._publisher = None if log_file is None else CsvPublisher(log_file)

        # update model now?
        if update:
            self._calc_focus_model()
예제 #7
0
    def __init__(
        self,
        telescope: Union[str, ITelescope],
        camera: Union[str, ICamera],
        flat_fielder: Optional[Union[Dict[str, Any], FlatFielder]],
        filters: Optional[Union[str, IFilters]] = None,
        log_file: Optional[str] = None,
        **kwargs: Any,
    ):
        """Initialize a new flat fielder.

        Args:
            telescope: Name of ITelescope.
            camera: Name of ICamera.
            flat_fielder: Flat field object to use.
            filters: Name of IFilters, if any.
            log_file: Name of file to store flat field log in.
        """
        Module.__init__(self, **kwargs)

        # store telescope, camera, and filters
        self._telescope = telescope
        self._camera = camera
        self._filter_wheel = filters
        self._abort = asyncio.Event()
        self._running = False

        # flat fielder
        self._flat_fielder = self.get_object(flat_fielder,
                                             FlatFielder,
                                             callback=self.callback)

        # init log file
        self._publisher = None if log_file is None else CsvPublisher(log_file)

        # init binning and filter
        self._binning = (1, 1)
        self._filter: Optional[str] = None

        # need to add IFilters interface?
        if self._filter_wheel is not None:
            # check filters
            if not self._flat_fielder.has_filters:
                raise ValueError(
                    "Filter wheel module given in config, but no filters in functions."
                )

            # add it
            # self.__class__ = type('FlatFieldFilter', (FlatField, IFilters), {})

        # register exceptions
        if isinstance(camera, str):
            exc.register_exception(
                exc.RemoteError,
                3,
                timespan=600,
                module=camera,
                callback=self._default_remote_error_callback)
        if isinstance(telescope, str):
            exc.register_exception(
                exc.RemoteError,
                3,
                timespan=600,
                module=telescope,
                callback=self._default_remote_error_callback)
        if isinstance(filters, str):
            exc.register_exception(
                exc.RemoteError,
                3,
                timespan=600,
                module=filters,
                callback=self._default_remote_error_callback)