@@ -190,7 +190,7 @@ def _validate_settings(self, settings):
190
190
'values for {}' .format (scale_type , required_keys ))
191
191
192
192
def monitor_submission (self , submission_id ,
193
- solve_timeout = TIMEOUT ):
193
+ solve_timeout = TIMEOUT , verbose = True ):
194
194
"""
195
195
Monitor the submission for completion.
196
196
@@ -202,6 +202,8 @@ def monitor_submission(self, submission_id,
202
202
solve_timeout : ``int``
203
203
Time, in seconds, to wait for the astrometry.net solver to find
204
204
a solution.
205
+ verbose : bool, optional
206
+ Whether to print out information about the solving
205
207
206
208
Returns
207
209
-------
@@ -223,7 +225,8 @@ def monitor_submission(self, submission_id,
223
225
"""
224
226
has_completed = False
225
227
job_id = None
226
- print ('Solving' , end = '' , flush = True )
228
+ if verbose :
229
+ print ('Solving' , end = '' , flush = True )
227
230
start_time = time .time ()
228
231
status = ''
229
232
while not has_completed :
@@ -242,7 +245,8 @@ def monitor_submission(self, submission_id,
242
245
elapsed = now - start_time
243
246
timed_out = elapsed > solve_timeout
244
247
has_completed = (status in ['success' , 'failure' ] or timed_out )
245
- print ('.' , end = '' , flush = True )
248
+ if verbose :
249
+ print ('.' , end = '' , flush = True )
246
250
if status == 'success' :
247
251
wcs_url = url_helpers .join (self .URL , 'wcs_file' , str (job_id ))
248
252
wcs_response = self ._request ('GET' , wcs_url )
@@ -259,6 +263,7 @@ def monitor_submission(self, submission_id,
259
263
260
264
def solve_from_source_list (self , x , y , image_width , image_height ,
261
265
solve_timeout = TIMEOUT ,
266
+ verbose = True ,
262
267
** settings
263
268
):
264
269
"""
@@ -278,6 +283,8 @@ def solve_from_source_list(self, x, y, image_width, image_height,
278
283
solve_timeout : int
279
284
Time, in seconds, to wait for the astrometry.net solver to find
280
285
a solution.
286
+ verbose : bool, optional
287
+ Whether to print out information about the solving
281
288
282
289
For a list of the remaining settings, use the method
283
290
`~AstrometryNetClass.show_allowed_settings`.
@@ -301,13 +308,15 @@ def solve_from_source_list(self, x, y, image_width, image_height,
301
308
response_d = response .json ()
302
309
submission_id = response_d ['subid' ]
303
310
return self .monitor_submission (submission_id ,
304
- solve_timeout = solve_timeout )
311
+ solve_timeout = solve_timeout ,
312
+ verbose = verbose )
305
313
306
314
def solve_from_image (self , image_file_path , force_image_upload = False ,
307
315
ra_key = None , dec_key = None ,
308
316
ra_dec_units = None ,
309
317
fwhm = 3 , detect_threshold = 5 ,
310
318
solve_timeout = TIMEOUT ,
319
+ verbose = True ,
311
320
** settings ):
312
321
"""
313
322
Plate solve from an image, either by uploading the image to
@@ -343,10 +352,14 @@ def solve_from_image(self, image_file_path, force_image_upload=False,
343
352
ra_dec_units : tuple, optional
344
353
Tuple specifying the units of the right ascension and declination in
345
354
the header. The default value is ``('hour', 'degree')``.
355
+
346
356
solve_timeout : int
347
357
Time, in seconds, to wait for the astrometry.net solver to find
348
358
a solution.
349
359
360
+ verbose : bool, optional
361
+ Whether to print out information about the solving
362
+
350
363
For a list of the remaining settings, use the method
351
364
`~AstrometryNetClass.show_allowed_settings`.
352
365
"""
@@ -386,32 +399,38 @@ def solve_from_image(self, image_file_path, force_image_upload=False,
386
399
else :
387
400
with fits .open (image_file_path ) as f :
388
401
data = f [0 ].data
389
-
390
- print ("Determining background stats" , flush = True )
402
+ if verbose :
403
+ print ("Determining background stats" , flush = True )
391
404
mean , median , std = sigma_clipped_stats (data , sigma = 3.0 ,
392
405
maxiters = 5 )
393
406
daofind = DAOStarFinder (fwhm = fwhm ,
394
407
threshold = detect_threshold * std )
395
- print ("Finding sources" , flush = True )
408
+ if verbose :
409
+ print ("Finding sources" , flush = True )
396
410
sources = daofind (data - median )
397
- print ('Found {} sources' .format (len (sources )), flush = True )
411
+ if verbose :
412
+ print ('Found {} sources' .format (len (sources )), flush = True )
398
413
# astrometry.net wants a sorted list of sources
399
414
# Sort first (which puts things in ascending order)
400
415
sources .sort ('flux' )
401
416
# Reverse to get descending order
402
417
sources .reverse ()
403
- print (sources )
418
+ if verbose :
419
+ print (sources )
404
420
return self .solve_from_source_list (sources ['xcentroid' ],
405
421
sources ['ycentroid' ],
406
422
ccd .header ['naxis1' ],
407
423
ccd .header ['naxis2' ],
424
+ solve_timeout = solve_timeout ,
425
+ verbose = verbose ,
408
426
** settings )
409
427
if response .status_code != 200 :
410
428
raise RuntimeError ('Post of job failed' )
411
429
response_d = response .json ()
412
430
submission_id = response_d ['subid' ]
413
431
return self .monitor_submission (submission_id ,
414
- solve_timeout = solve_timeout )
432
+ solve_timeout = solve_timeout ,
433
+ verbose = verbose )
415
434
416
435
417
436
# the default tool for users to interact with is an instance of the Class
0 commit comments