Skip to content

Commit

Permalink
Merge pull request #10368 from gem/fix-plot
Browse files Browse the repository at this point in the history
Fixed `oq plot?hcurves`
  • Loading branch information
micheles authored Feb 24, 2025
2 parents c161f19 + 0748827 commit 00c1025
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 2 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[Michele Simionato]
* Fixed `oq plot?hcurves`: the disaggregation PoEs were plotted in linear
scale and not in logarithmic scale
* Internal: introduced parameter `config.memory.gmf_data_rows`

[Marco Pagani, Michele Simionato]
Expand Down
3 changes: 2 additions & 1 deletion openquake/commands/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,13 @@ def make_figure_hcurves(extractors, what):
ax.set_xlabel('%s, site %s, inv_time=%dy' %
(imt, site, oq.investigation_time))
ax.set_ylabel('PoE')
ax.set_xlabel('acceleration')
for ck, arr in got.items():
if (arr == 0).all():
logging.warning('There is a zero curve %s_%s', *ck)
ax.loglog(imls, arr.flat, '-', label='%s_%s' % ck)
for poe in oq.poes:
ax.plot(imls, [poe]*len(imls), label=f'{poe=}')
ax.loglog(imls, [poe]*len(imls), label=f'{poe=}')
ax.grid(True)
ax.legend()
return plt
Expand Down
5 changes: 3 additions & 2 deletions openquake/commonlib/tests/logictree_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,9 @@ def test_branches_weight_wrong_sum(self):
exc = self._assert_logic_tree_error(
'lo', {'lo': lt, 'sm1': sm, 'sm2': sm}, logictree.LogicTreeError)
self.assertEqual(exc.lineno, 4)
self.assertEqual(exc.message, "branchset weights don't sum up to 1.0",
"wrong exception message: %s" % exc.message)
self.assertEqual(
exc.message, "branchset weights sum up to 1.1, not 1",
"wrong exception message: %s" % exc.message)

def test_apply_to_nonexistent_branch(self):
lt = _make_nrml("""\
Expand Down
2 changes: 1 addition & 1 deletion openquake/hazardlib/logictree.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ def parse_branches(self, branchset_node, branchset):
if abs(weight_sum - 1.0) > pmf.PRECISION:
raise LogicTreeError(
branchset_node, self.filename,
"branchset weights don't sum up to 1.0")
f"branchset weights sum up to {weight_sum}, not 1")
if ''.join(values) and len(set(values)) < len(values):
raise LogicTreeError(
branchset_node, self.filename,
Expand Down
4 changes: 0 additions & 4 deletions openquake/hazardlib/map_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,6 @@ def check_hmaps(hcurves, imtls, poes):
if rel_err > .05:
raise ValueError(f'The {imt} hazard curve for {site_id=} cannot '
f'be inverted reliably around {poe=}')
elif rel_err > .01:
logging.warning(
f'The {imt} hazard curve for {site_id=} cannot be '
f'inverted reliably around {poe=}: {iml=}, {iml99=}')


# not used right now
Expand Down

0 comments on commit 00c1025

Please sign in to comment.