yt-project / yt

Main yt repository
http://yt-project.org
Other
469 stars 280 forks source link

Make slice visualizations periodically wrap correctly #1185

Open yt-fido opened 8 years ago

yt-fido commented 8 years ago

Originally reported by: Patrick Shriwise (Bitbucket: pshriwise, GitHub: pshriwise)


When creating sliceplots, I've been experiencing an effect in which some hdf5 data that is cutoff by the set width of the plot is added on or wrapped onto the remaining space at the other end of the plot. This can be fixed by increasing the width of the plot along the axis for which the wrapping is occuring, but clearly shouldn't be happening so I thought I'd let you know. :)

The wrapping effect can be seen on the left side of the first plot along the white line. In the next plot I've increased the width along the problematic axes and the problem goes away.

I've attached as simple a notebook as possible which shows this. I did not attach the dataset here due to its size, but I'd be happy to provide it as well as the geometry facets which may help to show this more clearly. yt is great and I hope to keep using it in the future!

import numpy as np
import yt
from yt.testing import fake_random_ds

m = fake_random_ds(64, bbox=np.array([[0, 2000], [-600, 600], [-1500, 1900]]))

ys = yt.SlicePlot(m, 'y', 'density', origin='native', center=(1000,0,0))
ys.set_font({'family': 'Arial', 'size': 11})
ys.annotate_title("y=0")
ys.set_width(((3400, 'cm'), (2000, 'cm')))
ys.save('one.png')

ys = yt.SlicePlot(m, 'y', 'density', origin='native', center=(1000, 0, 0))
ys.set_font({'family': 'Arial', 'size': 11})
ys.annotate_title("y=0")
ys.set_width(((3800,'cm'), (2000,'cm')))
ys.save('two.png')

yt-fido commented 8 years ago

Original comment by Kacper Kowalik (Bitbucket: xarthisius, GitHub: xarthisius):


Right now pixelizer is only aware of data points that are withing domain edges. If the desired behavior is to fully populate frb that's larger than the domain, we need to iterate over ghost copies or perform some sort of tiling at the end.

yt-fido commented 8 years ago

Original comment by Kacper Kowalik (Bitbucket: xarthisius, GitHub: xarthisius):


Reproducible with:

#!python

import numpy as np
import yt
from yt.testing import fake_random_ds

m = fake_random_ds(64, bbox=np.array([[0, 2000], [-600, 600], [-1500, 1900]]))

ys = yt.SlicePlot(m, 'y', 'density', origin='native', center=(1000,0,0))
ys.set_font({'family': 'Arial', 'size': 11})
ys.annotate_title("y=0")
ys.set_width(((3400, 'cm'), (2000, 'cm')))
ys.save('one.png')

ys = yt.SlicePlot(m, 'y', 'density', origin='native', center=(1000, 0, 0))
ys.set_font({'family': 'Arial', 'size': 11})
ys.annotate_title("y=0")
ys.set_width(((3800,'cm'), (2000,'cm')))
ys.save('two.png')
yt-fido commented 8 years ago

Original comment by Nathan Goldbaum (Bitbucket: ngoldbaum, GitHub: ngoldbaum):


I messed with this a bit but I'm not really sure what's happening. Given that this is a very rare issue and that it seems to be somewhat complicated I'm going to punt on this until 3.4.

yt-fido commented 8 years ago

Original comment by Nathan Goldbaum (Bitbucket: ngoldbaum, GitHub: ngoldbaum):


If I manually set periodic to False before the call to pixelize_cartesian in CartesianCoordinateHandler, I still see this, so this has nothing to do with the periodic support in the pixelizer, or at least it's not controllable at that level.

yt-fido commented 8 years ago

Original comment by Nathan Goldbaum (Bitbucket: ngoldbaum, GitHub: ngoldbaum):


I'm able to reproduce this.

It looks like the pixelizer is getting confused and incorrectly periodically mirroring the data. Here's an imshow plot of ys.frb['z'] after running the example in the attached notebook:

http://i.imgur.com/LVSzDF3.png

Going to look closer at the pixelizer to try to understand what's going on here....

yt-fido commented 8 years ago

Original comment by Nathan Goldbaum (Bitbucket: ngoldbaum, GitHub: ngoldbaum):


Moving version to 3.3. I wasn't able to reproduce because the data file is large and my internet connection at this conference is slow.

yt-fido commented 8 years ago

Original comment by Patrick Shriwise (Bitbucket: pshriwise, GitHub: pshriwise):


Thanks for your quick response @ngoldbaum!

Just finished uploading the dataset at http://use.yt/upload/1ce1e8eb

yt-fido commented 8 years ago

Original comment by Nathan Goldbaum (Bitbucket: ngoldbaum, GitHub: ngoldbaum):


Here's a view of the notebook on nbviewer:

http://nbviewer.jupyter.org/urls/bitbucket.org/yt_analysis/yt/issues/attachments/1185/yt_analysis/yt/1457965645.62/1185/yt_wrap_bug_simple.ipynb

I'm not sure what's happening here - I'd need to dig in with a debugger. If you'd like you can share a copy of the dataset using the yt curldrop:

$ curl -T yt_bug_data.h5m http://use.yt/upload/
ngoldbaum commented 7 years ago

This will be tackled along with #1366

matthewturk commented 7 years ago

My reading of this is that the issue arises because in one of these we're extending more than one period away; we're setting the width to just over 2x the domain width. This wasn't ever expected to happen. I don't think this is a "bug" as much as an unexpected situation -- which should be fixable by modifying the pixelization routine to allow for multiple iterations. (I think @Xarthisius noted this above.) That will likely come at the expense of simplicity/speed.