Python file of Ubertone are updtaed to be adapted to the packaging of Acoused
parent
b01b4541bb
commit
1b19bd1175
|
|
@ -9,9 +9,9 @@
|
||||||
import logging
|
import logging
|
||||||
from math import ceil
|
from math import ceil
|
||||||
|
|
||||||
from .apf04_gain import convert_dB_m2code, convert_code2dB_m, convert_code2dB, convert_dB2code, APF04_CODE_MAX_APPLIED
|
from Model.peacock_uvp.apf04_gain import convert_dB_m2code, convert_code2dB_m, convert_code2dB, convert_dB2code, APF04_CODE_MAX_APPLIED
|
||||||
#from .ap_exception import ap_protocol_error
|
#from .ap_exception import ap_protocol_error
|
||||||
from .apf_type import cast_int16, cast_uint16
|
from Model.peacock_uvp.apf_type import cast_int16, cast_uint16
|
||||||
|
|
||||||
#ap_protocol_error(3300, "Warning: v_min has to be in [-Nyquist_Range, 0].")
|
#ap_protocol_error(3300, "Warning: v_min has to be in [-Nyquist_Range, 0].")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,11 @@ from datetime import datetime
|
||||||
import struct
|
import struct
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from .apf04_modbus import Apf04Modbus
|
from Model.peacock_uvp.apf04_modbus import Apf04Modbus
|
||||||
from .apf04_addr_cmd import *
|
from Model.peacock_uvp.apf04_addr_cmd import *
|
||||||
from .apf04_config_hw import ConfigHw
|
from Model.peacock_uvp.apf04_config_hw import ConfigHw
|
||||||
from .apf_timestamp import encode_timestamp
|
from Model.peacock_uvp.apf_timestamp import encode_timestamp
|
||||||
from .apf04_exception import apf04_exception
|
from Model.peacock_uvp.apf04_exception import apf04_exception
|
||||||
|
|
||||||
# TODO gérer ici les erreur spécifiques au HW
|
# TODO gérer ici les erreur spécifiques au HW
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,8 @@ from array import *
|
||||||
from struct import calcsize, unpack
|
from struct import calcsize, unpack
|
||||||
from math import sqrt, pi, pow
|
from math import sqrt, pi, pow
|
||||||
|
|
||||||
from .apf_timestamp import decode_timestamp
|
from Model.peacock_uvp.apf_timestamp import decode_timestamp
|
||||||
from .apf04_gain import _convert_code2dB_trunc, convert_code2dB_m, convert_code2dB, calc_gain
|
from Model.peacock_uvp.apf04_gain import _convert_code2dB_trunc, convert_code2dB_m, convert_code2dB, calc_gain
|
||||||
|
|
||||||
|
|
||||||
# @brief Utilise une frame pour récupérer un profil voulu (format UDT005)
|
# @brief Utilise une frame pour récupérer un profil voulu (format UDT005)
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,8 @@ import traceback
|
||||||
import logging
|
import logging
|
||||||
from time import time, sleep
|
from time import time, sleep
|
||||||
|
|
||||||
from .apf04_exception import apf04_error, apf04_exception
|
from Model.peacock_uvp.apf04_exception import apf04_error, apf04_exception
|
||||||
from .modbus_crc import crc16
|
from Model.peacock_uvp.modbus_crc import crc16
|
||||||
|
|
||||||
def hex_print (_bytes):
|
def hex_print (_bytes):
|
||||||
""" @brief print a byte array in hexadecimal string
|
""" @brief print a byte array in hexadecimal string
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
from array import array
|
from array import array
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from .apf06_gain import calc_gain, convert_code2dB_m, convert_code2dB, APF06_CODE_MAX_APPLIED
|
from Model.udt_extract.apf06_gain import calc_gain, convert_code2dB_m, convert_code2dB, APF06_CODE_MAX_APPLIED
|
||||||
|
|
||||||
class apf06_hardware ():
|
class apf06_hardware ():
|
||||||
def conversion_profile(self, vectors_dict, sound_speed, n_vol, n_avg, c_prf, gain_ca0, gain_ca1, blind_ca0, blind_ca1):
|
def conversion_profile(self, vectors_dict, sound_speed, n_vol, n_avg, c_prf, gain_ca0, gain_ca1, blind_ca0, blind_ca1):
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# -*- coding: UTF_8 -*-
|
# -*- coding: UTF_8 -*-
|
||||||
|
|
||||||
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
#Le script d'import quand à lui renvoie un Warning lorsque aucun paramètre ne correspond .
|
#Le script d'import quand à lui renvoie un Warning lorsque aucun paramètre ne correspond .
|
||||||
#Ce Warning contient le fichier importé concerné et préviens de la valeur qui n'a pas été acceptée.
|
#Ce Warning contient le fichier importé concerné et préviens de la valeur qui n'a pas été acceptée.
|
||||||
|
|
||||||
|
|
@ -63,13 +63,93 @@ def translate_key(raw_key, _type="data"):
|
||||||
translated_key = None
|
translated_key = None
|
||||||
|
|
||||||
# use of a json file for the translation in valid data type names for the DB
|
# use of a json file for the translation in valid data type names for the DB
|
||||||
_transation_path = os.path.dirname(os.path.realpath(__file__))+'/translation.json'
|
# _transation_path = os.path.dirname(os.path.realpath(__file__))+'/translation.json'
|
||||||
f = open(_transation_path)
|
#
|
||||||
translation_dict = json.loads(f.read())[_type]
|
# print(f"os.path.realpath(__file__) : {os.path.realpath(__file__)}")
|
||||||
|
|
||||||
for key, value in translation_dict.items():
|
# cwd = os.getcwd()
|
||||||
|
# print(f"cwd : {cwd}")
|
||||||
|
# # print(f"os.path.dirname(os.path.abspath(__file__)) : {os.path.dirname(os.path.abspath(__file__))}")
|
||||||
|
# # _transation_path = os.path.abspath(__file__).split('convert_type.py')[0] + "translation.json"
|
||||||
|
# _transation_path = cwd + "/Model/udt_extract/translation.json"
|
||||||
|
# # print("path : ", os.path.dirname(os.path.abspath(sys.argv[0])))
|
||||||
|
# print(f"_transation_path : {_transation_path}")
|
||||||
|
# print(f"__file__ : {__file__}")
|
||||||
|
|
||||||
|
# f = open(_transation_path)
|
||||||
|
|
||||||
|
# f = open(".translation.json", "r")
|
||||||
|
# translation_dict = json.loads(f.read())[_type]
|
||||||
|
|
||||||
|
# for key, value in translation_dict.items():
|
||||||
|
# # leave unchanged the already valid data type names
|
||||||
|
# # translate those which are translatable
|
||||||
|
# # print(f"key : {key}, value : {value}")
|
||||||
|
# if (raw_key == key):
|
||||||
|
# translated_key = key
|
||||||
|
# break
|
||||||
|
# elif value["alter_ego"] is not None:
|
||||||
|
# if raw_key in value["alter_ego"]:
|
||||||
|
# translated_key = key
|
||||||
|
# break
|
||||||
|
|
||||||
|
translation_dict = {"data" : { "echo_avg_profile": {"alter_ego":["amplitude"], "unit": "V", "graph_title": "Echo"},
|
||||||
|
"velocity_avg_profile": {"alter_ego":["velocity"], "unit": "m/s", "graph_title": "Velocity"},
|
||||||
|
"snr_doppler_avg_profile": {"alter_ego":["snr"], "unit": "dB", "graph_title": "SNR <br> Doppler"},
|
||||||
|
"velocity_std_profile": {"alter_ego":["std_velocity", "std"], "unit": "m/s", "graph_title": "Velocity <br> standard deviation"},
|
||||||
|
"turbidity_avg_profile": {"alter_ego":["turbi"], "unit": "1/m" },
|
||||||
|
"saturation_avg_profile": {"alter_ego":["saturation"], "unit": None},
|
||||||
|
"ny_jump_avg_profile": {"alter_ego":None, "unit": None},
|
||||||
|
"saturation_profile": {"alter_ego":None, "unit": None},
|
||||||
|
"ny_jump_profile": {"alter_ego":None, "unit": None},
|
||||||
|
"echo_profile": {"alter_ego":["instamplitude"], "unit": "V", "graph_title": "Echo"},
|
||||||
|
"velocity_profile": {"alter_ego":["instvelocity"], "unit": "m/s", "graph_title": "Velocity"},
|
||||||
|
"snr_doppler_profile": {"alter_ego":["instsnr"], "unit": "dB", "graph_title": "SNR <br> Doppler"},
|
||||||
|
"turbidity_profile": {"alter_ego":["instturbi"], "unit": "1/m"},
|
||||||
|
"temperature": {"alter_ego":["temp"], "unit": "K"},
|
||||||
|
"sound_speed": {"alter_ego": None, "unit": "m/s"},
|
||||||
|
"roll": {"alter_ego": None, "unit": "rad"},
|
||||||
|
"pitch": {"alter_ego": None, "unit": "rad"},
|
||||||
|
"velocity_avg": {"alter_ego": ["v_moy"], "unit": "m/s"},
|
||||||
|
"velocity_max": {"alter_ego": ["v_max"], "unit": "m/s"},
|
||||||
|
"velocity_min": {"alter_ego": ["v_min"], "unit": "m/s"},
|
||||||
|
"velocity_std": {"alter_ego": ["v_std"], "unit": "m/s"},
|
||||||
|
"snr_doppler_avg": {"alter_ego": ["snr_doppler"], "unit": "dB"},
|
||||||
|
"snr_echo_avg": {"alter_ego": ["snr_echo"], "unit": "dB"},
|
||||||
|
"rate_doppler": {"alter_ego": ["n_good"], "unit": "%"},
|
||||||
|
"velocity_distribution": {"alter_ego": ["tests_av_distrib_in_air","tests_av_distrib_in_flume", "distrib"], "unit": None},
|
||||||
|
"noise_g_high": {"alter_ego": ["noise"], "unit": "V"},
|
||||||
|
"noise_g_low": {"alter_ego": None, "unit": "V"}
|
||||||
|
},
|
||||||
|
"param_const" : {"operator" : {"alter_ego": None, "unit": None},
|
||||||
|
"comments" : {"alter_ego": None, "unit": None},
|
||||||
|
"emitter" : {"alter_ego": ["tr_out"], "unit": None},
|
||||||
|
"receiver" : {"alter_ego": ["tr_in"], "unit": None}
|
||||||
|
},
|
||||||
|
"param_var" : {"f0": {"alter_ego": None, "unit": "Hz"},
|
||||||
|
"v_min": {"alter_ego": ["v_min_1"], "unit": "m/s"},
|
||||||
|
"v_max": {"alter_ego": None, "unit": "m/s"},
|
||||||
|
"prf": {"alter_ego": None, "unit": "Hz"},
|
||||||
|
"r_cell1": {"alter_ego": ["r_vol1"], "unit": "m"},
|
||||||
|
"r_dcell": {"alter_ego": ["r_dvol"], "unit": "m"},
|
||||||
|
"n_cell": {"alter_ego": ["n_vol"], "unit": None},
|
||||||
|
"r_em": {"alter_ego": None, "unit": "m"},
|
||||||
|
"n_p": {"alter_ego": ["n_ech"], "unit": None},
|
||||||
|
"v_em": {"alter_ego": None, "unit": "V"},
|
||||||
|
"n_avg": {"alter_ego": ["n_profile", "n_profil"], "unit": None},
|
||||||
|
"a0": {"alter_ego": ["gain_a0"], "unit": "dB"},
|
||||||
|
"a1": {"alter_ego": ["gain_a1"], "unit": "dB/m"},
|
||||||
|
"phase_coding": {"alter_ego": None, "unit": None},
|
||||||
|
"static_echo_filter": {"alter_ego": None, "unit": None},
|
||||||
|
"sound_speed": {"alter_ego": None, "unit": "m/s"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for key_dict, values_dict in translation_dict.items():
|
||||||
|
for key, value in values_dict.items():
|
||||||
# leave unchanged the already valid data type names
|
# leave unchanged the already valid data type names
|
||||||
# translate those which are translatable
|
# translate those which are translatable
|
||||||
|
# print(f"key : {key}, value : {value}")
|
||||||
if (raw_key == key):
|
if (raw_key == key):
|
||||||
translated_key = key
|
translated_key = key
|
||||||
break
|
break
|
||||||
|
|
@ -80,6 +160,8 @@ def translate_key(raw_key, _type="data"):
|
||||||
|
|
||||||
#if translated_key == None:
|
#if translated_key == None:
|
||||||
# print("delete %s"%raw_key)
|
# print("delete %s"%raw_key)
|
||||||
|
|
||||||
|
print(f"translated_key : {translated_key}")
|
||||||
return translated_key
|
return translated_key
|
||||||
|
|
||||||
def translate_paramdict(param_dict):
|
def translate_paramdict(param_dict):
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,9 @@
|
||||||
import json
|
import json
|
||||||
from datetime import datetime # pour time count
|
from datetime import datetime # pour time count
|
||||||
|
|
||||||
from .ubt_raw_file import ubt_raw_file
|
from Model.udt_extract.ubt_raw_file import ubt_raw_file
|
||||||
from .ubt_raw_data import ubt_raw_data
|
from Model.udt_extract.ubt_raw_data import ubt_raw_data
|
||||||
from .ubt_raw_flag import *
|
from Model.udt_extract.ubt_raw_flag import *
|
||||||
|
|
||||||
|
|
||||||
def raw_extract(_raw_file):
|
def raw_extract(_raw_file):
|
||||||
|
|
@ -74,6 +74,7 @@ def raw_extract(_raw_file):
|
||||||
|
|
||||||
ubt_data.set_config(settings_dict)
|
ubt_data.set_config(settings_dict)
|
||||||
|
|
||||||
|
print("ubt_data.set_config(settings_dict) : ", ubt_data.set_config(settings_dict))
|
||||||
|
|
||||||
if flag == CONFIG_TAG:
|
if flag == CONFIG_TAG:
|
||||||
# what is needed from here and which is not in param_us_dict is only blind_ca0 and blind_ca1
|
# what is needed from here and which is not in param_us_dict is only blind_ca0 and blind_ca1
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
|
||||||
from .convert_type import translate_paramdict
|
from Model.udt_extract.convert_type import translate_paramdict
|
||||||
|
|
||||||
def paramus_rawdict2ormdict(settings_dict):
|
def paramus_rawdict2ormdict(settings_dict):
|
||||||
"""Function that converts a settings dict read from a raw file (webui2, UB-Lab P) to a formatted dict for data processing.
|
"""Function that converts a settings dict read from a raw file (webui2, UB-Lab P) to a formatted dict for data processing.
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,9 @@ from numpy import asarray as ar
|
||||||
|
|
||||||
from Model.peacock_uvp.apf_timestamp import decode_timestamp
|
from Model.peacock_uvp.apf_timestamp import decode_timestamp
|
||||||
|
|
||||||
from .convert_type import translate_key
|
from Model.udt_extract.convert_type import translate_key
|
||||||
from .date_parser import date_parse
|
from Model.udt_extract.date_parser import date_parse
|
||||||
from .ubt_raw_config import paramus_rawdict2ormdict
|
from Model.udt_extract.ubt_raw_config import paramus_rawdict2ormdict
|
||||||
|
|
||||||
class ubt_raw_data () :
|
class ubt_raw_data () :
|
||||||
def __init__ (self, _const):
|
def __init__ (self, _const):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue