Get sondes that failed to detect a launch

Get sondes that failed to detect a launch#

This is probably outdated

Let’s first import the needed modules.

[1]:
from halodrops.processor import Sonde
from halodrops.helper import paths, rawreader as rr

Then, we provide the path to where we have the A-files. Here the example is for all sondes from one flight. Our objective is to find out how many sondes failed to detect a launch and list their serial IDs.

First, we provide the paths to where we store all our campaign data as data_directory. Next, we provide the flight_id in the format of YYYYMMDD.

[2]:
# Main directory for campaign data
data_directory = '../../../example_data'

# Flight ID in YYYYMMDD format
flight_id = '20200119'

With the help of the Paths class, we can then create a bunch of useful paths to help in various stages of data handling. In our example here, we need to look at all A-files from this flight to get the launch detect indicator. Thus, we will ask the instance for a list of paths to all A-files in the flight.

[3]:
# Instantiate paths object
flight_instance = paths.Paths(data_directory, flight_id)

# Get paths to all A-files for a flight
afiles = flight_instance.get_all_afiles()

The Sonde object has useful attributes that help identify several features useful during data-handling always corresponding to its unique serial_id. Here, we will assign the launch_detect attributes to quickly help us get a list of all sondes that failed to detect a launch during this flight.

[4]:
# Create an empty dictionary for instances of all sondes during the flight
Sondes = {}

for a_file in afiles:
    # Get launch detect boolean
    launch_detect = rr.check_launch_detect_in_afile(a_file)

    # Get sonde serial ID
    sonde_id = rr.get_sonde_id(a_file)

    # Get sonde's launch time
    launch_time = rr.get_launch_time(a_file)

    # Instantiate sonde
    Sondes[sonde_id] = Sonde(sonde_id,launch_time=launch_time)

    # Add `launch_detect` attribute
    Sondes[sonde_id].add_launch_detect(launch_detect)

In fact, what we did above constitutes a core part of the workflow for batch-processing sondes. The function populate_sonde_instance essentially does the same as above and populates more attributes to the instances.

Back to our task! Now, we can simply print out relevant details of all sondes that failed to detect a launch.

[5]:
for _,item in Sondes.items():
    if not item.launch_detect:
        print(f'ID = {item.serial_id}; Time = {item.launch_time}; Launch Detected? = {item.launch_detect}')
ID = 213450447; Time = 2022-04-01T10:12:59.000000; Launch Detected? = False
ID = 213341449; Time = 2022-04-01T09:34:02.000000; Launch Detected? = False
ID = 213450599; Time = 2022-04-01T12:57:10.000000; Launch Detected? = False
ID = 213010063; Time = 2022-04-01T10:16:34.000000; Launch Detected? = False
ID = 210440276; Time = 2022-04-01T12:45:41.000000; Launch Detected? = False