-
Notifications
You must be signed in to change notification settings - Fork 10
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
Can not create flat multiscale graphs with >= 3 levels #33
Comments
Hi @joeloskarsson . Seems like there has been a bit of modifications since the issue was posted - the Running the following code doesn't crash:
However, output graph is not exactly as I would expect, I get, producint a regular grid when |
Hi @matschreiner! Happy to see you looking into this 😄 You are absolutely correct that there have been some changes now so my code from above does not work. Here is a modified example that should create the same crash: import weather_model_graphs as wmg
import numpy as np
x_coords = np.linspace(0, 15, 50)
y_coords = np.linspace(0, 5, 50)
meshgridded = np.meshgrid(x_coords, y_coords)
xy_grid = np.stack(meshgridded, axis=-1)
xy = xy_grid.reshape(-1, 2)
graph = wmg.create.archetype.create_graphcast_graph(
xy,
mesh_node_distance=0.5,
level_refinement_factor=3,
) With this mesh_node_distance the resulting graph contains 3 collapsed mesh levels, which is when the crash happens. Regarding your example: The reason that these examples work is that they only create one level of mesh nodes, that is then collapsed. Note in the output
and
So the leftmost graph has 9x3 mesh nodes and the rightmost has 5x5 mesh nodes. (this is a bit easier to see with |
I did a quick test here to see if it was indeed
num_nodes_x and num_nodes_y are not getting set correctly, but I did not dig deeper than that right now.
|
I think I figured out the problem with this now, which is indeed that num_nodes_x and num_nodes_y are not getting set correctly at each iteration of the loop. Luckily I think we can compute the correct updates to these really easily. I implemented a fix here that seems to work: joeloskarsson@30bfb82 But requires a little bit more testing. Will prepare a proper PR after testing it. |
There seems to be a bug in
weather-model-graphs/src/weather_model_graphs/create/mesh/kinds/flat.py
Line 8 in 2456064
that causes a crash whenever you try to create a multiscale graph by collapsing >= 3 levels of flat graphs.
Minimum example to reproduce
This gives output
but then crashes with
Problem
The issue seems to relate to the loop
weather-model-graphs/src/weather_model_graphs/create/mesh/kinds/flat.py
Lines 58 to 76 in 2456064
where the variables
num_nodes_x
andnum_nodes_y
are not set correctly on the second iteration. I am a bit suspicious of the linesweather-model-graphs/src/weather_model_graphs/create/mesh/kinds/flat.py
Lines 73 to 75 in 2456064
which modify the graph
G_all_levels[lev]
, which is what is used in the next iteration of the loop. It could be that this graph is being overwritten before it is used.I encountered this when working on #32, but since this is an orthogonal issue I will not fix it in there.
The text was updated successfully, but these errors were encountered: