修改swan数据属性后,如何保存
icebound1 opened this issue · 1 comments
icebound1 commented
例如将swan雷达数据变量名RC改成rc2如何保存雷达数据?
pysoer commented
例如将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)