forked from NHERI-SimCenter/pelicun
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1e2adb7
commit 22d3422
Showing
5 changed files
with
358 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
{ | ||
"GeneralInformation": { | ||
"NumberOfStories": 1, | ||
"YearBuilt": 1900, | ||
"StructureType": "C1", | ||
"OccupancyClass": "EDU1", | ||
"units": { | ||
"force": "kips", | ||
"length": "ft", | ||
"time": "sec" | ||
}, | ||
"DesignLevel": "LC", | ||
"BuildingRise": "L" | ||
}, | ||
"assetType": "Buildings", | ||
"Applications": { | ||
"DL": { | ||
"ApplicationData": { | ||
"ground_failure": false | ||
} | ||
} | ||
}, | ||
"DL": { | ||
"Asset": { | ||
"ComponentAssignmentFile": "CMP_QNT.csv", | ||
"ComponentDatabase": "Hazus Earthquake - Buildings", | ||
"NumberOfStories": "1", | ||
"OccupancyType": "EDU1", | ||
"PlanArea": "1" | ||
}, | ||
"Damage": { | ||
"DamageProcess": "Hazus Earthquake", | ||
"ScalingSpecification": {"LF.C1.L.LC-1-1": "*1.2", "collapse-0-1": "*1.2"} | ||
}, | ||
"Demands": { | ||
"DemandFilePath": "response.csv", | ||
"SampleSize": "100", | ||
"CoupledDemands": true | ||
}, | ||
"Losses": { | ||
"Repair": { | ||
"ConsequenceDatabase": "Hazus Earthquake - Buildings", | ||
"MapApproach": "Automatic" | ||
} | ||
}, | ||
"Options": { | ||
"NonDirectionalMultipliers": { | ||
"ALL": 1.0 | ||
} | ||
}, | ||
"Outputs": { | ||
"Demand": { | ||
"Sample": true, | ||
"Statistics": false | ||
}, | ||
"Asset": { | ||
"Sample": true, | ||
"Statistics": false | ||
}, | ||
"Damage": { | ||
"Sample": false, | ||
"Statistics": false, | ||
"GroupedSample": true, | ||
"GroupedStatistics": true | ||
}, | ||
"Loss": { | ||
"Repair": { | ||
"Sample": true, | ||
"Statistics": true, | ||
"GroupedSample": true, | ||
"GroupedStatistics": false, | ||
"AggregateSample": true, | ||
"AggregateStatistics": true | ||
} | ||
}, | ||
"Format": { | ||
"CSV": false, | ||
"JSON": true | ||
}, | ||
"Settings": { | ||
"CondenseDS": true, | ||
"SimpleIndexInJSON": true, | ||
"AggregateColocatedComponentResults": true | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
,Units,Location,Direction,Theta_0,Family | ||
LF.C1.L.LC,ea,1,1,1,N/A |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright (c) 2018 Leland Stanford Junior University | ||
# Copyright (c) 2018 The Regents of the University of California | ||
# | ||
# This file is part of pelicun. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# | ||
# 1. Redistributions of source code must retain the above copyright notice, | ||
# this list of conditions and the following disclaimer. | ||
# | ||
# 2. Redistributions in binary form must reproduce the above copyright notice, | ||
# this list of conditions and the following disclaimer in the documentation | ||
# and/or other materials provided with the distribution. | ||
# | ||
# 3. Neither the name of the copyright holder nor the names of its contributors | ||
# may be used to endorse or promote products derived from this software without | ||
# specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
# POSSIBILITY OF SUCH DAMAGE. | ||
# | ||
# You should have received a copy of the BSD 3-Clause License along with | ||
# pelicun. If not, see <http://www.opensource.org/licenses/>. |
101 changes: 101 additions & 0 deletions
101
pelicun/tests/dl_calculation/e1_no_autopop/response.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
,1-PGA-1-1 | ||
0.000000000000000000e+00,6.849029933956130911e+00 | ||
1.000000000000000000e+00,1.237134226051886543e+01 | ||
2.000000000000000000e+00,1.972131621939452018e+01 | ||
3.000000000000000000e+00,9.152152931865703778e+00 | ||
4.000000000000000000e+00,4.762545330142875954e+00 | ||
5.000000000000000000e+00,5.119594082152485903e+00 | ||
6.000000000000000000e+00,8.985259370480688901e+00 | ||
7.000000000000000000e+00,5.800429585653212428e+00 | ||
8.000000000000000000e+00,6.721154036788936637e+00 | ||
9.000000000000000000e+00,1.180442967680789756e+01 | ||
1.000000000000000000e+01,1.757573848172475195e+01 | ||
1.100000000000000000e+01,2.408892253534509109e+01 | ||
1.200000000000000000e+01,5.366956767518109572e+00 | ||
1.300000000000000000e+01,6.689460282908749278e+00 | ||
1.400000000000000000e+01,9.837892431968002782e+00 | ||
1.500000000000000000e+01,3.108201101576595793e+00 | ||
1.600000000000000000e+01,7.969306015954598976e+00 | ||
1.700000000000000000e+01,6.239227951703175457e+00 | ||
1.800000000000000000e+01,1.265503535460110918e+01 | ||
1.900000000000000000e+01,5.152699658386873161e+00 | ||
2.000000000000000000e+01,8.945841984822743953e+00 | ||
2.100000000000000000e+01,5.271650608692700857e+00 | ||
2.200000000000000000e+01,1.217883862654925764e+01 | ||
2.300000000000000000e+01,4.565064448801355645e+00 | ||
2.400000000000000000e+01,2.827185963889101927e+01 | ||
2.500000000000000000e+01,8.360633657235220895e+00 | ||
2.600000000000000000e+01,1.771275449651086475e+01 | ||
2.700000000000000000e+01,1.353470186586244495e+01 | ||
2.800000000000000000e+01,1.585083782737845048e+01 | ||
2.900000000000000000e+01,7.743412977553257193e+00 | ||
3.000000000000000000e+01,1.673262791659537640e+01 | ||
3.100000000000000000e+01,1.125514571474493408e+01 | ||
3.200000000000000000e+01,6.706408356999864928e+00 | ||
3.300000000000000000e+01,7.770377729315534943e+00 | ||
3.400000000000000000e+01,9.665443132282717897e+00 | ||
3.500000000000000000e+01,1.723980753309739811e+01 | ||
3.600000000000000000e+01,1.291221957249968177e+01 | ||
3.700000000000000000e+01,5.012730578330669040e+00 | ||
3.800000000000000000e+01,1.143700619441758626e+01 | ||
3.900000000000000000e+01,1.252350066480562596e+01 | ||
4.000000000000000000e+01,6.383801705492390788e+00 | ||
4.100000000000000000e+01,8.314748267032781470e+00 | ||
4.200000000000000000e+01,8.332817023133479495e+00 | ||
4.300000000000000000e+01,7.344179823126522066e+00 | ||
4.400000000000000000e+01,1.645381636611937282e+01 | ||
4.500000000000000000e+01,1.204983450209533657e+01 | ||
4.600000000000000000e+01,1.165673673862969828e+01 | ||
4.700000000000000000e+01,7.513555832366318299e+00 | ||
4.800000000000000000e+01,2.024437216200684730e+01 | ||
4.900000000000000000e+01,8.920834603836945931e+00 | ||
5.000000000000000000e+01,1.080188057233199572e+01 | ||
5.100000000000000000e+01,6.199736427905365943e+00 | ||
5.200000000000000000e+01,1.372165205481582362e+01 | ||
5.300000000000000000e+01,7.684718998480578378e+00 | ||
5.400000000000000000e+01,5.171043463741079371e+00 | ||
5.500000000000000000e+01,2.111664537027713706e+01 | ||
5.600000000000000000e+01,1.019006581042710913e+01 | ||
5.700000000000000000e+01,4.275116867520939223e+00 | ||
5.800000000000000000e+01,1.899195644078132261e+01 | ||
5.900000000000000000e+01,1.213049449493617438e+01 | ||
6.000000000000000000e+01,4.832690227828255303e+00 | ||
6.100000000000000000e+01,3.791254293305350132e+00 | ||
6.200000000000000000e+01,8.030002531225640894e+00 | ||
6.300000000000000000e+01,1.163245027176597013e+01 | ||
6.400000000000000000e+01,2.171715232778592508e+01 | ||
6.500000000000000000e+01,7.206784171136174422e+00 | ||
6.600000000000000000e+01,4.534544778468278636e+00 | ||
6.700000000000000000e+01,8.180354349576319350e+00 | ||
6.800000000000000000e+01,2.096016461144264653e+01 | ||
6.900000000000000000e+01,1.020904287768493468e+01 | ||
7.000000000000000000e+01,3.578274393687075783e+00 | ||
7.100000000000000000e+01,1.207216137873451700e+01 | ||
7.200000000000000000e+01,1.899808690168648084e+01 | ||
7.300000000000000000e+01,1.447931410453573520e+01 | ||
7.400000000000000000e+01,4.652951138159096445e+00 | ||
7.500000000000000000e+01,9.959855894302648949e+00 | ||
7.600000000000000000e+01,4.533117400993131874e+00 | ||
7.700000000000000000e+01,7.248896994573899910e+00 | ||
7.800000000000000000e+01,8.842184263094427621e+00 | ||
7.900000000000000000e+01,4.215076299759047629e+00 | ||
8.000000000000000000e+01,1.529557773187450032e+01 | ||
8.100000000000000000e+01,4.175349145066248546e+00 | ||
8.200000000000000000e+01,1.009543326050395251e+01 | ||
8.300000000000000000e+01,8.690186504818180779e+00 | ||
8.400000000000000000e+01,1.547032449114289854e+01 | ||
8.500000000000000000e+01,7.042901121410118925e+00 | ||
8.600000000000000000e+01,4.125904243435575935e+00 | ||
8.700000000000000000e+01,1.376223081867616571e+01 | ||
8.800000000000000000e+01,7.388148474784416386e+00 | ||
8.900000000000000000e+01,1.453892207787288093e+01 | ||
9.000000000000000000e+01,1.299062984361380124e+01 | ||
9.100000000000000000e+01,6.391741821717948469e+00 | ||
9.200000000000000000e+01,8.088304936390127153e+00 | ||
9.300000000000000000e+01,2.300799414165177481e+01 | ||
9.400000000000000000e+01,1.575348473932006321e+01 | ||
9.500000000000000000e+01,1.019287352203471109e+01 | ||
9.600000000000000000e+01,1.786715222266329661e+01 | ||
9.700000000000000000e+01,1.328402105666898869e+01 | ||
9.800000000000000000e+01,5.457579231912252915e+00 | ||
9.900000000000000000e+01,5.857004480627420406e+00 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
# Copyright (c) 2018 Leland Stanford Junior University | ||
# Copyright (c) 2018 The Regents of the University of California | ||
# | ||
# This file is part of pelicun. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# | ||
# 1. Redistributions of source code must retain the above copyright notice, | ||
# this list of conditions and the following disclaimer. | ||
# | ||
# 2. Redistributions in binary form must reproduce the above copyright notice, | ||
# this list of conditions and the following disclaimer in the documentation | ||
# and/or other materials provided with the distribution. | ||
# | ||
# 3. Neither the name of the copyright holder nor the names of its contributors | ||
# may be used to endorse or promote products derived from this software without | ||
# specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
# POSSIBILITY OF SUCH DAMAGE. | ||
# | ||
# You should have received a copy of the BSD 3-Clause License along with | ||
# pelicun. If not, see <http://www.opensource.org/licenses/>. | ||
|
||
"""DL Calculation Example 1.""" | ||
|
||
import os | ||
import shutil | ||
import tempfile | ||
from pathlib import Path | ||
from typing import Generator | ||
|
||
import pytest | ||
|
||
from pelicun.pelicun_warnings import PelicunWarning | ||
from pelicun.tools.DL_calculation import run_pelicun | ||
|
||
|
||
@pytest.fixture | ||
def obtain_temp_dir() -> Generator: | ||
# get the path of this file | ||
this_file = __file__ | ||
|
||
initial_dir = Path.cwd() | ||
this_dir = str(Path(this_file).parent) | ||
|
||
temp_dir = tempfile.mkdtemp() | ||
|
||
yield this_dir, temp_dir | ||
|
||
# go back to the right directory, otherwise any tests that follow | ||
# could have issues. | ||
os.chdir(initial_dir) | ||
|
||
|
||
def test_dl_calculation_1(obtain_temp_dir: str) -> None: | ||
this_dir: str | ||
temp_dir: str | ||
|
||
this_dir, temp_dir = obtain_temp_dir # type: ignore | ||
|
||
# Copy all input files to a temporary directory. | ||
# All outputs will also go there. | ||
# This approach is more robust to changes in the output files over | ||
# time. | ||
|
||
os.chdir(this_dir) | ||
temp_dir = tempfile.mkdtemp() | ||
# copy input files | ||
for file_name in ('8000-AIM.json', 'response.csv', 'CMP_QNT.csv'): | ||
shutil.copy(f'{this_dir}/{file_name}', f'{temp_dir}/{file_name}') | ||
|
||
# change directory to there | ||
os.chdir(temp_dir) | ||
|
||
# run | ||
with pytest.warns(PelicunWarning): | ||
run_pelicun( | ||
demand_file='response.csv', | ||
config_path='8000-AIM.json', | ||
output_path=None, | ||
coupled_edp=True, | ||
realizations=100, | ||
auto_script_path=None, | ||
detailed_results=False, | ||
output_format=None, | ||
custom_model_dir=None, | ||
) | ||
|
||
# | ||
# Test files | ||
# | ||
|
||
# Ensure the number of files is as expected | ||
num_files = sum(1 for entry in Path(temp_dir).iterdir() if entry.is_file()) | ||
assert num_files == 18 | ||
|
||
# Verify their names | ||
files = { | ||
'8000-AIM.json', | ||
'CMP_QNT.csv', | ||
'CMP_sample.json', | ||
'DEM_sample.json', | ||
'DL_summary.csv', | ||
'DL_summary.json', | ||
'DL_summary_stats.csv', | ||
'DL_summary_stats.json', | ||
'DMG_grp.json', | ||
'DMG_grp_stats.json', | ||
'DV_repair_agg.json', | ||
'DV_repair_agg_stats.json', | ||
'DV_repair_grp.json', | ||
'DV_repair_sample.json', | ||
'DV_repair_stats.json', | ||
'pelicun_log.txt', | ||
'pelicun_log_warnings.txt', | ||
'response.csv', | ||
} | ||
|
||
for file in files: | ||
assert Path(f'{temp_dir}/{file}').is_file() | ||
|
||
# | ||
# Check the values: TODO | ||
# |