python-toolbox
python-toolbox copied to clipboard
There is a problem with TurbSimFile writing
Dear all I had some problems when I used the pyFAST library to replace the data with turbsim, I was confused, when I used this function alone, the output file was fine, but when I called it in other programs, the replaced data was not correct
Below is my function code, any help would be greatly appreciated
bts_change .txt
`class replacement_bts_data(QThread): result_signal = pyqtSignal(str) result_signal_2 = pyqtSignal(str)
def __init__(self, big_bts_name, small_bts_name):
super().__init__()
# 读取数据
self.big_bts_name = big_bts_name
self.small_bts_name = small_bts_name
def run(self):
self.result_signal_2.emit("开始替换,请等待...")
bts_case = bts_change()
i = bts_case.bts_big_in_small(self.big_bts_name[0], self.small_bts_name[0])
self.result_signal_2.emit(i)
self.result_signal_2.emit("执行结束!")
self.result_signal_2.emit("_____________________________________")`
This is the code that I call the function
Hi,
I'm not sure where this behavior comes from. You seem to be using QThread, I'm not too familiar with it. I wonder if you could try to reproduce this behavior with a simple non threaded script at first. I'm enclosing a simple script below that modifies a turbsim file and reads it. It seems to perform as expected. Small errors are expected due to the binary format and internal scaling done.
ts = TurbSimFile('file.bts')
ts['u']=np.random.randn(*ts['u'].shape)
ts['u'][0]+=10
ts.write('aaaaaa.bts')
ts2 = TurbSimFile('aaaaaa.bts')
abs_error = np.abs(ts2['u'].flatten()-ts['u'].flatten())
print('abs error:',np.max(abs_error), np.mean(abs_error))
I would advise to simplify your case and see if the problem persists. Let us know if you find out what's happening. Feel free to submit a fix.