gfail.logbase¶
- class gfail.logbase.LogisticModelBase(shakefile, config, bounds=None, uncertfile=None, trimfile=None, slopefile=None, saveinputs=False)[source]¶
Bases:
object
TODO needs documentation
- Parameters
object (_type_) – _description_
- Raises
Exception – _description_
Exception – _description_
- Returns
_description_
- Return type
_type_
Initialize LogisticModelBase object.
- Parameters
shakefile (str) – Path to ShakeMap grid.xml file.
config (dict) – Dict like object as a result of reading in “logbase” format INI files.
bounds (dict) – Fields are ‘xmin’, ‘xmax’, ‘ymin’, ‘ymax’.
uncertfile (str) – Path to ShakeMap uncertainty.xml file.
trimfile (str) – Path to shapefile to use for masking ocean pixels.
slopefile (str) – File containing slope data to be used for slope masking.
saveinputs (bool) – Save input layer grids with model output.
Notes: All input data grids are loaded in one at a time, and saved to a temporary folder that is deleted when the object is deleted. The file names loaded are stored in the self.layers dictionary.
- COEFFS = {}¶
- TERMS = {}¶
- TERMLAYERS = {}¶
- SHAKELAYERS = []¶
- do_coverage = False¶
- notes = ''¶
- nonzero = None¶
- slopemin = 'none'¶
- slopemax = 'none'¶
- slopefile = None¶
- prob_units = None¶
- get_units(layer)[source]¶
Get units for an input layer.
- Parameters
layer (str) – name of layer.
- Returns
units.
- Return type
str
- validate_units(cmodel)[source]¶
Validate model units.
- Parameters
cmodel (dict) – Sub-dictionary from config for specific model.
- Returns
Model units.
- Return type
dict
- validate_refs(cmodel)[source]¶
Validate references for models and layers.
- Parameters
cmodel (dict) – Sub-dictionary from config for specific model.
- Returns
- (modelrefs, longrefs, shortrefs) where:
- modelrefs: dictionary of citation information for model
keys=’longref’, ‘shortref’
- shortrefs: dictionary containing short reference for each
input layer
- longrefs: dictionary containing full references for each
input layer
- Return type
tuple
- calculate()[source]¶
Calculate the probability, and sigma (if possible).
- Returns:
- dict: Must contain at least one sub dictionary with
key “model”. That dictionary should look like: {‘grid’: Grid2D object contanining probability values,
‘label’: String used for display label ‘type’: ‘output’, ‘description’: String description of model.
}
This method uses an “accumulator” array, and loads in data layers from the temporary directory one term at a time. As some terms can be a combination of layers, this may mean that multiple grids are loaded into memory simultaneously, in addition to the accumulator grid. Layer grids are deleted from memory once they have been added to the accumulator array.