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

skip_patches_outside_xylimits doesn't work with grid mappings #278

Open
rjleveque opened this issue Sep 21, 2020 · 9 comments
Open

skip_patches_outside_xylimits doesn't work with grid mappings #278

rjleveque opened this issue Sep 21, 2020 · 9 comments

Comments

@rjleveque
Copy link
Member

The new feature added in #262 skips plotting AMR patches that are outside the specified xlimits and ylimits, unless plotaxes.skip_patches_outside_xylimits == False as provided in #263. By default this is set to True.

I recently discovered that this doesn't work well with a mapped grid where a mapc2p function is provided to map the computational xc, yc to the physical space xp, yp for plotting. The problem is that xlimits, ylimits are specified in physical coordinates (what you see in the plot) whereas the check on whether to skip a patch is done before mapc2p is applied, and hence the xc ,yc used in the test are in computational coordinates. A patch may easily appear to be outside the limits even though after the mapping it will be inside. This is also a problem in 1d if mapc2p is specified to map xc to xp.

This would be fairly easy to fix if mapc2p were also a ClawPlotAxes attribute, and it seems like it probably should be since the axes should presumably be in the same coordinate system regardless of what item is being plotted on it.

However, for some reason (my bad design, probably), mapc2p is an attribute of a ClawPlotItem, or if that is not set, the code also checks for mapc2p as an attribute of plotdata, but there is no plotaxes.mapc2p.

Cleaning this up will take some work and needs further discussion.

In the meantime, users should be aware that if using a mapc2p function, you should also set plotaxes.skip_patches_outside_xylimits to False.

Should this be the default, rather than True?

@mjberger
Copy link

mjberger commented Sep 21, 2020 via email

@mandli
Copy link
Member

mandli commented Sep 22, 2020

I would favor keeping the default as True myself.

The reasoning is that there are very few who use mapped grids to plot and I would consider those who do to be the experts. I also think that the speedup that this enables for the generic GeoClaw user, who is more than likely not an expert, would be well worth the issue as @rjleveque outlined it. Furthermore I think that adding mapc2p to the plotting capabilities is something we should enforce as was done in the old Matlab plotting code.

Of course just my 2¢.

@mjberger
Copy link

mjberger commented Sep 22, 2020 via email

@mandli
Copy link
Member

mandli commented Sep 22, 2020

@mjberger oh man, if you are not an expert are any of us except for maybe @rjleveque 😉

@rjleveque
Copy link
Member Author

I won't say how long it took me to figure out why nothing showed up in my plots with a mapped grid the other day, but much too long. So I agree with @mjberger that True is not a good default in general. On the other hand for many GeoClaw applications with zoomed plots are small regions from big computations, it is nice to have it skip patches by default. I've got a quick and dirty fix that I think sets the default to True unless there's a mapc2p function for any item in which case it's set to False. We can consider to discuss better long-term options.

rjleveque added a commit to rjleveque/visclaw that referenced this issue Sep 22, 2020
Instead of always setting to True if not set by user, set to False
if there is a mapc2p function for some item, since it doesn't work
properly in this case.  clawpack#278
@mandli
Copy link
Member

mandli commented Sep 22, 2020

I like the idea you had in the PR myself.

@mandli
Copy link
Member

mandli commented Sep 22, 2020

Do you think we should raise a warning maybe?

@rjleveque
Copy link
Member Author

Where would we raise it, whenever skip_patches_outside_xylimits is set to True by default? That might get tiresome?

Note there's a possible warning message in the file that's not currently activated but could be, and would be even more tiresome since it would print a message for every axes in every frame if patches are being skipped...

            if False and num_skipped > 0:
                # possible warning message:
                print('Skipped plotting %i patches not visible' % num_skipped)

@mandli
Copy link
Member

mandli commented Sep 22, 2020

Not sure, I was thinking maybe if someone set plotaxes.skip_patches_outside_xylimits = True, had a mapped grid and did not specify a mapc2p that we should raise a warning.

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

No branches or pull requests

3 participants