Skip to content

Commit 0e440c7

Browse files
committed
Allow to disable points upon addition to the pointing model
1 parent 50000e8 commit 0e440c7

File tree

3 files changed

+38
-4
lines changed

3 files changed

+38
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### ✨ Improved
66

77
* Check AG cameras and power cycle them if necessary in the cleanup recipe.
8+
* Allow to disable points upon addition to the pointing model.
89

910

1011
## 1.11.3 - November 6, 2025

src/gort/__main__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,13 @@ async def observe():
232232
default=True,
233233
help="Add points to the PWI model.",
234234
)
235+
@click.option(
236+
"-D/-d",
237+
"--disable-on-addition/--no-disable-on-addition",
238+
is_flag=True,
239+
default=True,
240+
help="Disable points after adding them.",
241+
)
235242
@click.option(
236243
"--only-slew",
237244
is_flag=True,
@@ -246,6 +253,7 @@ async def pointing_model(
246253
n_points: int = 50,
247254
home: bool = False,
248255
add_points: bool = True,
256+
disable_on_addition: bool = True,
249257
only_slew: bool = False,
250258
):
251259
"""Acquires a pointing model."""
@@ -263,6 +271,7 @@ async def pointing_model(
263271
telescopes=telescopes,
264272
home=home,
265273
add_points=add_points,
274+
disable_on_addition=disable_on_addition,
266275
calculate_offset=not only_slew,
267276
)
268277

src/gort/pointing.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ async def get_offset(
9090
dec: float,
9191
exposure_time: float = 5,
9292
add_point: bool = True,
93+
disable_on_addition: bool = False,
9394
):
9495
"""Determines the offset between a pointing an the measured coordinates.
9596
@@ -105,6 +106,9 @@ async def get_offset(
105106
The exposure time.
106107
add_point
107108
Whether to add the point to the PWI model.
109+
disable_on_addition
110+
Disables the newly added point. This is generally recommended to avoid the
111+
model solution from being skewed by offliers.
108112
109113
Returns
110114
-------
@@ -141,10 +145,19 @@ async def get_offset(
141145
return_dict["separation"] = measured_pointing["separation"]
142146

143147
if add_point:
144-
await gort.telescopes[telescope].actor.commands.modelAddPoint(
148+
tel_actor = gort.telescopes[telescope].actor
149+
150+
reply = await tel_actor.commands.modelAddPoint(
145151
measured_pointing["ra"] / 15,
146152
measured_pointing["dec"],
147153
)
154+
reply = reply.flatten()
155+
156+
if "model" in reply:
157+
n_points = reply["model"]["num_points_total"]
158+
if disable_on_addition:
159+
gort.log.info(f"({telescope}: disabling new point.")
160+
await tel_actor.commands.modelDisablePoint(n_points - 1)
148161

149162
return return_dict
150163

@@ -158,6 +171,7 @@ async def pointing_model(
158171
calculate_offset: bool = True,
159172
home: bool = True,
160173
add_points: bool = True,
174+
disable_on_addition: bool = False,
161175
) -> polars.DataFrame | None:
162176
"""Iterates over a series of points on the sky measuring offsets.
163177
@@ -180,6 +194,9 @@ async def pointing_model(
180194
Whether to home the telescope before starting.
181195
add_points
182196
Add points to the PWI model. Ignored if ``calculate_offset=False``.
197+
disable_on_addition
198+
Disables the newly added point. This is generally recommended to avoid the
199+
model solution from being skewed by offliers.
183200
184201
"""
185202

@@ -198,12 +215,12 @@ async def pointing_model(
198215
output_file = outputs_dir / output_file
199216
output_file.parent.mkdir(parents=True, exist_ok=True)
200217

201-
data = polars.read_parquet(str(output_file))
218+
if output_file.exists():
219+
data = polars.read_parquet(str(output_file))
202220

203221
assert data is None or isinstance(data, polars.DataFrame)
204222

205223
if home:
206-
await gort.telescopes.goto_named_position("zenith")
207224
await gort.telescopes.home()
208225

209226
for npoint, (alt, az) in enumerate(points):
@@ -235,7 +252,14 @@ async def pointing_model(
235252

236253
results = await asyncio.gather(
237254
*[
238-
get_offset(gort, tel, ra, dec, add_point=add_points)
255+
get_offset(
256+
gort,
257+
tel,
258+
ra,
259+
dec,
260+
add_point=add_points,
261+
disable_on_addition=disable_on_addition,
262+
)
239263
for tel in telescopes
240264
],
241265
return_exceptions=True,

0 commit comments

Comments
 (0)