<div dir="ltr">Hi all,<div><br></div><div>I'm trying to gaussian smooth a 3D field of gas. I'm convolving the field with a gaussian kernel, but my results look odd. I think this might be because of how I'm reshaping my data. You can see my scripts <a href="https://github.com/rasmi/deviant-cosmology/blob/master/scripts/convolve.py">here</a> and <a href="https://github.com/rasmi/deviant-cosmology/blob/4f6b4886c01c92cfe3987d4a66e25ba84ecebf86/scripts/convolve.py">here</a>, and a more detailed explanation with plots <a href="https://github.com/astropy/astropy/issues/5169#issuecomment-238304706">here</a>.</div><div><br></div><div>My suspicion (and someone from astropy's) is that I'm reshaping data improperly. I access the fields like this:</div><div><span style="color:rgb(51,51,51);font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;line-height:20px;white-space:pre">ad </span><span class="" style="color:rgb(167,29,93);font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;line-height:20px;white-space:pre">=</span><span style="color:rgb(51,51,51);font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;line-height:20px;white-space:pre"> ds.all_data()</span><br></div><div><span style="color:rgb(51,51,51);font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;line-height:20px;white-space:pre">density </span><span class="" style="color:rgb(167,29,93);font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;line-height:20px;white-space:pre">=</span><span style="color:rgb(51,51,51);font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;line-height:20px;white-space:pre"> ad[fields[</span><span class="" style="color:rgb(24,54,145);font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;line-height:20px;white-space:pre"><span class="" style="">'</span>density<span class="" style="">'</span></span><span style="color:rgb(51,51,51);font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;line-height:20px;white-space:pre">]]</span><span style="color:rgb(51,51,51);font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;line-height:20px;white-space:pre"><br></span></div><div>Which gives me a 1D array of length (1024^3) = 1073741824. To convolve this with a 3D gaussian kernel, I attempt to reshape the 1D array into its original 3D shape:</div><div><span style="color:rgb(51,51,51);font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;line-height:20px;white-space:pre">density </span><span class="" style="color:rgb(167,29,93);font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;line-height:20px;white-space:pre">=</span><span style="color:rgb(51,51,51);font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;line-height:20px;white-space:pre"> density.reshape(ds.domain_dimensions)</span><br></div>Which gives me a 3D 1024^3 matrix, but I'm not sure if this is correct. Does this correctly transform the 1D data from ds.all_data()[field] back into its 3D grid, or are things being misaligned somehow? Is there a better way to access a certain field's data in 3D without getting it in 1D first and reshaping?<div><br></div><div><br></div><div>Thanks,</div><div><br></div><div>Rasmi</div></div>