solys2.automation package

solys2.automation.autohelper module

AutoHelper

Module that contains the functionalities that are used for performing automatic actions with the Solys2.

It exports the following functions:
  • get_body_calculator : Obtain the BodyCalculator object corresponding to the given parameters.

  • check_time_solys : Check the solys internal time against the computer time and log an info or warning message if necessary.

  • wait_position_reached : Waits until the solys is approx. pointing at the given position.

  • read_and_move : Reads some information from the solys and writes it down to the logger.

Then it moves it to a position using the given position function and parameters.
  • exception_tracking : When an execution fails and must end a set of actions must be taken in order to communicate it and synchronize it.

class solys2.automation.autohelper.AutomationWorker

Bases: abc.ABC

abstract is_finished() bool

Check if the thread has successfully finished executing.

abstract start()

Start the automatic process in the thread.

abstract stop()

Stop the automatic thread, although not immediately.

solys2.automation.autohelper.check_time_solys(solys: solys2.solys2.Solys2, logger: logging.Logger)

Check the solys internal time against the computer time and log an info or warning message if necessary.

Parameters
  • solys (solys2.Solys2) – Solys2 which time is wanted to be checked agains computer time.

  • logger (logging.Logger) – Logger that will log out the log messages.

solys2.automation.autohelper.exception_tracking(logger: logging.Logger, e: Exception, solys: solys2.solys2.Solys2, is_finished: solys2.common.ContainedBool)

When an execution fails and must end a set of actions must be taken in order to communicate it and synchronize it.

Parameters
  • logger (logging.Logger) – Logger that will log out the log messages

  • e (Exception) – Exception that stopped the execution

  • solys (Solys2) – Connected Solys2

  • is_finished – Container for the boolean value that initially was False, but it should be changed to True when exiting the function.

solys2.automation.autohelper.get_body_calculator(solys: solys2.solys2.Solys2, library: solys2.automation.positioncalc._BodyLibrary, logger: logging.Logger, altitude: float = 0, kernels_path: str = './kernels') solys2.automation.positioncalc.BodyCalculator

Obtain the BodyCalculator corresponding to the given parameters.

Parameters
  • solys (solys2.Solys2) – Solys2 instance that will be used to send de messages with.

  • library (_BodyLibrary) – Body library that will be used to track the body. Moon or Sun.

  • logger (logging.Logger) – Logger that will log out the log messages

  • altitude (float) – Altitude in meters of the observer point. Used only if SPICE library is selected.

  • kernels_path (str) – Directory where the needed SPICE kernels are stored. Used only if SPICE library is selected.

Returns

calc – Calculator that will be able to calculate the position of the body for a given date.

Return type

BodyCalculator

solys2.automation.autohelper.read_and_move(solys: solys2.solys2.Solys2, body_calc: solys2.automation.positioncalc.BodyCalculator, logger: logging.Logger, offset: Tuple[float, float] = (0, 0), datetime_offset: float = 0)

Reads some information from the solys and writes it down to the logger. Then it moves it to a position using the given position function and parameters.

Parameters
  • solys (solys2.Solys2) – Solys2 in which to perform the read and move actions.

  • body_calc (BodyCalculator) – Calculator that will be able to calculate the position of the body for a given date.

  • logger (logging.Logger) – Logger that will log out the log messages.

  • offset (tuple of 2 floats.) – It will move to the calculated position + some optional offset in degrees. (azimuth_offset, zenith_offset). By default (0,0).

  • datetime_offset (float) – Offset of seconds that the body positions will be calculated, added to currrent time.

solys2.automation.autohelper.wait_position_reached(solys: solys2.solys2.Solys2, az: float, ze: float, logger: logging.Logger)

Waits until the solys is approx. pointing at the given position.

Parameters
  • solys (solys2.Solys2) – Solys2 that will eventually point to the given position.

  • az (float) – Azimuth of the position.

  • ze (float) – Zenith of the position.

  • logger (logging.Logger) – Logger that will log out the log messages.

