Skip to content

Conversation

@Zapiano
Copy link
Member

@Zapiano Zapiano commented May 22, 2025

This is useful when running a single scenario directly for debugging purposes. A version of that aggregating across all scenarios can be developed in the future as well.

An example of how it looks like for different metrics:

bleaching_mort_stratified_sc1_sc2_bleaching

cover_stratified_sc1_sc2_bleaching

dhw_tol_stratified_sc1_sc2_bleaching

@Zapiano Zapiano requested a review from ConnectedSystems May 22, 2025 07:09
@Zapiano Zapiano self-assigned this May 22, 2025
@Zapiano Zapiano added the enhancement New feature or request label May 22, 2025
Copy link
Collaborator

@ConnectedSystems ConnectedSystems left a comment

Choose a reason for hiding this comment

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

A few minor comments, thanks.

# as a Label to the whole figure, but left it like this for simplicity
title = pop!(axis_opts, :title, "")

for fg in 1:n_groups
Copy link
Collaborator

Choose a reason for hiding this comment

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

axes() is recommended over 1:n but I understand this is more readable (with YAXArrays you could iterate over the dimension name, but this isn't the case here.

You can also squash nested loops like so:

for fg in 1:n_groups, sc in 1:n_sizes

Copy link
Member Author

Choose a reason for hiding this comment

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

I made this function accept a Array, instead of a YAXArray, because of a few operations that are different with both (like taking the mean`medianpassing the axis name or callinglines!`, that expects an Array). I think it would be nice to accept both (either having two methods one for each of making this one more flexible somehow) but since this is meant for debugging purposes (for now) and the time limit I decided to go only with Arrays for now.

axis_opts::OPT_TYPE=DEFAULT_OPT_TYPE()
)
n_timesteps, n_sizes, n_groups, n_locations = size(data)
f = Figure(; size=(1000, 1200), fig_opts...)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Arguably, size be part of fig_opts, suggest setting a default value in this method similar to how you're handling ylabel and title below.

Comment on lines +261 to +262
end
Label(f[0, :], title; fontsize=24)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Spacing for clarity.

Suggested change
end
Label(f[0, :], title; fontsize=24)
end
Label(f[0, :], title; fontsize=24)

Comment on lines +258 to +259
ydata = mean_data[:, sc, fg]
lines!(ax, xdata, ydata)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know you're making it more readable but this is more direct and fairly meaningful

Suggested change
ydata = mean_data[:, sc, fg]
lines!(ax, xdata, ydata)
lines!(ax, xdata, mean_data[:, sc, fg])

function scenarios() end
function scenarios!() end

# Plot a single scenario
Copy link
Collaborator

Choose a reason for hiding this comment

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

Single scenario of what?

axis_opts=Dict{Symbol,Any}(:limits=(nothing, (0.0, 1.0)))
)
# Plot scenario cover
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems out of place? Or the example is unfinished?

# Plot scenario cover
```
"""
function ADRIA.viz.scenario_stratified(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think scenario_stratified is a good name - there are many ways a scenario can be stratified - but I also understand it's hard to come up with a name that makes sense and isn't overly verbose.

Best alternative I can think of is scenario_by_taxa which at least indicates what will be shown.

Copy link
Member Author

Choose a reason for hiding this comment

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

I also don't like scenario_stratified very much. I don't like scenario_by_taxa because it plots by functional group and by size class. And, in the future, this could have a flag so the user decides if they want it plotted by functional group, by size class or both. Alternatively

  1. We could simple call this scenario_by_size_and_group (I know, long name...) and in the future have a scenario_by_group and a scenario_by_size.
  2. We could call it scenario and have a flag group_by that can be size_and_group, size, group or nothing.

# Arguments
- `data` : Either a 4D array comprising (timesteps, size_classes, functional_groups and
locations) or a 3D array comprising (timesteps, size_groups, locations).
- `axis_opts` : Opts to be passed to Makie.Axis.
Copy link
Collaborator

@ConnectedSystems ConnectedSystems May 24, 2025

Choose a reason for hiding this comment

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

Suggested change
- `axis_opts` : Opts to be passed to Makie.Axis.
- `axis_opts` : Options to be passed to `Makie.Axis()`.

Arguably dimension names (timesteps, size_classes, etc.) should also be backticked, but it's a small comment.

Comment on lines +200 to +201
- `data` : Either a 4D array comprising (timesteps, size_classes, functional_groups and
locations) or a 3D array comprising (timesteps, size_groups, locations).
Copy link
Collaborator

Choose a reason for hiding this comment

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

It states 3D or 4D array but the function signature specifies it must be 4D?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants