oasislmf.pytools.pla.streams¶
Attributes¶
Classes¶
Read an event loss stream and apply post-loss amplification factors to each loss. |
Functions¶
|
Read the gul loss stream, apply the post loss amplification factor and load it into out_byte_mv buffer |
|
|
|
Read input stream from gulpy or gulcalc, determine amplification ID from |
Module Contents¶
- oasislmf.pytools.pla.streams.read_buffer(byte_mv, cursor, valid_buff, event_id, item_id, items_amps, plafactors, default_factor, out_byte_mv, out_cursor)[source]¶
Read the gul loss stream, apply the post loss amplification factor and load it into out_byte_mv buffer This modified version of the read_buffer template return result when the whole input buffer is read and not when an event is read. therefore it cannot be used to read multiple stream at a time because events would be mixed up.
- Parameters:
byte_mv – input byte array
cursor – read cursor
valid_buff – valid part of input array
event_id – last event id
item_id – last item_id
items_amps (numpy array) – amplification IDs where indexes correspond to item IDs
plafactors (dict) – event ID and amplification ID pairs mapped to loss factors
default_factor (float) – post loss reduction/amplification factor to be used if loss factor not found in plafactors
out_byte_mv – output byte arrau
out_cursor – single value array to store valid part of out_byte_mv
- oasislmf.pytools.pla.streams.read_buffer_uniform(byte_mv, cursor, valid_buff, event_id, item_id, items_amps, plafactors, default_factor, out_byte_mv, out_cursor)[source]¶
- class oasislmf.pytools.pla.streams.PlaReader(items_amps, plafactors, default_factor)[source]¶
Bases:
oasislmf.pytools.common.event_stream.EventReaderRead an event loss stream and apply post-loss amplification factors to each loss.
- oasislmf.pytools.pla.streams.read_and_write_streams(stream_in, stream_out, items_amps, plafactors, default_factor)[source]¶
Read input stream from gulpy or gulcalc, determine amplification ID from item ID, determine loss factor from event ID and amplification ID pair, multiply losses by relevant factors, and write to output stream.
- Input stream is binary file with layout:
stream type (oasis_int), maximum sidx value (oasis_int), event ID 1 (oasis_int), item ID 1 (oasis_int), sample ID/sidx 1 (oasis_int), loss for sidx 1 (oasis_float), … sample ID/sidx n (oasis_int), loss for sidx n (oasis_float), 0 (oasis_int), 0.0 (4-byte float), event ID 1 (oasis_int), item ID 2 (oasis_int), … event ID M (oasis_int), item ID N (oasis_int), sample ID/sidx 1 (oasis_int), loss for sidx 1 (oasis_float), … sample ID/sidx n (oasis_int), loss for sidx n (oasis_float)
Sample ID/sidx of 0 indicates start of next event ID-item ID pair. Output stream has same format as input stream.
- Parameters:
stream_in (buffer) – input stream
stream_out (buffer) – output stream
items_amps (numpy array) – amplification IDs where indexes correspond to item IDs
plafactors (dict) – event ID and amplification ID pairs mapped to loss factors
default_factor (float) – post loss reduction/amplification factor to be used if loss factor not found in plafactors