solys2.automation.autotrack module

AutoTrack

Module that contains the functionalities of performing automatic actions with the Solys2.

It exports the following classes:
  • MoonTracker : Object that contains the thread that controls the Solys2 for tracking automatically the Moon.

  • SunTracker : Object that contains the thread that controls the Solys2 for tracking automatically the Sun.

class solys2.automation.autotrack.MoonTracker(ip: str, seconds: float, port: int = 15000, password: str = 'solys', logger: Optional[logging.Logger] = None, library: solys2.automation.positioncalc.MoonLibrary = MoonLibrary.EPHEM_MOON, altitude: float = 0, kernels_path: str = './kernels', solys_delay: float = 5, inst_callback: Optional[Callable] = None, instrument_delay: float = 2)

Bases: solys2.automation.autotrack._BodyTracker

Object that when created will create a thread executing the function of controlling the Solys2 so it tracks the Moon.

class solys2.automation.autotrack.SunTracker(ip: str, seconds: float, port: int = 15000, password: str = 'solys', logger: Optional[logging.Logger] = None, library: solys2.automation.positioncalc.SunLibrary = SunLibrary.PYSOLAR, altitude: float = 0, kernels_path: str = './kernels', solys_delay: float = 5, inst_callback: Optional[Callable] = None, instrument_delay: float = 2)

Bases: solys2.automation.autotrack._BodyTracker

Object that when created will create a thread executing the function of controlling the Solys2 so it tracks the Sun.

solys2.automation.calibration module

Calibration

This module contains the functionalities related to different calibration methods, most of them used by the GOA-UVa.

It exports the following classes:
  • LunarCross : Object that when created will create a thread executing the function of controlling the Solys2 so it performs a cross over the Moon.

  • SolarCross : Object that when created will create a thread executing the function of controlling the Solys2 so it performs a cross over the Sun.

  • LunarMesh : Object that when created will create a thread executing the function of controlling the Solys2 so it performs a mesh over the Moon.

  • SolarMesh : Object that when created will create a thread executing the function of controlling the Solys2 so it performs a mesh over the Sun.

It exports the following functions:
  • black_moon : Perform a black for the moon. Point to a position where the moon is not present so the noise can be calculated. (Opposite azimuth and zenith = 45).

class solys2.automation.calibration.CalibrationParameters(azimuth_min_offset: float, azimuth_max_offset: float, azimuth_step: float, zenith_min_offset: float, zenith_max_offset: float, zenith_step: float, countdown: int, post_wait: int)

Bases: object

Parameters needed when performing a cross or a mesh over a Body.

The offset attributes will define the interval that will be per

azimuth_min_offset

Minimum value of azimuth offset in degrees. Included in the interval.

Type

float

azimuth_max_offset

Maximum value of azimuth offset in degrees. Included in the interval.

Type

float

azimuth_step

Amount of degrees that are between each azimuth cross point.

Type

float

zenith_min_offset

Minimum value of zenith offset in degrees. Included in the interval.

Type

float

zenith_max_offset

Maximum value of zenith offset in degrees. Included in the interval.

Type

float

zenith_step

Amount of degrees that are between each zenith cross point.

Type

float

countdown

Amount of seconds that the Solys2 will wait before the ASD is calculated, logging a countdown in level INFO following the format “COUNTDOWN:<value>”, and the value will go from the initial countdown value to 0, unless the given solys delays are not sufficient, in which case the countdown will be reduced for every second that it has been delayed in excess.

Type

float

post_wait

Amount of seconds that the Solys2 will wait after the ASD has been calculated.

Type

float

azimuth_max_offset: float
azimuth_min_offset: float
azimuth_step: float
countdown: int
post_wait: int
zenith_max_offset: float
zenith_min_offset: float
zenith_step: float
class solys2.automation.calibration.LunarCross(ip: str, cross_params: solys2.automation.calibration.CalibrationParameters, library: solys2.automation.positioncalc.MoonLibrary = MoonLibrary.EPHEM_MOON, logger: Optional[logging.Logger] = None, port: int = 15000, password: str = 'solys', altitude: float = 0, kernels_path: str = './kernels', solys_delay: float = 5, solys_delay_margin: float = 2, instrument_delay: float = 2, inst_callback: Optional[Callable] = None)

Bases: solys2.automation.calibration._BodyCross

Object that when created will create a thread executing the function of controlling the Solys2 so it performs a cross over the Moon.

class solys2.automation.calibration.LunarMesh(ip: str, mesh_params: solys2.automation.calibration.CalibrationParameters, library: solys2.automation.positioncalc.MoonLibrary = MoonLibrary.EPHEM_MOON, logger: Optional[logging.Logger] = None, port: int = 15000, password: str = 'solys', altitude: float = 0, kernels_path: str = './kernels', solys_delay: float = 5, solys_delay_margin: float = 2, instrument_delay: float = 2, inst_callback: Optional[Callable] = None)

Bases: solys2.automation.calibration._BodyMesh

Object that when created will create a thread executing the function of controlling the Solys2 so it performs a mesh/matrix over the Moon.

class solys2.automation.calibration.SolarCross(ip: str, cross_params: solys2.automation.calibration.CalibrationParameters, library: solys2.automation.positioncalc.SunLibrary = SunLibrary.PYSOLAR, logger: Optional[logging.Logger] = None, port: int = 15000, password: str = 'solys', altitude: float = 0, kernels_path: str = './kernels', solys_delay: float = 5, solys_delay_margin: float = 2, instrument_delay: float = 2, inst_callback: Optional[Callable] = None)

Bases: solys2.automation.calibration._BodyCross

Object that when created will create a thread executing the function of controlling the Solys2 so it performs a cross over the Sun.

class solys2.automation.calibration.SolarMesh(ip: str, mesh_params: solys2.automation.calibration.CalibrationParameters, library: solys2.automation.positioncalc.SunLibrary = SunLibrary.PYSOLAR, logger: Optional[logging.Logger] = None, port: int = 15000, password: str = 'solys', altitude: float = 0, kernels_path: str = './kernels', solys_delay: float = 5, solys_delay_margin: float = 2, instrument_delay: float = 2, inst_callback: Optional[Callable] = None)

Bases: solys2.automation.calibration._BodyMesh

Object that when created will create a thread executing the function of controlling the Solys2 so it performs a mesh/matrix over the Sun.

solys2.automation.calibration.black_moon(ip: str, logger: logging.Logger, port: int = 15000, password: str = 'solys', is_finished: Optional[solys2.common.ContainedBool] = None, library: solys2.automation.positioncalc.MoonLibrary = MoonLibrary.EPHEM_MOON, altitude: float = 0, kernels_path: str = './kernels')

Perform a black for the moon. Point to a position where the moon is not present so the noise can be calculated. (Opposite azimuth and zenith = 45)

Parameters
  • ip (str) – IP of the solys.

  • logger (logging.Logger) – Logger that will log out the log messages

  • port (int) – Access port. By default 15000.

  • password (str) – Ethernet user password. By default is “solys”.

  • is_finished (ContainedBool) – Container for the boolean value that initially will be False, but it should be changed to True when exiting the function.

  • library (MoonLibrary) – Lunar library that will be used to track the Moon. By default is ephem.

  • altitude (float) – Altitude in meters of the observer point. Used only if SPICE library is selected.

  • kernels_path (str) – Directory where the needed SPICE kernels are stored. Used only if SPICE library is selected.

solys2.automation.positioncalc module

Position Calc

Module that contains the objects that allow the calculation of the position of the moon and the sun using different libraries, like ephem, pysolar or SPICE (spicedmoon and spicedsun).

It exports the following classes:
  • MoonLibrary : Enum that contains all available moon calculation libraries.

  • SunLibrary : Enum that contains all available sun calculation libraries.

  • BodyCalculator : Abstract class of an object that calculates a celestial body’s zenith and azimuth for a given location at a given datetime.

  • MoonCalculator : Abstract class of an object that calculates the lunar zenith and azimuth for a given location at a given datetime.

  • SunCalculator : Abstract class of an object that calculates the solar zenith and azimuth for a given location at a given datetime.

  • PylunarMoonCalc : Object that calculates the lunar zenith and azimuth for a given location at a given datetime, using pylunar library.

  • EphemMoonCalc : Object that calculates the lunar zenith and azimuth for a given location at a given datetime, using ephem library.

  • SpiceMoonCalc : Object that calculates the lunar zenith and azimuth for a given location at a given datetime, using spicedmoon (SPICE) library.

  • PysolarSunCalc : Object that calculates the solar zenith and azimuth for a given location at a given datetime, using pysolar library.

  • EphemSunCalc : Object that calculates the solar zenith and azimuth for a given location at a given datetime, using ephem library.

  • SpiceSunCalc : Object that calculates the solar zenith and azimuth for a given location at a given datetime, using spicedsun (SPICE) library.

class solys2.automation.positioncalc.BodyCalculator(lat: float, lon: float)

Bases: abc.ABC

Object that calculates a celestial body’s zenith and azimuth for a given location at a given datetime.

abstract get_position(dt: datetime.datetime) Tuple[float, float]

Obtain body’s azimuth and zenith.

Parameters

dt (datetime.datetime) – Datetime at which the body’s position will be calculated.

Returns

  • azimuth (float) – Body’s azimuth calculated.

  • zenith (float) – Body’s zenith calculated.

class solys2.automation.positioncalc.EphemMoonCalc(lat: float, lon: float)

Bases: solys2.automation.positioncalc.MoonCalculator

Object that calculates the lunar zenith and azimuth for a given location at a given datetime, using ephem library.

get_position(dt: datetime.datetime) Tuple[float, float]

Obtain lunar azimuth and zenith.

Parameters

dt (datetime.datetime) – Datetime at which the lunar position will be calculated.

Returns

  • azimuth (float) – Lunar azimuth calculated.

  • zenith (float) – Lunar zenith calculated.

class solys2.automation.positioncalc.EphemSunCalc(lat: float, lon: float)

Bases: solys2.automation.positioncalc.SunCalculator

Object that calculates the solar zenith and azimuth for a given location at a given datetime, using ephem library.

get_position(dt: datetime.datetime) Tuple[float, float]

Obtain solar azimuth and zenith.

Parameters

dt (datetime.datetime) – Datetime at which the solar position will be calculated.

Returns

  • azimuth (float) – Solar azimuth calculated.

  • zenith (float) – Solar zenith calculated.

class solys2.automation.positioncalc.MoonCalculator(lat: float, lon: float)

Bases: solys2.automation.positioncalc.BodyCalculator

Object that calculates the lunar zenith and azimuth for a given location at a given datetime.

abstract get_position(dt: datetime.datetime) Tuple[float, float]

Obtain lunar azimuth and zenith.

Parameters

dt (datetime.datetime) – Datetime at which the lunar position will be calculated.

Returns

  • azimuth (float) – Lunar azimuth calculated.

  • zenith (float) – Lunar zenith calculated.

class solys2.automation.positioncalc.MoonLibrary(value)

Bases: enum.Enum

Enum that represents the library that can be used for calculating the lunar position.

EPHEM: Library that is very close to the correct data from SPICE, and doesn’t require the presence of extra

files. This is the default one, although the error might be too big for some users.

SPICEDMOON: Library that uses NASA’s data. The most exact one, but requires the presence of kernels files. PYLUNAR: Library that is very incorrect for some punctual data. Usage not recommended. SPICEDMOONSAFE: Like SPICEDMOON, but in case that it fails (which is very rare but possible) it uses EPHEM

library as a backup library instead of raising an Exception.

EPHEM_MOON = 0
PYLUNAR = 2
SPICEDMOON = 1
SPICEDMOONSAFE = 3
class solys2.automation.positioncalc.PylunarMoonCalc(lat: float, lon: float)

Bases: solys2.automation.positioncalc.MoonCalculator

Object that calculates the lunar zenith and azimuth for a given location at a given datetime, using pylunar library.

get_position(dt: datetime.datetime) Tuple[float, float]

Obtain lunar azimuth and zenith.

Parameters

dt (datetime.datetime) – Datetime at which the lunar position will be calculated.

Returns

  • azimuth (float) – Lunar azimuth calculated.

  • zenith (float) – Lunar zenith calculated.

class solys2.automation.positioncalc.PysolarSunCalc(lat: float, lon: float)

Bases: solys2.automation.positioncalc.SunCalculator

Object that calculates the solar zenith and azimuth for a given location at a given datetime, using pysolar library.

get_position(dt: datetime.datetime) Tuple[float, float]

Obtain solar azimuth and zenith.

Parameters

dt (datetime.datetime) – Datetime at which the solar position will be calculated.

Returns

  • azimuth (float) – Solar azimuth calculated.

  • zenith (float) – Solar zenith calculated.

class solys2.automation.positioncalc.SpiceMoonCalc(lat: float, lon: float, alt: float = 0, kernels='./kernels', retry_nospice: bool = False, logger: Optional[logging.Logger] = None)

Bases: solys2.automation.positioncalc.MoonCalculator

Object that calculates the lunar zenith and azimuth for a given location at a given datetime, using spicedmoon (SPICE) library.

get_position(dt: datetime.datetime) Tuple[float, float]

Obtain lunar azimuth and zenith.

Parameters

dt (datetime.datetime) – Datetime at which the lunar position will be calculated.

Returns

  • azimuth (float) – Lunar azimuth calculated.

  • zenith (float) – Lunar zenith calculated.

class solys2.automation.positioncalc.SpiceSunCalc(lat: float, lon: float, alt: float = 0, kernels='./kernels', retry_nospice: bool = False, logger: Optional[logging.Logger] = None)

Bases: solys2.automation.positioncalc.SunCalculator

Object that calculates the solar zenith and azimuth for a given location at a given datetime, using spicedmoon (SPICE) library.

get_position(dt: datetime.datetime) Tuple[float, float]

Obtain solar azimuth and zenith.

Parameters

dt (datetime.datetime) – Datetime at which the solar position will be calculated.

Returns

  • azimuth (float) – Solar azimuth calculated.

  • zenith (float) – Solar zenith calculated.

class solys2.automation.positioncalc.SunCalculator(lat: float, lon: float)

Bases: solys2.automation.positioncalc.BodyCalculator

Object that calculates the solar zenith and azimuth for a given location at a given datetime.

abstract get_position(dt: datetime.datetime) Tuple[float, float]

Obtain solar azimuth and zenith.

Parameters

dt (datetime.datetime) – Datetime at which the solar position will be calculated.

Returns

  • azimuth (float) – Solar azimuth calculated.

  • zenith (float) – Solar zenith calculated.

class solys2.automation.positioncalc.SunLibrary(value)

Bases: enum.Enum

Enum that represents the library that can be used for calculating the solar position.

PYSOLAR: Library that is very close to the correct data from SPICE, and doesn’t require the presence of extra

files. This is the default one. The errors are related to the sunrise and sunset.

EPHEM: Library that is also close to the correct data from SPICE, but not as much as pysolar. The errors

are related to the sunrise and sunset.

SPICEDSUN: Library that uses NASA’s data. The most exact one, but requires the presence of kernels files. SPICEDSUNSAFE: Like SPICEDSUN, but in case that it fails (which is very rare but possible) it uses PYSOLAR

library as a backup library instead of raising an Exception.

EPHEM_SUN = 101
PYSOLAR = 100
SPICEDSUN = 102
SPICEDSUNSAFE = 103