Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

There is a problem with TurbSimFile writing #79

Open
Relax-in opened this issue Nov 23, 2023 · 2 comments
Open

There is a problem with TurbSimFile writing #79

Relax-in opened this issue Nov 23, 2023 · 2 comments
Assignees
Labels
question Further information is requested

Comments

@Relax-in
Copy link

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
2023-11-23 11-21-53屏幕截图
2023-11-23 11-23-00屏幕截图

@Relax-in
Copy link
Author

`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

@ebranlard
Copy link
Collaborator

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.

@ebranlard ebranlard self-assigned this Nov 23, 2023
@ebranlard ebranlard added the question Further information is requested label Nov 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants