Merge pull request #67 from EelkeVisser/fixprocess
Make process.py robust for when not yet calibratedmaster
commit
733ef85b9f
67
process.py
67
process.py
|
@ -200,43 +200,50 @@ if __name__ == "__main__":
|
||||||
solved = False
|
solved = False
|
||||||
# Loop over files to find a suitable calibration file
|
# Loop over files to find a suitable calibration file
|
||||||
for fname in fnames:
|
for fname in fnames:
|
||||||
# Generate star catalog
|
# Was this file already tried?
|
||||||
pix_catalog = generate_star_catalog(fname)
|
if not os.path.exists(fname+".cat"):
|
||||||
|
# Generate star catalog
|
||||||
|
pix_catalog = generate_star_catalog(fname)
|
||||||
|
|
||||||
# Solve
|
# Solve
|
||||||
if pix_catalog.nstars > nstarsmin:
|
if pix_catalog.nstars > nstarsmin:
|
||||||
print(colored("Computing astrometric calibration for %s" % fname, "yellow"))
|
print(colored("Computing astrometric calibration for %s" % fname, "yellow"))
|
||||||
solved = generate_reference_with_anet(fname, "")
|
solved = generate_reference_with_anet(fname, "")
|
||||||
|
|
||||||
# Break when solved
|
# Break when solved
|
||||||
if solved:
|
if solved:
|
||||||
break
|
break
|
||||||
|
else:
|
||||||
|
# test.fits exists, so calibration has been solved
|
||||||
|
solved = True
|
||||||
|
|
||||||
p = mp.Pool(processes=cpu_count)
|
# Only attempt processing if we have a calibration file
|
||||||
|
if solved:
|
||||||
|
p = mp.Pool(processes=cpu_count)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Loop over files in parallel, print output every batch size of cpu_count
|
# Loop over files in parallel, print output every batch size of cpu_count
|
||||||
satobs_chunks = chunks(fnames,cpu_count)
|
satobs_chunks = chunks(fnames,cpu_count)
|
||||||
for chk in satobs_chunks:
|
for chk in satobs_chunks:
|
||||||
for result in p.map(process_loop, chk):
|
for result in p.map(process_loop, chk):
|
||||||
(screenoutput, fileoutput, screenoutput_idents) = result
|
(screenoutput, fileoutput, screenoutput_idents) = result
|
||||||
|
|
||||||
fstat.write(fileoutput)
|
fstat.write(fileoutput)
|
||||||
print(screenoutput)
|
print(screenoutput)
|
||||||
|
|
||||||
if screenoutput_idents is not None:
|
if screenoutput_idents is not None:
|
||||||
for [outfilename, iod_line, color] in screenoutput_idents:
|
for [outfilename, iod_line, color] in screenoutput_idents:
|
||||||
print(colored(iod_line,color))
|
print(colored(iod_line,color))
|
||||||
# Write iodline
|
# Write iodline
|
||||||
with open(outfilename, "a") as fp:
|
with open(outfilename, "a") as fp:
|
||||||
fp.write("%s\n" % iod_line)
|
fp.write("%s\n" % iod_line)
|
||||||
|
|
||||||
p.close()
|
p.close()
|
||||||
p.join()
|
p.join()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
fstat.close()
|
fstat.close()
|
||||||
p.close()
|
p.close()
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
# Sleep
|
# Sleep
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue