Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix aggregate loss curve computation #1151

Merged
merged 2 commits into from
Apr 22, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions openquake/engine/calculators/risk/event_based/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ def profile(name):
asset.value,
asset.deductible,
asset.ins_limit),
tses,
time_span,
loss_curve_resolution))
tses=tses,
time_span=time_span,
curve_resolution=loss_curve_resolution))

# FIXME(lp). Insured losses are still computed
# as absolute values.
Expand Down Expand Up @@ -328,7 +328,7 @@ def post_process(self):
Compute aggregate loss curves and event loss tables
"""

tses, time_span = self.hazard_times()
time_span, tses = self.hazard_times()

for hazard_output in self.considered_hazard_outputs():

Expand All @@ -344,7 +344,7 @@ def post_process(self):
if aggregate_losses:
aggregate_loss_losses, aggregate_loss_poes = (
scientific.event_based(
aggregate_losses, tses, time_span,
aggregate_losses, tses=tses, time_span=time_span,
curve_resolution=self.rc.loss_curve_resolution))

models.AggregateLossCurveData.objects.create(
Expand Down
5 changes: 3 additions & 2 deletions openquake/engine/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -955,9 +955,10 @@ def points_to_compute(self):
if self.pk and self.inputs.filter(input_type='exposure').exists():
assets = self.exposure_model.exposuredata_set.all().order_by(
'asset_ref')

# the points here must be sorted
lons, lats = zip(
*list(
set([(asset.site.x, asset.site.y)
*sorted(set([(asset.site.x, asset.site.y)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need the list; just do sorted(set((asset.site.x, asset.site.y) for asset in assets)))

for asset in assets])))
# Cache the mesh:
self._points_to_compute = hazardlib_geo.Mesh(
Expand Down