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
f98fb03c
Commit
f98fb03c
authored
Nov 12, 2021
by
Cecilia Nievas
Browse files
Added feature to retrieve cost and people per building
parent
9addb633
Pipeline
#30408
passed with stage
in 3 minutes and 22 seconds
Changes
9
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
gdeimporter/aggregatedexposuremodel.py
View file @
f98fb03c
...
...
@@ -266,6 +266,12 @@ class ExposureModelESRM20(AggregatedExposureModel):
"building_class_name"
:
"TAXONOMY"
,
"settlement_type"
:
"SETTLEMENT_TYPE"
,
"occupancy_subtype"
:
"OCCUPANCY_TYPE"
,
"area_per_dwelling"
:
"AREA_PER_DWELLING_SQM"
,
"cost_per_area"
:
"COST_PER_AREA_EUR"
,
"dwellings_per_building"
:
"DWELLINGS_PER_BUILDING"
,
"people_per_dwelling"
:
"PEOPLE_PER_DWELLING"
,
"census_people_per_building"
:
"OCCUPANTS_PER_BUILDING"
,
"total_cost_per_building"
:
"TOTAL_REPL_COST_PER_BUILDING"
,
}
self
.
currency
=
"EUR"
self
.
exposure_entities
=
self
.
retrieve_exposure_entities
(
configuration
)
...
...
@@ -456,9 +462,9 @@ 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
# Retrieve proportions
and properties
of building classes
building_classes_proportions
_and_properties
=
self
.
_retrieve_building_classes
(
data_table
,
id_column_name_data
,
data_units_ids
,
exposure_entity_name
)
for
data_unit_id
in
data_units_ids
:
...
...
@@ -473,7 +479,7 @@ class ExposureModelESRM20(AggregatedExposureModel):
total_people
[
data_unit_id
],
total_cost
[
data_unit_id
],
self
.
currency
,
building_classes_proportions
[
data_unit_id
],
building_classes_proportions
_and_properties
[
data_unit_id
],
)
return
...
...
@@ -529,7 +535,12 @@ class ExposureModelESRM20(AggregatedExposureModel):
return
data_units_type
,
data_units_level
,
data_units_definition
def
_read_data_table
(
self
,
configuration
,
exposure_entity
,
occupancy_case
,
datatypes
):
"""This function reads an ESRM20 CSV file and returns it as a Pandas DataFrame.
"""This function reads an ESRM20 CSV file and returns it as a Pandas DataFrame. As CSV
files for different occupancy cases contain different columns, this function normalises
the output as well by adding missing columns and renaming columns with equivalent
content. This allows the output of this function to be treated in the same way,
irrespective of the occupancy_case. Parameters derived from existing columns are added
as columns of the output table as well.
Args:
configuration (Configuration object):
...
...
@@ -579,6 +590,38 @@ class ExposureModelESRM20(AggregatedExposureModel):
[
"ALL"
for
j
in
range
(
data_table
.
shape
[
0
])]
)
# pylint: disable=no-member
if
"DWELLINGS"
not
in
data_table
.
columns
:
# for commercial and industrial
data_table
[
self
.
csv_column_names
[
"Dwellings"
]]
=
data_table
[
self
.
csv_column_names
[
"Buildings"
]
]
# one dwelling per building
if
"AREA_PER_BUILDING_SQM"
in
data_table
.
columns
:
# for commercial and industrial
data_table
=
data_table
.
rename
(
columns
=
{
"AREA_PER_BUILDING_SQM"
:
self
.
csv_column_names
[
"area_per_dwelling"
]}
)
data_table
[
self
.
csv_column_names
[
"dwellings_per_building"
]]
=
(
data_table
[
self
.
csv_column_names
[
"Dwellings"
]]
/
data_table
[
self
.
csv_column_names
[
"Buildings"
]]
)
data_table
[
self
.
csv_column_names
[
"people_per_dwelling"
]]
=
(
data_table
[
self
.
csv_column_names
[
"People"
][
"Census"
]]
/
data_table
[
self
.
csv_column_names
[
"Dwellings"
]]
)
data_table
[
self
.
csv_column_names
[
"census_people_per_building"
]]
=
(
data_table
[
self
.
csv_column_names
[
"People"
][
"Census"
]]
/
data_table
[
self
.
csv_column_names
[
"Buildings"
]]
)
data_table
[
self
.
csv_column_names
[
"total_cost_per_building"
]]
=
(
data_table
[
self
.
csv_column_names
[
"dwellings_per_building"
]]
*
data_table
[
self
.
csv_column_names
[
"area_per_dwelling"
]]
*
data_table
[
self
.
csv_column_names
[
"cost_per_area"
]]
)
return
data_table
def
_read_geometries_table
(
self
,
configuration
,
exposure_entity
,
occupancy_case
,
datatypes
):
...
...
@@ -757,9 +800,12 @@ 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
):
def
_retrieve_building_classes
(
self
,
data_table
,
ids_column_name
,
data_units_ids
,
exposure_entity_name
):
"""This function retrieves from data_table the proportions of building classes in each
data unit enumerated in data_units_ids.
data unit enumerated in data_units_ids, as well as their associated total replacement
costs and total census people per building.
A building class is defined by a combination of three columns in data_table. The names
of these columns are found under:
...
...
@@ -776,9 +822,11 @@ class ExposureModelESRM20(AggregatedExposureModel):
data_units_ids (list of str):
List of IDs of data units assumed to be found in column ids_column_name of
data_table.
exposure_entity_name (str):
Name of the ExposureEntity to which data_units_ids belong.
Returns:
proportions (dict):
proportions
_and_properties
(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:
...
...
@@ -794,28 +842,60 @@ class ExposureModelESRM20(AggregatedExposureModel):
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.
census_people_per_building (float):
Number of census-derived people per building (i.e. not accounting for
time of the day).
total_cost_per_building (float):
Total replacement cost per building, including costs of structural and
non-structural components as well as contents.
"""
content
s
=
[
building_class_field
s
=
[
"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
]
columns_to_group
=
[
self
.
csv_column_names
[
building_class_fields
[
i
]]
for
i
in
range
(
len
(
building_class_fields
))
]
columns_to_filter_proportions
=
[
*
columns_to_group
,
self
.
csv_column_names
[
"Buildings"
],
]
building_fundamental_properties_fields
=
[
"area_per_dwelling"
,
"cost_per_area"
,
"dwellings_per_building"
,
"people_per_dwelling"
,
]
building_output_properties_fields
=
[
"census_people_per_building"
,
"total_cost_per_building"
,
]
columns_to_filter_properties
=
[
*
columns_to_filter_proportions
,
*
[
self
.
csv_column_names
[
building_fundamental_properties_fields
[
i
]]
for
i
in
range
(
len
(
building_fundamental_properties_fields
))
],
*
[
self
.
csv_column_names
[
building_output_properties_fields
[
i
]]
for
i
in
range
(
len
(
building_output_properties_fields
))
],
]
proportions
=
{}
proportions
_and_properties
=
{}
for
data_unit_id
in
data_units_ids
:
# Retrieve from data_table
the
rows for this Data Unit and
the
columns_to_filter
# Retrieve from data_table rows for this Data Unit and columns_to_filter
_proportions
which
=
numpy
.
where
(
data_table
[
ids_column_name
].
values
==
data_unit_id
)[
0
]
data_filtered
=
data_table
.
loc
[
which
,
columns_to_filter
].
copy
()
data_filtered
=
data_table
.
loc
[
which
,
columns_to_filter
_proportions
].
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
]
):
for
j
,
col
in
enumerate
(
building_class_fields
):
unique_vals
[
col
]
=
numpy
.
array
(
[
grouped
.
index
[
i
][
j
]
for
i
in
range
(
grouped
.
shape
[
0
])]
)
...
...
@@ -824,7 +904,24 @@ class ExposureModelESRM20(AggregatedExposureModel):
grouped
[
self
.
csv_column_names
[
"Buildings"
]].
to_numpy
()
/
grouped
[
self
.
csv_column_names
[
"Buildings"
]].
to_numpy
().
sum
()
)
# Retrieve from data_table rows for this Data Unit and columns_to_filter_properties
data_filtered
=
data_table
.
loc
[
which
,
columns_to_filter_properties
].
copy
()
# Identify unique combinations of the columns_to_group and minimum and maximum
# values of building properties
grouped_max
=
data_filtered
.
groupby
(
columns_to_group
).
max
()
grouped_min
=
data_filtered
.
groupby
(
columns_to_group
).
min
()
grouped_diff
=
grouped_max
-
grouped_min
for
j
,
col
in
enumerate
(
building_fundamental_properties_fields
):
if
numpy
.
any
(
abs
(
grouped_diff
[
self
.
csv_column_names
[
col
]].
to_numpy
())
>
1e-2
):
error_message
=
(
"Problem found when grouping building classes for Data Unit %s of %s: "
"building property '%s' is inconsistent."
%
(
data_unit_id
,
exposure_entity_name
,
col
)
)
logger
.
critical
(
error_message
)
for
j
,
col
in
enumerate
(
building_output_properties_fields
):
unique_vals
[
col
]
=
grouped_max
[
self
.
csv_column_names
[
col
]].
to_numpy
()
proportions
[
data_unit_id
]
=
pandas
.
DataFrame
(
unique_vals
)
proportions
_and_properties
[
data_unit_id
]
=
pandas
.
DataFrame
(
unique_vals
)
return
proportions
return
proportions
_and_properties
gdeimporter/dataunit.py
View file @
f98fb03c
...
...
@@ -86,7 +86,7 @@ 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):
self.building_classes_proportions
_and_properties
(Pandas DataFrame):
Pandas DataFrame with the following columns:
building_class_name (str):
Name of the building classes associated with the Data Unit.
...
...
@@ -100,6 +100,12 @@ class DataUnit:
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.
census_people_per_building (float):
Number of census-derived people per building (i.e. not accounting for time
of the day).
total_cost_per_building (float):
Total replacement cost per building, including costs of structural and
non-structural components as well as contents.
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
...
...
@@ -133,7 +139,7 @@ class DataUnit:
total_people
=
_TOTAL_PEOPLE_DEFAULT
,
total_cost
=
_TOTAL_COST_DEFAULT
,
currency
=
None
,
building_classes_proportions
=
None
,
building_classes_proportions
_and_properties
=
None
,
):
"""
Args:
...
...
@@ -163,7 +169,7 @@ 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):
building_classes_proportions
_and_properties
(Pandas DataFrame):
Pandas DataFrame with the following columns:
building_class_name (str):
String describing the building class as per the building classification
...
...
@@ -177,6 +183,12 @@ class DataUnit:
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.
census_people_per_building (float):
Number of census-derived people per building (i.e. not accounting for
time of the day).
total_cost_per_building (float):
Total replacement cost per building, including costs of structural and
non-structural components as well as contents.
"""
# Check that the keys of total_people are the expected ones
...
...
@@ -200,7 +212,9 @@ class DataUnit:
self
.
total_people
=
total_people
self
.
total_cost
=
total_cost
self
.
currency
=
currency
self
.
building_classes_proportions
=
building_classes_proportions
self
.
building_classes_proportions_and_properties
=
(
building_classes_proportions_and_properties
)
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 @
f98fb03c
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
LON,LAT,TAXONOMY,SETTLEMENT_TYPE,OCCUPANCY_TYPE,BUILDINGS,ID_1,DWELLINGS,
AREA_PER_DWELLING_SQM,COST_PER_AREA_EUR,
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,
90,1400,
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,
120,1050,
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,
85,1300,
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,
85,1300,
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,
110,980,
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,
95,1280,
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,
120,1050,
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,
90,1400,
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,
110,1100,
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,
115,1200,
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 @
f98fb03c
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
LON,LAT,TAXONOMY,BUILDINGS,SETTLEMENT_TYPE,OCCUPANCY_TYPE,ID_1,DWELLINGS,
AREA_PER_DWELLING_SQM,COST_PER_AREA_EUR,
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,
90,1400,
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,
110,1100,
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,
85,1300,
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,
95,1380,
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,
95,1280,
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,
95,1280,
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,
120,1050,
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,
90,1400,
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,
110,1100,
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,
115,1200,
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 @
f98fb03c
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
LON,LAT,TAXONOMY,BUILDINGS,OCCUPANCY_TYPE,ID_2,DWELLINGS,
AREA_PER_DWELLING_SQM,COST_PER_AREA_EUR,
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,
150,1400,
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,
200,1300,
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,
500,1200,
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,
300,1100,
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,
150,1400,
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,
400,1500,
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,
250,1350,
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,
150,1400,
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,
500,1200,
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,
300,1100,
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 @
f98fb03c
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
LON,LAT,TAXONOMY,BUILDINGS,SETTLEMENT_TYPE,ID_1,DWELLINGS,
AREA_PER_DWELLING_SQM,COST_PER_AREA_EUR,
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,
90,1400,
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,
110,1100,
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,
97,1300,
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,
92,1450,
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,
95,1280,
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,
92,1450,
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,
92,1450,
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,
95,1280,
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,
110,1100,
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,
92,1450,
165330000,82665000,49599000,33066000,275.55,41.3325,192.885,55.11,96.4425
tests/data/expected_results_test_building_classes_proportions.csv
deleted
100644 → 0
View file @
9addb633
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/data/expected_results_test_building_classes_proportions_and_properties.csv
0 → 100644
View file @
f98fb03c
entity_names,occupancy_names,Data_Unit_ID,building_class_name,settlement_type,occupancy_subtype,proportions,census_people_per_building,total_cost_per_building
Entity_1,residential,Unit_1,A,BIG_CITY,Apartment,0.5632,7.5,378000
Entity_1,residential,Unit_1,B,BIG_CITY,Apartment,0.2032,7.5,363000
Entity_1,residential,Unit_1,C,BIG_CITY,Apartment,0.1424,7.5,331500
Entity_1,residential,Unit_1,C,BIG_CITY,Single,0.0912,7.5,393300
Entity_1,residential,Unit_2,A,URBAN,Apartment,0.587719298,7.5,364800
Entity_1,residential,Unit_2,B,RURAL,Apartment,0.412280702,7.5,378000
Entity_1,residential,Unit_3,A,BIG_CITY,Apartment,0.447163515,7.5,378000
Entity_1,residential,Unit_3,B,BIG_CITY,Apartment,0.18131257,7.5,363000
Entity_1,residential,Unit_3,C,RURAL,Single,0.371523915,7.5,414000
Entity_1,commercial,Unit_X,A,BIG_CITY,ALL,0.5632,30,126000
Entity_1,commercial,Unit_X,B,RURAL,ALL,0.2032,30,126000
Entity_1,commercial,Unit_X,C,BIG_CITY,ALL,0.2336,30,110500
Entity_1,commercial,Unit_Y,A,RURAL,ALL,0.449122807,30,107800
Entity_1,commercial,Unit_Y,A,URBAN,ALL,0.138596491,30,121600
Entity_1,commercial,Unit_Y,B,RURAL,ALL,0.412280702,30,126000
Entity_1,commercial,Unit_Z,A,BIG_CITY,ALL,0.447163515,30,126000
Entity_1,commercial,Unit_Z,B,BIG_CITY,ALL,0.18131257,30,121000
Entity_1,commercial,Unit_Z,C,RURAL,ALL,0.371523915,30,138000
Entity_2,commercial,Unit_A,A,ALL,Offices,0.5632,30,210000
Entity_2,commercial,Unit_A,B,ALL,Offices,0.2032,30,260000
Entity_2,commercial,Unit_A,B,ALL,Hotels,0.1424,30,600000
Entity_2,commercial,Unit_A,C,ALL,Trade,0.0912,30,330000
Entity_2,commercial,Unit_B,A,ALL,Offices,0.449122807,30,210000
Entity_2,commercial,Unit_B,C,ALL,Trade,0.138596491,30,600000
Entity_2,commercial,Unit_B,C,ALL,Offices,0.412280702,30,337500
Entity_2,commercial,Unit_C,A,ALL,Offices,0.447163515,30,210000
Entity_2,commercial,Unit_C,B,ALL,Hotels,0.18131257,30,600000
Entity_2,commercial,Unit_C,C,ALL,Trade,0.371523915,30,330000
tests/test_aggregatedexposuremodel.py
View file @
f98fb03c
...
...
@@ -208,11 +208,11 @@ def test_ExposureModelESRM20():
),
sep
=
","
,
)
expected_results_proportions
=
pandas
.
read_csv
(
expected_results_proportions
_and_properties
=
pandas
.
read_csv
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"data"
,
"expected_results_test_building_classes_proportions.csv"
,
"expected_results_test_building_classes_proportions
_and_properties
.csv"
,
),
sep
=
","
,
)
...
...
@@ -304,54 +304,85 @@ def test_ExposureModelESRM20():
assert
difference_returned_expected
<
1e-5
# Check building classes
and
proportions
# Check building classes
, their
proportions
and properties
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 of expected_results_proportions
_and_properties
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
expected_results_proportions_and_properties
[
"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
)
returned_proportions_and_properties
=
(
returned_data_unit
.
building_classes_proportions_and_properties
)
assert
returned_proportions_and_properties
.
shape
[
0
]
==
len
(
rows_data_unit
)
for
j
in
range
(
returned_proportions
.
shape
[
0
]):
returned_building_class_name
=
returned_proportions
[
for
j
in
range
(
returned_proportions
_and_properties
.
shape
[
0
]):
returned_building_class_name
=
returned_proportions
_and_properties
[
"building_class_name"
].
to_numpy
()[
j
]
returned_settlement_type
=
returned_proportions
[
"settlement_type"
].
to_numpy
()[
j
]
returned_occupancy_subtype
=
returned_proportions
[
returned_settlement_type
=
returned_proportions_and_properties
[
"settlement_type"
].
to_numpy
()[
j
]
returned_occupancy_subtype
=
returned_proportions_and_properties
[
"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
]
expected_results_proportions
_and_properties
[
"building_class_name"
]
.
to_numpy
()[
rows_data_unit
]
==
returned_building_class_name
,
expected_results_proportions
[
"settlement_type"
].
to_numpy
()
[
rows_data_unit
]
expected_results_proportions
_and_properties
[
"settlement_type"
]
.
to_numpy
()[
rows_data_unit
]
==
returned_settlement_type
,
),
expected_results_proportions
[
"occupancy_subtype"
].
to_numpy
()
[
rows_data_unit
]
expected_results_proportions
_and_properties
[
"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
assert
round
(
returned_proportions_and_properties
[
"proportions"
].
to_numpy
()[
j
],
4
)
==
round
(
expected_results_proportions_and_properties
[
"proportions"
].
to_numpy
()[
rows_data_unit
][
which_in_expected
],
4
,
)
assert
round
(
returned_proportions_and_properties
[
"census_people_per_building"
].
to_numpy
()[
j
],
4
,
)
==
round
(
expected_results_proportions_and_properties
[
"census_people_per_building"
].
to_numpy
()[
rows_data_unit
][
which_in_expected
],
4
,
)
assert
round
(
returned_proportions_and_properties
[
"total_cost_per_building"
].
to_numpy
()[
j
],
4
,
)
==
round
(
expected_results_proportions_and_properties
[
"total_cost_per_building"
].
to_numpy
()[
rows_data_unit
][
which_in_expected
],
4
,
)
assert
(
...
...
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