oasislmf.pytools.getmodel.footprint¶
This file houses the classes that load the footprint data from compressed, binary, and CSV files.
Attributes¶
Exceptions¶
Raises exceptions when loading footprints. |
Classes¶
This class is the base class for the footprint loaders. |
|
This class is responsible for loading footprint data from CSV. |
|
This class is responsible loading the event data from the footprint binary files. |
|
This class is responsible for loading event data from compressed event data. |
|
This class is responsible for loading event data from parquet event data. |
|
This class is responsible for loading event data from parquet dynamic event sets and maps |
Functions¶
|
Creates a list of tuples from three np.arrays (all inputs must be the same length). |
Module Contents¶
- exception oasislmf.pytools.getmodel.footprint.OasisFootPrintError(message: str)[source]¶
Bases:
Exception
Raises exceptions when loading footprints.
- class oasislmf.pytools.getmodel.footprint.Footprint(storage: oasis_data_manager.filestore.backends.base.BaseStorage, df_engine='oasis_data_manager.df_reader.reader.OasisPandasReader')[source]¶
This class is the base class for the footprint loaders.
- Attributes:
storage (BaseStorage): the storage object used to lookup files stack (ExitStack): the context manager that combines other context managers and cleanup functions
- static get_footprint_fmt_priorities()[source]¶
Get list of footprint file format classes in order of priority.
Returns: (list) footprint file format classes
- classmethod load(storage: oasis_data_manager.filestore.backends.base.BaseStorage, ignore_file_type=set(), df_engine='oasis_data_manager.df_reader.reader.OasisPandasReader')[source]¶
Loads the loading classes defined in this file checking to see if the files are in the static path whilst doing so. The loading goes through the hierarchy with the following order:
-> parquet -> compressed binary file -> binary file -> CSV file -> parquet (with dynamic generation)
If the compressed binary file is present, this will be loaded. If it is not, then the binary file will be loaded and so on.
- Args:
storage (BaseStorage): the storage object used to lookup files ignore_file_type (Set[str]): type of file to be skipped in the hierarchy. This can be a choice of:
parquet json z bin idx
Returns: (Union[FootprintBinZ, FootprintBin, FootprintCsv]) the loaded class
- class oasislmf.pytools.getmodel.footprint.FootprintCsv(storage: oasis_data_manager.filestore.backends.base.BaseStorage, df_engine='oasis_data_manager.df_reader.reader.OasisPandasReader')[source]¶
Bases:
Footprint
This class is responsible for loading footprint data from CSV.
- Attributes (when in context):
footprint (np.array[EventCSV]): event data loaded from the CSV file num_intensity_bins (int): number of intensity bins in the data has_intensity_uncertainty (bool): if the data has uncertainty footprint_index (dict): map of footprint IDs with the index in the data
- class oasislmf.pytools.getmodel.footprint.FootprintBin(storage: oasis_data_manager.filestore.backends.base.BaseStorage, df_engine='oasis_data_manager.df_reader.reader.OasisPandasReader')[source]¶
Bases:
Footprint
This class is responsible loading the event data from the footprint binary files.
- Attributes (when in context):
footprint (mmap.mmap): loaded data from the binary file which has header and then Event data num_intensity_bins (int): number of intensity bins in the data has_intensity_uncertainty (bool): if the data has uncertainty footprint_index (dict): map of footprint IDs with the index in the data
- class oasislmf.pytools.getmodel.footprint.FootprintBinZ(storage: oasis_data_manager.filestore.backends.base.BaseStorage, df_engine='oasis_data_manager.df_reader.reader.OasisPandasReader')[source]¶
Bases:
Footprint
This class is responsible for loading event data from compressed event data.
- Attributes (when in context):
zfootprint (mmap.mmap): loaded data from the compressed binary file which has header and then Event data num_intensity_bins (int): number of intensity bins in the data has_intensity_uncertainty (bool): if the data has uncertainty uncompressed_size (int): the size in which the data is when it is decompressed index_dtype (Union[EventIndexBinZ, EventIndexBin]) the data type footprint_index (dict): map of footprint IDs with the index in the data
- class oasislmf.pytools.getmodel.footprint.FootprintParquet(storage: oasis_data_manager.filestore.backends.base.BaseStorage, df_engine='oasis_data_manager.df_reader.reader.OasisPandasReader')[source]¶
Bases:
Footprint
This class is responsible for loading event data from parquet event data.
- Attributes (when in context):
num_intensity_bins (int): number of intensity bins in the data has_intensity_uncertainty (bool): if the data has uncertainty footprint_index (dict): map of footprint IDs with the index in the data
- class oasislmf.pytools.getmodel.footprint.FootprintParquetDynamic(storage: oasis_data_manager.filestore.backends.base.BaseStorage, df_engine='oasis_data_manager.df_reader.reader.OasisPandasReader')[source]¶
Bases:
Footprint
This class is responsible for loading event data from parquet dynamic event sets and maps It will build the footprint from the underlying event defintion and hazard case files
- Attributes (when in context):
num_intensity_bins (int): number of intensity bins in the data has_intensity_uncertainty (bool): if the data has uncertainty. Only “no” is supported return periods (list): the list of return periods in the model. Not currently used
- oasislmf.pytools.getmodel.footprint.stitch_data(areaperil_id, intensity_bin_id, probability, buffer)[source]¶
Creates a list of tuples from three np.arrays (all inputs must be the same length). Args:
areaperil_id: (np.array) list of areaperil IDs intensity_bin_id: (np.array) list of probability bin IDs probability: (np.array) list of probabilities buffer: (np.array[Event]) list of zeros to be populated with the previous lists
Returns: