Skip to content

Conversation

@jommme
Copy link
Collaborator

@jommme jommme commented Dec 10, 2024

  • Created fix for handling large jumps in plotted data.
  • Reworked patch collection.
  • Added draw quad mesh but with no handling.

intersection = line.intersection(cliprect)
except:
intersection = Polygon()
except Exception:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we catch a more specific Exception here? Generally, it is considered bad practice to have try/except without specifying the exact exception you are expecting.

# Behandle PolyCollection som en samling av 'patch'-objekter
for path in paths:
# Kombiner master_transform med path_transform for hver path
for i, path in enumerate(paths):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Has this been reverted to an old version of the code?

Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the reason for this change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When I tried to figure out where the failure happend, I tried some different approaches and that we didnt handle all_transforms was one thing I was looking into.
I just revert it for now, even though I think the new code is working asmit should as well :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry, I figured out it actually fixed a bug as well!
I completely forgot, but some lines from the simple sounding plot was not plotted before this change.
So I will actually leave it as it is here :)

intersection = Polygon()
except Exception:
# Fix plotted values with large gaps/jumps crashing the intersection function
gap_threshold = 50
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 it's a good idea to use a hard coded value here. If we have plots ranging between 0 and 2000, for example the pore pressure in a CPT, a gap threshold of 50 is quite small.

# Fix plotted values with large gaps/jumps crashing the intersection function
gap_threshold = 50
smoothed_vertices = [vertices[0]] # Start with the first point
for i in range(1, len(vertices)):
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can use np.diff to compute this more effectively, and filter using np.where.

def points_to_pixels(self, points):
return points / 72.0 * self.dpi

def draw_quad_mesh(
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the reason for this change? Do we need it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When I tried to figure out where the failure happend, I tried some different approaches and figured out that we didnt handle quad mesh, so I set up some of the entities we didnt handle to see what wass passed to them.
Thought we just could keep them to be aware of them and implement them if necessary at a later stage.
But I will just remove it for now, since not in use.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants