esbo_etc.classes package

Submodules

esbo_etc.classes.AFactory module

class esbo_etc.classes.AFactory.AFactory(common_conf: esbo_etc.classes.Entry.Entry)[source]

Bases: object

A Factory for creating objects of the radiation transportation pipeline

abstract __init__(common_conf: esbo_etc.classes.Entry.Entry)[source]

Instantiate a new factory object

Parameters

common_conf (Entry) – The common configuration of the configuration file

collectOptions(options: esbo_etc.classes.Entry.Entry) → dict[source]

Collect all options from the configuration file as dictionary

Parameters

options (Entry) – The options to be used as parameters for the instantiation of the new object.

Returns

opts (dict) – The collected options as dictionary

abstract create(options: esbo_etc.classes.Entry.Entry, parent: esbo_etc.classes.IRadiant.IRadiant = None)[source]

Create a new object of the radiation transportation pipeline

Parameters
  • options (Entry) – The options to be used as parameters for the instantiation of the new object.

  • parent (IRadiant) – The optional parent element of the object (necessary for subclasses of AOpticalComponent and ASensor).

Returns

obj – The created object

esbo_etc.classes.ARadiantFactory module

class esbo_etc.classes.ARadiantFactory.ARadiantFactory(common_conf: esbo_etc.classes.Entry.Entry)[source]

Bases: esbo_etc.classes.AFactory.AFactory

A Factory creating objects of the type IRadiant

abstract __init__(common_conf: esbo_etc.classes.Entry.Entry)[source]

Instantiate a new factory object

Parameters

common_conf (Entry) – The common configuration of the configuration file

abstract create(options: esbo_etc.classes.Entry.Entry, parent: esbo_etc.classes.IRadiant.IRadiant = None)esbo_etc.classes.IRadiant.IRadiant[source]

Create a new object of the type IRadiant

Parameters
  • options (Entry) – The options to be used as parameters for the instantiation of the new object.

  • parent (IRadiant) – The optional parent element of the object (necessary for subclasses of AOpticalComponent).

Returns

obj (IRadiant) – The created object

esbo_etc.classes.Config module

class esbo_etc.classes.Config.Configuration(file='esbo-etc_defaults.xml')[source]

Bases: object

