Use default logger

This commit is contained in:
Lukas Klass 2020-05-29 09:36:02 +02:00
parent 696076e131
commit 2c8bf1bb1f
11 changed files with 111 additions and 105 deletions

View File

@ -2,8 +2,8 @@ import xml.etree.ElementTree as eT
import numpy as np
import astropy.units as u
import os
import logging
from ..lib.helpers import error, readCSV
from ..lib.helpers import readCSV
from ..lib.logger import logger
from .Entry import Entry
from ..classes import target as tg
from ..classes import optical_component as oc
@ -37,10 +37,10 @@ class Configuration(object):
# Check if configuration file exists
if not os.path.exists(file):
error("Configuration file '" + file + "' doesn't exist.")
logger.error("Configuration file '" + file + "' doesn't exist.")
# Read configuration file
logging.info("Reading configuration from file '" + file + "'.")
logger.info("Reading configuration from file '" + file + "'.")
self.conf = self.__parser(eT.parse(file).getroot())
self.__check_config()
@ -105,53 +105,54 @@ class Configuration(object):
"""
# Check common
if not hasattr(self.conf, "common"):
error("Configuration check: Missing required container 'common'.")
logger.error("Configuration check: Missing required container 'common'.")
if not hasattr(self.conf.common, "wl_min"):
error("Configuration check: common: Missing required container 'wl_min'.")
logger.error("Configuration check: common: Missing required container 'wl_min'.")
mes = self.conf.common.wl_min.check_quantity("val", u.m)
mes is not None and error("Configuration check: common -> wl_min: " + mes)
mes is not None and logger.error("Configuration check: common -> wl_min: " + mes)
if not hasattr(self.conf.common, "wl_max"):
error("Configuration check: common: Missing required container 'wl_max'.")
logger.error("Configuration check: common: Missing required container 'wl_max'.")
mes = self.conf.common.wl_max.check_quantity("val", u.m)
mes is not None and error("Configuration check: common -> wl_max: " + mes)
mes is not None and logger.error("Configuration check: common -> wl_max: " + mes)
if hasattr(self.conf.common, "wl_delta"):
mes = self.conf.common.wl_delta.check_quantity("val", u.m)
mes is not None and error("Configuration check: common -> wl_delta: " + mes)
mes is not None and logger.error("Configuration check: common -> wl_delta: " + mes)
elif hasattr(self.conf.common, "res"):
mes = self.conf.common.res.check_quantity("val", u.dimensionless_unscaled)
mes is not None and error("Configuration check: common -> res: " + mes)
mes is not None and logger.error("Configuration check: common -> res: " + mes)
else:
error("Configuration check: common: Expected one of the containers 'wl_delta' or 'res' but got none.")
logger.error(
"Configuration check: common: Expected one of the containers 'wl_delta' or 'res' but got none.")
if not hasattr(self.conf.common, "d_aperture"):
error("Configuration check: common: Missing required container 'd_aperture'.")
logger.error("Configuration check: common: Missing required container 'd_aperture'.")
mes = self.conf.common.d_aperture.check_quantity("val", u.m)
mes is not None and error("Configuration check: common -> d_aperture: " + mes)
mes is not None and logger.error("Configuration check: common -> d_aperture: " + mes)
if hasattr(self.conf.common, "psf"):
if hasattr(self.conf.common.psf, "val"):
if self.conf.common.psf().lower() != "airy":
mes = self.conf.common.psf.check_file("val")
mes is not None and error("Configuration check: common -> psf: " + mes)
mes is not None and logger.error("Configuration check: common -> psf: " + mes)
else:
setattr(self.conf.common.psf, "val", "Airy")
if hasattr(self.conf.common.psf, "osf"):
mes = self.conf.common.psf.check_float("osf")
mes is not None and error("Configuration check: common -> psf: " + mes)
mes is not None and logger.error("Configuration check: common -> psf: " + mes)
else:
setattr(self.conf.common.psf, "osf", 10 * u.dimensionless_unscaled)
else:
setattr(self.conf.common, "psf", Entry(val="Airy", osf=10 * u.dimensionless_unscaled))
if hasattr(self.conf.common, "jitter_sigma"):
mes = self.conf.common.jitter_sigma.check_quantity("val", u.arcsec)
mes is not None and error("Configuration check: common -> jitter_sigma: " + mes)
mes is not None and logger.error("Configuration check: common -> jitter_sigma: " + mes)
if hasattr(self.conf.common, "output_path"):
if hasattr(self.conf.common.output, "val"):
mes = self.conf.common.output.check_path("path")
mes is not None and error("Configuration check: common -> output: " + mes)
mes is not None and logger.error("Configuration check: common -> output: " + mes)
else:
setattr(self.conf.common.output, "val", ".")
if hasattr(self.conf.common.output, "format"):
mes = self.conf.common.output.check_selection("format", ["csv", "CSV", "fits", "FITS"])
mes is not None and error("Configuration check: common -> output: " + mes)
mes is not None and logger.error("Configuration check: common -> output: " + mes)
else:
setattr(self.conf.common.output, "format", "CSV")
else:
@ -160,67 +161,70 @@ class Configuration(object):
mes = self.conf.common.exposure_time.check_quantity("val", u.s)
if mes is not None:
mes = self.conf.common.exposure_time.check_file("val")
mes is not None and error("Configuration check: common -> exposure_time: " + mes)
mes is not None and logger.error("Configuration check: common -> exposure_time: " + mes)
self.conf.common.exposure_time.val = readCSV(self.conf.common.exposure_time.val, [u.s],
format_="csv").columns[0].quantity
if hasattr(self.conf.common, "snr"):
mes = self.conf.common.snr.check_quantity("val", u.dimensionless_unscaled)
if mes is not None:
mes = self.conf.common.snr.check_file("val")
mes is not None and error("Configuration check: common -> snr: " + mes)
mes is not None and logger.error("Configuration check: common -> snr: " + mes)
self.conf.common.snr.val = readCSV(self.conf.common.snr.val, [u.dimensionless_unscaled],
format_="csv").columns[0].quantity
if hasattr(self.conf.common, "exposure_time") and len(self.conf.common.snr.val) != len(
self.conf.common.exposure_time.val):
error(
logger.error(
"Configuration check: common -> snr: Length of exposure time (%d) not matching the length of "
"the SNR (%d)" % (len(self.conf.common.exposure_time.val), len(self.conf.common.snr.val)))
if not (hasattr(self.conf.common, "exposure_time") or hasattr(self.conf.common, "snr")):
error("Configuration check: common: Expected at least one of the containers 'exposure_time' or 'snr' but" +
"got none.")
logger.error(
"Configuration check: common: Expected at least one of the containers 'exposure_time' or 'snr' but" +
"got none.")
# Check astroscene
if not hasattr(self.conf, "astroscene"):
error("Configuration check: Missing required container 'astroscene'.")
logger.error("Configuration check: Missing required container 'astroscene'.")
if not hasattr(self.conf.astroscene, "target"):
error("Configuration check: astroscene: Missing required container 'target'.")
logger.error("Configuration check: astroscene: Missing required container 'target'.")
if not hasattr(self.conf.astroscene.target, "type"):
error("Configuration check: astroscene -> target: Missing required parameter 'type'.")
logger.error("Configuration check: astroscene -> target: Missing required parameter 'type'.")
if self.conf.astroscene.target.type not in dir(tg):
# noinspection PyTypeChecker
error("Configuration check: astroscene -> target: Target type '" + self.conf.astroscene.target.type +
"' does not exist. Did you mean '" + difflib.get_close_matches(self.conf.astroscene.target.type,
dir(tg), 1)[0] + "'?")
logger.error("Configuration check: astroscene -> target: Target type '" + self.conf.astroscene.target.type +
"' does not exist. Did you mean '" +
difflib.get_close_matches(self.conf.astroscene.target.type,
dir(tg), 1)[0] + "'?")
mes = getattr(tg, self.conf.astroscene.target.type).check_config(self.conf.astroscene.target)
mes is not None and error("Configuration check: astroscene -> target: " + mes)
mes is not None and logger.error("Configuration check: astroscene -> target: " + mes)
if hasattr(self.conf.common, "exposure_time") and hasattr(self.conf.common, "snr"):
if self.conf.astroscene.target.type.lower() != "blackbodytarget":
error("Configuration check: astroscene -> target: Sensitivity calculation only possible for " +
"a target of the type 'BlackBodyTarget'.")
logger.error("Configuration check: astroscene -> target: Sensitivity calculation only possible for " +
"a target of the type 'BlackBodyTarget'.")
mes = self.__check_optical_components(self.conf.astroscene)
mes is not None and error("Configuration check: astroscene -> " + mes)
mes is not None and logger.error("Configuration check: astroscene -> " + mes)
# Check common_optics
if hasattr(self.conf, "common_optics") and isinstance(self.conf.common_optics, Entry):
mes = self.__check_optical_components(self.conf.common_optics)
mes is not None and error("Configuration check: common_optics -> " + mes)
mes is not None and logger.error("Configuration check: common_optics -> " + mes)
# Check instrument
if not hasattr(self.conf, "instrument"):
error("Configuration check: Missing required container 'instrument'.")
logger.error("Configuration check: Missing required container 'instrument'.")
mes = self.__check_optical_components(self.conf.instrument)
mes is not None and error("Configuration check: instrument -> " + mes)
mes is not None and logger.error("Configuration check: instrument -> " + mes)
if not hasattr(self.conf.instrument, "sensor"):
error("Configuration check: instrument: Missing required container 'sensor'.")
logger.error("Configuration check: instrument: Missing required container 'sensor'.")
if not hasattr(self.conf.instrument.sensor, "type"):
error("Configuration check: instrument -> sensor: Missing required parameter 'type'.")
logger.error("Configuration check: instrument -> sensor: Missing required parameter 'type'.")
if self.conf.instrument.sensor.type not in dir(sensor):
# noinspection PyTypeChecker
error("Configuration check: instrument -> sensor: Sensor type '" + self.conf.instrument.sensor.type +
"' does not exist. Did you mean '" + difflib.get_close_matches(self.conf.instrument.sensor.type,
dir(sensor), 1)[0] + "'?")
logger.error("Configuration check: instrument -> sensor: Sensor type '" + self.conf.instrument.sensor.type +
"' does not exist. Did you mean '" +
difflib.get_close_matches(self.conf.instrument.sensor.type,
dir(sensor), 1)[0] + "'?")
mes = getattr(sensor, self.conf.instrument.sensor.type).check_config(self.conf.instrument.sensor, self.conf)
mes is not None and error("Configuration check: instrument -> sensor -> " + mes)
mes is not None and logger.error("Configuration check: instrument -> sensor -> " + mes)
@staticmethod
def __check_optical_components(conf: Union[Entry, list]) -> Union[None, str]:
@ -238,17 +242,18 @@ class Configuration(object):
The error message of the check. This will be None if the check was successful.
"""
if hasattr(conf, "optical_component"):
for component in (conf.optical_component if type(conf.optical_component) == list else
[conf.optical_component]):
if not hasattr(component, "type"):
for component in (
conf.optical_component if type(conf.optical_component) == list else [conf.optical_component]):
if hasattr(component, "type"):
if component.type not in dir(oc):
# noinspection PyTypeChecker
return "optical_component: optical component type '" + component.type + \
"' does not exist. Did you mean '" + \
difflib.get_close_matches(component.type, dir(tg), 1)[0] + "'?"
mes = getattr(oc, component.type).check_config(component)
if mes is not None:
print(component.type)
print(mes)
return "optical_component -> " + component.type + ": " + mes
else:
return "optical_component: Missing required parameter 'type'."
if component.type not in dir(oc):
# noinspection PyTypeChecker
return "optical_component: optical component type '" + component.type + \
"' does not exist. Did you mean '" + \
difflib.get_close_matches(component.type, dir(tg), 1)[0] + "'?"
mes = getattr(oc, component.type).check_config(component)
if mes is not None:
print(component.type)
print(mes)
return "optical_component -> " + component.type + ": " + mes

View File

@ -2,7 +2,7 @@ from typing import Union
import re
import xml.etree.ElementTree as eT
import astropy.units as u
from ..lib.helpers import error
from ..lib.logger import logger
import difflib
import os
@ -45,8 +45,8 @@ class Entry(object):
val = val[0]
setattr(self, var, val)
except (ValueError, LookupError):
error("unable to convert units in entry '" + xml.tag + "': " + getattr(self, var) + " " +
getattr(self, unit), exit_=False)
logger.error("unable to convert units in entry '" + xml.tag + "': " + getattr(self, var) + " " +
getattr(self, unit), exit_=False)
# Convert boolean values
if hasattr(self, "val") and type(self.val) == str and self.val.lower() in ["false", "true"]:
self.val = (self.val.lower() == "true")
@ -61,6 +61,8 @@ class Entry(object):
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
-------
@ -109,7 +111,7 @@ class Entry(object):
match = difflib.get_close_matches(attr, choices, 1)
if len(match) > 0:
# noinspection PyTypeChecker
return "Value '" + attr + "' not allowed for parameter '" + name + "'. Did you mean '" +\
return "Value '" + attr + "' not allowed for parameter '" + name + "'. Did you mean '" + \
match[0] + "'?"
else:
return "Value '" + attr + "' not allowed for parameter '" + name + "'."

View File

@ -3,7 +3,7 @@ from .Entry import Entry
from .IRadiant import IRadiant
from ..classes import optical_component as oc
from ..classes import target as tg
from ..lib.helpers import error
from ..lib.logger import logger
import copy
import re
@ -58,7 +58,7 @@ class RadiantFactory:
# File Target
return getattr(tg, options.type)(**attribs)
else:
error("Unknown target type: '" + options.type + "'")
logger.error("Unknown target type: '" + options.type + "'")
else:
# New component is of type Optical Component
attribs["parent"] = parent
@ -75,11 +75,11 @@ class RadiantFactory:
elif hasattr(options, "start") and hasattr(options, "end"):
return oc.Filter.fromRange(**attribs)
else:
error("Wrong parameters for filter.")
logger.error("Wrong parameters for filter.")
else:
error("Unknown optical component type: '" + options.type + "'")
logger.error("Unknown optical component type: '" + options.type + "'")
else:
error("Optical component needs to have a type specified.")
logger.error("Optical component needs to have a type specified.")
def fromConfigBatch(self, conf: Entry) -> IRadiant:
"""
@ -103,9 +103,11 @@ class RadiantFactory:
if hasattr(conf, "common_optics") and hasattr(conf.common_optics, "optical_component"):
for entry in conf.common_optics.optical_component if type(conf.common_optics.optical_component) == \
list else [conf.common_optics.optical_component]:
parent = self.create(entry, parent)
if isinstance(entry, Entry):
parent = self.create(entry, parent)
if hasattr(conf, "instrument") and hasattr(conf.instrument, "optical_component"):
for entry in conf.instrument.optical_component if type(conf.instrument.optical_component) == list else\
[conf.instrument.optical_component]:
parent = self.create(entry, parent)
if isinstance(entry, Entry):
parent = self.create(entry, parent)
return parent

View File

@ -1,11 +1,9 @@
from ..lib.helpers import error, isLambda, readCSV
from ..lib.helpers import isLambda, readCSV
from ..lib.logger import logger
from scipy.interpolate import interp1d
import astropy.units as u
import math
from typing import Union, Callable
import logging
from astropy.io import ascii
import re
import os
from scipy.integrate import trapz
@ -47,7 +45,7 @@ class SpectralQty:
else:
self.qty = qty * u.dimensionless_unscaled
else:
error("Lengths not matching")
logger.error("Lengths not matching")
self._fill_value = fill_value
@classmethod
@ -166,7 +164,7 @@ class SpectralQty:
# Wavelengths are still not matching as extrapolation is disabled, rebin this spectral quantity
return SpectralQty(other_rebinned.wl, self.rebin(other_rebinned.wl).qty + other_rebinned.qty)
else:
error("Units are not matching for addition.")
logger.error("Units are not matching for addition.")
__radd__ = __add__
@ -214,7 +212,7 @@ class SpectralQty:
# Wavelengths are still not matching as extrapolation is disabled, rebin this spectral quantity
return SpectralQty(other_rebinned.wl, self.rebin(other_rebinned.wl).qty - other_rebinned.qty)
else:
error("Units are not matching for substraction.")
logger.error("Units are not matching for substraction.")
def __mul__(self, other: Union[int, float, u.Quantity, "SpectralQty", Callable[[u.Quantity], u.Quantity]]) ->\
"SpectralQty":
@ -254,7 +252,7 @@ class SpectralQty:
# Wavelengths are still not matching as extrapolation is disabled, rebin this spectral quantity
return SpectralQty(other_rebinned.wl, self.rebin(other_rebinned.wl).qty * other_rebinned.qty)
else:
error("Units are not matching for multiplication.")
logger.error("Units are not matching for multiplication.")
__rmul__ = __mul__
@ -296,7 +294,7 @@ class SpectralQty:
# Wavelengths are still not matching as extrapolation is disabled, rebin this spectral quantity
return SpectralQty(other_rebinned.wl, self.rebin(other_rebinned.wl).qty / other_rebinned.qty)
else:
error("Units are not matching for division.")
logger.error("Units are not matching for division.")
def rebin(self, wl: u.Quantity) -> "SpectralQty":
"""
@ -315,11 +313,11 @@ class SpectralQty:
"""
if not wl.unit.is_equivalent(self.wl.unit):
error("Mismatching units for rebinning: " + wl.unit + ", " + self.wl.unit)
logger.error("Mismatching units for rebinning: " + wl.unit + ", " + self.wl.unit)
if min(wl) < min(self.wl) or max(wl) > max(self.wl):
if isinstance(self._fill_value, bool):
if not self._fill_value:
logging.warning("Extrapolation disabled, bandwidth will be reduced.")
logger.warning("Extrapolation disabled, bandwidth will be reduced.")
# Remove new wavelengths where extrapolation would have been necessary
wl = [x.value for x in wl if min(self.wl) <= x <= max(self.wl)] * wl.unit
f = interp1d(self.wl, self.qty.value, fill_value="extrapolate")

View File

@ -1,11 +1,10 @@
from ..IRadiant import IRadiant
from ..SpectralQty import SpectralQty
from ...lib.helpers import error
from ...lib.logger import logger
from abc import abstractmethod
import astropy.units as u
from astropy.modeling.models import BlackBody
from typing import Union, Callable, Tuple
from logging import info, debug
from ..Entry import Entry
@ -66,10 +65,10 @@ class AOpticalComponent(IRadiant):
The obstruction factor as A_ob / A_ap.
"""
signal, size, obstruction = self.__parent.calcSignal()
info("Calculating signal for class '" + self.__class__.__name__ + "'.")
logger.info("Calculating signal for class '" + self.__class__.__name__ + "'.")
signal = self._propagate(signal) * (1 - self.__obstruction)
obstruction = obstruction + self.__obstruction
debug(signal)
logger.debug(signal)
return signal, size, obstruction
def calcBackground(self) -> SpectralQty:
@ -82,7 +81,7 @@ class AOpticalComponent(IRadiant):
The spectral radiance of the background
"""
parent = self.__parent.calcBackground()
info("Calculating background for class '" + self.__class__.__name__ + "'.")
logger.info("Calculating background for class '" + self.__class__.__name__ + "'.")
parent = self._propagate(parent)
if self.__obstructor_temp > 0 * u.K:
bb = BlackBody(temperature=self.__obstructor_temp, scale=1. * u.W / (u.m ** 2 * u.nm * u.sr))
@ -91,7 +90,7 @@ class AOpticalComponent(IRadiant):
else:
background = parent * (1. - self.__obstruction)
background = background + self._ownNoise()
debug(background)
logger.debug(background)
return background
def _propagate(self, rad: SpectralQty) -> SpectralQty:
@ -111,7 +110,7 @@ class AOpticalComponent(IRadiant):
try:
return rad * self.__transreflectivity
except AttributeError:
error("Transreflectivity not given. Method propagate() needs to be implemented.")
logger.error("Transreflectivity not given. Method propagate() needs to be implemented.")
def _ownNoise(self) -> Union[SpectralQty, Callable[[u.Quantity], u.Quantity], int, float]:
"""
@ -125,7 +124,7 @@ class AOpticalComponent(IRadiant):
try:
return self.__noise
except AttributeError:
error("noise not given. Method ownNoise() needs to be implemented.")
logger.error("noise not given. Method ownNoise() needs to be implemented.")
@staticmethod
@abstractmethod

View File

@ -1,7 +1,7 @@
from .AHotOpticalComponent import AHotOpticalComponent
from ..SpectralQty import SpectralQty
from ..IRadiant import IRadiant
from ...lib.helpers import error
from ...lib.logger import logger
from ..Entry import Entry
from astropy import units as u
from typing import Union, Callable
@ -86,7 +86,7 @@ class Filter(AHotOpticalComponent):
The instantiated filter object.
"""
if band not in cls._band.keys():
error("Band has to be one of '[" + ", ".join(list(cls._band.keys())) + "]'")
logger.error("Band has to be one of '[" + ", ".join(list(cls._band.keys())) + "]'")
return cls.fromRange(parent, cls._band[band]["cwl"] - cls._band[band]["bw"] / 2,
cls._band[band]["cwl"] + cls._band[band]["bw"] / 2, emissivity, temp, obstruction,
obstructor_temp, obstructor_emissivity)

View File

@ -1,10 +1,10 @@
from .IPSF import IPSF
from ...lib.helpers import error, rasterizeCircle
from ...lib.helpers import rasterizeCircle
from ..sensor.PixelMask import PixelMask
from ...lib.logger import logger
import numpy as np
import astropy.units as u
import re
from logging import warning
from typing import Union
from scipy.optimize import bisect
from scipy.signal import fftconvolve
@ -52,7 +52,7 @@ class Zemax(IPSF):
# Parse shape of the grid and check the read PSF-array
shape = [int(x) for x in re.findall("[0-9]+", list(filter(re.compile("Image grid size: ").match, head))[0])]
if shape != list(self.__psf.shape):
warning("Not all PSF entries read.")
logger.warning("Not all PSF entries read.")
# Parse and calculate the grid width
grid_delta = [float(x.replace(",", ".")) for x in
re.findall("[0-9]+,*[0-9]*", list(filter(re.compile("Data area is ").match, head))[0])]
@ -95,7 +95,7 @@ class Zemax(IPSF):
try:
contained_energy = float(contained_energy) / 100.0 * u.dimensionless_unscaled
except ValueError:
error("Could not convert encircled energy to float.")
logger.error("Could not convert encircled energy to float.")
elif type(contained_energy) in [int, float]:
contained_energy = contained_energy / 100 * u.dimensionless_unscaled

View File

@ -1,6 +1,6 @@
import astropy.units as u
from logging import warning
from ...lib.helpers import error, rasterizeCircle
from ...lib.logger import logger
from ...lib.helpers import rasterizeCircle
import numpy as np
@ -99,7 +99,7 @@ class PixelMask(np.ndarray):
yc = self.psf_center_ind[0] * u.pix
if (xc + radius).value > self.pixel_geometry[0].value - 1 or (xc - radius).value < 0 or\
(yc + radius).value > self.pixel_geometry[1].value - 1 or (yc - radius).value < 0:
warning("Some parts of the photometric aperture are outside of the array.")
logger.warning("Some parts of the photometric aperture are outside of the array.")
if shape.lower() == "circle":
# Rasterize a circle on the grid
rasterizeCircle(self, radius.value, xc.value, yc.value)
@ -117,4 +117,4 @@ class PixelMask(np.ndarray):
# Mark the pixels contained in the square with 1
self[y_up:(y_low + 1), x_left:(x_right + 1)] = 1
else:
error("Unknown photometric aperture shape: '" + shape + "'.")
logger.error("Unknown photometric aperture shape: '" + shape + "'.")

View File

@ -2,7 +2,7 @@ from ..IRadiant import IRadiant
from ..Entry import Entry
from .ASensor import ASensor
from .Imager import Imager
from ...lib.helpers import error
from ...lib.logger import logger
class SensorFactory:
@ -50,4 +50,4 @@ class SensorFactory:
args["contained_pixels"] = options.photometric_aperture.contained_pixels()
return Imager(**args)
else:
error("Wrong sensor type: " + options.type)
logger.error("Wrong sensor type: " + options.type)

View File

@ -3,7 +3,7 @@ from ..IRadiant import IRadiant
from ..SpectralQty import SpectralQty
import astropy.units as u
import numpy as np
from logging import info, debug
from ...lib.logger import logger
from typing import Tuple
from ..Entry import Entry
@ -41,9 +41,9 @@ class ATarget(IRadiant):
background : SpectralQty
The spectral radiance of the target's background
"""
info("Calculating Noise for class '" + self.__class__.__name__ + "'.")
logger.info("Calculating noise for class '" + self.__class__.__name__ + "'.")
background = SpectralQty(self.__wl_bins, np.repeat(0, len(self.__wl_bins)) << u.W / (u.m**2 * u.nm * u.sr))
debug(background)
logger.debug(background)
return background
def calcSignal(self) -> Tuple[SpectralQty, str, float]:
@ -59,8 +59,8 @@ class ATarget(IRadiant):
obstruction : float
The obstruction factor as A_ob / A_ap.
"""
info("Calculating Signal for class '" + self.__class__.__name__ + "'.")
debug(self.__sfd)
logger.info("Calculating signal for class '" + self.__class__.__name__ + "'.")
logger.debug(self.__sfd)
return self.__sfd, self.__size, 0.0
@staticmethod

View File

@ -2,7 +2,7 @@ from ..target.ATarget import ATarget
from ..SpectralQty import SpectralQty
import astropy.units as u
from astropy.modeling.models import BlackBody
from ...lib.helpers import error
from ...lib.logger import logger
from ..Entry import Entry
from typing import Union
@ -47,7 +47,7 @@ class BlackBodyTarget(ATarget):
-------
"""
if band.upper() not in self._band.keys():
error("Band has to be one of '[" + ", ".join(list(self._band.keys())) + "]'")
logger.error("Band has to be one of '[" + ", ".join(list(self._band.keys())) + "]'")
# Create blackbody model with given temperature
bb = BlackBody(temperature=temp, scale=1 * u.W / (u.m ** 2 * u.nm * u.sr))