Realtime functionality

pull/17/head
Cees Bassa 2019-04-27 12:38:27 +02:00
parent 52864f2269
commit cb487ae9dd
1 changed files with 58 additions and 41 deletions

View File

@ -16,6 +16,8 @@ import configparser
import argparse
import os
from termcolor import colored
import time
import shutil
if __name__ == "__main__":
# Read commandline options
@ -48,16 +50,6 @@ if __name__ == "__main__":
lon=cfg.getfloat('Common', 'observer_lon')*u.deg,
height=cfg.getfloat('Common', 'observer_el')*u.m)
# Move to processing directory
os.chdir(args.file_dir)
# Get files
fnames = sorted(glob.glob("2*.fits"))
# Statistics file
fstat = open("imgstat.csv", "w")
fstat.write("fname,mjd,ra,de,rmsx,rmsy,mean,std,nstars,nused\n")
# Extract settings
# Minimum predicted velocity (pixels/s)
drdtmin = 10.0
@ -71,6 +63,13 @@ if __name__ == "__main__":
# Minimum track points
ntrkmin = 10
# Move to processing directory
os.chdir(args.file_dir)
# Statistics file
fstat = open("imgstat.csv", "w")
fstat.write("fname,mjd,ra,de,rmsx,rmsy,mean,std,nstars,nused\n")
# Create output dirs
path = args.file_dir
if not os.path.exists(os.path.join(path, "classfd")):
@ -79,6 +78,13 @@ if __name__ == "__main__":
os.makedirs(os.path.join(path, "catalog"))
if not os.path.exists(os.path.join(path, "unid")):
os.makedirs(os.path.join(path, "unid"))
if not os.path.exists(os.path.join(path, "processed")):
os.makedirs(os.path.join(path, "processed"))
# Forever loop
while True:
# Get files
fnames = sorted(glob.glob("2*.fits"))
# Loop over files
for fname in fnames:
@ -113,5 +119,16 @@ if __name__ == "__main__":
ff.crval[1], 3600*ff.crres[0],
3600*ff.crres[1], np.mean(ff.zavg),
np.std(ff.zavg), nstars, nused))
# Move processed files
shutil.move(fname, "processed")
shutil.move(fname + ".png", "processed")
shutil.move(fname + ".id", "processed")
shutil.move(fname + ".cat", "processed")
# Sleep
time.sleep(10)
# Close files
fstat.close()