Modtran
source module isofit.atmosphere.engines.modtran
Classes
-
SerialEncoder — Encoder for json to help ensure json objects can be passed to the workflow manager.
source class ModtranRT(engine_config, min_samples_per_nm=10, max_samples_per_nm=100, **kwargs)
Bases : BaseAtmosphere, Writer
Methods
-
parseTokens — Processes tokens returned by parseLine()
-
parseLine — Parses a single line of a .chn file into a list of token values
-
load_chn — Parses a MODTRAN channel file and extracts relevant data
-
load_tp7 — Read a MODTRAN TP7 file and return the data as a dictionary, one entry for each case in the file. Don't do anything but read the data; all the data.
-
load_tp6 — Parses relevant information from a tp6 file. Specifically, seeking a table in the unstructured text and extracting a column from it.
-
preSim — Post-initialized, pre-simulation setup
-
readSim — For a given point, parses the tp6 and chn file and returns the data
-
makeSim — Prepares the command to execute MODTRAN
-
modtran_driver — Write a MODTRAN 6.0 input file.
-
wl2flt — Helper function to generate Gaussian distributions around the center wavelengths.
source staticmethod ModtranRT.samples_per_nm(wl, fq_resolution)
source staticmethod ModtranRT.calc_band_model(samples_per_nm: int, wavelength: float)
Raises
-
ValueError
source staticmethod ModtranRT.parseTokens(tokens: list, coszen: float) → dict
Processes tokens returned by parseLine()
Parameters
-
tokens : list — List of floats returned by parseLine()
-
coszen : float — cos(zenith(filename))
Returns
-
dict — Dictionary of calculated values using the tokens list
source staticmethod ModtranRT.parseLine(line: str) → list
Parses a single line of a .chn file into a list of token values
Parameters
-
line : str — Singular data line of a MODTRAN .chn file
Returns
-
list — List of floats parsed from the line
source method ModtranRT.load_chn(file: str, coszen: float, header: int = 4) → dict
Parses a MODTRAN channel file and extracts relevant data
Parameters
-
file : str — Path to a .chn file
-
coszen : float — ...
-
header : int, defaults=5 — Number of lines to skip for the header
Returns
-
chn : dict — Channel data
source method ModtranRT.load_tp7(file_path: str, num_albedos: int, num_models: int, coszen: float)
Read a MODTRAN TP7 file and return the data as a dictionary, one entry for each case in the file. Don't do anything but read the data; all the data.
Parameters
-
file_path : str — Path to the MODTRAN TP7 file
-
num_albedos : int — Number of unique albedos
-
num_models : int — Number of models per albedo
-
coszen : float — cosine of the solar zenith angle (TOA)
Returns
-
dict — Cases dictionary reordered by model then albedo.
Raises
-
ValueError
source staticmethod ModtranRT.load_tp6(file)
Parses relevant information from a tp6 file. Specifically, seeking a table in the unstructured text and extracting a column from it.
Parameters
-
tp6 : str — tp6 file path
Raises
-
ValueError
source method ModtranRT.preSim()
Post-initialized, pre-simulation setup
Raises
-
ValueError
source method ModtranRT.readSim(point)
For a given point, parses the tp6 and chn file and returns the data
source method ModtranRT.makeSim(point, file=None, timeout=None)
Prepares the command to execute MODTRAN
source method ModtranRT.modtran_driver(overrides)
Write a MODTRAN 6.0 input file.
Raises
-
AttributeError
source method ModtranRT.required_results_exist(filename_base)
source method ModtranRT.wl2flt(wavelengths: np.array, fwhms: np.array, outfile: str) → None
Helper function to generate Gaussian distributions around the center wavelengths.
Parameters
-
wavelengths : np.array — wavelength centers
-
fwhms : np.array — full width at half max
-
outfile : str — file to write to
source class SerialEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)
Bases : json.JSONEncoder
Encoder for json to help ensure json objects can be passed to the workflow manager.
Constructor for JSONEncoder, with sensible defaults.
If skipkeys is false, then it is a TypeError to attempt encoding of keys that are not str, int, float, bool or None. If skipkeys is True, such items are simply skipped.
If ensure_ascii is true, the output is guaranteed to be str objects with all incoming non-ASCII characters escaped. If ensure_ascii is false, the output can contain non-ASCII characters.
If check_circular is true, then lists, dicts, and custom encoded objects will be checked for circular references during encoding to prevent an infinite recursion (which would cause an RecursionError). Otherwise, no such check takes place.
If allow_nan is true, then NaN, Infinity, and -Infinity will be encoded as such. This behavior is not JSON specification compliant, but is consistent with most JavaScript based encoders and decoders. Otherwise, it will be a ValueError to encode such floats.
If sort_keys is true, then the output of dictionaries will be sorted by key; this is useful for regression tests to ensure that JSON serializations can be compared on a day-to-day basis.
If indent is a non-negative integer, then JSON array elements and object members will be pretty-printed with that indent level. An indent level of 0 will only insert newlines. None is the most compact representation.
If specified, separators should be an (item_separator, key_separator)
tuple. The default is (', ', ': ') if indent is None and
(',', ': ') otherwise. To get the most compact JSON representation,
you should specify (',', ':') to eliminate whitespace.
If specified, default is a function that gets called for objects
that can't otherwise be serialized. It should return a JSON encodable
version of the object or raise a TypeError.
Methods
source method SerialEncoder.default(obj)