-
Notifications
You must be signed in to change notification settings - Fork 274
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
BUG: fix buffer masking in cartesian geometry #3856
BUG: fix buffer masking in cartesian geometry #3856
Conversation
a35f35b
to
ed17a7a
Compare
So far I haven't been able to localise the source of differences in the affected @matthewturk, any idea what might be causing this ? |
Can you do a floating point comparison? I'm not entirely sure why the masking would cause these things, except that it's possible that some things that were previously 0.0 are now NaN right at the boundary, or vice versa. |
So I was able to reproduce this locally by running the following on the tip of main import yt
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import LogNorm
field = ("gas", "temperature")
ds = yt.load("output_00080/info_00080.txt")
obj = ds.sphere("max", (0.1, "unitary"))
axis = 0
weight_field = ("gas", "density")
proj = ds.proj(field, axis, weight_field=weight_field, data_source=obj)
frb = proj.to_frb((1.0, "unitary"), 256)
np.save(f"main_weightfield_{weight_field}.npy", frb[field].d) followed by
Then repeating the script but saving to a different file np.save(f"branch_weightfield_{weight_field}.npy", frb[field].d) and finally running fig, axs = plt.subplots(nrows=1, ncols=3, figsize=(15, 4))
d1 = np.load(f"main_weightfield_('gas', 'density').npy")
d2 = np.load(f"branch_weightfield_('gas', 'density').npy")
n1 = LogNorm(vmin=np.nanmin(d1), vmax=np.nanmax(d1))
n2 = LogNorm(vmin=np.nanmin(d2), vmax=np.nanmax(d2))
diff = np.nansum((d2, -d1), axis=0)
for data, norm, ax in [
(d1, n1, axs[0]),
(d2, n2, axs[1]),
(diff, LogNorm(), axs[2]),
]:
im = ax.imshow(data, norm=norm, cmap="cmyt.arbre")
fig.colorbar(im, ax=ax)
fig.savefig("/tmp/bench.png") So it seems that your intuition was right Matt, the only place where there are actual differences is at the boundary of the selection, though I still do not understand why that is. |
I agree with your assertion that this is a fix. My suspicion is that it involves the anti-aliasing argument, and that if it were turned off we would see less difference. Regardless, this looks like an improvement to me, and I say move forward. |
385a295
to
30888c2
Compare
So, my attempt to generalise using nan as a fill value to sph-like particle pixelization routines has resulted in multiple test failures that I can't seem to reproduce locally. |
@neutrinoceros Yes, I think that's reasonable. |
30888c2
to
ed17a7a
Compare
@matthewturk this is ready |
@@ -98,5 +100,4 @@ def test_field_cut_off_axis_octree(): | |||
(p3.frb[("gas", "density")] == p4.frb[("gas", "density")]).all(), False | |||
) | |||
p4rho = p4.frb[("gas", "density")] | |||
assert_equal(p4rho.min() == 0.0, True) # Lots of zeros | |||
assert_equal(p4rho[p4rho > 0.0].min() >= 0.5, True) | |||
assert_equal(np.nanmin(p4rho[p4rho > 0.0]) >= 0.5, True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use the following?
assert_equal(np.nanmin(p4rho[p4rho > 0.0]) >= 0.5, True) | |
assert np.nanmin(p4rho[p4rho > 0.0]) >= 0.5 |
Note that I am absolutely happy about the PR as is and don't want to delay it any further, so feel free to push the merge button!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I’m going to keep it as is to match the local dominant convention, even though this is actually not a unit test-based test, so your suggestion should indeed work.
In my comment I wrote
Note that I am absolutely happy about the PR as is and don't want to delay it any further, so feel free to push the merge button!
So that's absolutely fine by me :)
31 Mar 2022 12:00:51 Matthew Turk ***@***.***>:
… @neutrinoceros[https://github.com/neutrinoceros] did you just merge your own PR, before @cphyc[https://github.com/cphyc] responded to your reply?
—
Reply to this email directly, view it on GitHub[#3856 (comment)], or unsubscribe[https://github.com/notifications/unsubscribe-auth/ABJJII6KYOUNSYWA746TSUDVCWAWFANCNFSM5RI7ZGIQ].
You are receiving this because you were mentioned.[Tracking image][https://github.com/notifications/beacon/ABJJIIZV7QJ3NNLKQSYFYHLVCWAWFA5CNFSM5RI7ZGI2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOICRP25Q.gif]
|
@cphyc I deleted my comment right after I posted, because I realized |
…6-on-yt-4.0.x Backport PR #3856 on branch yt-4.0.x (BUG: fix buffer masking in cartesian geometry)
PR Summary
Goal: fix #3854
Applying the patch from the issue. Let's see what image tests fail.