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

Template redshift enhancements #551

Merged
merged 12 commits into from
Nov 26, 2019
Merged

Template redshift enhancements #551

merged 12 commits into from
Nov 26, 2019

Conversation

ibusko
Copy link
Contributor

@ibusko ibusko commented Nov 14, 2019

This PR addresses issue #549 .

Copy link
Contributor

@nmearl nmearl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. My only suggestion is that we merge the known_redshift and redshift parameters into a single parameter to avoid duplicate logic.

The maximum redshift allowed.
delta_redshift : `float`
The amount the redshift will change between loops.
redshift : `list`, `tuple`, 'numpy.array`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should merge redshift and known_redshift into a single parameter. We can then check if the value is a float or array-like and deal with it appropriately. Using this function, I wouldn't expect that a single value or a list of values would require two different arguments.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with this, but the one question is: is there some specific science case for known_redshift being used in addition to the redshift grid? I can't think of one offhand but just want to be sure... maybe @camipacifici has some insight?

min_redshift, max_redshift, delta_redshift)
if redshift is not None and all(x is not None for x in redshift):
_, redshifted_spectrum, _ = template_redshift(observed_spectrum, spectral_templates,
redshift=redshift)
spectral_templates = redshifted_spectrum
elif known_redshift:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This elif block can then be removed if we go with a single redshift argument that can be either a float or a list.)

min_redshift, max_redshift, delta_redshift)
if redshift is not None and all(x is not None for x in redshift):
_, redshifted_spectrum, _ = template_redshift(observed_spectrum, spectrum,
redshift=redshift)
spectrum = redshifted_spectrum

elif known_redshift:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Again, can be removed.)

The maximum redshift allowed.
delta_redshift : `float`
The amount the redshift will change between loops.
redshift : `list`, `tuple`, 'numpy.array`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
redshift : `list`, `tuple`, 'numpy.array`
redshift : `float`, `list`, `tuple`, 'numpy.array`

raise ValueError("The `max_redshift` value must be greater than `min_redshift`.")
return

redshift = min_redshift
chi2_min = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
chi2_min = None
redshift = np.array(redshift).reshape((np.array(redshift).size,))
chi2_min = None

Copy link
Member

@eteq eteq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @nmearl's suggestions and had one of my own, but this is looking mostly there!

The maximum redshift allowed.
delta_redshift : `float`
The amount the redshift will change between loops.
redshift : `list`, `tuple`, 'numpy.array`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with this, but the one question is: is there some specific science case for known_redshift being used in addition to the redshift grid? I can't think of one offhand but just want to be sure... maybe @camipacifici has some insight?

@@ -224,29 +223,28 @@ def template_redshift(observed_spectrum, template_spectrum, min_redshift, max_re
redshifted_spectrum: :class:`~specutils.Spectrum1D`
A new Spectrum1D object which incorporates the template_spectrum with a spectral_axis
that has been redshifted using the final_redshift.
chi2_list : `list`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be an ndarray instead of a list. That will make it a lot easier to work with if it's multidimensional.

Relatedly, I'm having a bit of trouble following the logic: is the resulting array is of dimension equal to the spectral template set, or is it a 2D array that's n_template x n_redshift ? I think the latter is the eventual goal, but if we're not quite there it could be a follow-on.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In some out-of-band discussion, @ibusko said he'd write a test for the SpectrumCollection case and see what happens.

My preference is that it returns a 2D array as indicated above (or the transpose)

Copy link
Member

@eteq eteq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now - thanks @ibusko !

@eteq eteq merged commit 0ca3c02 into astropy:master Nov 26, 2019
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

Successfully merging this pull request may close these issues.

None yet

3 participants