Revert changes

pull/64/head
Cees Bassa 2021-10-24 09:11:14 +02:00
parent 15ac81a025
commit d4a64c9c0d
2 changed files with 26 additions and 13 deletions

View File

@ -19,8 +19,9 @@ import zwoasi as asi
# Capture images from cv2
def capture_cv2(image_queue, z1, t1, z2, t2, nx, ny, nz, tend, device_id, live):
# Array flag
# Intialization
first = True
slow_CPU = False
# Initialize cv2 device
device = cv2.VideoCapture(device_id)
@ -290,6 +291,20 @@ def compress(image_queue, z1, t1, z2, t2, nx, ny, nz, tend, path, device_id, cfg
filepath = os.path.join(path, obsid)
logger.info("Storing files in %s" % filepath)
# Create output directory
if not os.path.exists(filepath):
try:
os.makedirs(filepath)
except PermissionError:
logger.error("Can not create output directory: %s" % filepath)
raise
# Get mount position
with open(os.path.join(controlpath, "position.txt"), "r") as fp:
line = fp.readline()
with open(os.path.join(filepath, "position.txt"), "w") as fp:
fp.write(line)
# Wait for completed capture buffer to become available
while (image_queue.qsize == 0):
time.sleep(0.1)
@ -314,6 +329,9 @@ def compress(image_queue, z1, t1, z2, t2, nx, ny, nz, tend, path, device_id, cfg
time.gmtime(t[0])), int((t[0] - np.floor(t[0])) * 1000))
t0 = Time(nfd, format='isot')
dt = t - t[0]
# Cast to 32 bit float
z = z.astype("float32")
# Compute statistics
zmax = np.max(z, axis=0)
@ -356,20 +374,12 @@ def compress(image_queue, z1, t1, z2, t2, nx, ny, nz, tend, path, device_id, cfg
hdr['RADECSYS'] = "ICRS"
hdr['COSPAR'] = cfg.getint('Common', 'observer_cospar')
hdr['OBSERVER'] = cfg.get('Common', 'observer_name')
hdr['TRACKED'] = int(cfg.getboolean('Astrometry', 'tracking_mount'))
hdr['TRACKED'] = 0
for i in range(nz):
hdr['DT%04d' % i] = dt[i]
for i in range(10):
hdr['DUMY%03d' % i] = 0.0
# Create output directory
if not os.path.exists(filepath):
try:
os.makedirs(filepath)
except PermissionError:
logger.error("Can not create output directory: %s" % filepath)
raise
# Write fits file
hdu = fits.PrimaryHDU(data=np.array([zavg, zstd, zmax, znum]),
header=hdr)

View File

@ -197,7 +197,8 @@ def store_results(ident, fname, path, iod_line):
color = "magenta"
# Copy files
pngfile = "%05d_%s" % (ident.norad, fname.replace(".fits", ".png"))
#pngfile = "%05d_%s" % (ident.norad, fname.replace(".fits", ".png"))
pngfile = fname.replace(".fits", "_%05d.png" % ident.norad)
try:
shutil.copy2(fname, dest)
shutil.copy2(fname + ".cat", dest)
@ -368,7 +369,8 @@ def extract_tracks(fname, trkrmin, drdtmin, drdtmax, trksig, ntrkmin, path, resu
obs.nfd, obs.ra, obs.de)
# Create diagnostic plot
pngfile = "%05d_%s" % (ident.norad, fname.replace(".fits", ".png"))
#pngfile = "%05d_%s" % (ident.norad, fname.replace(".fits", ".png"))
pngfile = fname.replace(".fits", "_%05d.png" % ident.norad)
plot_header(pngfile + "/png", ff, iod_line)
ppg.pgimag(ff.zmax, ff.nx, ff.ny, 0, ff.nx - 1, 0, ff.ny - 1,
@ -454,7 +456,8 @@ def extract_tracks(fname, trkrmin, drdtmin, drdtmax, trksig, ntrkmin, path, resu
obs.nfd, obs.ra, obs.de)
# Create diagnostic plot
pngfile = "%05d_%s" % (ident.norad, fname.replace(".fits", ".png"))
#pngfile = "%05d_%s" % (ident.norad, fname.replace(".fits", ".png"))
pngfile = fname.replace(".fits", "_%05d.png" % ident.norad)
plot_header(pngfile + "/png", ff, iod_line)
ppg.pgimag(ztrk, ff.nx, ff.ny, 0, ff.nx - 1, 0, ff.ny - 1, vmax,