|
|
@ -9,7 +9,7 @@ from scipy.optimize import leastsq |
|
|
|
from datetime import datetime, timedelta |
|
|
|
from datetime import datetime, timedelta |
|
|
|
from myRamses import RamsesFactoryHandle,AirWater |
|
|
|
from myRamses import RamsesFactoryHandle,AirWater |
|
|
|
from tools.mylogger import log |
|
|
|
from tools.mylogger import log |
|
|
|
from myconfig import TOKEN,NEWLINE,DATA_DIR,SAVE_EXT_NAME |
|
|
|
from myconfig import TOKEN,NEWLINE,DATA_DIR,SAVE_EXT_NAME,CAL_DIR |
|
|
|
from myconfig import RamsesPROFILE |
|
|
|
from myconfig import RamsesPROFILE |
|
|
|
from pubsub import pub |
|
|
|
from pubsub import pub |
|
|
|
|
|
|
|
|
|
|
@ -291,6 +291,7 @@ class Profiler(object): |
|
|
|
depth : List[float] =None |
|
|
|
depth : List[float] =None |
|
|
|
wavelength:List[np.ndarray] =None |
|
|
|
wavelength:List[np.ndarray] =None |
|
|
|
spectrum:List[np.ndarray] =None |
|
|
|
spectrum:List[np.ndarray] =None |
|
|
|
|
|
|
|
immersion_factors:np.ndarray = None |
|
|
|
beginWavelength: float = None |
|
|
|
beginWavelength: float = None |
|
|
|
endWavelength: float = None |
|
|
|
endWavelength: float = None |
|
|
|
rowFactor:float = None |
|
|
|
rowFactor:float = None |
|
|
@ -333,6 +334,12 @@ class Profiler(object): |
|
|
|
self.newWavelength = np.arange(self.beginWavelength,self.endWavelength,self.wvInterval) |
|
|
|
self.newWavelength = np.arange(self.beginWavelength,self.endWavelength,self.wvInterval) |
|
|
|
pass |
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def set_immersion_factors(self, ifs:np.ndarray): |
|
|
|
|
|
|
|
wv = ifs[:, 0] |
|
|
|
|
|
|
|
val = ifs[:, 1] |
|
|
|
|
|
|
|
self.immersion_factors = np.interp(self.newWavelength,wv,val) |
|
|
|
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
def set_ramses_sensor_numbers(self, num:int = 3): |
|
|
|
def set_ramses_sensor_numbers(self, num:int = 3): |
|
|
|
self.data.data_frame = DataFrame() |
|
|
|
self.data.data_frame = DataFrame() |
|
|
|
self.data.data_frame.set_ramses_num( num ) |
|
|
|
self.data.data_frame.set_ramses_num( num ) |
|
|
@ -494,7 +501,10 @@ class Profiler(object): |
|
|
|
'''' Get Lu0 Ku ''' |
|
|
|
'''' Get Lu0 Ku ''' |
|
|
|
log.info( " >> ", __name__, "get_Lu0_Ku" ) |
|
|
|
log.info( " >> ", __name__, "get_Lu0_Ku" ) |
|
|
|
x = np.array(self.depth) |
|
|
|
x = np.array(self.depth) |
|
|
|
y = np.log(self.Lu) # ln_Lu |
|
|
|
|
|
|
|
|
|
|
|
## 浸没因子处理 ## |
|
|
|
|
|
|
|
tmp = self.deal_Lu_by_immersion_factors() |
|
|
|
|
|
|
|
y = np.log(tmp) # ln_Lu |
|
|
|
self.Ku,ln_Lu0 = self.leastsq_linear_fitting( x, y) |
|
|
|
self.Ku,ln_Lu0 = self.leastsq_linear_fitting( x, y) |
|
|
|
self.Lu0 = np.exp(ln_Lu0) |
|
|
|
self.Lu0 = np.exp(ln_Lu0) |
|
|
|
|
|
|
|
|
|
|
@ -512,6 +522,12 @@ class Profiler(object): |
|
|
|
# log.warning(t) |
|
|
|
# log.warning(t) |
|
|
|
# log.warning(self.Ed0) |
|
|
|
# log.warning(self.Ed0) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def deal_Lu_by_immersion_factors ( self, ): |
|
|
|
|
|
|
|
'''' ?????? 浸没因子处理 Lu ??? ''' |
|
|
|
|
|
|
|
ifs = self.immersion_factors |
|
|
|
|
|
|
|
lu = self.Lu |
|
|
|
|
|
|
|
return lu |
|
|
|
|
|
|
|
|
|
|
|
def leastsq_linear_fitting( self, arr_depth:np.ndarray, arr_data:np.ndarray ): |
|
|
|
def leastsq_linear_fitting( self, arr_depth:np.ndarray, arr_data:np.ndarray ): |
|
|
|
'''最小二乘拟合 |
|
|
|
'''最小二乘拟合 |
|
|
|
# arr_depth np一维数组 |
|
|
|
# arr_depth np一维数组 |
|
|
@ -610,7 +626,7 @@ class ProfilerHandle(object): |
|
|
|
self.profiler.set_tilt_range(tilt_angle) |
|
|
|
self.profiler.set_tilt_range(tilt_angle) |
|
|
|
|
|
|
|
|
|
|
|
def read_info_path(self,infopath: Path ): |
|
|
|
def read_info_path(self,infopath: Path ): |
|
|
|
assert infopath.exists(), f">>>> not find {fpath} " |
|
|
|
assert infopath.exists(), f">>>> not find {infopath} " |
|
|
|
ret_bytes = b'' |
|
|
|
ret_bytes = b'' |
|
|
|
with open(infopath, 'rb') as file: |
|
|
|
with open(infopath, 'rb') as file: |
|
|
|
ret_bytes = file.read() |
|
|
|
ret_bytes = file.read() |
|
|
@ -618,7 +634,7 @@ class ProfilerHandle(object): |
|
|
|
self.profiler.data.set_info_frame( ret_bytes ) |
|
|
|
self.profiler.data.set_info_frame( ret_bytes ) |
|
|
|
|
|
|
|
|
|
|
|
def read_sensor_path(self, sensorpath:Path): |
|
|
|
def read_sensor_path(self, sensorpath:Path): |
|
|
|
assert sensorpath.exists(), f">>>> not find {fpath} " |
|
|
|
assert sensorpath.exists(), f">>>> not find {sensorpath} " |
|
|
|
with open(sensorpath, 'rb') as file: |
|
|
|
with open(sensorpath, 'rb') as file: |
|
|
|
ret_bytes = file.read() |
|
|
|
ret_bytes = file.read() |
|
|
|
assert len(ret_bytes) > 1754, f">>>> no data " |
|
|
|
assert len(ret_bytes) > 1754, f">>>> no data " |
|
|
@ -639,7 +655,7 @@ class ProfilerHandle(object): |
|
|
|
if bf.name != "info.bin": |
|
|
|
if bf.name != "info.bin": |
|
|
|
bytes_list.append( self.read_bin(bf) ) |
|
|
|
bytes_list.append( self.read_bin(bf) ) |
|
|
|
|
|
|
|
|
|
|
|
self.profiler.data.set_data_frame( bytes_list, pth, self.aw.callback ) # 目录也要传过去 |
|
|
|
self.profiler.data.set_data_frame( bytes_list, pth, self.profiler.callback ) # 目录也要传过去 |
|
|
|
pass |
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
def read_folders_from_SD(self, pth:Path): |
|
|
|
def read_folders_from_SD(self, pth:Path): |
|
|
@ -670,6 +686,7 @@ class ProfilerHandle(object): |
|
|
|
self.read_info_path(infopath) |
|
|
|
self.read_info_path(infopath) |
|
|
|
self.profiler.reset_profiler() |
|
|
|
self.profiler.reset_profiler() |
|
|
|
self.profiler.data.set_wavelength( ) # 设置波长 |
|
|
|
self.profiler.data.set_wavelength( ) # 设置波长 |
|
|
|
|
|
|
|
self.read_immersion_factors( ) # 读取浸没因子 |
|
|
|
# log.warning( f" {self.profiler.data.wavelength}" ) |
|
|
|
# log.warning( f" {self.profiler.data.wavelength}" ) |
|
|
|
self.profiler.get_depth_offset() |
|
|
|
self.profiler.get_depth_offset() |
|
|
|
self.read_sensor_path(sensorpath) |
|
|
|
self.read_sensor_path(sensorpath) |
|
|
@ -684,6 +701,14 @@ class ProfilerHandle(object): |
|
|
|
pub.sendMessage('update' , msg=msg) |
|
|
|
pub.sendMessage('update' , msg=msg) |
|
|
|
pass |
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def read_immersion_factors(self,)->np.ndarray: |
|
|
|
|
|
|
|
assert fpath.exists(), f">>>> not find {fpath} " |
|
|
|
|
|
|
|
fname = "immersion_factors_Lu.dat" |
|
|
|
|
|
|
|
fpath = CAL_DIR.joinpath( "profiler" ,fname) |
|
|
|
|
|
|
|
ret = np.loadtxt(fpath,skiprows=2) |
|
|
|
|
|
|
|
return ret |
|
|
|
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
def read_bin(self,fpath: Path): |
|
|
|
def read_bin(self,fpath: Path): |
|
|
|
assert fpath.exists(), f">>>> not find {fpath} " |
|
|
|
assert fpath.exists(), f">>>> not find {fpath} " |
|
|
|
ret = b'' |
|
|
|
ret = b'' |
|
|
@ -750,35 +775,48 @@ def profiler_demo(): |
|
|
|
ph.profiler.get_Lw_Rs(ph.retrieve["n_t_square"]) |
|
|
|
ph.profiler.get_Lw_Rs(ph.retrieve["n_t_square"]) |
|
|
|
ph.profiler.save(savedir) |
|
|
|
ph.profiler.save(savedir) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# def read_immersion_factors( )->np.ndarray: |
|
|
|
|
|
|
|
# fname = "immersion_factors_Lu.dat" |
|
|
|
|
|
|
|
# fpath = CAL_DIR.joinpath( "profiler" ,fname) |
|
|
|
|
|
|
|
# assert fpath.exists(), f">>>> not find {fpath} " |
|
|
|
|
|
|
|
# ret = np.loadtxt(fpath,skiprows=2) |
|
|
|
|
|
|
|
# return ret |
|
|
|
|
|
|
|
# pass |
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
if __name__ == '__main__': |
|
|
|
|
|
|
|
|
|
|
|
device_id = 2 |
|
|
|
# ret = read_immersion_factors() |
|
|
|
ph = ProfilerHandle( device_id, ProfilerCfg.cfg, ProfilerCfg.calcfg, ProfilerCfg.rtv) |
|
|
|
# print(ret) |
|
|
|
fpath = Path.cwd() |
|
|
|
# print(ret[:,0]) |
|
|
|
# t= ("data", "2","2002","8", "17","51", "info.bin") |
|
|
|
# print(ret[:,1]) |
|
|
|
# t= ("data" ) |
|
|
|
|
|
|
|
infopath = fpath.joinpath('data','2','37','info.bin') |
|
|
|
# device_id = 2 |
|
|
|
sensorpath = fpath.joinpath('data','2','37','sensor.bin') |
|
|
|
# ph = ProfilerHandle( device_id, ProfilerCfg.cfg, ProfilerCfg.calcfg, ProfilerCfg.rtv) |
|
|
|
savedir = fpath.joinpath('data','2','37' ) |
|
|
|
# fpath = Path.cwd() |
|
|
|
|
|
|
|
# # t= ("data", "2","2002","8", "17","51", "info.bin") |
|
|
|
ph.set_ramses_number(3) |
|
|
|
# # t= ("data" ) |
|
|
|
ph.set_tilt_range(21.0) |
|
|
|
# infopath = fpath.joinpath('data','2','37','info.bin') |
|
|
|
|
|
|
|
# sensorpath = fpath.joinpath('data','2','37','sensor.bin') |
|
|
|
ph.read_info_path(infopath) |
|
|
|
# savedir = fpath.joinpath('data','2','37' ) |
|
|
|
ph.profiler.reset_profiler() |
|
|
|
|
|
|
|
ph.profiler.data.set_wavelength( ) # 设置波长 |
|
|
|
# ph.set_ramses_number(3) |
|
|
|
ph.profiler.get_depth_offset() |
|
|
|
# ph.set_tilt_range(21.0) |
|
|
|
ph.read_sensor_path(sensorpath) |
|
|
|
|
|
|
|
|
|
|
|
# ph.read_info_path(infopath) |
|
|
|
# log.info( f" Ed: {ph.profiler.Ed} ") |
|
|
|
# ph.profiler.reset_profiler() |
|
|
|
# log.info( f" Lu: {ph.profiler.Lu} ") |
|
|
|
# ph.profiler.data.set_wavelength( ) # 设置波长 |
|
|
|
ph.profiler.get_Ed0_kd() |
|
|
|
# ph.profiler.get_depth_offset() |
|
|
|
ph.profiler.get_Lu0_Ku() |
|
|
|
# ph.read_sensor_path(sensorpath) |
|
|
|
# log.info( f" Ed0: {ph.profiler.Ed0} ") |
|
|
|
|
|
|
|
# log.info( f" Lu0: {ph.profiler.Lu0} ") |
|
|
|
# # log.info( f" Ed: {ph.profiler.Ed} ") |
|
|
|
ph.profiler.get_Lw_Rs(ph.retrieve["n_t_square"]) |
|
|
|
# # log.info( f" Lu: {ph.profiler.Lu} ") |
|
|
|
# log.info( f" Lw: {ph.profiler.Lw} ") |
|
|
|
# ph.profiler.get_Ed0_kd() |
|
|
|
# log.info( f" Rs: {ph.profiler.Rs} ") |
|
|
|
# ph.profiler.get_Lu0_Ku() |
|
|
|
ph.profiler.save(savedir) |
|
|
|
# # log.info( f" Ed0: {ph.profiler.Ed0} ") |
|
|
|
|
|
|
|
# # log.info( f" Lu0: {ph.profiler.Lu0} ") |
|
|
|
|
|
|
|
# ph.profiler.get_Lw_Rs(ph.retrieve["n_t_square"]) |
|
|
|
|
|
|
|
# # log.info( f" Lw: {ph.profiler.Lw} ") |
|
|
|
|
|
|
|
# # log.info( f" Rs: {ph.profiler.Rs} ") |
|
|
|
|
|
|
|
# ph.profiler.save(savedir) |
|
|
|
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|