Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修改swan数据属性后,如何保存 #120

Open
icebound1 opened this issue Oct 30, 2024 · 1 comment
Open

修改swan数据属性后,如何保存 #120

icebound1 opened this issue Oct 30, 2024 · 1 comment

Comments

@icebound1
Copy link

例如将swan雷达数据变量名RC改成rc2如何保存雷达数据?

@pysoer
Copy link
Contributor

pysoer commented Nov 5, 2024

例如将swan雷达数据变量名RC改成rc2如何保存雷达数据?

建议直接从2进制数据上面去更改:
1.读取数据;

from cinrad.io.base import prepare_file
ff = prepare_file(file)
content = ff.read()
ff.close()

2.将第12-50个字节处的数据修改为rc2

site_code = "rc2" # your data name
pname_encoded = struct.pack("38s", site_code.encode("utf-8"))
content = content[:12] + pname_encoded + content[50:]

3.保存文件.

if file.lower().endswith("bz2"):
        with bz2.open(newfile, "wb") as f:
            f.write(content)
else:
    with open(newfile, "wb") as f0:
        f0.write(content)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants