Closed yt-fido closed 7 years ago
Original comment by chummels (Bitbucket: chummels, GitHub: chummels):
Right now density is not a required field for generating the AbsorptionSpectrum
object, which is why I was potentially proposing making it required. The example script in Issue 1232 actually didn't have 'density', which is why the change in your PR was required. I'm actually looking at just allowing all zero-value fields (including density) and no mask whatsoever in the LightRay
construction, and then have the mask/zero-value check occur at the AbsorptionSpectrum
level when the spectra are actually made. Unless people think that this is a bad idea.
Originally reported by: chummels (Bitbucket: chummels, GitHub: chummels)
Recently, there was a problem with LightRay objects attempting to be created from zero density trajectories, which led to problems when attempting to use the
AbsorptionSpectrum
functionality because it expects non-zero density fields in order to work correctly (Issue #1232).This issue was addressed by PR #2300, which searched for any fields present in the
fields
kwarg of themake_light_ray()
function, identified which of these fields had units of'K', 'g/cm**3', or 'cm**-3'
, and applied a mask so only non-zero values of those fields were included in the resulting LightRay.The problem I've encountered is when you have several ion number density fields in a dataset and you want to include them in the LightRay object, you end up masking out all array elements that have zero values for any of the ion fields. So for example, if my simulation keeps track of Oxygen VI number density and H I number density (i.e.
O_p5_number_density
andH_p0_number_density
), and my LightRay passes through a region with zero metallicity (and thus, zero Oxygen VI, but non-zero H I), all of the cells with zero oxygen VI will get masked out of the LightRay, even though they contain valid densities and H I densities. I've created an example script below:make_light_ray fails because it is trying to mask all cells that the ray hits that have zero values in any probed field. Here is the STDERR/STDOUT:
I'm not sure the ideal solution. One might be to require users to include the
density
field when they make a LightRay, and then just use that field for masking out the zero-value density cells. Alternatively, we could accept zero-valued cells and then make AbsorptionSpectrum smarter about what it tries to do with these data. Ideas?