A Class to parse the XML configuration file. Adapted from ExoSim (https://github.com/ExoSim/ExoSimPublic)

conf

Parsed configuration file as Entry-tree

Type

Entry

__init__(file='esbo-etc_defaults.xml')[source]

Parse a XML configuration file.

Parameters

file (str) – configuration file to parse

conf = None

esbo_etc.classes.Entry module

class esbo_etc.classes.Entry.Entry(**kwargs)[source]

Bases: object

A class used to represent a configuration entry. Taken from ExoSim (https://github.com/ExoSim/ExoSimPublic)

check_file(name) → Union[None, str][source]

Check a parameter to be a valid path to a file.

Parameters

name (str) – The name of the parameter to be checked.

Returns

mes (Union[None, str]) – The error message of the check. This will be None if the check was successful.

check_float(name) → Union[None, str][source]

Check a parameter to be a floating point value

Parameters

name (str) – The name of the parameter to be checked.

Returns

mes (Union[None, str]) – The error message of the check. This will be None if the check was successful.

check_path(name) → Union[None, str][source]

Check a parameter to be a valid path to a file.

Parameters

name (str) – The name of the parameter to be checked.

Returns

mes (Union[None, str]) – The error message of the check. This will be None if the check was successful.

check_quantity(name: str, unit: astropy.units.core.Unit, use_default: bool = True) → Union[None, str][source]

Check a parameter as type quantity

Parameters
  • name (str) – The name of the parameter to be checked.

  • unit (Quantity) – The default quantity to be used for conversion and equality checking.

  • use_default (bool) – Use the given unit as default unit and try to convert strings to Quantities with this unit.

Returns

mes (Union[None, str]) – The error message of the check. This will be None if the check was successful.

check_selection(name: str, choices: list) → Union[None, str][source]

Check a parameter against a list of possible choices. In case of a mismatch, a recommendation will be given.

Parameters
  • name (str) – The name of the parameter to be checked.

  • choices (list) – List of choices to be used for checking.

Returns

mes (Union[None, str]) – The error message of the check. This will be None if the check was successful.

parse(xml: xml.etree.ElementTree.Element)[source]

Parse attributes of a XML element

Parameters

xml (xml.etree.ElementTree.Element) – XML element to parse the attributes from

val: Union[str, bool, u.Quantity]

esbo_etc.classes.IRadiant module

class esbo_etc.classes.IRadiant.IRadiant[source]

Bases: abc.ABC

Interface for getting the signal and the background radiation of a emitting, reflecting or transmitting component in the beam.

abstract calcBackground()esbo_etc.classes.SpectralQty.SpectralQty[source]

Calculate the background radiation coming from the component

Returns

signal (SpectralQty) – The emitted, reflected or transmitted background radiation

abstract calcSignal() → Tuple[esbo_etc.classes.SpectralQty.SpectralQty, float][source]

Calculate the signal coming from the component

Returns

  • signal (SpectralQty) – The emitted, reflected or transmitted signal

  • obstruction (float) – The obstruction factor as A_ob / A_ap.

esbo_etc.classes.SpectralQty module

class esbo_etc.classes.SpectralQty.SpectralQty(wl: astropy.units.quantity.Quantity, qty: astropy.units.quantity.Quantity, fill_value: Union[bool, int, float] = 0)[source]

Bases: object

A class to hold and work with spectral quantities

__add__(other: Union[int, float, astropy.units.quantity.Quantity, SpectralQty, Callable[[astropy.units.quantity.Quantity], astropy.units.quantity.Quantity]])esbo_etc.classes.SpectralQty.SpectralQty[source]

Calculate the sum with another object

Parameters

other (Union[int, float, u.Quantity, "SpectralQty", Callable]) – Addend to be added to this object. If the binning of the object on the right hand side differs from the binning of the left object, the object on the right hand side will be rebinned.

Returns

sum (SpectralQty) – The sum of both objects

__eq__(other) → bool[source]

Check if this object is equal to another object

Parameters

other (SpectralQty) – Object to compare with

Returns

res (bool) – Result of the comparison

__init__(wl: astropy.units.quantity.Quantity, qty: astropy.units.quantity.Quantity, fill_value: Union[bool, int, float] = 0)[source]

Initialize a new spectral quantity

Parameters
  • wl (Quantity) – The binned wavelengths

  • qty (Quantity) – The quantity values corresponding to the binned wavelengths. If the values are supplied without a unit, they are assumed to be dimensionless.

  • fill_value (Union[bool, int, float]) – How to treat missing values. True enables extrapolation, False disables extrapolation and the spectrum will be truncated. If a numeric value is given, the missing values will be filled with this value.

Returns

sqty (SpectralQty) – The created spectral quantity.

__mul__(other: Union[int, float, astropy.units.quantity.Quantity, SpectralQty, Callable[[astropy.units.quantity.Quantity], astropy.units.quantity.Quantity]])esbo_etc.classes.SpectralQty.SpectralQty[source]

Calculate the product with another object

Parameters

other (Union[int, float, u.Quantity, "SpectralQty", Callable]) – Factor to be multiplied with this object. If the binning of the object on the right hand side differs from the binning of the left object, the object on the right hand side will be rebinned.

Returns

prod (SpectralQty) – The product of both objects

__pow__(other: Union[int, float])esbo_etc.classes.SpectralQty.SpectralQty[source]

Raise to spectral quantity to the given power.

Parameters

other (Union[int, float]) – The exponent for this object.

Returns

prod (SpectralQty) – The spectral quantity raised to the given power.

__radd__(other: Union[int, float, astropy.units.quantity.Quantity, SpectralQty, Callable[[astropy.units.quantity.Quantity], astropy.units.quantity.Quantity]])esbo_etc.classes.SpectralQty.SpectralQty

Calculate the sum with another object

Parameters

other (Union[int, float, u.Quantity, "SpectralQty", Callable]) – Addend to be added to this object. If the binning of the object on the right hand side differs from the binning of the left object, the object on the right hand side will be rebinned.

Returns

sum (SpectralQty) – The sum of both objects

__rmul__(other: Union[int, float, astropy.units.quantity.Quantity, SpectralQty, Callable[[astropy.units.quantity.Quantity], astropy.units.quantity.Quantity]])esbo_etc.classes.SpectralQty.SpectralQty

Calculate the product with another object

Parameters

other (Union[int, float, u.Quantity, "SpectralQty", Callable]) – Factor to be multiplied with this object. If the binning of the object on the right hand side differs from the binning of the left object, the object on the right hand side will be rebinned.

Returns

prod (SpectralQty) – The product of both objects

__str__(precision: int = 4) → str[source]

Convert a SpectralQty object to a string representation

Parameters

precision (int) – Precision of the printed values

Returns

ret (str) – String representation of the object

__sub__(other: Union[int, float, astropy.units.quantity.Quantity, SpectralQty, Callable[[astropy.units.quantity.Quantity], astropy.units.quantity.Quantity]])esbo_etc.classes.SpectralQty.SpectralQty[source]

Calculate the difference to another object

Parameters

other (Union[int, float, u.Quantity, "SpectralQty", Callable]) – Subtrahend to be subtracted from this object. If the binning of the object on the right hand side differs from the binning of the left object, the object on the right hand side will be rebinned.

Returns

diff (SpectralQty) – The difference of both objects

__truediv__(other: Union[int, float, astropy.units.quantity.Quantity, SpectralQty, Callable[[astropy.units.quantity.Quantity], astropy.units.quantity.Quantity]])esbo_etc.classes.SpectralQty.SpectralQty[source]

Calculate the quotient with another object

Parameters

other (Union[int, float, u.Quantity, "SpectralQty", Callable]) – Divisor for this object. If the binning of the object on the right hand side differs from the binning of the left object, the object on the right hand side will be rebinned.

Returns

quot (SpectralQty) – The quotient of both objects

classmethod fromFile(file: str, wl_unit_default: astropy.units.quantity.Quantity = None, qty_unit_default: astropy.units.quantity.Quantity = None, fill_value: Union[bool, int, float] = 0)esbo_etc.classes.SpectralQty.SpectralQty[source]

Initialize a new spectral quantity and read the values from a file

Parameters
  • file (str) – Path to the file to read the values from. The file needs to provide two columns: wavelength and the corresponding spectral quantity. The format of the file will be guessed by astropy.io.ascii.read(). If the file doesn’t provide units via astropy’s enhanced CSV format, the units will be read from the column headers or otherwise assumed to be wl_unit_default and qty_unit_default.

  • wl_unit_default (Quantity) – Default unit to be used for the wavelength column if no units are provided by the file.

  • qty_unit_default (Quantity) – Default unit to be used for the quantity column if no units are provided by the file.

  • fill_value (Union[bool, int, float]) – How to treat missing values. True enables extrapolation, False disables extrapolation and the spectrum will be truncated. If a numeric value is given, the missing values will be filled with this value.

Returns

sqty (SpectralQty) – The created spectral quantity.

integrate() → astropy.units.quantity.Quantity[source]

Integrate the spectral quantity over the given spectrum using

Returns

int (Quantity) – The integrated quantity

rebin(wl: astropy.units.quantity.Quantity)esbo_etc.classes.SpectralQty.SpectralQty[source]

Resample the spectral quantity sqty(wl) over the new grid wl, rebinning if necessary, otherwise interpolates. Copied from ExoSim (https://github.com/ExoSim/ExoSimPublic).

Parameters

wl (Quantity) – new binned wavelengths

Returns

sqty (SpectralQty) – The rebinned spectral quantity

esbo_etc.classes.SpinnerHandler module

class esbo_etc.classes.SpinnerHandler.SpinnerHandler(spinner: halo.halo.Halo = <halo.halo.Halo object>, level: int = 0)[source]

Bases: logging.Handler

A handler for the logging-package to allow a spinner indicate an ongoing calculation.

The spinner is started by a log-message with the extra-key ‘spinning’: logger.info(“running…”, extra={“spinning”: True}) logger.info(“end”, extra={“spinning”: False})

__init__(spinner: halo.halo.Halo = <halo.halo.Halo object>, level: int = 0)[source]

Initialize a new spinner handler

Parameters
  • spinner (Halo) – The spinner to show.

  • level (int) – The logging level of this handler.

emit(record)[source]

Add a spinner to the given log record and emit the final record.

Parameters

record (LogRecord) – The log record to be extended.

Returns

record (LogRecord) – The extended log record.

filter(record)[source]

Check if this handler should be applied on the given log record.

Parameters

record (LogRecord) – The log record to be checked

Returns

res (bool) – True if this handler should be applied on the given log record, otherwise False.

esbo_etc.classes.esbo_etc module

class esbo_etc.classes.esbo_etc.esbo_etc(config: str = 'esbo-etc_defaults.xml', logging: int = 30, spin: bool = False)[source]

Bases: object

Top level class of the exposure time calculator

__init__(config: str = 'esbo-etc_defaults.xml', logging: int = 30, spin: bool = False)[source]

Initialize a new exposure time calculator (ETC)

Parameters
  • config (str) – Path to the configuration file

  • logging (int) – Loglevel from package logging

  • spin (bool) – Show a spinner during computations

run() → astropy.units.quantity.Quantity[source]
Returns

res (Quantity) – The result of the computation. Depending on the input parameters, this will be either a dimensionless signal-to-noise ratio (SNR), an exposure time in seconds or a sensitivity in apparent magnitues.

Module contents