Skip to content

Commit

Permalink
Merge pull request #173 from sot/yoshi-a-couple-more-things
Browse files Browse the repository at this point in the history
Tweaks to sparkles / yoshi based on cycle 24 work
  • Loading branch information
taldcroft authored Jun 1, 2022
2 parents af55201 + e0cb374 commit f48f000
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 17 deletions.
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
22 changes: 15 additions & 7 deletions sparkles/roll_optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,16 @@ 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 default '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.
: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 +179,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
10 changes: 8 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 @@ -82,11 +83,12 @@ def test_get_params():
"ra_targ": 149.91616666666664,
"roll_targ": 62.01050867568485,
"sim_offset": 0,
"target_name": "C-COSMOS",
}
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,
)
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": "C-COSMOS",
}
assert_dict_equal(params_proseco, exp_proseco)

Expand All @@ -125,9 +128,12 @@ 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
11 changes: 7 additions & 4 deletions sparkles/yoshi.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def get_yoshi_params_from_ocat(obsid, obs_date=None, web_ocat=True):
"dec_targ": ocat["dec"],
"offset_y": ocat["y_off"],
"offset_z": ocat["z_off"],
"target_name": ocat["target_name"],
}

# Leaving focus offset as not-implemented
Expand Down Expand Up @@ -101,7 +102,7 @@ def run_one_yoshi(
obs_date,
t_ccd,
man_angle,
**kwargs
**kwargs,
):
"""
Run proseco and sparkles for an observation request in a roll/temperature/man_angle
Expand Down Expand Up @@ -149,11 +150,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 +192,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 +214,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 +256,6 @@ def convert_yoshi_to_proseco_params(
n_fid=3,
)

out.update(kwargs)

return out

0 comments on commit f48f000

Please sign in to comment.