@@ -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