Skip to content

Commit

Permalink
More refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
taldcroft committed Dec 29, 2018
1 parent 5d2fb94 commit 095a712
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 43 deletions.
21 changes: 4 additions & 17 deletions proseco/acq.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ class AcqTable(ACACatalogTable):
"""
Catalog of acquisition stars
"""
# Catalog type when plotting (None | 'FID' | 'ACQ' | 'GUI')
catalog_type = 'ACQ'

# Elements of meta that should not be directly serialized to pickle
# (either too big or requires special handling).
pickle_exclude = ('stars', 'dark', 'bad_stars')
Expand Down Expand Up @@ -190,21 +193,6 @@ def thumbs_up(self):
out = int(self.get_log_p_2_or_fewer() <= np.log10(ACQ.acq_prob))
return out

def plot(self, ax=None, **kwargs):
"""
Plot the catalog and background stars.
:param ax: matplotlib axes object for plotting to (optional)
:param kwargs: other keyword args for plot_stars
"""
# Make a temp light copy and set type to 'ACQ' for plotting
catalog = self.as_array()
catalog['type'] = 'ACQ'
kwargs.setdefault('catalog', catalog)
kwargs.setdefault('stars', self.stars)
kwargs.setdefault('bad_stars', self.bad_stars)
super().plot(ax, **kwargs)

def make_report(self, rootdir='.'):
"""
Make summary HTML report for acq selection process and outputs.
Expand Down Expand Up @@ -273,8 +261,7 @@ def get_obs_info(self):
'detector', 'sim_offset', 'focus_offset')
return {key: getattr(self, key) for key in keys}

@staticmethod
def get_candidates_filter(stars):
def get_candidates_filter(self, stars):
"""Get base filter for acceptable candidates.
This does not include spatial filtering.
Expand Down
28 changes: 4 additions & 24 deletions proseco/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,30 +160,10 @@ def thumbs_up(self):
self.fids.thumbs_up &
self.guides.thumbs_up)

@property
def bad_stars(self):
if not hasattr(self, '_bad_stars'):
# Star is OK if OK for either acqs or guides
ok_stars = (self.acqs.get_candidates_filter(self.stars) |
self.guides.get_candidates_filter(self.stars))
self._bad_stars = ~ok_stars
return self._bad_stars

@bad_stars.setter
def bad_stars(self, value):
self._bad_stars = value

def plot(self, ax=None, **kwargs):
"""
Plot the catalog and background stars.
:param ax: matplotlib axes object for plotting to (optional)
:param kwargs: other keyword args for plot_stars
"""
kwargs.setdefault('catalog', self)
kwargs.setdefault('stars', self.stars)
kwargs.setdefault('bad_stars', self.bad_stars)
super().plot(ax, **kwargs)
def get_candidates_filter(self, stars):
ok = (self.acqs.get_candidates_filter(stars) |
self.guides.get_candidates_filter(stars))
return ok

def make_report(self, rootdir='.'):
"""
Expand Down
19 changes: 19 additions & 0 deletions proseco/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,9 @@ class BaseCatalogTable(Table):
- Indexing on 'id' column
"""
# Catalog type when plotting (None | 'FID' | 'ACQ' | 'GUI')
catalog_type = None

def __init__(self, data=None, **kwargs):
super().__init__(data=data, **kwargs)

Expand Down Expand Up @@ -590,6 +593,22 @@ def set_stars(self, acqs=None, filter_near_fov=True):

self.stars = stars

def plot(self, ax=None, **kwargs):
"""
Plot the catalog and background stars.
:param ax: matplotlib axes object for plotting to (optional)
:param kwargs: other keyword args for plot_stars
"""
# Make a temp light copy and set type to 'ACQ' for plotting
catalog = self.as_array()
if self.catalog_type:
catalog['type'] = self.catalog_type
kwargs.setdefault('catalog', catalog)
kwargs.setdefault('stars', self.stars)
kwargs.setdefault('bad_stars', self.bad_stars)
super().plot(ax, **kwargs)

@property
def dither(self):
return None
Expand Down
3 changes: 3 additions & 0 deletions proseco/fid.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ def get_fid_catalog(obsid=0, **kwargs):


class FidTable(ACACatalogTable):
# Catalog type when plotting (None | 'FID' | 'ACQ' | 'GUI')
catalog_type = 'FID'

# Name of table. Use to define default file names where applicable.
# (e.g. `obs19387/fids.pkl`).
name = 'fids'
Expand Down
5 changes: 3 additions & 2 deletions proseco/guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def get_guide_catalog(obsid=0, **kwargs):


class GuideTable(ACACatalogTable):
# Catalog type when plotting (None | 'FID' | 'ACQ' | 'GUI')
catalog_type = 'GUI'

# Elements of meta that should not be directly serialized to pickle.
# (either too big or requires special handling).
Expand Down Expand Up @@ -303,8 +305,7 @@ def process_include_ids(self, cand_guides, stars):

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

@staticmethod
def get_candidates_filter(stars):
def get_candidates_filter(self, stars):
"""Get base filter for acceptable candidates.
This does not include spatial filtering.
Expand Down

0 comments on commit 095a712

Please sign in to comment.