From b7df09c3d89a24d50e7ce7c2120818424906bb18 Mon Sep 17 00:00:00 2001 From: Wilfred Tyler Gee Date: Sat, 30 Dec 2017 19:47:19 +1100 Subject: [PATCH] Image utils updates * Removing unused experimental function * Fixing pragma --- pocs/utils/images.py | 75 ++------------------------------------------ 1 file changed, 2 insertions(+), 73 deletions(-) diff --git a/pocs/utils/images.py b/pocs/utils/images.py index 3e7505637..893deee3c 100644 --- a/pocs/utils/images.py +++ b/pocs/utils/images.py @@ -204,77 +204,6 @@ def get_solve_field(fname, replace=True, remove_extras=True, **kwargs): return out_dict -def improve_wcs(fname, remove_extras=True, replace=True, **kwargs): - verbose = kwargs.get('verbose', False) - out_dict = {} - output = None - errs = None - - if verbose: - print("Entering improve_wcs:", fname) - - options = [ - '--continue', - '-t', '3', - '-q', '0.01', - '-V', fname, - ] - - proc = solve_field(fname, solve_opts=options, **kwargs) - try: - output, errs = proc.communicate(timeout=kwargs.get('timeout', 30)) - except subprocess.TimeoutExpired: - proc.kill() - raise error.Timeout("Timeout while solving") - else: - if verbose: - print("Output: {}", output) - print("Errors: {}", errs) - - if not os.path.exists(fname.replace('.fits', '.solved')): - raise error.SolveError('File not solved') - - try: - # Handle extra files created by astrometry.net - new = fname.replace('.fits', '.new') - rdls = fname.replace('.fits', '.rdls') - axy = fname.replace('.fits', '.axy') - xyls = fname.replace('.fits', '-indx.xyls') - - if replace and os.path.exists(new): - # Remove converted fits - os.remove(fname) - # Rename solved fits to proper extension - os.rename(new, fname) - - out_dict['solved_fits_file'] = fname - else: - out_dict['solved_fits_file'] = new - - if remove_extras: - for f in [rdls, xyls, axy]: - if os.path.exists(f): - os.remove(f) - - except Exception as e: - warn('Cannot remove extra files: {}'.format(e)) - - if errs is not None: - warn("Error in solving: {}".format(errs)) - else: - # Read the EXIF information from the CR2 - if fname.endswith('cr2'): - out_dict.update(read_exif(fname)) - - try: - out_dict.update(fits.getheader(fname)) - except OSError: - if verbose: - print("Can't read fits header for", fname) - - return out_dict - - def crop_data(data, box_width=200, center=None, verbose=False): """ Return a cropped portion of the image @@ -347,7 +276,7 @@ def get_wcsinfo(fits_fname, verbose=False): stderr=subprocess.STDOUT, universal_newlines=True) try: output, errs = proc.communicate(timeout=5) - except subprocess.TimeoutExpired: # pragma : no cover + except subprocess.TimeoutExpired: # pragma: no cover proc.kill() output, errs = proc.communicate() @@ -514,7 +443,7 @@ def _make_pretty_from_fits(fname, timeout=15, **kwargs): return new_filename -def _make_pretty_from_cr2(fname, timeout=15, **kwargs): +def _make_pretty_from_cr2(fname, timeout=15, **kwargs): # pragma: no cover verbose = kwargs.get('verbose', False) title = '{} {}'.format(kwargs.get('title', ''), current_time().isot)