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

Visualize losses produced by an aristotle calculation #9529

Merged
merged 25 commits into from
Mar 22, 2024
Merged

Conversation

ptormene
Copy link
Member

@ptormene ptormene commented Mar 18, 2024

image

The outputs in aristotle mode are displayed using a new template that we can further customize.
For now, all outputs and all export formats are available, and the losses table is presented on top (see the screenshot).
Below the table I also added a button to download the table as csv.

TODO:

  • give a better format to numbers and perhaps add the dollar sign before economic losses
  • add timestamp and magnitude of the event

Part of #9227

@ptormene ptormene added this to the Engine 3.20.0 milestone Mar 18, 2024
@ptormene ptormene self-assigned this Mar 18, 2024
@ptormene ptormene marked this pull request as draft March 18, 2024 15:15
@ptormene ptormene marked this pull request as ready for review March 20, 2024 08:49
@ptormene ptormene requested a review from micheles March 20, 2024 13:14
iso_codes = [
iso_code.decode('utf8')
for iso_code in
dstore['assetcol/tagcol/ID_0'][numpy.unique(assetcol['ID_0'])]]
Copy link
Contributor

Choose a reason for hiding this comment

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

For performance reasons, the right way to do this is as follows:

ALL_ID_0 =  dstore['assetcol/tagcol/ID_0'][:]
ID_0 = ALL_ID_0[numpy.unique(assetcol['ID_0'])]

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@@ -1264,6 +1263,75 @@ def web_engine_get_outputs_aelo(request, calc_id, **kwargs):
warnings=warnings))


def get_aggrisk(calc_id):
Copy link
Contributor

Choose a reason for hiding this comment

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

The docstring should say something like "Converting the aggrisk dataframe into a table like this:
..." and add an example table.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

content_type="text/csv",
headers={
"Content-Disposition":
'attachment; filename="aggrisk.csv"'
Copy link
Contributor

Choose a reason for hiding this comment

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

Please check what happens when downloading the other aggrisk output (i.e. is the name "aggrisk.csv" already taken or not?)

Copy link
Member Author

Choose a reason for hiding this comment

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

The name of the csv file created downloading the standard aggrisk outputs is something like output-101-aggrisk-_45.csv, I suppose we might use a similar approach here, adding the calc_id, and we might decide to further differentiate the name.

Copy link
Member Author

Choose a reason for hiding this comment

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

We should add the calc_id

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

except KeyError: # ID_0 might be missing
ax.legend()
else:
id_0_str = ', '.join([id_0.decode('utf8') for id_0 in ID_0])
Copy link
Contributor

Choose a reason for hiding this comment

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

The square brackets are not needed

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed

@ptormene ptormene merged commit 396e423 into master Mar 22, 2024
6 checks passed
@ptormene ptormene deleted the aristotle-run branch March 22, 2024 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants