diff --git a/Pipeline_flow_diagram.pdf b/Pipeline_flow_diagram.pdf deleted file mode 100644 index 08c6042..0000000 Binary files a/Pipeline_flow_diagram.pdf and /dev/null differ diff --git a/Stack_examples.pdf b/Stack_examples.pdf deleted file mode 100644 index ad0a9ea..0000000 Binary files a/Stack_examples.pdf and /dev/null differ diff --git a/potpyri/_version.py b/potpyri/_version.py index 277a711..b6ae0b0 100644 --- a/potpyri/_version.py +++ b/potpyri/_version.py @@ -1,7 +1,14 @@ # file generated by setuptools-scm # don't change, don't track in version control -__all__ = ["__version__", "__version_tuple__", "version", "version_tuple"] +__all__ = [ + "__version__", + "__version_tuple__", + "version", + "version_tuple", + "__commit_id__", + "commit_id", +] TYPE_CHECKING = False if TYPE_CHECKING: @@ -9,13 +16,19 @@ from typing import Union VERSION_TUPLE = Tuple[Union[int, str], ...] + COMMIT_ID = Union[str, None] else: VERSION_TUPLE = object + COMMIT_ID = object version: str __version__: str __version_tuple__: VERSION_TUPLE version_tuple: VERSION_TUPLE +commit_id: COMMIT_ID +__commit_id__: COMMIT_ID -__version__ = version = '1.0.2.dev4' -__version_tuple__ = version_tuple = (1, 0, 2, 'dev4') +__version__ = version = '1.0.14.dev12' +__version_tuple__ = version_tuple = (1, 0, 14, 'dev12') + +__commit_id__ = commit_id = 'g0f75b276d' diff --git a/potpyri/stages/image_procs.py b/potpyri/stages/image_procs.py index ab5e9e0..4a1d055 100755 --- a/potpyri/stages/image_procs.py +++ b/potpyri/stages/image_procs.py @@ -631,6 +631,9 @@ def create_mask(science_data, saturation, rdnoise, sigclip=3.5, else: print('Setting sky background to 2000.0') + # This needs to be done before data is modified to preserve bad pixels + mask_bp = (data==0.0) | np.isnan(data) + # Set data background to skybkg data = data + skybkg # Also need to adjust the saturation level by SKYBKG for saturated pixels @@ -638,8 +641,6 @@ def create_mask(science_data, saturation, rdnoise, sigclip=3.5, if log: log.info('Masking saturated pixels.') - mask_bp = (data==0.0) | np.isnan(data) - mask_sat = np.zeros(data.shape).astype(bool) # create empty mask mask_sat = mask_sat.astype(np.uint8) #set saturated star mask type mask_sat[data >= saturation] = 4 #set saturated pixel flag diff --git a/potpyri/stages/photometry.py b/potpyri/stages/photometry.py index a95fffe..23f91bd 100755 --- a/potpyri/stages/photometry.py +++ b/potpyri/stages/photometry.py @@ -526,7 +526,8 @@ def photloop(stack, phot_sn_min=3.0, phot_sn_max=40.0, fwhm_init=5.0, log=None): 'snthresh_final': signal_to_noise} try: do_phot(stack, star_param=star_param) - except: + except Exception as e: + log.error(e) signal_to_noise = signal_to_noise / 2.0 continue break diff --git a/potpyri/stages/solve_wcs.py b/potpyri/stages/solve_wcs.py index e4a3c41..fe45d51 100755 --- a/potpyri/stages/solve_wcs.py +++ b/potpyri/stages/solve_wcs.py @@ -20,10 +20,10 @@ import astropy.units as u from astropy.stats import sigma_clipped_stats from astropy.io import fits -from astropy.io import ascii from astropy.coordinates import SkyCoord from astropy.coordinates import match_coordinates_sky -from astropy.table import Table, Column +from astropy.table import Column +from astropy.table import Table from astropy.utils.exceptions import AstropyWarning from astropy.wcs import WCS from astropy.wcs.utils import fit_wcs_from_points @@ -67,7 +67,10 @@ def get_gaia_catalog(input_file, log=None): try: cat = vizier.query_region(coord, width=20 * u.arcmin, catalog='I/355/gaiadr3') - break + if cat is None: + if log: log.error(f'Gaia did not return catalog. Try #{tries+1}') + else: + break except requests.exceptions.ReadTimeout: if log: log.error(f'Gaia catalog timeout. Try #{tries+1}') tries += 1 @@ -195,7 +198,7 @@ def solve_astrometry(file, tel, binn, paths, radius=0.5, replace=True, tries = 1 good = False - while tries < 4 and not good: + while tries < 5 and not good: input_args = args + extra_opts if log: @@ -226,6 +229,13 @@ def solve_astrometry(file, tel, binn, paths, radius=0.5, replace=True, extra_opts='--objs 15' elif tries==3: extra_opts='' + elif tries==4: + # Try with no constraint on RA/Dec + args = '--scale-units arcsecperpix ' + args += f'--scale-low {scale_low} --scale-high {scale_high} ' + args += f'--no-plots -T ' + args += f'--overwrite -N {newfile} --dir {directory} ' + extra_opts='' file_exists=os.path.exists(newfile) diff --git a/tests/test_photometry.py b/tests/test_photometry.py index ecd3fe3..db182b5 100644 --- a/tests/test_photometry.py +++ b/tests/test_photometry.py @@ -22,6 +22,15 @@ def test_photometry(tmp_path): if key in [h.name for h in hdu]: del hdu[key] + # Sanitize error array + mask = np.isnan(hdu['ERROR'].data) + hdu['ERROR'].data[mask] = np.nanmedian(hdu['ERROR'].data) + mask = hdu['ERROR'].data < 0.0 + hdu['ERROR'].data[mask] = np.nanmedian(hdu['ERROR'].data) + maxval = np.max(hdu['SCI'].data) + mask = np.isinf(hdu['ERROR'].data) + hdu['ERROR'].data[mask] = maxval + hdu.writeto(file_path, overwrite=True) data_path, basefile = os.path.split(file_path)