-
Notifications
You must be signed in to change notification settings - Fork 29
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
read the subsets and the name of fields after reading FlatJsonRenderer().render(bufr_message) #18
Comments
Have you tried the |
thank you very much. Until now I use the following code to start reading bufr:
in json_data I obtain a list of all values for each message and I would like to have a list of all name of each variable and entract data from subsets. I try looking the link but I don't understand how to use it correctly Thank you again |
This is a piece of code to explain how you can read and decode the main data. import pandas as pd
from pybufrkit.decoder import Decoder
from pybufrkit.decoder import generate_bufr_message
from pybufrkit.renderer import FlatJsonRenderer
FILENAME = "L-000-MSG4__-MPEF________-AMV______-000001___-202106171330-__"
decoder = Decoder()
df = pd.DataFrame()
# this file is a multiple-message BUFR file
with open(FILENAME, "rb") as ins:
for bufr_message in generate_bufr_message(decoder, ins.read()):
json_data = FlatJsonRenderer().render(bufr_message)
df = pd.concat([df, `pd.DataFrame(json_data[3][2])])`
# df contains all the wind records as a matrix
# extracting (some of ) the most important fields
amv = pd.DataFrame({'latitude':df[17], 'longitude':df[18], 'pressure':df[27], 'direction':df[28], 'speed':df[29], 'u':df[30], 'v':df[31], 'channel':df[54], 'qix':df[170]})
print(amv) # there are 50346 wind records
# extracting the records for the SEVIRI channel 9 (IR 10.8)
seviri9 = amv.loc[(amv['channel']==9)]
print(seviri9) # only 11067 extracted from thermal infrared data
# filtering the 'good' winds
goodwinds = seviri9.loc[(seviri9['speed']>2.5) & (seviri9['qix']>=80)]
print(goodwinds) # 6302 passed the selection criteria |
thank you really much for your help. It works |
Looks really good and helpful !!! However, how did you get the column association, eg. latitude = df[17] ? |
HI all I'm trying to extract some data from a bufr file but I don't understand how to read the field names and the different subsets to extract data as U-COMPONET, V-COMPONENT, PRESSURE etc after reading any bufr_message. I send in attachment an example file. thank you very much in advance
L-000-MSG4__-MPEF________-AMV______-000001___-202106171330-__.zip
The text was updated successfully, but these errors were encountered: