def __init__(self, name, **kwargs): self.name = name self.params = kwargs try: self.function = self.functions[name](**kwargs) except KeyError as e: self.errorUnknown(e) raise exceptions.ConfigurationError() except TypeError as e: raise exceptions.ConfigurationError(e)
def load_YAML(fileObject): try: config = yaml.safe_load(fileObject) except yaml.composer.ComposerError as e: log.error(f"YAML composer error {e}") raise exceptions.ConfigurationError(e) from e except yaml.scanner.ScannerError as e: log.error(f"YAML scanner error {e}") raise exceptions.ConfigurationError(e) from e return dotmap.DotMap(config)
def get_space(self, definition): try: if isinstance(definition, dotmap.DotMap): return self.get_space_range(**definition.toDict()) elif isinstance(definition, numbers.Number) or isinstance( definition, datetime.datetime): return [definition] else: raise exceptions.ConfigurationError( f"Parameter space definition must be either a number or a dictionary with min, max and count defined" ) except TypeError as e: raise exceptions.ConfigurationError(e)
def __init__(self, name, **kwargs): self.name = name self.params = kwargs try: self.sample = self.functions.get(name)(**kwargs) except TypeError: self.error_unknown(name) raise exceptions.ConfigurationError()
def __init__(self, parameters, streaks=True): log.debug(f"Initializing the population") self.generator = Generator.from_config(parameters) self.parameters = parameters self.streaks = streaks try: log.info("Configuring meteoroid property distributions") except AttributeError as e: raise exceptions.ConfigurationError(e) from e
def from_config(cls, config): try: return cls(config.distribution, **config.parameters.toDict()) except KeyError: log.error("{cfg} is not a valid configuration option for {name}".format( cfg = c.param(config), name = c.name(cls.__name__) )) log.error("Expected distribution name \"distribution: 'string'\" and a dictionary of parameters") raise exceptions.ConfigurationError("Could not initialize {name}".format( name = c.name(cls.__name__) ))
def configure(self): self.campaign = Campaign.load(self.dataset, analyses=self.config) if self.args.bias: try: log.info("Setting bias function discriminators") discriminators = { 'apparent_magnitude': MagnitudeDiscriminator.from_config(self.bias.magnitude), 'altitude': AltitudeDiscriminator.from_config(self.bias.altitude), 'angular_speed': AngularSpeedDiscriminator.from_config(self.bias.angular_speed), } log.info(f"Loaded {c.num(len(discriminators))} discriminators:") for discriminator in discriminators.values(): discriminator.log_info() self.campaign.set_discriminators(discriminators) except AttributeError as e: raise exceptions.ConfigurationError(e) from e else: log.debug("No bias file set")