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

Update acq report format a bit, tidy code, change raise_exc default #285

Merged
merged 3 commits into from
Feb 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions proseco/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ def get_aca_catalog(obsid=0, **kwargs):
appending this string, e.g. with ``obs_text + '--force-catalog'`` in the
call to ``get_aca_catalog``.

NOTE on API:

Keywords that have ``_acq`` and/or ``_guide`` suffixes are handled with
the AliasAttribute in core.py. If one calls get_aca_catalog() with e.g.
``t_ccd=-10`` then that will set the CCD temperature for both acq and
guide selection. This is not part of the public API but is a private
feature of the implementation that works for now.

:param obsid: obsid (int) or starcheck text (str) (default=0)
:param att: attitude (any object that can initialize Quat)
:param n_acq: desired number of acquisition stars (default=8)
Expand All @@ -51,19 +59,12 @@ def get_aca_catalog(obsid=0, **kwargs):
:param optimize: optimize star catalog after initial selection (default=True)
:param verbose: provide extra logging info (mostly calc_p_safe) (default=False)
:param print_log: print the run log to stdout (default=False)
:param raise_exc: raise exception if it occurs in processing (default=True)

:returns: ACATable of stars and fids

"""
# NOTE on API:
#
# Keywords that have ``_acq`` and/or ``_guide`` suffixes are handled with
# the AliasAttribute in core.py. If one calls get_aca_catalog() with e.g.
# ``t_ccd=-10`` then that will set the CCD temperature for both acq and
# guide selection. This is not part of the public API but is a private
# feature of the implementation that works for now.

raise_exc = kwargs.pop('raise_exc', None) # This cannot credibly fail
raise_exc = kwargs.pop('raise_exc', True) # This cannot credibly fail

try:
# If obsid is supplied as a string then it is taken to be starcheck text
Expand Down
21 changes: 13 additions & 8 deletions proseco/index_template_acq.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,19 @@ <h4>Probability of acquisition from the chandra_aca model </h4>
<h4> Probability star is on the usable part of the CCD </h4>
{{ acq['p_on_ccd_table'] | safe }}

<h4> Spoilers (stars)</h4>
<img src="{{ acq['spoilers_plot'] }}">
{{ acq['spoilers_table'] | safe }}

<h4> Imposters (hot pixels)</h4>
<img src="{{ acq['imposters_plot'] }}">
{{ acq['imposters_table'] | safe }}

<table>
<tr>
<td>
<h4> Spoilers (stars)</h4>
<img src="{{ acq['spoilers_plot'] }}">
{{ acq['spoilers_table'] | safe }}
</td>
<td>
<h4> Imposters (hot pixels)</h4>
<img src="{{ acq['imposters_plot'] }}">
{{ acq['imposters_table'] | safe }}
</td>
</table>

{% endfor %}

Expand Down
2 changes: 0 additions & 2 deletions proseco/report_acq.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,6 @@ def make_acq_star_details_report(acqs, cand_acqs, events, context, obsdir):
######################################################
# Candidate acq star detail sections
######################################################
acqs.dark = get_dark_cal_image(date=acqs.date, select='before',
t_ccd_ref=acqs.t_ccd)

context['cand_acqs'] = []

Expand Down
2 changes: 0 additions & 2 deletions proseco/report_guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ def make_report(obsid, rootdir='.'):

# Get information that is not stored in the acqs pickle for space reasons
guides.stars = StarsTable.from_agasc(guides.att, date=guides.date)
guides.dark = get_dark_cal_image(date=guides.date, select='before',
t_ccd_ref=guides.t_ccd)

# For include/exclude stars, add some bookkeeping (the forced column)
cand_guides['forced'] = False
Expand Down
9 changes: 5 additions & 4 deletions proseco/tests/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def test_exception_handling():
t_ccd_acq=-10, t_ccd_guide=-10,
detector='ACIS-S', sim_offset=0, focus_offset=0,
n_guide=8, n_fid=3, n_acq=8,
include_ids_acq=[1]) # Fail
include_ids_acq=[1], raise_exc=False) # Fail
assert 'include_ids and include_halfws must have same length' in aca.exception

for obj in (aca, aca.acqs, aca.guides, aca.fids):
Expand Down Expand Up @@ -149,7 +149,7 @@ def test_no_candidates():
dither_guide=(8.0, 8.0))
stars = StarsTable.empty()
stars.add_fake_constellation(mag=13.0, n_stars=2)
acas = get_aca_catalog(**test_info, stars=stars)
acas = get_aca_catalog(**test_info, stars=stars, raise_exc=False)

assert 'id' in acas.acqs.colnames
assert 'halfw' in acas.acqs.colnames
Expand Down Expand Up @@ -357,7 +357,8 @@ def test_t_ccd_effective_acq_guide(t_ccd_case):


def test_call_args_attr():
aca = get_aca_catalog(**mod_std_info(optimize=False, n_guide=0, n_acq=0, n_fid=0))
aca = get_aca_catalog(**mod_std_info(optimize=False, n_guide=0, n_acq=0, n_fid=0),
raise_exc=False)
jeanconn marked this conversation as resolved.
Show resolved Hide resolved
assert aca.call_args == {'att': (0, 0, 0),
'date': '2018:001',
'detector': 'ACIS-S',
Expand All @@ -374,7 +375,7 @@ def test_call_args_attr():


def test_bad_obsid():
aca = get_aca_catalog(obsid='blah blah') # Expects this to be starcheck catalog
aca = get_aca_catalog(obsid='blah blah', raise_exc=False) # Expects this to be starcheck catalog
assert 'ValueError: text does not have OBSID' in aca.exception

assert aca.thumbs_up == 0
Expand Down