meteortools.utils.drawFTPfile
1# Copyright (C) 2018-2023 Mark McIntyre 2# 3# python code to read in an FTPdetect file and plot all the detections 4# 5 6import os 7import configparser as cr 8from matplotlib import pyplot as plt 9 10 11def _readFTPfile(filename, h): 12 """ Internal function to load ftpfile into arrays """ 13 events = [] 14 with open(filename) as f: 15 # Skip the header 16 for i in range(11): 17 next(f) 18 19 for line in f: 20 line = line.replace('\n', '').replace('\r', '') 21 # The separator marks the beginning of a new meteor 22 if "-------------------------------------------------------" in line: 23 # Skip the event header 24 for i in range(2): 25 next(f) 26 # read line containing detail of this event 27 line = f.readline() 28 rows = int(line.split()[2]) 29 xvals=[] 30 yvals=[] 31 # now read in the data of interest 32 for r in range(rows): 33 line = f.readline() 34 _, x, y, _, _, _, _, _ = list(map(float, line.split()[:8])) 35 xvals.append(x) 36 yvals.append(h-y) 37 dta = {'x': xvals, 'y': yvals} 38 events.append(dta) 39 40 return events 41 42 43def drawFTPFile(ftpfile, cfgfile=None): 44 """ 45 Creates a simple representation of an FTPdetect file, showing the locations of each meteor trail. 46 Its like a stack of the night's detections but in a much simpler format. Useful for diagnosing false detections. 47 48 Arguments: 49 ftpfile: [str] full path to the FTPdetect file. 50 cfgfile: [str] full path to RMS config file to read image dimensions. Default is 1280x720. 51 """ 52 config = cr.ConfigParser() 53 if cfgfile is None: 54 width=1280 55 height=720 56 else: 57 config.read(cfgfile) 58 width = int(config['Capture']['width']) 59 height = int(config['Capture']['height']) 60 61 print('plotting field of view {}x{}'.format(width, height)) 62 events = _readFTPfile(ftpfile, height) 63 for ev in events: 64 plt.plot(ev['x'],ev['y']) 65 pth, ftpf = os.path.split(ftpfile) 66 spls = ftpf.split('_') 67 outfname = f'{spls[1]}_{spls[2]}_{spls[3]}_{spls[3]}_ftpmap.png' 68 plt.savefig(os.path.join(pth, outfname)) 69 plt.close() 70 return
def
drawFTPFile(ftpfile, cfgfile=None):
44def drawFTPFile(ftpfile, cfgfile=None): 45 """ 46 Creates a simple representation of an FTPdetect file, showing the locations of each meteor trail. 47 Its like a stack of the night's detections but in a much simpler format. Useful for diagnosing false detections. 48 49 Arguments: 50 ftpfile: [str] full path to the FTPdetect file. 51 cfgfile: [str] full path to RMS config file to read image dimensions. Default is 1280x720. 52 """ 53 config = cr.ConfigParser() 54 if cfgfile is None: 55 width=1280 56 height=720 57 else: 58 config.read(cfgfile) 59 width = int(config['Capture']['width']) 60 height = int(config['Capture']['height']) 61 62 print('plotting field of view {}x{}'.format(width, height)) 63 events = _readFTPfile(ftpfile, height) 64 for ev in events: 65 plt.plot(ev['x'],ev['y']) 66 pth, ftpf = os.path.split(ftpfile) 67 spls = ftpf.split('_') 68 outfname = f'{spls[1]}_{spls[2]}_{spls[3]}_{spls[3]}_ftpmap.png' 69 plt.savefig(os.path.join(pth, outfname)) 70 plt.close() 71 return
Creates a simple representation of an FTPdetect file, showing the locations of each meteor trail.
Its like a stack of the night's detections but in a much simpler format. Useful for diagnosing false detections.
Arguments:
ftpfile: [str] full path to the FTPdetect file.
cfgfile: [str] full path to RMS config file to read image dimensions. Default is 1280x720.