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

Make plot() method behave consistently and correctly #221

Merged
merged 3 commits into from
Dec 30, 2018
Merged

Conversation

taldcroft
Copy link
Member

@taldcroft taldcroft commented Dec 29, 2018

Plotting was kinda broken with regards to bad stars and the attempt to use just a single method for all classes didn't cut it. This PR fixes things up by introducing class-specific plot methods that do the right thing. Along the way I did a lot of refactoring and re-organizing:

  • Add a bad_stars_mask property
  • Add a get_candidates_mask method that indicates acceptable candidates (apart from spatial filtering)
  • Add a catalog_type class attribute to indicate the type of catalog represented by the class.
  • Add a helper method get_catalog_for_plot (minor catalog munge for plotting)

There was a reason for the madness, namely in development of #216 I was frustrated by the bugs and not being able to evaluate by eye whether a particular candidate should be acceptable at a different roll.

This supercedes #222.

@taldcroft taldcroft force-pushed the fix-plot branch 2 times, most recently from 095a712 to 0bda4c6 Compare December 29, 2018 22:47
@taldcroft
Copy link
Member Author

@jeanconn - related to your comment about different definitions of bad_stars, hopefully the new name and code comments help. I also realized it would make sense to set the bad_stars_mask for any stars that are in the bad_stars_set. Will do, though this will only happen for stars that are considered as candidates.

@@ -288,6 +290,26 @@ def process_include_ids(self, cand_guides, stars):

super().process_include_ids(cand_guides, stars[ok])

def get_candidates_mask(self, stars):
"""Get base filter for acceptable candidates.
Copy link
Contributor

Choose a reason for hiding this comment

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

Worth noting that, in general, I don't know what value the label of "acceptable" really has when the CCD-position and more detailed spoiler checks have not been done. But that's more of an issue for the seeking-the-right-roll PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

"Acceptable" means it can be chosen as a candidate. It doesn't mean it will be a candidate. Conversely, a star that is "not acceptable" will never be chosen as a guide or acq, so this is the initial entry ("base") filter.

# internal version (which is no lot always the right answer).
kwargs.setdefault('bad_stars', np.zeros(len(kwargs['stars']), dtype=bool))

plot_stars(attitude=self.att, ax=ax, **kwargs)
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good. Do we need more changes/options in chandra_aca.plot_stars? Other colors etc?

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe, but that's for another day.

@jeanconn
Copy link
Contributor

Thanks, and yeah, I don't know if we should just come up with a new name for the list of stars we are tracking that should be excluded, but the _mask helps some.

:param cand_guides: Table of candidate stars
:returns: boolean mask where True means star is in bad star list
"""
bad = np.in1d(cand_guides['id'], list(ACA.bad_star_set))
Copy link
Member Author

Choose a reason for hiding this comment

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

I discovered this function recently and it's very handy! But apparently you cannot have a set as the second argument.

"""
bad = np.in1d(cand_guides['id'], list(ACA.bad_star_set))

# Set any matching bad stars as bad for plotting
Copy link
Member Author

Choose a reason for hiding this comment

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

Side effects like this are not totally ideal, but so it goes...

"""
Obsid 17896 attitude
Will need to find another bad star, as this one is now excluded via VAR
def test_bad_star_list():
Copy link
Member Author

Choose a reason for hiding this comment

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

Changed to a synthetic test, esp. since the comment indicated the test might not be valid anyway.

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 this will make conflicts on #218 which I may let you resolve.

@taldcroft taldcroft merged commit ddb5c64 into master Dec 30, 2018
@taldcroft taldcroft deleted the fix-plot branch December 30, 2018 17:31
taldcroft added a commit that referenced this pull request Dec 31, 2018
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.

2 participants