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

Dumping weather data live to file #124

Open
guidocioni opened this issue Apr 13, 2022 · 3 comments
Open

Dumping weather data live to file #124

guidocioni opened this issue Apr 13, 2022 · 3 comments

Comments

@guidocioni
Copy link

Hi,
I'm trying to decode weather data (temperature, winds, pressure...) from ADS-B messages and dump it to file.
I already have a working installation of dump1090-fa and can see the data by connecting with modeslive to the beast port (modeslive --source net --connect 127.0.0.1 30005 beast).

The question is..how can I connect and stream the data directly using the python module to a file using the Meteorological reports [Experimental] section functions?

I'm currently looking into the source of modeslive, and could probably build something using that, but I was wondering whether maybe you already have some example written with this scope in mind and wanted to avoid reinventing the wheel :D

Thanks

@junzis
Copy link
Owner

junzis commented Jul 9, 2022

hi, you can use this example code that process a specific type of messages in your code: https://github.com/junzis/pyModeS#customize-the-streaming-module

@guidocioni
Copy link
Author

guidocioni commented Jul 28, 2022

Thanks.
In the end I could decode easily temperature, winds and pressure readings but the part about latitude and longitude was too complicated to port it.
So I just adapted the code for modeslive to allow for decoding of weather data (from

for t, msg in zip(commb_ts, commb_msg):
)

        # process commb message
           ........
            if bds == "BDS50":
                ...
                winds = pms.commb.wind44(msg)     # Wind speed (kt) and direction (true) (deg)
                temp = pms.commb.temp44(msg)     # Static air temperature (C)
                pres = pms.commb.p44(msg)        # Average static pressure (hPa)
                hum = pms.commb.hum44(msg)      # Humidity (%)

added it to the output_buffer and filter the dump to CSV (from

if self.dumpto is not None:
)

        if self.dumpto is not None:
            dh = str(datetime.datetime.now().strftime("%Y%m%d_%H"))
            fn = self.dumpto + "/pymodes_dump_%s.csv" % dh
            output_buffer.sort(key=lambda x: x[0])
            # filter output buffer
            # only take acs with 3D position
            if self.acs[icao]["lon"] and self.acs[icao]["lat"] and self.acs[icao]["alt"]:
                # only print interesting variables
                output_buffer = [o for o in output_buffer 
                                          if o[2] in ["winds","temp","pres", "hum","lat","lon","alt"]]
                with open(fn, "a") as f:
                    writer = csv.writer(f)
                    writer.writerows(output_buffer)

That seems to work well for now.

@guidocioni
Copy link
Author

Ok, actually now I understood that the meteorological variables need a BDS44, which seems to never appear in my messages because it hasn't been implemented yet.

Is there any way to use pyModeS to extract temperature and winds from the wind speed, heading, etc... ?

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