def get_filelist(self, directory): result = [] for filename in FileList.get(directory): if fnmatch(filename, '????????_????_iono.ion'): result.append(filename) return result
def run(self): if self.isActive: time = datetime.now().replace(microsecond=0) self.log.emit('{}. Processing started.'.format(time)) directory_name = self.configuration['directory_name'] files = FileList.get(directory_name) if self.isActive else [] for filename in files: if self.isActive: self.log.emit('Reading \'{}\' from \'{}\'...'.format( filename, directory_name)) data = self.read_input_file(directory_name + '/' + filename) if data is None or not data: self.log.emit('No data available in file.') continue if self.isActive: data = self.filter(data, self.configuration) num = len(data) if num > 1: self.log.emit('{} passes were found.'.format(num)) elif num == 1: self.log.emit('1 pass was found.') else: self.log.emit('No passes were found.') continue if self.isActive: proxy_host = self.configuration['proxy_host'] proxy_port = self.configuration['proxy_port'] proxy = { 'proxy_host': proxy_host, 'proxy_port': proxy_port } if proxy_host else None iri = IriModelAccess(proxy) igrf = IgrfModelAccess(proxy) if self.isActive: self.log.emit(Formats.HEADER) n = 0 for d in data: mlt = None date = d['date'] l_shell = -1 if wnd.checkLocalTime.isChecked(): if self.isActive: try: print('Req. 1') mlt = float( iri.get_data(date, d['lat'], d['long'], 3, False)[0]) except ValueError: self.finished.emit(False) return if mlt is None: self.finished.emit(False) return if self.isActive: print('Req. 2') iri_result = iri.get_data_cached( date, self.configuration['point_lat'], self.configuration['point_long'], 3) if iri_result[0]: try: times = [float(x) for x in iri_result] except ValueError: self.finished.emit(False) return delta = float('inf') k = 0 for i, v in enumerate(times): if abs(v - mlt) < delta: k = i delta = abs(v - mlt) kt = k * 0.025 date_out = datetime(date.year, date.month, date.day) date_out += timedelta(seconds=int(kt * 3600.0)) delta = date_out - date if abs(delta.total_seconds()) > 12 * 60 * 60: if delta.total_seconds() > 0: date_out += timedelta(days=-1) else: date_out += timedelta(days=1) date_out = date_out.isoformat() else: kt = -1 date_out = '{:>20s}'.format('-1') else: mlt = -1 kt = -1 date_out = '{:>20s}'.format('-1') if wnd.checkLShell.isChecked(): if self.isActive: cgm = self.configuration['cgm'] l_shell = float( igrf.get_data(date.year, d['lat'], d['long'], d['alt'], 1, cgm=cgm)[0]) if self.isActive: out_str = Formats.ROW_FORMAT.format( n + 1, d['sat_id'], d['lat'], d['long'], d['alt'], d['ti'], d['te'], d['ne'], d['po'], d['ph'], d['phe'], d['rpa'], d['idm'], date.replace(microsecond=0).isoformat(), date.hour + date.minute / 60.0 + date.second / 3600.0, d['mlt'], mlt, kt, date_out, l_shell) if self.isActive: needFiltering = wnd.shellFilterCheckBox.isChecked() if needFiltering and l_shell > 0: l_shell_set = self.configuration['l_shell_set'] dl_shell_set = self.configuration['dl_shell_set'] if abs(l_shell_set - l_shell) < dl_shell_set: self.log.emit(out_str) n += 1 elif not needFiltering or l_shell < 0: self.log.emit(out_str) n += 1 self.finished.emit(True)