Skip to content

Commit 08cba00

Browse files
committed
return_job_id option added to astrometry_net monitor_submission.
1 parent a4716fd commit 08cba00

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

astroquery/astrometry_net/core.py

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def _validate_settings(self, settings):
199199
'values for {}'.format(scale_type, required_keys))
200200

201201
def monitor_submission(self, submission_id, *,
202-
solve_timeout=TIMEOUT, verbose=True):
202+
solve_timeout=TIMEOUT, verbose=True, return_job_id=False):
203203
"""
204204
Monitor the submission for completion.
205205
@@ -212,15 +212,19 @@ def monitor_submission(self, submission_id, *,
212212
Time, in seconds, to wait for the astrometry.net solver to find
213213
a solution.
214214
verbose : bool, optional
215-
Whether to print out information about the solving
215+
Whether to print out information about the solving.
216+
return_job_id : bool, optional
217+
Whether to return the Submission ID number (called Job ID on Astrometry.net).
216218
217219
Returns
218220
-------
219221
220-
None or `astropy.io.fits.Header`
222+
None or `astropy.io.fits.Header` or (`astropy.io.fits.Header`, str)
221223
The contents of the returned object depend on whether the solve
222224
succeeds or fails. If the solve succeeds the header with
223-
the WCS solution generated by astrometry.net is returned. If the solve
225+
the WCS solution generated by astrometry.net is returned. A tuple
226+
containing WCS solution and Submission ID is return if the
227+
return_job_id parameter is set True. If the solve
224228
fails then an empty dictionary is returned. See below for the outcome
225229
if the solve times out.
226230
@@ -268,11 +272,15 @@ def monitor_submission(self, submission_id, *,
268272
else:
269273
# Try to future-proof a little bit
270274
raise RuntimeError('Unrecognized status {}'.format(status))
271-
return wcs
275+
if return_job_id == False:
276+
return wcs
277+
else:
278+
return (wcs, submission_id)
272279

273280
def solve_from_source_list(self, x, y, image_width, image_height, *,
274281
solve_timeout=TIMEOUT,
275282
verbose=True,
283+
return_job_id=False,
276284
**settings
277285
):
278286
"""
@@ -293,7 +301,9 @@ def solve_from_source_list(self, x, y, image_width, image_height, *,
293301
Time, in seconds, to wait for the astrometry.net solver to find
294302
a solution.
295303
verbose : bool, optional
296-
Whether to print out information about the solving
304+
Whether to print out information about the solving.
305+
return_job_id : bool, optional
306+
Whether to return the Submission ID number (called Job ID on Astrometry.net).
297307
298308
For a list of the remaining settings, use the method
299309
`~AstrometryNetClass.show_allowed_settings`.
@@ -318,14 +328,16 @@ def solve_from_source_list(self, x, y, image_width, image_height, *,
318328
submission_id = response_d['subid']
319329
return self.monitor_submission(submission_id,
320330
solve_timeout=solve_timeout,
321-
verbose=verbose)
331+
verbose=verbose,
332+
return_job_id=return_job_id)
322333

323334
def solve_from_image(self, image_file_path, *, force_image_upload=False,
324335
ra_key=None, dec_key=None,
325336
ra_dec_units=None,
326337
fwhm=3, detect_threshold=5,
327338
solve_timeout=TIMEOUT,
328339
verbose=True,
340+
return_job_id=False,
329341
**settings):
330342
"""
331343
Plate solve from an image, either by uploading the image to
@@ -367,7 +379,10 @@ def solve_from_image(self, image_file_path, *, force_image_upload=False,
367379
a solution.
368380
369381
verbose : bool, optional
370-
Whether to print out information about the solving
382+
Whether to print out information about the solving.
383+
384+
return_job_id : bool, optional
385+
Whether to return the Submission ID number (called Job ID on Astrometry.net).
371386
372387
For a list of the remaining settings, use the method
373388
`~AstrometryNetClass.show_allowed_settings`.
@@ -439,7 +454,8 @@ def solve_from_image(self, image_file_path, *, force_image_upload=False,
439454
submission_id = response_d['subid']
440455
return self.monitor_submission(submission_id,
441456
solve_timeout=solve_timeout,
442-
verbose=verbose)
457+
verbose=verbose,
458+
return_job_id=return_job_id)
443459

444460

445461
# the default tool for users to interact with is an instance of the Class

0 commit comments

Comments
 (0)