Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Dynamic Exposure
Global Dynamic Exposure
gde-importer
Commits
e35b1c2d
Commit
e35b1c2d
authored
Nov 10, 2021
by
Cecilia Nievas
Browse files
Added feature to retrieve building classes and their proportions
parent
d01f10c5
Pipeline
#30311
passed with stage
in 3 minutes and 27 seconds
Changes
8
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
gdeimporter/aggregatedexposuremodel.py
View file @
e35b1c2d
...
...
@@ -263,6 +263,9 @@ class ExposureModelESRM20(AggregatedExposureModel):
"Non-Structural"
:
"COST_NONSTRUCTURAL_EUR"
,
"Contents"
:
"COST_CONTENTS_EUR"
,
},
"building_class_name"
:
"TAXONOMY"
,
"settlement_type"
:
"SETTLEMENT_TYPE"
,
"occupancy_subtype"
:
"OCCUPANCY_TYPE"
,
}
self
.
currency
=
"EUR"
self
.
exposure_entities
=
self
.
retrieve_exposure_entities
(
configuration
)
...
...
@@ -453,6 +456,11 @@ class ExposureModelESRM20(AggregatedExposureModel):
)
total_buildings
,
total_dwellings
,
total_people
,
total_cost
=
results
# Retrieve proportions of building classes
building_classes_proportions
=
self
.
_retrieve_building_classes
(
data_table
,
id_column_name_data
,
data_units_ids
)
for
data_unit_id
in
data_units_ids
:
self
.
exposure_entities
[
exposure_entity_name
].
occupancy_cases
[
occupancy_case
][
"data_units"
...
...
@@ -465,6 +473,7 @@ class ExposureModelESRM20(AggregatedExposureModel):
total_people
[
data_unit_id
],
total_cost
[
data_unit_id
],
self
.
currency
,
building_classes_proportions
[
data_unit_id
],
)
return
...
...
@@ -559,6 +568,17 @@ class ExposureModelESRM20(AggregatedExposureModel):
sep
=
","
,
)
# Fill in data_table with potentially missing columns with default values
to_add_if_non_existent
=
[
self
.
csv_column_names
[
"settlement_type"
],
self
.
csv_column_names
[
"occupancy_subtype"
],
]
for
i
in
range
(
len
(
to_add_if_non_existent
)):
if
to_add_if_non_existent
[
i
]
not
in
data_table
.
columns
:
data_table
[
to_add_if_non_existent
[
i
]]
=
numpy
.
array
(
[
"ALL"
for
j
in
range
(
data_table
.
shape
[
0
])]
)
return
data_table
def
_read_geometries_table
(
self
,
configuration
,
exposure_entity
,
occupancy_case
,
datatypes
):
...
...
@@ -736,3 +756,75 @@ class ExposureModelESRM20(AggregatedExposureModel):
)
return
total_buildings
,
total_dwellings
,
total_people
,
total_cost
def
_retrieve_building_classes
(
self
,
data_table
,
ids_column_name
,
data_units_ids
):
"""This function retrieves from data_table the proportions of building classes in each
data unit enumerated in data_units_ids.
A building class is defined by a combination of three columns in data_table. The names
of these columns are found under:
self.csv_column_names["building_class_name"]
self.csv_column_names["settlement_type"]
self.csv_column_names["occupancy_subtype"]
Args:
data_table (Pandas DataFrame):
DataFrame with all contents of the ESRM20 CSV file for a specific
ExposureEntity and occupancy_case.
ids_column_name (str):
Name of the column of data_table where the data unit IDs are found.
data_units_ids (list of str):
List of IDs of data units assumed to be found in column ids_column_name of
data_table.
Returns:
proportions (dict):
Dictionary containing the proportions of buildings classes per data unit. The
keys of the dictionary are the data_units_ids. Each proportions[key] contains a
Pandas DataFrames with the following columns:
building_class_name (str):
String describing the building class as per the building classification
schema specified in self.building_classification_schema.
settlement_type (str):
Type of settlement: "URBAN", "RURAL", "BIG_CITY", "ALL".
occupancy_subtype (str):
Details on the occupancy, if available and relevant to characterise the
building classes. E.g. "Hotels", "Trade", "Offices", "Apartment", etc.
proportions (float):
Proportions in which each combination of building_class_name,
settlement_type and occupancy_subtype are present in the Data Unit. The
values of proportions need to add up to 1.0.
"""
contents
=
[
"building_class_name"
,
"settlement_type"
,
"occupancy_subtype"
,
"Buildings"
,
]
columns_to_filter
=
[
self
.
csv_column_names
[
contents
[
i
]]
for
i
in
range
(
len
(
contents
))]
columns_to_group
=
columns_to_filter
[:
-
1
]
proportions
=
{}
for
data_unit_id
in
data_units_ids
:
# Retrieve from data_table the rows for this Data Unit and the columns_to_filter
which
=
numpy
.
where
(
data_table
[
ids_column_name
].
values
==
data_unit_id
)[
0
]
data_filtered
=
data_table
.
loc
[
which
,
columns_to_filter
].
copy
()
# Identify unique combinations of the columns_to_group and sum the num. of buildings
grouped
=
data_filtered
.
groupby
(
columns_to_group
).
sum
()
# Split the resulting DataFrame index containing the unique combinations
unique_vals
=
{}
for
j
,
col
in
enumerate
(
contents
[:
-
1
]):
unique_vals
[
col
]
=
numpy
.
array
(
[
grouped
.
index
[
i
][
j
]
for
i
in
range
(
grouped
.
shape
[
0
])]
)
# Transform numbers of buildings into proportions
unique_vals
[
"proportions"
]
=
(
grouped
[
self
.
csv_column_names
[
"Buildings"
]].
to_numpy
()
/
grouped
[
self
.
csv_column_names
[
"Buildings"
]].
to_numpy
().
sum
()
)
proportions
[
data_unit_id
]
=
pandas
.
DataFrame
(
unique_vals
)
return
proportions
gdeimporter/dataunit.py
View file @
e35b1c2d
...
...
@@ -86,6 +86,20 @@ class DataUnit:
Replacement cost of the contents of all buildings.
self.currency (str):
Currency used in self.total_cost to express building replacement costs.
self.building_classes_proportions (Pandas DataFrame):
Pandas DataFrame with the following columns:
building_class_name (str):
Name of the building classes associated with the Data Unit.
settlement_type (str):
Type of settlement within the Data Unit. E.g. "URBAN", "RURAL",
"BIG_CITY", "ALL", etc.
occupancy_subtype (str):
Details on the occupancy, if available and relevant to characterise
the building classes.
proportions (float):
Proportions in which each of the building classes defined by
building_class_name, settlement_type and occupancy_subtype are
present in the Data Unit. This column needs to add up to 1.0.
self.data_unit_tiles (GeoPandas GeoDataFrame):
Definition of the data-unit tiles associated with the data unit. It is filled in by
ExposureEntity.create_data_unit_tiles(), processing all the data units associated
...
...
@@ -107,6 +121,7 @@ class DataUnit:
total_people
=
_TOTAL_PEOPLE_DEFAULT
,
total_cost
=
_TOTAL_COST_DEFAULT
,
currency
=
None
,
building_classes_proportions
=
None
,
):
"""
Args:
...
...
@@ -136,6 +151,20 @@ class DataUnit:
Contents. See definitions in the description of DataUnit.total_cost.
currency (str):
Currency used in total_cost to express building replacement costs.
building_classes_proportions (Pandas DataFrame):
Pandas DataFrame with the following columns:
building_class_name (str):
String describing the building class as per the building classification
schema specified in building_classification_schema.
settlement_type (str):
Type of settlement: "URBAN", "RURAL", "BIG_CITY", "ALL".
occupancy_subtype (str):
Details on the occupancy, if available and relevant to characterise the
building classes. E.g. "Hotels", "Trade", "Offices", "Apartment", etc.
proportions (float):
Proportions in which each combination of building_class_name,
settlement_type and occupancy_subtype are present in the Data Unit. The
values of proportions need to add up to 1.0.
"""
# Check that the keys of total_people are the expected ones
...
...
@@ -159,6 +188,7 @@ class DataUnit:
self
.
total_people
=
total_people
self
.
total_cost
=
total_cost
self
.
currency
=
currency
self
.
building_classes_proportions
=
building_classes_proportions
def
get_data_unit_geometry
(
self
,
geometries_table
,
target_column_name
):
"""This function retrieves the geometry of the data unit, by reading it from
...
...
tests/data/ExposureModelESRM20_non_trivial/_exposure_models/Exposure_Model_Entity_1_Com.csv
View file @
e35b1c2d
lon,lat,taxonomy
,BUILDINGS,ID_1,DWELLINGS,TOTAL_REPL_COST_EUR,COST_STRUCTURAL_EUR,COST_NONSTRUCTURAL_EUR,COST_CONTENTS_EUR,OCCUPANTS_PER_ASSET,OCCUPANTS_PER_ASSET_DAY,OCCUPANTS_PER_ASSET_NIGHT,OCCUPANTS_PER_ASSET_TRANSIT,OCCUPANTS_PER_ASSET_AVERAGE
20.1,47.3,A,35.2,Unit_X,35.2,316800000,126720000,63360000,126720000,1056,844.8,105.6,211.2,387.2
20.1,47.3,B,12.7,Unit_X,12.7,114300000,45720000,22860000,45720000,381,304.8,38.1,76.2,139.7
20.1,47.3,C,8.9,Unit_X,8.9,80100000,32040000,16020000,32040000,267,213.6,26.7,53.4,97.9
20.1,47.3,C,5.7,Unit_X,5.7,51300000,20520000,10260000,20520000,171,136.8,17.1,34.2,62.7
19.8,47.4,A,25.6,Unit_Y,25.6,230400000,92160000,46080000,92160000,768,614.4,76.8,153.6,281.6
19.8,47.4,A,7.9,Unit_Y,7.9,71100000,28440000,14220000,28440000,237,189.6,23.7,47.4,86.9
19.8,47.4,B,23.5,Unit_Y,23.5,211500000,84600000,42300000,84600000,705,564,70.5,141,258.5
20.4,46.9,A,40.2,Unit_Z,40.2,361800000,144720000,72360000,144720000,1206,964.8,120.6,241.2,442.2
20.4,46.9,B,16.3,Unit_Z,16.3,146700000,58680000,29340000,58680000,489,391.2,48.9,97.8,179.3
20.4,46.9,C,33.4,Unit_Z,33.4,300600000,120240000,60120000,120240000,1002,801.6,100.2,200.4,367.4
LON,LAT,TAXONOMY,SETTLEMENT_TYPE,OCCUPANCY_TYPE
,BUILDINGS,ID_1,DWELLINGS,TOTAL_REPL_COST_EUR,COST_STRUCTURAL_EUR,COST_NONSTRUCTURAL_EUR,COST_CONTENTS_EUR,OCCUPANTS_PER_ASSET,OCCUPANTS_PER_ASSET_DAY,OCCUPANTS_PER_ASSET_NIGHT,OCCUPANTS_PER_ASSET_TRANSIT,OCCUPANTS_PER_ASSET_AVERAGE
20.1,47.3,A,
BIG_CITY,ALL,
35.2,Unit_X,35.2,316800000,126720000,63360000,126720000,1056,844.8,105.6,211.2,387.2
20.1,47.3,B,
RURAL,ALL,
12.7,Unit_X,12.7,114300000,45720000,22860000,45720000,381,304.8,38.1,76.2,139.7
20.1,47.3,C,
BIG_CITY,ALL,
8.9,Unit_X,8.9,80100000,32040000,16020000,32040000,267,213.6,26.7,53.4,97.9
20.1,47.3,C,
BIG_CITY,ALL,
5.7,Unit_X,5.7,51300000,20520000,10260000,20520000,171,136.8,17.1,34.2,62.7
19.8,47.4,A,
RURAL,ALL,
25.6,Unit_Y,25.6,230400000,92160000,46080000,92160000,768,614.4,76.8,153.6,281.6
19.8,47.4,A,
URBAN,ALL,
7.9,Unit_Y,7.9,71100000,28440000,14220000,28440000,237,189.6,23.7,47.4,86.9
19.8,47.4,B,
RURAL,ALL,
23.5,Unit_Y,23.5,211500000,84600000,42300000,84600000,705,564,70.5,141,258.5
20.4,46.9,A,
BIG_CITY,ALL,
40.2,Unit_Z,40.2,361800000,144720000,72360000,144720000,1206,964.8,120.6,241.2,442.2
20.4,46.9,B,
BIG_CITY,ALL,
16.3,Unit_Z,16.3,146700000,58680000,29340000,58680000,489,391.2,48.9,97.8,179.3
20.4,46.9,C,
RURAL,ALL,
33.4,Unit_Z,33.4,300600000,120240000,60120000,120240000,1002,801.6,100.2,200.4,367.4
tests/data/ExposureModelESRM20_non_trivial/_exposure_models/Exposure_Model_Entity_1_Res.csv
View file @
e35b1c2d
lon,lat,taxonomy,BUILDINGS
,ID_1,DWELLINGS,TOTAL_REPL_COST_EUR,COST_STRUCTURAL_EUR,COST_NONSTRUCTURAL_EUR,COST_CONTENTS_EUR,OCCUPANTS_PER_ASSET,OCCUPANTS_PER_ASSET_DAY,OCCUPANTS_PER_ASSET_NIGHT,OCCUPANTS_PER_ASSET_TRANSIT,OCCUPANTS_PER_ASSET_AVERAGE
20.1,47.3,A,35.2,Unit_1,105.6,158400000,79200000,47520000,31680000,264,39.6,184.8,52.8,92.4
20.1,47.3,B,12.7,Unit_1,38.1,57150000,28575000,17145000,11430000,95.25,14.2875,66.675,19.05,33.3375
20.1,47.3,C,8.9,Unit_1,26.7,40050000,20025000,12015000,8010000,66.75,10.0125,46.725,13.35,23.3625
20.1,47.3,C,5.7,Unit_1,17.1,25650000,12825000,7695000,5130000,42.75,6.4125,29.925,8.55,14.9625
19.8,47.4,A,25.6,Unit_2,76.8,115200000,57600000,34560000,23040000,192,28.8,134.4,38.4,67.2
19.8,47.4,A,7.9,Unit_2,23.7,35550000,17775000,10665000,7110000,59.25,8.8875,41.475,11.85,20.7375
19.8,47.4,B,23.5,Unit_2,70.5,105750000,52875000,31725000,21150000,176.25,26.4375,123.375,35.25,61.6875
20.4,46.9,A,40.2,Unit_3,120.6,180900000,90450000,54270000,36180000,301.5,45.225,211.05,60.3,105.525
20.4,46.9,B,16.3,Unit_3,48.9,73350000,36675000,22005000,14670000,122.25,18.3375,85.575,24.45,42.7875
20.4,46.9,C,33.4,Unit_3,100.2,150300000,75150000,45090000,30060000,250.5,37.575,175.35,50.1,87.675
LON,LAT,TAXONOMY,BUILDINGS,SETTLEMENT_TYPE,OCCUPANCY_TYPE
,ID_1,DWELLINGS,TOTAL_REPL_COST_EUR,COST_STRUCTURAL_EUR,COST_NONSTRUCTURAL_EUR,COST_CONTENTS_EUR,OCCUPANTS_PER_ASSET,OCCUPANTS_PER_ASSET_DAY,OCCUPANTS_PER_ASSET_NIGHT,OCCUPANTS_PER_ASSET_TRANSIT,OCCUPANTS_PER_ASSET_AVERAGE
20.1,47.3,A,35.2,
BIG_CITY,Apartment,
Unit_1,105.6,158400000,79200000,47520000,31680000,264,39.6,184.8,52.8,92.4
20.1,47.3,B,12.7,
BIG_CITY,Apartment,
Unit_1,38.1,57150000,28575000,17145000,11430000,95.25,14.2875,66.675,19.05,33.3375
20.1,47.3,C,8.9,
BIG_CITY,Apartment,
Unit_1,26.7,40050000,20025000,12015000,8010000,66.75,10.0125,46.725,13.35,23.3625
20.1,47.3,C,5.7,
BIG_CITY,Single,
Unit_1,17.1,25650000,12825000,7695000,5130000,42.75,6.4125,29.925,8.55,14.9625
19.8,47.4,A,25.6,
URBAN,Apartment,
Unit_2,76.8,115200000,57600000,34560000,23040000,192,28.8,134.4,38.4,67.2
19.8,47.4,A,7.9,
URBAN,Apartment,
Unit_2,23.7,35550000,17775000,10665000,7110000,59.25,8.8875,41.475,11.85,20.7375
19.8,47.4,B,23.5,
RURAL,Apartment,
Unit_2,70.5,105750000,52875000,31725000,21150000,176.25,26.4375,123.375,35.25,61.6875
20.4,46.9,A,40.2,
BIG_CITY,Apartment,
Unit_3,120.6,180900000,90450000,54270000,36180000,301.5,45.225,211.05,60.3,105.525
20.4,46.9,B,16.3,
BIG_CITY,Apartment,
Unit_3,48.9,73350000,36675000,22005000,14670000,122.25,18.3375,85.575,24.45,42.7875
20.4,46.9,C,33.4,
RURAL,Single,
Unit_3,100.2,150300000,75150000,45090000,30060000,250.5,37.575,175.35,50.1,87.675
tests/data/ExposureModelESRM20_non_trivial/_exposure_models/Exposure_Model_Entity_2_Com.csv
View file @
e35b1c2d
lon,lat,taxonomy,BUILDINGS
,ID_2,DWELLINGS,TOTAL_REPL_COST_EUR,COST_STRUCTURAL_EUR,COST_NONSTRUCTURAL_EUR,COST_CONTENTS_EUR,OCCUPANTS_PER_ASSET,OCCUPANTS_PER_ASSET_DAY,OCCUPANTS_PER_ASSET_NIGHT,OCCUPANTS_PER_ASSET_TRANSIT,OCCUPANTS_PER_ASSET_AVERAGE
20.6,46.8,A,38.72,Unit_A,38.72,348480000,139392000,69696000,139392000,1161.6,929.28,116.16,232.32,425.92
20.6,46.8,B,13.97,Unit_A,13.97,125730000,50292000,25146000,50292000,419.1,335.28,41.91,83.82,153.67
20.6,46.8,B,9.79,Unit_A,9.79,88110000,35244000,17622000,35244000,293.7,234.96,29.37,58.74,107.69
20.6,46.8,C,6.27,Unit_A,6.27,56430000,22572000,11286000,22572000,188.1,150.48,18.81,37.62,68.97
20.3,46.9,A,28.16,Unit_B,28.16,253440000,101376000,50688000,101376000,844.8,675.84,84.48,168.96,309.76
20.3,46.9,C,8.69,Unit_B,8.69,78210000,31284000,15642000,31284000,260.7,208.56,26.07,52.14,95.59
20.3,46.9,C,25.85,Unit_B,25.85,232650000,93060000,46530000,93060000,775.5,620.4,77.55,155.1,284.35
20.9,46.4,A,44.22,Unit_C,44.22,397980000,159192000,79596000,159192000,1326.6,1061.28,132.66,265.32,486.42
20.9,46.4,B,17.93,Unit_C,17.93,161370000,64548000,32274000,64548000,537.9,430.32,53.79,107.58,197.23
20.9,46.4,C,36.74,Unit_C,36.74,330660000,132264000,66132000,132264000,1102.2,881.76,110.22,220.44,404.14
LON,LAT,TAXONOMY,BUILDINGS,OCCUPANCY_TYPE
,ID_2,DWELLINGS,TOTAL_REPL_COST_EUR,COST_STRUCTURAL_EUR,COST_NONSTRUCTURAL_EUR,COST_CONTENTS_EUR,OCCUPANTS_PER_ASSET,OCCUPANTS_PER_ASSET_DAY,OCCUPANTS_PER_ASSET_NIGHT,OCCUPANTS_PER_ASSET_TRANSIT,OCCUPANTS_PER_ASSET_AVERAGE
20.6,46.8,A,38.72,
Offices,
Unit_A,38.72,348480000,139392000,69696000,139392000,1161.6,929.28,116.16,232.32,425.92
20.6,46.8,B,13.97,
Offices,
Unit_A,13.97,125730000,50292000,25146000,50292000,419.1,335.28,41.91,83.82,153.67
20.6,46.8,B,9.79,
Hotels,
Unit_A,9.79,88110000,35244000,17622000,35244000,293.7,234.96,29.37,58.74,107.69
20.6,46.8,C,6.27,
Trade,
Unit_A,6.27,56430000,22572000,11286000,22572000,188.1,150.48,18.81,37.62,68.97
20.3,46.9,A,28.16,
Offices,
Unit_B,28.16,253440000,101376000,50688000,101376000,844.8,675.84,84.48,168.96,309.76
20.3,46.9,C,8.69,
Trade,
Unit_B,8.69,78210000,31284000,15642000,31284000,260.7,208.56,26.07,52.14,95.59
20.3,46.9,C,25.85,
Offices,
Unit_B,25.85,232650000,93060000,46530000,93060000,775.5,620.4,77.55,155.1,284.35
20.9,46.4,A,44.22,
Offices,
Unit_C,44.22,397980000,159192000,79596000,159192000,1326.6,1061.28,132.66,265.32,486.42
20.9,46.4,B,17.93,
Hotels,
Unit_C,17.93,161370000,64548000,32274000,64548000,537.9,430.32,53.79,107.58,197.23
20.9,46.4,C,36.74,
Trade,
Unit_C,36.74,330660000,132264000,66132000,132264000,1102.2,881.76,110.22,220.44,404.14
tests/data/ExposureModelESRM20_non_trivial/_exposure_models/Exposure_Model_Entity_2_Res.csv
View file @
e35b1c2d
lon,lat,taxonomy,BUILDINGS
,ID_1,DWELLINGS,TOTAL_REPL_COST_EUR,COST_STRUCTURAL_EUR,COST_NONSTRUCTURAL_EUR,COST_CONTENTS_EUR,OCCUPANTS_PER_ASSET,OCCUPANTS_PER_ASSET_DAY,OCCUPANTS_PER_ASSET_NIGHT,OCCUPANTS_PER_ASSET_TRANSIT,OCCUPANTS_PER_ASSET_AVERAGE
20.6,46.8,A,38.72,Unit_1,116.16,174240000,87120000,52272000,34848000,290.4,43.56,203.28,58.08,101.64
20.6,46.8,B,13.97,Unit_1,41.91,62865000,31432500,18859500,12573000,104.775,15.71625,73.3425,20.955,36.67125
20.6,46.8,B,9.79,Unit_1,29.37,44055000,22027500,13216500,8811000,73.425,11.01375,51.3975,14.685,25.69875
20.6,46.8,C,6.27,Unit_1,18.81,28215000,14107500,8464500,5643000,47.025,7.05375,32.9175,9.405,16.45875
20.3,46.9,A,28.16,Unit_2,84.48,126720000,63360000,38016000,25344000,211.2,31.68,147.84,42.24,73.92
20.3,46.9,C,8.69,Unit_2,26.07,39105000,19552500,11731500,7821000,65.175,9.77625,45.6225,13.035,22.81125
20.3,46.9,C,25.85,Unit_2,77.55,116325000,58162500,34897500,23265000,193.875,29.08125,135.7125,38.775,67.85625
20.9,46.4,A,44.22,Unit_3,132.66,198990000,99495000,59697000,39798000,331.65,49.7475,232.155,66.33,116.0775
20.9,46.4,B,17.93,Unit_3,53.79,80685000,40342500,24205500,16137000,134.475,20.17125,94.1325,26.895,47.06625
20.9,46.4,C,36.74,Unit_3,110.22,165330000,82665000,49599000,33066000,275.55,41.3325,192.885,55.11,96.4425
LON,LAT,TAXONOMY,BUILDINGS,SETTLEMENT_TYPE
,ID_1,DWELLINGS,TOTAL_REPL_COST_EUR,COST_STRUCTURAL_EUR,COST_NONSTRUCTURAL_EUR,COST_CONTENTS_EUR,OCCUPANTS_PER_ASSET,OCCUPANTS_PER_ASSET_DAY,OCCUPANTS_PER_ASSET_NIGHT,OCCUPANTS_PER_ASSET_TRANSIT,OCCUPANTS_PER_ASSET_AVERAGE
20.6,46.8,A,38.72,
BIG_CITY,
Unit_1,116.16,174240000,87120000,52272000,34848000,290.4,43.56,203.28,58.08,101.64
20.6,46.8,B,13.97,
BIG_CITY,
Unit_1,41.91,62865000,31432500,18859500,12573000,104.775,15.71625,73.3425,20.955,36.67125
20.6,46.8,B,9.79,
URBAN,
Unit_1,29.37,44055000,22027500,13216500,8811000,73.425,11.01375,51.3975,14.685,25.69875
20.6,46.8,C,6.27,
URBAN,
Unit_1,18.81,28215000,14107500,8464500,5643000,47.025,7.05375,32.9175,9.405,16.45875
20.3,46.9,A,28.16,
URBAN,
Unit_2,84.48,126720000,63360000,38016000,25344000,211.2,31.68,147.84,42.24,73.92
20.3,46.9,C,8.69,
URBAN,
Unit_2,26.07,39105000,19552500,11731500,7821000,65.175,9.77625,45.6225,13.035,22.81125
20.3,46.9,C,25.85,
URBAN,
Unit_2,77.55,116325000,58162500,34897500,23265000,193.875,29.08125,135.7125,38.775,67.85625
20.9,46.4,A,44.22,
URBAN,
Unit_3,132.66,198990000,99495000,59697000,39798000,331.65,49.7475,232.155,66.33,116.0775
20.9,46.4,B,17.93,
BIG_CITY,
Unit_3,53.79,80685000,40342500,24205500,16137000,134.475,20.17125,94.1325,26.895,47.06625
20.9,46.4,C,36.74,
URBAN,
Unit_3,110.22,165330000,82665000,49599000,33066000,275.55,41.3325,192.885,55.11,96.4425
tests/data/expected_results_test_building_classes_proportions.csv
0 → 100644
View file @
e35b1c2d
entity_names,occupancy_names,Data_Unit_ID,building_class_name,settlement_type,occupancy_subtype,proportions
Entity_1,residential,Unit_1,A,BIG_CITY,Apartment,0.5632
Entity_1,residential,Unit_1,B,BIG_CITY,Apartment,0.2032
Entity_1,residential,Unit_1,C,BIG_CITY,Apartment,0.1424
Entity_1,residential,Unit_1,C,BIG_CITY,Single,0.0912
Entity_1,residential,Unit_2,A,URBAN,Apartment,0.587719298
Entity_1,residential,Unit_2,B,RURAL,Apartment,0.412280702
Entity_1,residential,Unit_3,A,BIG_CITY,Apartment,0.447163515
Entity_1,residential,Unit_3,B,BIG_CITY,Apartment,0.18131257
Entity_1,residential,Unit_3,C,RURAL,Single,0.371523915
Entity_1,commercial,Unit_X,A,BIG_CITY,ALL,0.5632
Entity_1,commercial,Unit_X,B,RURAL,ALL,0.2032
Entity_1,commercial,Unit_X,C,BIG_CITY,ALL,0.2336
Entity_1,commercial,Unit_Y,A,RURAL,ALL,0.449122807
Entity_1,commercial,Unit_Y,A,URBAN,ALL,0.138596491
Entity_1,commercial,Unit_Y,B,RURAL,ALL,0.412280702
Entity_1,commercial,Unit_Z,A,BIG_CITY,ALL,0.447163515
Entity_1,commercial,Unit_Z,B,BIG_CITY,ALL,0.18131257
Entity_1,commercial,Unit_Z,C,RURAL,ALL,0.371523915
Entity_2,commercial,Unit_A,A,ALL,Offices,0.5632
Entity_2,commercial,Unit_A,B,ALL,Offices,0.2032
Entity_2,commercial,Unit_A,B,ALL,Hotels,0.1424
Entity_2,commercial,Unit_A,C,ALL,Trade,0.0912
Entity_2,commercial,Unit_B,A,ALL,Offices,0.449122807
Entity_2,commercial,Unit_B,C,ALL,Trade,0.138596491
Entity_2,commercial,Unit_B,C,ALL,Offices,0.412280702
Entity_2,commercial,Unit_C,A,ALL,Offices,0.447163515
Entity_2,commercial,Unit_C,B,ALL,Hotels,0.18131257
Entity_2,commercial,Unit_C,C,ALL,Trade,0.371523915
tests/test_aggregatedexposuremodel.py
View file @
e35b1c2d
...
...
@@ -208,6 +208,14 @@ def test_ExposureModelESRM20():
),
sep
=
","
,
)
expected_results_proportions
=
pandas
.
read_csv
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"data"
,
"expected_results_test_building_classes_proportions.csv"
,
),
sep
=
","
,
)
for
i
in
range
(
len
(
entity_names
)):
# Check number of data units
...
...
@@ -296,6 +304,56 @@ def test_ExposureModelESRM20():
assert
difference_returned_expected
<
1e-5
# Check building classes and proportions
for
unit_id
in
unit_ids
[
i
]:
returned_data_unit
=
returned_aem
.
exposure_entities
[
entity_names
[
i
]
].
occupancy_cases
[
occupancy_names
[
i
]][
"data_units"
][
unit_id
]
# Rows of expected_results_proportions associated with this data-unit ID
# (within rows_entity_occupancy)
rows_data_unit
=
numpy
.
where
(
expected_results_proportions
[
"Data_Unit_ID"
].
to_numpy
()
==
unit_id
)[
0
]
returned_proportions
=
returned_data_unit
.
building_classes_proportions
assert
returned_proportions
.
shape
[
0
]
==
len
(
rows_data_unit
)
for
j
in
range
(
returned_proportions
.
shape
[
0
]):
returned_building_class_name
=
returned_proportions
[
"building_class_name"
].
to_numpy
()[
j
]
returned_settlement_type
=
returned_proportions
[
"settlement_type"
].
to_numpy
()[
j
]
returned_occupancy_subtype
=
returned_proportions
[
"occupancy_subtype"
].
to_numpy
()[
j
]
which_in_expected
=
numpy
.
where
(
numpy
.
logical_and
(
numpy
.
logical_and
(
expected_results_proportions
[
"building_class_name"
].
to_numpy
()[
rows_data_unit
]
==
returned_building_class_name
,
expected_results_proportions
[
"settlement_type"
].
to_numpy
()[
rows_data_unit
]
==
returned_settlement_type
,
),
expected_results_proportions
[
"occupancy_subtype"
].
to_numpy
()[
rows_data_unit
]
==
returned_occupancy_subtype
,
)
)[
0
][
0
]
assert
round
(
returned_proportions
[
"proportions"
].
to_numpy
()[
j
],
4
)
==
round
(
expected_results_proportions
[
"proportions"
].
to_numpy
()[
rows_data_unit
][
which_in_expected
],
4
,
)
assert
(
"data_units"
not
in
returned_aem
.
exposure_entities
[
"Entity_1"
].
occupancy_cases
[
"industrial"
]
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment