projecthorus / radiosonde_auto_rx

Automatically Track Radiosonde Launches using RTLSDR
GNU General Public License v3.0
499 stars 126 forks source link

Remove trailing newline to ensure correct parsing #940

Closed argilo closed 1 week ago

argilo commented 1 week ago

The read_ka9q_power_log function keeps the trailing newline character on each line it reads. Because ka9q-radio's "powers" utility ends lines with a trailing comma (proposed fix: https://github.com/ka9q/ka9q-radio/pull/65), np.fromstring interprets the trailing newline character as an invalid value and replaces it with -1. As a result, the list of bin powers is one too long, which causes the frequency range generated by np.linspace to be incorrect.

Here I've corrected the problem by removing the trailing newline with rstrip(). It is idiomatic to do this when reading lines from a file in Python. After this change, np.fromstring ignores powers' trailing comma.

I verified that this change works correctly with or without https://github.com/ka9q/ka9q-radio/pull/65.