oasislmf.pytools.fm.financial_structure¶
Functions¶
|
Load the raw financial data from static_path as numpy ndarray |
|
Build the in-memory financial structure arrays from the raw fm input files. |
|
Compute the financial structure and save it as .npy files in |
|
Module Contents¶
- oasislmf.pytools.fm.financial_structure.load_static(static_path)[source]¶
Load the raw financial data from static_path as numpy ndarray first check if .bin file is present then try .cvs try loading profile_step before falling back to normal profile,
- Parameters:
static_path (str) – path to the folder holding the static input files
- Returns:
programme: link between nodes
policytc: info on layer
profile: policy profile can be profile_step or profile
stepped: True when fm_profile_step was loaded, None when falling back to fm_profile
xref: node to output_id
items: items (item_id and coverage_id mapping), empty when items and coverages disagree on the number of coverages
coverages: Tiv value for each coverage id, empty when items and coverages disagree on the number of coverages
- Return type:
Tuple[np.ndarray, np.ndarray, np.ndarray, Optional[bool], np.ndarray, np.ndarray, np.ndarray]
- Raises:
FileNotFoundError – if one of the static is missing
- oasislmf.pytools.fm.financial_structure.extract_financial_structure(allocation_rule, fm_programme, fm_policytc, fm_profile, stepped, fm_xref, items, coverages)[source]¶
Build the in-memory financial structure arrays from the raw fm input files.
- Parameters:
allocation_rule (int) – option to indicate how the losses are allocated to the output
fm_programme (np.ndarray[fm_programme_dtype]) – structure of the levels
fm_policytc (np.ndarray[fm_policytc_dtype]) – structure of the layers and policy_id to apply
fm_profile (np.ndarray) – definition of the policy_id, of fm_profile_dtype or fm_profile_step_dtype
stepped (Optional[bool]) – True when fm_profile holds step policies, None otherwise
fm_xref (np.ndarray[fm_xref_dtype]) – mapping between the output of the allocation and output item_id
items (np.ndarray[items_dtype]) – item_id and coverage_id mapping, empty when unavailable
coverages (np.ndarray[oasis_float]) – Tiv value for each coverage id, empty when unavailable
- Returns:
compute_infos: array describing the steps of the computation to perform
nodes_array: array of the nodes of the financial structure
node_parents_array: array mapping each node to its parent nodes
node_profiles_array: array mapping each node to its profiles
output_array: array mapping each output to its node
fm_profile: the fm_profile array used by the computation
- Return type:
Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray]
- Raises:
KeyError – if a node at the output level has no output_id
- oasislmf.pytools.fm.financial_structure.create_financial_structure(allocation_rule, static_path)[source]¶
Compute the financial structure and save it as .npy files in
static_path.The extracted structure (
compute_info,nodes_array,node_parents_array,node_profiles_array,output_arrayandfm_profile) is written tostatic_path; nothing is returned.- Parameters:
- Raises:
ValueError – if allocation_rule is not one of the allowed allocation rules