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

Tweaks to sparkles / yoshi based on cycle 24 work #173

Merged
merged 3 commits into from
Jun 1, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion sparkles/index_template_preview.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ <h3>Roll options (roll_min={{roll_min}}
{% for aca in acas %}

<a name="id{{aca.report_id}}"></a>
<h2> {{id_label}} {{aca.report_id}} at {{aca.date}}</h1>
<h2> {{id_label}} {{aca.report_id}} ({{aca.target_name}}) at {{aca.date}}</h1>
{% if aca.context['reports_dir'] %}
<pre>Reports: <a href="{{aca.context['reports_dir']}}/acq/index.html">Acquisition</a> <a href="{{aca.context['reports_dir']}}/guide/index.html">Guide</a></pre>
{% endif %}
Expand Down
24 changes: 17 additions & 7 deletions sparkles/roll_optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,18 @@ def get_roll_intervals(self, cand_idxs, d_roll=None, roll_dev=None,
- 'uniform': roll interval is uniform over allowed range with ``d_roll`` spacing

:param cand_idxs: index values for candidate better stars
:param y_off: Y offset (deg, sign per OR-list convention)
:param z_off: Z offset (deg, sign per OR-list convention)
:param d_roll: step size for examining roll range (deg, default=0.25 for
uniq_ids and 0.5 for uniform)
:param roll_dev: roll deviation about nominal to sample (DEPRECATED,
use max_roll_dev instead)
:param method: method for determining roll intervals ('uniq_ids' | 'uniform')
The 'uniq_ids' method is a faster method that frequently finds an
acceptable roll option, while 'uniform' is a brute-force search of
the entire roll range at ``d_roll`` increments. If not provided, the
default is to try *both* methods in order, stopping when an
jeanconn marked this conversation as resolved.
Show resolved Hide resolved
acceptable option is found.
:param max_roll_dev: roll deviation about nominal to sample (deg,
default=max allowed by pitch)

:returns: list of candidate rolls

Expand Down Expand Up @@ -173,11 +181,13 @@ def get_ids_list(roll_offsets):
att_nom_targ = self._calc_targ_from_aca(att_nom, *self.target_offset)
roll_nom = att_nom_targ.roll

if roll_dev is None:
roll_dev = Ska.Sun.allowed_rolldev(pitch)

if max_roll_dev is not None:
roll_dev = min(roll_dev, max_roll_dev)
if roll_dev is not None:
warnings.warn(
'roll_dev will be removed in a future release, use max_roll_dev instead',
FutureWarning
)
else:
roll_dev = Ska.Sun.allowed_rolldev(pitch) if max_roll_dev is None else max_roll_dev

# Ensure roll_nom in range 0 <= roll_nom < 360 to match att_targ.roll.
# Also ensure that roll_min < roll < roll_max. It can happen that the
Expand Down
11 changes: 8 additions & 3 deletions sparkles/tests/test_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,15 +410,20 @@ def test_get_roll_intervals():
aca_or = get_aca_catalog(**kw_or)
acar_or = aca_or.get_review_table()

roll_dev = 5
max_roll_dev = 5

with pytest.warns(FutureWarning):
er_roll_intervs, er_info = acar_er.get_roll_intervals(
acar_er.get_candidate_better_stars(),
roll_dev=max_roll_dev)

er_roll_intervs, er_info = acar_er.get_roll_intervals(
acar_er.get_candidate_better_stars(),
roll_dev=roll_dev)
max_roll_dev=max_roll_dev)

or_roll_intervs, or_info = acar_or.get_roll_intervals(
acar_or.get_candidate_better_stars(),
roll_dev=roll_dev)
max_roll_dev=max_roll_dev)

assert acar_er.att.roll <= er_info['roll_max']
assert acar_er.att.roll >= er_info['roll_min']
Expand Down
9 changes: 7 additions & 2 deletions sparkles/tests/test_yoshi.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def test_run_one_yoshi():
"roll_targ": 197.12,
"sim_offset": 0,
"t_ccd": -9.1,
"target_name": "Target name",
}

expected = {
Expand Down Expand Up @@ -86,7 +87,8 @@ def test_get_params():
assert_dict_equal(params, exp)

params_proseco = convert_yoshi_to_proseco_params(
**params, obsid=8008, t_ccd=-10, man_angle=5.0
**params, obsid=8008, t_ccd=-10, man_angle=5.0, target_name="Target name",

)
exp_proseco = {
"att": Quat([0.15017923, 0.49292814, 0.83025727, 0.21246392]),
Expand All @@ -101,6 +103,7 @@ def test_get_params():
"obsid": 8008,
"sim_offset": 0,
"t_ccd": -10,
"target_name": "Target name",
}
assert_dict_equal(params_proseco, exp_proseco)

Expand All @@ -125,9 +128,11 @@ def test_acar_from_ocat(monkeypatch):
"""Get an AcaReviewTable with minimal information filling in rest from OCAT"""
monkeypatch.setenv(agasc.SUPPLEMENT_ENABLED_ENV, "False")

acar = ACAReviewTable.from_ocat(obsid=8008, date="2022:001", t_ccd=-10, n_acq=6)
acar = ACAReviewTable.from_ocat(obsid=8008, date="2022:001", t_ccd=-10,
n_acq=6, target_name="Target name")
assert acar.obsid == 8008
assert acar.date == "2022:001:00:00:00.000"
assert acar.target_name == "Target name"
assert len(acar.acqs) == 6
exp = [
"idx slot id type mag yang zang row col ",
Expand Down
8 changes: 5 additions & 3 deletions sparkles/yoshi.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,9 @@ def run_one_yoshi(
obs_date,
t_ccd,
man_angle,
**kwargs,
)

# Update or override params from yoshi for call to get_aca_catalog
params.update(kwargs)

aca = get_aca_catalog(**params)
acar = aca.get_review_table()
acar.run_aca_review()
Expand Down Expand Up @@ -193,6 +191,7 @@ def convert_yoshi_to_proseco_params(
obs_date,
t_ccd,
man_angle,
**kwargs,
):
"""
Convert yoshi parameters to equivalent proseco arguments
Expand All @@ -214,6 +213,7 @@ def convert_yoshi_to_proseco_params(
:param obs_date: observation date (for proper motion and ACA offset projection)
:param t_ccd: ACA CCD temperature (degrees C)
:param man_angle: maneuver angle (degrees)
:param **kwargs: extra keyword arguments which update the output proseco params
:returns: dictionary of keyword arguments for proseco

"""
Expand Down Expand Up @@ -255,4 +255,6 @@ def convert_yoshi_to_proseco_params(
n_fid=3,
)

out.update(kwargs)

return out