OasisLMF / ktools

In-memory simulation kernel for loss modelling.
BSD 3-Clause "New" or "Revised" License
28 stars 19 forks source link

Incorporate model file validation checks into csv to binary conversion tools #370

Closed hchagani-oasislmf closed 7 months ago

hchagani-oasislmf commented 7 months ago

Incorporate model file validation checks into csv to binary conversion tools

Validation checks for damage bin dictionary, footprint and vulnerability model files have been incorporated into their respective csv to binary conversion tools, and are run by default. These checks can be suppressed with the -N command line flag. For example:

# Convert to binary file and suppress validation checks
$ damagebintobin -N < damage_bin_dict.csv > damage_bin_dict.bin
$ footprinttobin -N -i 121 -b footprint.bin -x footprint.idx < footprint.csv
$ vulnerabilitytobin -N -d 102 < vulnerability.csv > vulnerability.bin

# Convert to binary file and execute validation checks
$ damagebintobin < damage_bin_dict.csv > damage_bin_dict.bin
$ footprinttobin -i 121 -b footprint.bin -x footprint.idx < footprint.csv
$ vulnerabilitytobin -d 102 < vulnerability.csv > vulnerability.bin

# Execute validation checks
$ validatedamagebin < damage_bin_dict.csv
$ validatefootprint < footprint.csv
$ validatevulnerability < vulnerability.csv

Additionally, the -S command line flag has been introduced to validatevulnerability and vulnerabilitytobin to suppress warnings when all intensity bins are not present each vulnerability ID. It is recommended to suppress these warnings for multiple peril models:

$ validatevulnerability -S < vulnerability.csv
WARNING: Vulnerability ID 1: Intensity bin 4 missing. All intensity bins must be present for each vulnerability ID in single peril models.
WARNING: Vulnerability ID 2: Intensity bins 1 and 2 missing. All intensity bins must be present for each vulnerability ID in single peril models.
INFO: All Vulnerability file validation checks have passed. Please take note of any warnings.