oasislmf.pytools.pla.structure

Attributes

Functions

get_items_amplifications(path)

Get array of amplification IDs from amplifications.bin, where index

fill_post_loss_amplification_factors(event_id, count, ...)

Fill Post Loss Amplification (PLA) factors dictionary mapped to

get_post_loss_amplification_factors(storage, ...[, ...])

Get Post Loss Amplification (PLA) factors mapped to event ID-item ID pair.

Module Contents

oasislmf.pytools.pla.structure.logger[source]
oasislmf.pytools.pla.structure.get_items_amplifications(path)[source]

Get array of amplification IDs from amplifications.bin, where index corresponds to item ID.

amplifications.bin is binary file with layout:

reserved header (4-byte int), item ID 1 (4-byte int), amplification ID a_1 (4-byte int), … item ID n (4-byte int), amplification ID a_n (4-byte int)

Args:

path (str): path to amplifications.bin file

Returns:
items_amps (numpy.ndarray): array of amplification IDs, where index

corresponds to item ID

oasislmf.pytools.pla.structure.fill_post_loss_amplification_factors(event_id, count, cursor, valid_length, event_count, amp_factor, plafactors, secondary_factor)[source]

Fill Post Loss Amplification (PLA) factors dictionary mapped to event ID-item ID pair.

Args:

event_id (int): current event ID count (int): number of remaning amplification IDs associated with

current event ID

cursor (int): position in buffer valid_length (int): length of buffer in 8-bit chunks event_count (numpy.ndarray): array of event ID-count pairs amp_factor (numpy.ndarray): array of amplification ID-loss pairs plafactors (numba.typed.typeddict.Dict): PLA factors dictionary secondary_factor (float): secondary factor to apply to post loss

amplification

Returns:

event_id (int): current event ID count (int): number of remaining amplification IDs associated with

current event ID

plafactors (numba.typed.typeddict.Dict): PLA factors dictionary

oasislmf.pytools.pla.structure.get_post_loss_amplification_factors(storage: oasis_data_manager.filestore.backends.base.BaseStorage, secondary_factor, uniform_factor, ignore_file_type=set())[source]

Get Post Loss Amplification (PLA) factors mapped to event ID-item ID pair. Returns empty dictionary if uniform factor to apply across all losses has been given.

lossfactors.bin is binary file with layout:

reserved header (4-byte int), event ID 1 (4-byte int), number of amplification IDs for event ID 1 (4-byte int), amplification ID 1 (4-byte int), loss factor for amplification ID 1 (4-byte float), … amplification ID n (4-byte int), loss factor for amplification ID n (4-byte float), event ID 2 (4-byte int), number of amplification IDs for event ID 2 (4-byte int), … event ID N (4-byte int), number of amplification IDs for event ID N (4-byte int), amplification ID 1 (4-byte int), loss factor for amplification ID 1 (4-byte float), … amplification ID n (4-byte int), loss factor for amplification ID n (4-byte float)

Args:

storage: (BaseStorage) the storage connector for fetching the model data secondary_factor (float): secondary factor to apply to post loss

amplification

uniform_factor (float): uniform factor to apply across all losses ignore_file_type: set(str) file extension to ignore when loading

Returns:

plafactors (dict): event ID-item ID pairs mapped to amplification IDs