[docs]class MWRError(Exception):
"""Base exception for MWR"""
###############################
[docs]class MWRFileError(MWRError):
"""Base exception for MWR Files"""
[docs]class MWRDataError(MWRError):
"""Base exception if some feature of data triggers and error in a function"""
[docs]class MWROutputError(MWRError):
"""Raised when something with the output file goes wrong"""
[docs]class MWRConfigError(MWRError):
"""Raised if something with the configuration file is wrong"""
[docs]class MWRTestError(MWRError):
"""Raised if something goes wrong during set up or clean up of testing"""
################################
[docs]class UnknownFileType(MWRFileError):
"""Raised if the filetype of the datafile is not in the known range of file ID types"""
[docs]class WrongFileType(MWRFileError):
"""Raised if the filetype does not match with the chosen reader"""
[docs]class FileTooShort(MWRFileError):
"""Raised if file seems too short, e.g. if parameter n_meas > rest of buffer"""
[docs]class UnknownRecordType(MWRFileError):
"""Raised if Radiometrics file contains a record type number that is not known, i.e. can't be matched with header"""
[docs]class MissingData(MWRFileError):
"""Raised if no observation data is found in file"""
[docs]class MissingVariable(MWRFileError):
"""Raised if file seems not to contain a mandatory variable. Might be due to a modified header in the input file"""
[docs]class FilenameError(MWRFileError):
"""Raised if the filename does not correspond to the expected pattern"""
# --------------------------
[docs]class UnknownFlagValue(MWRInputError):
"""Raised if the value of a flag in the input files does not correspond to the range of known values"""
[docs]class UnknownManufacturer(MWRInputError):
"""Raised if the manufacturer specified in Measurement is not known"""
[docs]class MissingDataSource(MWRInputError):
"""Raised if a mandatory data source for creation of Measurement is missing in input"""
# --------------------------
[docs]class EmptyLineError(WrongInputFormat):
"""Raised if trying to do operations on an empty csv line"""
[docs]class CorruptRectype(WrongInputFormat):
"""Raised if record type cannot be interpreted, e.g. if not integer"""
# --------------------------
[docs]class DimensionMismatch(MWRDataError):
"""Raised if data dimensions do not match"""
[docs]class TimeMismatch(MWRDataError):
"""Raised if time period covered by different data sources does not match"""
[docs]class UnknownFrequencyBand(MWRDataError):
"""Raised if the frequencies of the data cannot be attributed to a band expected for the retrieval of T or q"""
# --------------------------
[docs]class OutputDimensionError(MWROutputError):
"""Raised if requested output dimensions do not match data"""
# --------------------------
[docs]class MissingConfig(MWRConfigError):
"""Raised if a mandatory entry of the config file is missing"""
# --------------------------
[docs]class TimerefError(MWRError):
"""Raised if time reference is local but UTC is required"""
[docs]class WrongNumberOfChannels(MWRError):
"""Raised if a wrong number of frequency channels is assumed for reading the file
-> this can happen for old-version BLB files where n_freq is read after being used"""
[docs]class DimensionError(MWRError):
"""Raised if specified dimensions do not match variable dimension"""
def __init__(self, dims_required, var, n_dims_var):
self.dims_required = dims_required
self.var = var
self.n_dims_var = n_dims_var
def __str__(self):
return "specified {} dimensions but data['{}'] is {}-dimensional".format(
len(self.dims_required), self.var, self.n_dims_var)