Use solve-field only once per pointing
parent
c1e3005631
commit
911da42c47
36
process.py
36
process.py
|
@ -59,7 +59,7 @@ if __name__ == "__main__":
|
|||
|
||||
# Extract settings
|
||||
# Minimum predicted velocity (pixels/s)
|
||||
drdtmin = 10.0
|
||||
drdtmin = 5.0
|
||||
|
||||
# Track selection region around prediction (pixels)
|
||||
trkrmin = 10.0
|
||||
|
@ -99,26 +99,32 @@ if __name__ == "__main__":
|
|||
# Get files
|
||||
fnames = sorted(glob.glob("2*.fits"))
|
||||
|
||||
# Create reference calibration file
|
||||
if not os.path.exists("test.fits"):
|
||||
solved = False
|
||||
# Loop over files to find a suitable calibration file
|
||||
for fname in fnames:
|
||||
# Generate star catalog
|
||||
pix_catalog = generate_star_catalog(fname)
|
||||
|
||||
# Solve
|
||||
if pix_catalog.nstars > 100:
|
||||
print(colored("Computing astrometric calibration for %s" % fname, "yellow"))
|
||||
solved = generate_reference_with_anet(fname, "")
|
||||
|
||||
# Break when solved
|
||||
if solved:
|
||||
break
|
||||
|
||||
# Loop over files
|
||||
for fname in fnames:
|
||||
# Generate star catalog
|
||||
pix_catalog = generate_star_catalog(fname)
|
||||
if not os.path.exists(fname + ".cat"):
|
||||
pix_catalog = generate_star_catalog(fname)
|
||||
|
||||
# Create reference calibration file
|
||||
if not os.path.exists("test.fits"):
|
||||
solved = generate_reference_with_anet(fname, "")
|
||||
|
||||
# Calibrate astrometry
|
||||
# Calibrate from reference
|
||||
calibrate_from_reference(fname, "test.fits", pix_catalog)
|
||||
|
||||
# Redo refence if astrometry failed
|
||||
if not is_calibrated(fourframe(fname)) and pix_catalog.nstars > 10:
|
||||
print(colored("Recomputing astrometric calibration for %s" % fname, "yellow"))
|
||||
solved = generate_reference_with_anet(fname, "")
|
||||
|
||||
# Calibrate astrometry
|
||||
calibrate_from_reference(fname, "test.fits", pix_catalog)
|
||||
|
||||
# Generate satellite predictions
|
||||
generate_satellite_predictions(fname)
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ from astropy import wcs
|
|||
from astropy.coordinates import SkyCoord, FK5, ICRS
|
||||
from astropy.time import Time
|
||||
from scipy import optimize
|
||||
|
||||
from stvid.stars import pixel_catalog
|
||||
|
||||
# Class for the Tycho 2 catalog
|
||||
class tycho2_catalog:
|
||||
|
@ -223,9 +223,13 @@ def is_calibrated(ff):
|
|||
def generate_reference_with_anet(fname, cmd_args, reffname="test.fits", tempfroot="cal"):
|
||||
# Copy file to generic name
|
||||
shutil.copy2(fname, tempfroot + ".fits")
|
||||
|
||||
# Get center
|
||||
hdu = fits.open(fname)
|
||||
ny, nx = hdu[0].data[0].shape
|
||||
|
||||
# Generate command
|
||||
command = "solve-field %s -O -T -N %s %s.fits" % (cmd_args, reffname, tempfroot)
|
||||
command = "solve-field %s -l 20 -O -N %s --crpix-x %d --crpix-y %d -t 1 %s.fits" % (cmd_args, reffname, nx//2, ny//2, tempfroot)
|
||||
|
||||
# Run command
|
||||
try:
|
||||
|
@ -245,4 +249,3 @@ def generate_reference_with_anet(fname, cmd_args, reffname="test.fits", tempfroo
|
|||
|
||||
return solved
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue