def __init__(self, name: Optional[str] = None, label: Optional[str] = None, **kwargs: Any): """ Args: name: Name of module. If None, ID from comm object is used. label: Label for module. If None, name is used. """ Object.__init__(self, **kwargs) # get list of client interfaces self._interfaces: List[Type[Interface]] = [] self._methods: Dict[str, Tuple[Callable[..., Any], inspect.Signature]] = {} self._get_interfaces_and_methods() # get configuration caps, i.e. all parameters from c'tor self._config_caps = self._get_config_caps() # name and label self._device_name = name if name is not None else self.comm.name self._label = label if label is not None else self._device_name # state self._state = ModuleState.READY self._error_string = ""
def __init__(self, world: SimWorld, position: Tuple[float, float] = None, offsets: Tuple[float, float] = None, pointing_offset: Tuple[float, float] = None, move_accuracy: float = 2., speed: float = 20., focus: float = 50, filters: List[str] = None, filter: str = 'clear', drift: Tuple[float, float] = None, focal_length: float = 5000., *args, **kwargs): """Initializes new telescope. Args: world: World object. position: RA/Dec tuple with position of telescope in degrees. offsets: RA/Dec offsets of telescope in arcsecs. pointing_offset: Pointing offset in RA/Dec in arcsecs. move_accuracy: Accuracy of movements in RA/Dec, i.e. random error after any movement [arcsec]. speed: Speed of telescope in deg/sec. focus: Telescope focus. filters: List of filters. filter: Current filter. drift: RA/Dec drift of telescope in arcsec/sec. focal_length: Focal length of telescope in mm. """ Object.__init__(self, *args, **kwargs) # store self.world = world self.status = IMotion.Status.IDLE self.status_callback = None # init self._position = SkyCoord(0. * u.deg, 0. * u.deg, frame='icrs') if position is None else \ SkyCoord(position[0] * u.deg, position[1] * u.deg, frame='icrs') self._offsets = (0., 0.) if offsets is None else offsets self.pointing_offset = ( 20., 2.) if pointing_offset is None else pointing_offset self.move_accuracy = (1, 1) if move_accuracy is None else move_accuracy self.speed = speed # telescope speed in deg/sec self.focus = focus self.filters = ['clear', 'B', 'V', 'R'] if filters is None else filters self.filter = filter self.drift = ( 0.01, 0.0001) if drift is None else drift # arcsec/sec in RA/Dec self.focal_length = focal_length # private stuff self._drift = (0., 0.) self._dest_coords = None # locks self._pos_lock = threading.RLock() # threads self._add_thread_func(self._move_thread)
def __init__(self, steps: List[Union[Dict[str, Any], ImageProcessor]], **kwargs: Any): """Pipeline for science images. Args: steps: List of pipeline steps to perform. """ Object.__init__(self, **kwargs) PipelineMixin.__init__(self, steps)
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
def __init__(self, configuration: Any, task_archive: TaskArchive, **kwargs: Any): """Init Script. Args: comm: Comm object to use observer: Observer to use """ Object.__init__(self, **kwargs) # store self.exptime_done: float = 0.0 self.configuration = configuration self.task_archive = task_archive
def __init__( self, time: Optional[Union[Time, str]] = None, telescope: Optional[Union["SimTelescope", Dict[str, Any]]] = None, camera: Optional[Union["SimCamera", Dict[str, Any]]] = None, **kwargs: Any, ): """Initializes a new simulated world. Args: time: Time at start of simulation. telescope: Telescope to use. camera: Camera to use. observer: Observer to use. *args: **kwargs: """ from .camera import SimCamera from .telescope import SimTelescope Object.__init__(self, **kwargs) # get start time if time is None: time = Time.now() elif isinstance(time, str): time = Time(time) # calculate time offset self.time_offset = time - Time.now() # get telescope if telescope is None: self.telescope = SimTelescope(world=self) elif isinstance(telescope, SimTelescope): self.telescope = telescope elif isinstance(telescope, dict): self.telescope = create_object(telescope, world=self) else: raise ValueError("Invalid telescope.") # get camera if camera is None: self.camera = SimCamera(world=self) elif isinstance(camera, SimCamera): self.camera = camera elif isinstance(camera, dict): self.camera = create_object(camera, world=self) else: raise ValueError("Invalid camera.")
def __init__(self, host: str, port: int, username: str, password: str, **kwargs: Any): """ Create new driver. """ Object.__init__(self, **kwargs) # init some stuff self._host = host self._port = port self._username = username self._password = password self._filters: List[str] = [] self.protocol: Optional[PilarClientProtocol] = None # errors self._has_error = False self._error_thread = None # background tasks self.add_background_task(self._error_background_task)
def __init__( self, world: "SimWorld", image_size: Optional[Tuple[int, int]] = None, pixel_size: float = 0.015, images: Optional[str] = None, max_mag: float = 20.0, seeing: float = 3.0, **kwargs: Any, ): """Inits a new camera. Args: world: World to use. image_size: Size of image. pixel_size: Square pixel size in mm. images: Filename pattern (e.g. /path/to/*.fits) for files to return instead of simulated images. max_mag: Maximum magnitude for sim. seeing: Seeing in arcsec. """ Object.__init__(self, **kwargs) # store self.world = world self.telescope = world.telescope self.full_frame: Tuple[int, int, int, int] = ( (0, 0, image_size[0], image_size[1]) if image_size is not None else (0, 0, 512, 512) ) self.window = self.full_frame self.binning = (1, 1) self.pixel_size = pixel_size self.image_format = ImageFormat.INT16 self.images = ( [] if images is None else sorted(glob.glob(images)) if "*" in images or "?" in images else [images] ) self._max_mag = max_mag self._seeing = seeing # private stuff self._catalog = None self._catalog_coords = None
def __init__(self, name: str = None, label: str = None, comm: Union[Comm, dict] = None, *args, **kwargs): """Initializes a new pyobs module. Args: name: Name of module. If None, ID from comm object is used. label: Label for module. If None, name is used. comm: Comm object to use """ Object.__init__(self, *args, **kwargs) # get list of client interfaces self._interfaces: List[Type] = [] self._methods: Dict[str, Tuple[Callable, inspect.Signature]] = {} self._get_interfaces_and_methods() # get configuration options, i.e. all parameters from c'tor self._config_options = self._get_config_options() # comm object self.comm: Comm if comm is None: self.comm = DummyComm() elif isinstance(comm, Comm): self.comm = comm elif isinstance(comm, dict): log.info('Creating comm object...') self.comm = get_object(comm) else: raise ValueError('Invalid Comm object') # name and label self._name: str = name if name is not None else self.comm.name self._label: str = label if label is not None else self._name
def __init__(self, world: SimWorld, pixel_size: float = 0.015, *args, **kwargs): """Inits a new camera. Args: world: World to use. pixel_size: Square pixel size in mm. """ Object.__init__(self, *args, **kwargs) # store self.world = world self.telescope = world.telescope self.full_frame = (0, 0, 512, 512) self.window = (0, 0, 512, 512) self.binning = (1, 1) self.pixel_size = pixel_size # private stuff self._catalog = None self._catalog_coords = None
def __init__(self, **kwargs: Any): """Init new image processor.""" Object.__init__(self, **kwargs)
def __init__(self, tasks: "TaskArchive", **kwargs: Any): Object.__init__(self, **kwargs) self.task_archive = tasks
def __init__(self, *args, **kwargs): Object.__init__(self, *args, **kwargs)
def __init__( self, functions: Union[str, Dict[str, Union[str, Dict[str, str]]]], target_count: float = 30000, min_exptime: float = 0.5, max_exptime: float = 5, test_frame: Optional[Tuple[float, float, float, float]] = None, counts_frame: Optional[Tuple[float, float, float, float]] = None, allowed_offset_frac: float = 0.2, min_counts: int = 100, pointing: Optional[Union[Dict[str, Any], SkyFlatsBasePointing]] = None, callback: Optional[Callable[..., Coroutine[Any, Any, None]]] = None, **kwargs: Any, ): """Initialize a new flat fielder. Args: functions: Function f(h) for each filter to describe ideal exposure time as a function of solar elevation h, i.e. something like exp(-0.9*(h+3.9)). See ExpTimeEval for details. target_count: Count rate to aim for. min_exptime: Minimum exposure time. max_exptime: Maximum exposure time. test_frame: Tupel (left, top, width, height) in percent that describe the frame for on-sky testing. counts_frame: Tupel (left, top, width, height) in percent that describe the frame for calculating mean count rate. allowed_offset_frac: Offset from target_count (given in fraction of it) that's still allowed for good flat-field min_counts: Minimum counts in frames. observer: Observer to use. vfs: VFS to use. callback: Callback function for statistics. """ Object.__init__(self, **kwargs) # store stuff self._target_count = target_count self._min_exptime = min_exptime self._max_exptime = max_exptime self._test_frame = (45, 45, 10, 10) if test_frame is None else test_frame self._counts_frame = (25, 25, 75, 75) if counts_frame is None else counts_frame self._allowed_offset_frac = allowed_offset_frac self._min_counts = min_counts self._callback = callback # parse function self._eval = ExpTimeEval(self.observer, functions) # abort event self._abort = asyncio.Event() # pointing self._pointing: Optional[SkyFlatsBasePointing] = self.get_safe_object( pointing, SkyFlatsBasePointing) # state machine self._state = FlatFielder.State.INIT # current exposure time self._exptime = 0.0 # median of last image self._median = 0.0 # exposures to do self._exposures_total = 0 self._exposures_done = 0 self._exptime_done = 0.0 # bias level self._bias_level = 0.0 # which twilight are we in? just init something self._twilight = FlatFielder.Twilight.DAWN # current request self._cur_filter: Optional[str] = None self._cur_binning: Tuple[int, int] = (1, 1)