def obtain_vib_data(self, attr_key, mask_value): ''' method to get the data for attr_key for the fleet. If there is no value the mask_value will be assigned to mask the record from plotting ''' logger = Logger.getlogger() # determine list of field records for all vibes in the fleet vib_axis = set() for pss in self.pss_data: try: if int(pss[self.attr['unit_id']]) in self.fleet: vib_axis.add(int(pss[self.attr['record_index']])) except ValueError: pass vib_axis = list(vib_axis) vib_axis.sort() # create a vib_data_pairs list for each vib in the fleet vib_data_pairs = [[] for _ in self.fleet] unique_ids = [] # loop reverse as we want to keep the last entry and not the first for pss in reversed(self.pss_data): try: vib_id = int(pss[self.attr['unit_id']]) record = int(pss[self.attr['record_index']]) fleet_id = self.fleet.index(vib_id) # check if vibs have not been called again and tuple (record, vibe) is unique unique_id = (record, vib_id) if unique_id not in unique_ids: unique_ids.append(unique_id) data_point = (record, int(pss[self.attr[attr_key]])) vib_data_pairs[fleet_id].append(data_point) else: logger.info(f'this record is not unique: {unique_id}') except ValueError: pass # check if there are records where there is no value for the vibe unit # - if not assign the mask value vib_data = [[] for _ in self.fleet] for i, _ in enumerate(self.fleet): _vib_axis, _ = zip(*vib_data_pairs[i]) for x in vib_axis: if x not in _vib_axis: vib_data_pairs[i].append((x, mask_value)) vib_data_pairs[i].sort() _, vib_data[i] = zip((*vib_data_pairs[i])) vib_data[i] = list(vib_data[i]) assert len(vib_data[i]) == len(vib_axis), \ f'len(vib_data) = {len(vib_data[i])}, len(vib_exis) = {len(vib_axis)}' return vib_axis, vib_data
def print_pss_data(self, vibes): ''' method to print the pss data ''' logger = Logger.getlogger() self.fleet = list(vibes) for vib in self.fleet: for pss in self.pss_data: if pss[self.attr['unit_id']] and int( pss[self.attr['unit_id']]) == vib: record = int(pss[self.attr['record_index']]) phase_max = int(pss[self.attr['phase_max']]) phase_avg = int(pss[self.attr['phase_avg']]) thd_max = int(pss[self.attr['thd_max']]) thd_avg = int(pss[self.attr['thd_avg']]) force_max = int(pss[self.attr['force_max']]) force_avg = int(pss[self.attr['force_avg']]) logger.info(f'record: {record}: ' f'vibe: {vib} ' f'phase: {phase_avg} {phase_max}; ' f'distortion: {thd_avg} {thd_max}; ' f'force: {force_avg} {force_max}')
EPSG_OSM) from Utils.plogger import Logger, timed MARKERSIZE = 0.2 EDGECOLOR = 'black' maptypes = ['local', 'osm'] cmap = 'coolwarm' proj_map = Proj(init=f'epsg:{EPSG_OSM}') proj_local = Proj(EPSG_31256_adapted) ZOOM = 13 OFFSET_INLINE = 6000.0 OFFSET_CROSSLINE = 6000.0 maptitle = ('VPs 3D Schonkirchen', 18) logger = Logger.getlogger() nl = '\n' class PlotMap: ''' class contains method to plot the pss data, swath boundary, map and active patch ''' def __init__(self, maptype=None, swaths_selected=None): self.maptype = maptype self.swaths_selected = swaths_selected self.fig, self.ax = self.setup_map(figsize=(6, 5)) self.background = self.fig.canvas.copy_from_bbox(self.fig.bbox) connect = self.fig.canvas.mpl_connect
import hashlib import io import json import os from functools import wraps import numpy as np from shapely.geometry import Point import psycopg2 from PIL import Image, ImageShow from decouple import config import psutil from picture_exif import Exif from Utils.plogger import Logger logformat = '%(asctime)s:%(levelname)s:%(message)s' Logger.set_logger('.\\picture.log', logformat, 'INFO') logger = Logger.getlogger() if os.name == 'nt': ImageShow.WindowsViewer.format = 'PNG' display_process = 'Microsoft.Photos.exe' elif os.name == 'posix': ImageShow.UnixViewer = 'PNG' display_process = 'eog' else: assert False, f'operating system: {os.name} is not implemented' @dataclass
from Utils.utils import string_to_value_or_nan PREFIX = r'autoseis_data\OUT_' geo_shapefile = './areas_shapes/geo_shapefile.shp' EPSG_31256_adapted = "+proj=tmerc +lat_0=0 +lon_0=16.33333333333333"\ " +k=1 +x_0=+500000 +y_0=0 +ellps=bessel "\ "+towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 "\ "+units=m +no_defs" EPSG_OSM = 3857 EPSG_WGS84 = 4326 ASK_DATE = 'date (YYMMDD) [q - quit]: ' # start logger logformat = '%(asctime)s - %(levelname)s - %(message)s' Logger.set_logger('autoseis.log', logformat, 'INFO') logger = Logger.getlogger() def get_date(): _date = input(ASK_DATE) if _date in ['q', 'Q']: exit() _date = date(int(_date[0:2]) + 2000, int(_date[2:4]), int(_date[4:6])) return _date def daterange(start_date, end_date): assert start_date <= end_date, f'start date {start_date} must be less than '\ f'or equal to end date {end_date}'
j -= 1 j += 1 try: vib = stats.kde.gaussian_kde(_vib) axis.plot(attr_value, vib(attr_value), label=self.fleet[i]) except (np.linalg.LinAlgError): vib = [unit_function(x) for x in range(len(attr_value))] axis.plot(attr_value, vib, label=self.fleet[i]) return axis if __name__ == "__main__": logformat = '%(asctime)s - %(levelname)s - %(message)s' Logger.set_logger('pss_data.log', logformat, 'DEBUG') correct_file = False while True: pss_data = pss_read_file(get_date()) if pss_data == -1: pass else: pss = PssData(pss_data) correct_file = True while correct_file: fleet = input_fleet(pss.fleets) if fleet[0] == 0: