Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed Pipeline_flow_diagram.pdf
Binary file not shown.
Binary file removed Stack_examples.pdf
Binary file not shown.
19 changes: 16 additions & 3 deletions potpyri/_version.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
# 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:
from typing import Tuple
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'
5 changes: 3 additions & 2 deletions potpyri/stages/image_procs.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,15 +631,16 @@ 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
saturation += skybkg

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
Expand Down
3 changes: 2 additions & 1 deletion potpyri/stages/photometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 14 additions & 4 deletions potpyri/stages/solve_wcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions tests/test_photometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading