-
Notifications
You must be signed in to change notification settings - Fork 35
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
Unique components #410
Unique components #410
Conversation
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.
Few minor suggestions.
linetools/analysis/zlimits.py
Outdated
@@ -23,7 +24,8 @@ class LineLimits(object): | |||
zlim : tuple of floats | |||
Redshift limits for a line | |||
Defined as wave/wrest - 1. | |||
wvlim : Quantity array | |||
or |
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.
Do not really need 'or' line, do we?
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 even removed the line above as wrest is not required
@@ -41,7 +43,7 @@ def from_specline(cls, aline, z, zlim): | |||
if not isinstance(aline, (AbsLine, EmLine)): | |||
raise IOError("Input aline must be AbsLine or EmLine") | |||
# | |||
slf = cls(aline.wrest, z, zlim) | |||
slf = cls(z, zlim, wrest=aline.wrest) |
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.
Need to add z and zlim to parameters list in the docstring.
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.
added
linetools/analysis/zlimits.py
Outdated
z : float | ||
Redshift of the line. | ||
zlim : tuple or list | ||
Redshift limits for a line | ||
Defined as wave/wrest - 1. | ||
Ok to have zlim[1]==zlim[0], but then self.is_set() == False | ||
wrest : Quantity, optional | ||
Rest wavelength. Used for SpectralLine objects |
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.
Doesn't have to be used by SpectralLine objects, right? I'm able to instantiate just by declaring wrest.
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.
edited
@@ -142,7 +149,7 @@ def is_set(self): | |||
return False | |||
|
|||
def set(self, inp, chk_z=False):#, itype='zlim'): | |||
""" Over-ride = to re-init values | |||
""" Set (or reset) limits relative to self._z |
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.
Maybe add a note that this does not change the reference redshift. Perhaps change to: "Set (or reset) limits relative to self._z but does not change self._z"
I was unclear as to what this did before I tried it.
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.
agreed with the suggestion above.
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.
edited
self.vlim = vlim | ||
# Limits | ||
zlim = ltu.z_from_dv(vlim, zcomp) | ||
self.limits = zLimits(zcomp, zlim.tolist()) |
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 there needs to be a way to set the reference redshift, e.g., mycomp.limits.setz(0.4)
One could imagine plenty of scenarios where one may wish to instantiate an AbsLine or AbsComponent with some lines then change the redshift on later. I realize this can be done by setting limits._z, but that's a bit under the hood and may not occur to a user who did not review the PR ;)
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.
Good idea, should probably be a method of zLimit
class.
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 understand the desire, but how does one modify the limits
in that case? Leave them as is?
I think I'd argue that the user should in that case instantiate
a new zLimits object.
# Set vlim by min/max [Using non-relativistic + buffer] | ||
vmin = u.Quantity([(comp.zcomp-zcomp)/(1+zcomp)*const.c.to('km/s')+comp.vlim[0] for comp in components]) | ||
vmax = u.Quantity([(comp.zcomp-zcomp)/(1+zcomp)*const.c.to('km/s')+comp.vlim[1] for comp in components]) | ||
synth_comp.vlim = u.Quantity([np.min(vmin)-vbuff, np.max(vmax)+vbuff]) | ||
vlim = u.Quantity([np.min(vmin)-vbuff, np.max(vmax)+vbuff]) |
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.
Looks like the default value of vbuff is 0 km/s but the docstring indicates 10 km/s?
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.
Must have used to have been 10 km/s. I guess
I figured that was a problem..
Have edited the doc string accordingly and kept it at 0 km/s.
linetools/isgm/utils.py
Outdated
def unique_components(comps1, comps2, tol=5*u.arcsec): | ||
""" Identify which members of comps1 are *not* within | ||
comps2, to given tolerances. Note, that repeats in | ||
comps1 are not looked for. |
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.
Perhaps clarify 2nd sentence? "Note: nonunique members of comps1 are not identified."
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 do not understand this either. How can a component be within another component? This is based on velocity limits or was supposed to identify two components that may be considered the same physical entity?
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.
have tried to clarify.
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.
This remains unclear to me. I beleive you try to identify component duplications (?), but in this case why to allow for a tolerance? If you allow a tolerance (specially in velocity limits), then what would happen for multiple contiguous and overlapping components? Will there be considered the same? If so, why is this useful?
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.
Oops, I forgot to push utils.py
Look at the new docstring please
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.
Left some comments. I think is a good idea to add a method in zLimits to reset z
. Probably with some restrictions like:
- New z must be within zlims of the previous one
- wvlims must be preserved (?)
Another option is to add a resetz method to AbsComponent, redefining the zLimits from scracth.
linetools/analysis/zlimits.py
Outdated
@@ -23,7 +24,8 @@ class LineLimits(object): | |||
zlim : tuple of floats | |||
Redshift limits for a line | |||
Defined as wave/wrest - 1. | |||
wvlim : Quantity array | |||
or | |||
wvlim : Quantity array, only if _wrest is set | |||
wavelength limits for the line in observer frame |
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.
this docstring only if _wrest is set
is confusing. Maybe say that this is an optional parameter that applies for zLimits to individual AbsLines (for which a single wrest makes sense)?
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.
improved
@@ -23,7 +24,8 @@ class LineLimits(object): | |||
zlim : tuple of floats |
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.
add z
to docstring
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.
done
""" | ||
Parameters | ||
---------- | ||
wrest : Quantity | ||
Rest wavelength of the line. | ||
z : float | ||
Redshift of the line. |
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.
redshift of the line -> redshift to apply the zlimits to
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.
edited. ps. your version looks a bit out of date
linetools/analysis/zlimits.py
Outdated
z : float | ||
Redshift of the line. | ||
zlim : tuple or list | ||
Redshift limits for a line | ||
Defined as wave/wrest - 1. | ||
Ok to have zlim[1]==zlim[0], but then self.is_set() == False | ||
wrest : Quantity, optional | ||
Rest wavelength. Used for SpectralLine objects |
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.
Used for SpectralLine objects -> Used for applying zLimits to individual SpectralLine objects
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.
edited
@@ -142,7 +149,7 @@ def is_set(self): | |||
return False | |||
|
|||
def set(self, inp, chk_z=False):#, itype='zlim'): | |||
""" Over-ride = to re-init values | |||
""" Set (or reset) limits relative to self._z |
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.
agreed with the suggestion above.
self.vlim = vlim | ||
# Limits | ||
zlim = ltu.z_from_dv(vlim, zcomp) | ||
self.limits = zLimits(zcomp, zlim.tolist()) |
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.
Good idea, should probably be a method of zLimit
class.
linetools/isgm/utils.py
Outdated
def unique_components(comps1, comps2, tol=5*u.arcsec): | ||
""" Identify which members of comps1 are *not* within | ||
comps2, to given tolerances. Note, that repeats in | ||
comps1 are not looked for. |
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 do not understand this either. How can a component be within another component? This is based on velocity limits or was supposed to identify two components that may be considered the same physical entity?
Ok, the outstanding issue is how to modify the redshift if at all. I am preferring that the user re-instantiate, i.e. self._z is fixed. Another option would be a method that takes in a new redshift and self.limits = self.limits.shift_z(z) Thoughts? |
Now that I re-think about it, |
Yeah, I'm not married to the idea of modifying the z of an existing zLimits object if you guys feel strongly that the user should create a new one. However, at the very least can we inform the user that they need to reinstantiate for a different redshift?
As for what to do with the limits once we change zlim (if we did), one basic option is to keep the vlim and adjust zlim accordingly. I see that I'm able to change the z of an AbsLine with .setz(), so the point is moot in most applications I suppose. Here the user is advised to update limits but not required to. If I change the vlim after using setz(), the zlim are updated as well, so I suppose what I foresee doing is possible given current functionality.
…-Joe
On Sep 21, 2017, at 7:50 AM, J. Xavier Prochaska ***@***.***> wrote:
@profxj commented on this pull request.
In linetools/isgm/utils.py:
> @@ -886,3 +888,58 @@ def joebvp_from_components(comp_list, specfile, outfile):
f.close()
+def unique_components(comps1, comps2, tol=5*u.arcsec):
+ """ Identify which members of comps1 are *not* within
+ comps2, to given tolerances. Note, that repeats in
+ comps1 are not looked for.
Oops, I forgot to push utils.py
Look at the new docstring please
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub, or mute the thread.
|
linetools/isgm/utils.py
Outdated
comps1 are not looked for. | ||
""" Identify which AbsComponent members of the comps1 list | ||
are *not* within the comps2 list, to given tolerances. | ||
Note, AbsComponent objects in the comps1 list are examined |
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.
AbsComponent objects in the comps1 list are not examined against each other right? I though that's what the previous docstring was saying.
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.
whoops.. edited
Ok, give this a thumbs up (if you agree). |
I still do not understand the idea behind unique_components(), but I guess is fine. |
Merging. @ntejos -- You'll see this new method in use shortly. (z1IGM) Note, I suspect igmguesses will break again. But I'll help fix it. |
There are two threads to this PR:
The first allows for limits without reference to wrest.
That becomes optional, so previous functionality is maintained.
The second is a method useful for querying lists of components.
I also removed GaussianAbsorption1D as that is deprecated in astropy.
Includes a new test, but no new docs.