Querying the flight phase files#

We introduce here some new methods to select the flight segments, querying for different criteria.

Data access#

  • To analyse the data they first have to be loaded by importing the (AC)³airborne meta data catalogue. To do so the ac3airborne package has to be installed. More information on how to do that and about the catalog can be found here.

import os
from dotenv import load_dotenv

load_dotenv()

ac3cloud_username = os.environ['AC3_USER']
ac3cloud_password = os.environ['AC3_PASSWORD']

credentials = dict(user=ac3cloud_username, password=ac3cloud_password)

# local caching
kwds = {'simplecache': dict(
    cache_storage=os.environ['INTAKE_CACHE'], 
    same_names=True
)}
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[1], line 2
      1 import os
----> 2 from dotenv import load_dotenv
      4 load_dotenv()
      6 ac3cloud_username = os.environ['AC3_USER']

ModuleNotFoundError: No module named 'dotenv'

Get data#

import ac3airborne
cat = ac3airborne.get_intake_catalog()

datasets = []
for campaign in ['ACLOUD', 'PAMARCMiP', 'AFLUX', 'MOSAiC-ACA','HALO-AC3']:
    datasets.extend(list(cat[campaign]['P5']['GPS_INS']))
for campaign in ['ACLOUD','HALO-AC3']:
    datasets.extend(list(cat[campaign]['P6']['GPS_INS']))
for campaign in ['HALO-AC3']:
    datasets.extend(list(cat[campaign]['HALO']['GPS_INS']))
datasets
['ACLOUD_P5_RF04',
 'ACLOUD_P5_RF05',
 'ACLOUD_P5_RF06',
 'ACLOUD_P5_RF07',
 'ACLOUD_P5_RF08',
 'ACLOUD_P5_RF10',
 'ACLOUD_P5_RF11',
 'ACLOUD_P5_RF13',
 'ACLOUD_P5_RF14',
 'ACLOUD_P5_RF15',
 'ACLOUD_P5_RF16',
 'ACLOUD_P5_RF17',
 'ACLOUD_P5_RF18',
 'ACLOUD_P5_RF19',
 'ACLOUD_P5_RF20',
 'ACLOUD_P5_RF21',
 'ACLOUD_P5_RF22',
 'ACLOUD_P5_RF23',
 'ACLOUD_P5_RF25',
 'PAMARCMiP_P5_RF03',
 'PAMARCMiP_P5_RF04',
 'PAMARCMiP_P5_RF05',
 'PAMARCMiP_P5_RF06',
 'PAMARCMiP_P5_RF07',
 'PAMARCMiP_P5_RF08',
 'PAMARCMiP_P5_RF09',
 'PAMARCMiP_P5_RF10',
 'PAMARCMiP_P5_RF11',
 'PAMARCMiP_P5_RF12',
 'PAMARCMiP_P5_RF13',
 'PAMARCMiP_P5_RF14',
 'PAMARCMiP_P5_RF15',
 'PAMARCMiP_P5_RF16',
 'AFLUX_P5_RF02',
 'AFLUX_P5_RF03',
 'AFLUX_P5_RF04',
 'AFLUX_P5_RF05',
 'AFLUX_P5_RF06',
 'AFLUX_P5_RF07',
 'AFLUX_P5_RF08',
 'AFLUX_P5_RF09',
 'AFLUX_P5_RF10',
 'AFLUX_P5_RF11',
 'AFLUX_P5_RF12',
 'AFLUX_P5_RF13',
 'AFLUX_P5_RF14',
 'AFLUX_P5_RF15',
 'MOSAiC-ACA_P5_RF02',
 'MOSAiC-ACA_P5_RF03',
 'MOSAiC-ACA_P5_RF04',
 'MOSAiC-ACA_P5_RF05',
 'MOSAiC-ACA_P5_RF06',
 'MOSAiC-ACA_P5_RF07',
 'MOSAiC-ACA_P5_RF08',
 'MOSAiC-ACA_P5_RF09',
 'MOSAiC-ACA_P5_RF10',
 'MOSAiC-ACA_P5_RF11',
 'HALO-AC3_P5_RF01',
 'HALO-AC3_P5_RF02',
 'HALO-AC3_P5_RF03',
 'HALO-AC3_P5_RF04',
 'HALO-AC3_P5_RF05',
 'HALO-AC3_P5_RF06',
 'HALO-AC3_P5_RF07',
 'HALO-AC3_P5_RF08',
 'HALO-AC3_P5_RF09',
 'HALO-AC3_P5_RF10',
 'HALO-AC3_P5_RF11',
 'HALO-AC3_P5_RF12',
 'HALO-AC3_P5_RF13',
 'ACLOUD_P6_RF07',
 'ACLOUD_P6_RF08',
 'ACLOUD_P6_RF09',
 'ACLOUD_P6_RF10',
 'ACLOUD_P6_RF11',
 'ACLOUD_P6_RF12',
 'ACLOUD_P6_RF13',
 'ACLOUD_P6_RF14',
 'ACLOUD_P6_RF15',
 'ACLOUD_P6_RF16',
 'ACLOUD_P6_RF17',
 'ACLOUD_P6_RF18',
 'ACLOUD_P6_RF19',
 'ACLOUD_P6_RF20',
 'ACLOUD_P6_RF21',
 'ACLOUD_P6_RF22',
 'ACLOUD_P6_RF23',
 'ACLOUD_P6_RF24',
 'ACLOUD_P6_RF25',
 'HALO-AC3_P6_RF01',
 'HALO-AC3_P6_RF02',
 'HALO-AC3_P6_RF03',
 'HALO-AC3_P6_RF04',
 'HALO-AC3_P6_RF05',
 'HALO-AC3_P6_RF06',
 'HALO-AC3_P6_RF07',
 'HALO-AC3_P6_RF08',
 'HALO-AC3_P6_RF09',
 'HALO-AC3_P6_RF10',
 'HALO-AC3_P6_RF11',
 'HALO-AC3_P6_RF12',
 'HALO-AC3_P6_RF13',
 'HALO-AC3_HALO_RF00',
 'HALO-AC3_HALO_RF01',
 'HALO-AC3_HALO_RF02',
 'HALO-AC3_HALO_RF03',
 'HALO-AC3_HALO_RF04',
 'HALO-AC3_HALO_RF05',
 'HALO-AC3_HALO_RF06',
 'HALO-AC3_HALO_RF07',
 'HALO-AC3_HALO_RF08',
 'HALO-AC3_HALO_RF09',
 'HALO-AC3_HALO_RF10',
 'HALO-AC3_HALO_RF11',
 'HALO-AC3_HALO_RF12',
 'HALO-AC3_HALO_RF13',
 'HALO-AC3_HALO_RF14',
 'HALO-AC3_HALO_RF15',
 'HALO-AC3_HALO_RF16',
 'HALO-AC3_HALO_RF17',
 'HALO-AC3_HALO_RF18']

Note

Have a look at the attributes of the xarray dataset ds_gps for all relevant information on the dataset, such as author, contact, or citation information.

In this example we want to look at ACLOUD_P5_RF14. First we read the GPS information:

ds_gps = cat['ACLOUD']['P5']['GPS_INS']['ACLOUD_P5_RF14'].to_dask()
ds_gps
Invalid MIT-MAGIC-COOKIE-1 key
<xarray.Dataset>
Dimensions:  (time: 20211)
Coordinates:
  * time     (time) datetime64[ns] 2017-06-08T07:22:07 ... 2017-06-08T12:59:07
Data variables:
    alt      (time) float64 nan 28.83 28.85 28.7 28.62 ... 24.62 24.57 24.55 nan
    gs       (time) float64 nan 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0 0.0 nan
    lat      (time) float64 nan 78.25 78.25 78.25 ... 78.25 78.25 78.25 nan
    lon      (time) float64 nan 15.5 15.5 15.5 15.5 ... 15.5 15.5 15.5 15.5 nan
    vs       (time) float64 nan 0.1 0.1 -0.0 -0.0 0.0 ... -0.1 -0.1 0.1 0.0 nan
    pitch    (time) float64 12.23 12.23 12.23 12.22 ... 11.71 11.72 11.72 11.72
    roll     (time) float64 1.82 1.82 1.83 1.83 1.82 ... 1.93 1.92 1.93 1.94
    heading  (time) float64 0.0 0.0 0.0 0.0 0.0 ... -73.84 -73.84 -73.84 -73.83
Attributes: (12/15)
    title:          P5 position and attitude data
    description:    1 Hz subset based on GPS1 and INS data processed by AWI e...
    instruments:    GPS1 and INS
    version:        1.1
    institution:    Alfred-Wegener-Institut Helmholtz-Zentrum für Polar- und ...
    author:         Dr. Mario Mech
    ...             ...
    featureType:    trajectory
    mission:        ACLOUD
    platform:       P5
    flight_number:  RF14
    history:        acquired by P5 during ACLOUD campaign, quality checked by...
    created:        2022-05-25

Load Polar 5 flight phase information#

Polar 5 flights are divided into segments to easily access start and end times of flight patterns. For more information have a look at the respective github repository.

At first we want to load the flight segments of (AC)³airborne

meta = ac3airborne.get_flight_segments() 

In order to simplify things we can import the module flightphase from the ac3airborne.tools.

from ac3airborne.tools import flightphase

The next step is to select the flight segments of our flight:

flight = meta['ACLOUD']['P5']['ACLOUD_P5_RF14']
flight_query = flightphase.FlightPhaseFile(flight)

Plots#

First, the entire flight is plotted:

import warnings
warnings.filterwarnings('ignore')

import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cartopy.feature as cfeature
plt.style.use("../mplstyle/book")
proj = ccrs.NorthPolarStereo()
extent = (-5.0, 24.0, 78.0, 83.0)

fig = plt.figure(figsize=(8, 8))
ax = plt.axes(projection=proj)
ax.set_extent(extent)

ax.add_feature(cfeature.OCEAN)
ax.add_feature(cfeature.LAND)
ax.gridlines()
ax.coastlines()

nya_lat = 78.924444
nya_lon = 11.928611

ax.plot(nya_lon, nya_lat, 'ro', transform=ccrs.PlateCarree())
ax.text(nya_lon, nya_lat+0.05, 'Ny-Ålesund', transform=ccrs.PlateCarree())

line_all = ax.plot(ds_gps.lon, ds_gps.lat, transform=ccrs.PlateCarree())

plt.show()
../_images/8850f39e140465759500af4789a51f8ae7fb0e109196a55a808ff9f08122e8d1.png

Query all segments of a specific kind#

As an example only high_level flights are plotted in the following (only one kind of pattern):

queried = flight_query.selectKind(['high_level'])
queried
[{'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 8, 25, 56),
  'irregularities': [],
  'kinds': ['high_level', 'nya_overflight'],
  'levels': [9800],
  'name': 'high level 1',
  'segment_id': 'ACLOUD_P5_RF14_hl01',
  'start': datetime.datetime(2017, 6, 8, 8, 8, 54)},
 {'dropsondes': ['ACLOUD_P5_RF14_DS01'],
  'end': datetime.datetime(2017, 6, 8, 8, 58, 25),
  'irregularities': [],
  'kinds': ['high_level'],
  'levels': [9800],
  'name': 'high level 2',
  'segment_id': 'ACLOUD_P5_RF14_hl02',
  'start': datetime.datetime(2017, 6, 8, 8, 36, 30)},
 {'dropsondes': ['ACLOUD_P5_RF14_DS02', 'ACLOUD_P5_RF14_DS03'],
  'end': datetime.datetime(2017, 6, 8, 9, 30, 29),
  'irregularities': [],
  'kinds': ['high_level', 'a-train_underflight'],
  'levels': [9700],
  'name': 'high level 3',
  'segment_id': 'ACLOUD_P5_RF14_hl03',
  'start': datetime.datetime(2017, 6, 8, 8, 59, 8)},
 {'dropsondes': ['ACLOUD_P5_RF14_DS04'],
  'end': datetime.datetime(2017, 6, 8, 9, 51, 3),
  'irregularities': [],
  'kinds': ['high_level'],
  'levels': [9700],
  'name': 'high level 4',
  'segment_id': 'ACLOUD_P5_RF14_hl04',
  'start': datetime.datetime(2017, 6, 8, 9, 31, 41)},
 {'dropsondes': ['ACLOUD_P5_RF14_DS05'],
  'end': datetime.datetime(2017, 6, 8, 10, 0, 13),
  'irregularities': [],
  'kinds': ['high_level', 'polarstern_overflight'],
  'levels': [9800],
  'name': 'high level 5',
  'segment_id': 'ACLOUD_P5_RF14_hl05',
  'start': datetime.datetime(2017, 6, 8, 9, 51, 33)},
 {'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 11, 52, 56),
  'irregularities': [],
  'kinds': ['high_level'],
  'levels': [9700],
  'name': 'high level 6',
  'segment_id': 'ACLOUD_P5_RF14_hl06',
  'start': datetime.datetime(2017, 6, 8, 11, 11, 20)},
 {'dropsondes': ['ACLOUD_P5_RF14_DS06'],
  'end': datetime.datetime(2017, 6, 8, 12, 5, 13),
  'irregularities': [],
  'kinds': ['high_level'],
  'levels': [9800],
  'name': 'high level 7',
  'segment_id': 'ACLOUD_P5_RF14_hl07',
  'start': datetime.datetime(2017, 6, 8, 11, 53, 38)},
 {'end': datetime.datetime(2017, 6, 8, 8, 29, 27),
  'irregularities': [],
  'kinds': ['high_level'],
  'levels': [9800],
  'name': 'holding pattern 1 leg 1',
  'segment_id': 'ACLOUD_P5_RF14_ho01_l01',
  'start': datetime.datetime(2017, 6, 8, 8, 27, 33)},
 {'end': datetime.datetime(2017, 6, 8, 8, 33, 20),
  'irregularities': [],
  'kinds': ['high_level'],
  'levels': [9800],
  'name': 'holding pattern 1 leg 2',
  'segment_id': 'ACLOUD_P5_RF14_ho01_l02',
  'start': datetime.datetime(2017, 6, 8, 8, 31, 10)},
 {'end': datetime.datetime(2017, 6, 8, 10, 3, 13),
  'irregularities': [],
  'kinds': ['high_level'],
  'levels': [9600],
  'name': 'cross pattern 1 leg 1',
  'segment_id': 'ACLOUD_P5_RF14_cr01_l01',
  'start': datetime.datetime(2017, 6, 8, 10, 0, 14)},
 {'end': datetime.datetime(2017, 6, 8, 10, 10, 50),
  'irregularities': [],
  'kinds': ['high_level'],
  'levels': [9700],
  'name': 'cross pattern 1 leg 2',
  'segment_id': 'ACLOUD_P5_RF14_cr01_l02',
  'start': datetime.datetime(2017, 6, 8, 10, 8, 13)},
 {'end': datetime.datetime(2017, 6, 8, 12, 10, 13),
  'irregularities': [],
  'kinds': ['high_level'],
  'levels': [9800],
  'name': 'cross pattern 2 leg 1',
  'segment_id': 'ACLOUD_P5_RF14_cr02_l01',
  'start': datetime.datetime(2017, 6, 8, 12, 5, 14)},
 {'end': datetime.datetime(2017, 6, 8, 12, 18, 50),
  'irregularities': [],
  'kinds': ['high_level'],
  'levels': [9800],
  'name': 'cross pattern 2 leg 2',
  'segment_id': 'ACLOUD_P5_RF14_cr02_l02',
  'start': datetime.datetime(2017, 6, 8, 12, 14, 42)},
 {'end': datetime.datetime(2017, 6, 8, 12, 25, 39),
  'irregularities': [],
  'kinds': ['high_level'],
  'levels': [9800],
  'name': 'cross pattern 2 leg 3',
  'segment_id': 'ACLOUD_P5_RF14_cr02_l03',
  'start': datetime.datetime(2017, 6, 8, 12, 24, 15)}]

Plot the selected segments:

ll = line_all.pop(0)
ll.remove()

lines = []
for q in queried:
    start = q['start']
    end   = q['end']
    
    line = ax.plot(ds_gps.lon.sel(time=slice(start, end)),
                   ds_gps.lat.sel(time=slice(start, end)),
                   transform=ccrs.PlateCarree())
    lines.append(line)
    
fig
../_images/e19c1ad6e60bb26068483b1a1f123b8d4de43f07012afa77853889b4fece9a43.png

Of course, also more than one kind of pattern can be selected:

kinds = ['a-train_underflight', 'nya_overflight', 'polarstern_overflight']

queried = flight_query.selectKind(kinds)
queried
[{'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 8, 8, 53),
  'irregularities': ['whale-watching loop'],
  'kinds': ['major_ascent', 'nya_overflight', 'sveabreen_glacier_overflight'],
  'levels': [100, 9700],
  'name': 'major ascent',
  'segment_id': 'ACLOUD_P5_RF14_ma',
  'start': datetime.datetime(2017, 6, 8, 7, 36, 50)},
 {'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 8, 25, 56),
  'irregularities': [],
  'kinds': ['high_level', 'nya_overflight'],
  'levels': [9800],
  'name': 'high level 1',
  'segment_id': 'ACLOUD_P5_RF14_hl01',
  'start': datetime.datetime(2017, 6, 8, 8, 8, 54)},
 {'dropsondes': ['ACLOUD_P5_RF14_DS02', 'ACLOUD_P5_RF14_DS03'],
  'end': datetime.datetime(2017, 6, 8, 9, 30, 29),
  'irregularities': [],
  'kinds': ['high_level', 'a-train_underflight'],
  'levels': [9700],
  'name': 'high level 3',
  'segment_id': 'ACLOUD_P5_RF14_hl03',
  'start': datetime.datetime(2017, 6, 8, 8, 59, 8)},
 {'dropsondes': ['ACLOUD_P5_RF14_DS05'],
  'end': datetime.datetime(2017, 6, 8, 10, 0, 13),
  'irregularities': [],
  'kinds': ['high_level', 'polarstern_overflight'],
  'levels': [9800],
  'name': 'high level 5',
  'segment_id': 'ACLOUD_P5_RF14_hl05',
  'start': datetime.datetime(2017, 6, 8, 9, 51, 33)},
 {'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 10, 10, 50),
  'irregularities': [],
  'kinds': ['cross_pattern', 'polarstern_overflight'],
  'levels': [9600, 9700],
  'name': 'cross pattern 1',
  'parts': [{'end': datetime.datetime(2017, 6, 8, 10, 3, 13),
    'irregularities': [],
    'kinds': ['high_level'],
    'levels': [9600],
    'name': 'cross pattern 1 leg 1',
    'segment_id': 'ACLOUD_P5_RF14_cr01_l01',
    'start': datetime.datetime(2017, 6, 8, 10, 0, 14)},
   {'end': datetime.datetime(2017, 6, 8, 10, 8, 12),
    'kinds': ['cross_pattern_turn'],
    'name': 'cross pattern turn',
    'start': datetime.datetime(2017, 6, 8, 10, 3, 14)},
   {'end': datetime.datetime(2017, 6, 8, 10, 10, 50),
    'irregularities': [],
    'kinds': ['high_level'],
    'levels': [9700],
    'name': 'cross pattern 1 leg 2',
    'segment_id': 'ACLOUD_P5_RF14_cr01_l02',
    'start': datetime.datetime(2017, 6, 8, 10, 8, 13)}],
  'segment_id': 'ACLOUD_P5_RF14_cr01',
  'start': datetime.datetime(2017, 6, 8, 10, 0, 14)},
 {'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 10, 22, 43),
  'irregularities': ['not along straight line'],
  'kinds': ['large_descent', 'polarstern_overflight'],
  'levels': [9700, 200],
  'name': 'large descent 1',
  'segment_id': 'ACLOUD_P5_RF14_ld01',
  'start': datetime.datetime(2017, 6, 8, 10, 10, 51)},
 {'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 11, 11, 19),
  'irregularities': [],
  'kinds': ['large_ascent', 'polarstern_overflight'],
  'levels': [2400, 9700],
  'name': 'large ascent 1',
  'segment_id': 'ACLOUD_P5_RF14_la01',
  'start': datetime.datetime(2017, 6, 8, 11, 2, 25)},
 {'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 12, 25, 39),
  'irregularities': [],
  'kinds': ['cross_pattern', 'nya_overflight'],
  'levels': [9800, 9800, 9800],
  'name': 'cross pattern 2',
  'parts': [{'end': datetime.datetime(2017, 6, 8, 12, 10, 13),
    'irregularities': [],
    'kinds': ['high_level'],
    'levels': [9800],
    'name': 'cross pattern 2 leg 1',
    'segment_id': 'ACLOUD_P5_RF14_cr02_l01',
    'start': datetime.datetime(2017, 6, 8, 12, 5, 14)},
   {'end': datetime.datetime(2017, 6, 8, 12, 14, 41),
    'kinds': ['cross_pattern_turn'],
    'name': 'cross pattern turn',
    'start': datetime.datetime(2017, 6, 8, 12, 10, 14)},
   {'end': datetime.datetime(2017, 6, 8, 12, 18, 50),
    'irregularities': [],
    'kinds': ['high_level'],
    'levels': [9800],
    'name': 'cross pattern 2 leg 2',
    'segment_id': 'ACLOUD_P5_RF14_cr02_l02',
    'start': datetime.datetime(2017, 6, 8, 12, 14, 42)},
   {'end': datetime.datetime(2017, 6, 8, 12, 24, 14),
    'kinds': ['cross_pattern_turn'],
    'name': 'cross pattern turn',
    'start': datetime.datetime(2017, 6, 8, 12, 18, 51)},
   {'end': datetime.datetime(2017, 6, 8, 12, 25, 39),
    'irregularities': [],
    'kinds': ['high_level'],
    'levels': [9800],
    'name': 'cross pattern 2 leg 3',
    'segment_id': 'ACLOUD_P5_RF14_cr02_l03',
    'start': datetime.datetime(2017, 6, 8, 12, 24, 15)}],
  'segment_id': 'ACLOUD_P5_RF14_cr02',
  'start': datetime.datetime(2017, 6, 8, 12, 5, 14)},
 {'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 12, 51, 25),
  'irregularities': [],
  'kinds': ['major_descent', 'nya_overflight'],
  'levels': [9800, 100],
  'name': 'major descent',
  'segment_id': 'ACLOUD_P5_RF14_md',
  'start': datetime.datetime(2017, 6, 8, 12, 25, 40)}]

Plot the selected segments:

for l in lines:
    ll = l.pop(0)
    ll.remove()
    
lines = []
for q in queried:
    start = q['start']
    end   = q['end']
    
    line = ax.plot(ds_gps.lon.sel(time=slice(start, end)),
                   ds_gps.lat.sel(time=slice(start, end)),
                   transform=ccrs.PlateCarree())
    lines.append(line)
    
fig
../_images/625a47d0e459362d25c1e61bf9843240f7c8619c60188cfebd3afc8d41cacb2e.png

Sorting out all segments given a list of kinds#

sort_out = ['short_turn', 'holding_pattern', 'major_ascent', 'major_descent', 'high_level']

queried = flight_query.selectKind(sort_out, invertSelection=True)
queried
[{'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 10, 10, 50),
  'irregularities': [],
  'kinds': ['cross_pattern', 'polarstern_overflight'],
  'levels': [9600, 9700],
  'name': 'cross pattern 1',
  'parts': [{'end': datetime.datetime(2017, 6, 8, 10, 3, 13),
    'irregularities': [],
    'kinds': ['high_level'],
    'levels': [9600],
    'name': 'cross pattern 1 leg 1',
    'segment_id': 'ACLOUD_P5_RF14_cr01_l01',
    'start': datetime.datetime(2017, 6, 8, 10, 0, 14)},
   {'end': datetime.datetime(2017, 6, 8, 10, 8, 12),
    'kinds': ['cross_pattern_turn'],
    'name': 'cross pattern turn',
    'start': datetime.datetime(2017, 6, 8, 10, 3, 14)},
   {'end': datetime.datetime(2017, 6, 8, 10, 10, 50),
    'irregularities': [],
    'kinds': ['high_level'],
    'levels': [9700],
    'name': 'cross pattern 1 leg 2',
    'segment_id': 'ACLOUD_P5_RF14_cr01_l02',
    'start': datetime.datetime(2017, 6, 8, 10, 8, 13)}],
  'segment_id': 'ACLOUD_P5_RF14_cr01',
  'start': datetime.datetime(2017, 6, 8, 10, 0, 14)},
 {'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 10, 22, 43),
  'irregularities': ['not along straight line'],
  'kinds': ['large_descent', 'polarstern_overflight'],
  'levels': [9700, 200],
  'name': 'large descent 1',
  'segment_id': 'ACLOUD_P5_RF14_ld01',
  'start': datetime.datetime(2017, 6, 8, 10, 10, 51)},
 {'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 11, 2, 1),
  'irregularities': [],
  'kinds': ['racetrack_pattern'],
  'levels': [200, 300, 1500, 2400],
  'name': 'racetrack pattern 1',
  'parts': [{'end': datetime.datetime(2017, 6, 8, 10, 29, 20),
    'irregularities': [],
    'kinds': ['low_level'],
    'levels': [200],
    'name': 'racetrack pattern 1 leg 1',
    'segment_id': 'ACLOUD_P5_RF14_rt01_l01',
    'start': datetime.datetime(2017, 6, 8, 10, 22, 44)},
   {'end': datetime.datetime(2017, 6, 8, 10, 31, 40),
    'irregularities': [],
    'kinds': ['procedure_turn', 'small_ascent'],
    'levels': [200, 300],
    'name': 'racetrack pattern 1 ascent 1',
    'segment_id': 'ACLOUD_P5_RF14_rt01_a01',
    'start': datetime.datetime(2017, 6, 8, 10, 29, 21)},
   {'end': datetime.datetime(2017, 6, 8, 10, 40, 26),
    'irregularities': [],
    'kinds': ['low_level'],
    'levels': [300],
    'name': 'racetrack pattern 1 leg 2',
    'segment_id': 'ACLOUD_P5_RF14_rt01_l02',
    'start': datetime.datetime(2017, 6, 8, 10, 31, 41)},
   {'end': datetime.datetime(2017, 6, 8, 10, 42, 40),
    'irregularities': [],
    'kinds': ['procedure_turn', 'small_ascent'],
    'levels': [300, 1500],
    'name': 'racetrack pattern 1 ascent 2',
    'segment_id': 'ACLOUD_P5_RF14_rt01_a02',
    'start': datetime.datetime(2017, 6, 8, 10, 40, 27)},
   {'end': datetime.datetime(2017, 6, 8, 10, 50, 3),
    'irregularities': [],
    'kinds': ['low_level'],
    'levels': [1500],
    'name': 'racetrack pattern 1 leg 3',
    'segment_id': 'ACLOUD_P5_RF14_rt01_l03',
    'start': datetime.datetime(2017, 6, 8, 10, 42, 41)},
   {'end': datetime.datetime(2017, 6, 8, 10, 52, 53),
    'irregularities': [],
    'kinds': ['procedure_turn', 'small_ascent'],
    'levels': [1500, 2400],
    'name': 'racetrack pattern 1 ascent 3',
    'segment_id': 'ACLOUD_P5_RF14_rt01_a03',
    'start': datetime.datetime(2017, 6, 8, 10, 50, 4)},
   {'end': datetime.datetime(2017, 6, 8, 11, 2, 1),
    'irregularities': [],
    'kinds': ['low_level'],
    'levels': [2400],
    'name': 'racetrack pattern 1 leg 4',
    'segment_id': 'ACLOUD_P5_RF14_rt01_l04',
    'start': datetime.datetime(2017, 6, 8, 10, 52, 54)}],
  'segment_id': 'ACLOUD_P5_RF14_rt01',
  'start': datetime.datetime(2017, 6, 8, 10, 22, 44)},
 {'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 11, 11, 19),
  'irregularities': [],
  'kinds': ['large_ascent', 'polarstern_overflight'],
  'levels': [2400, 9700],
  'name': 'large ascent 1',
  'segment_id': 'ACLOUD_P5_RF14_la01',
  'start': datetime.datetime(2017, 6, 8, 11, 2, 25)},
 {'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 12, 25, 39),
  'irregularities': [],
  'kinds': ['cross_pattern', 'nya_overflight'],
  'levels': [9800, 9800, 9800],
  'name': 'cross pattern 2',
  'parts': [{'end': datetime.datetime(2017, 6, 8, 12, 10, 13),
    'irregularities': [],
    'kinds': ['high_level'],
    'levels': [9800],
    'name': 'cross pattern 2 leg 1',
    'segment_id': 'ACLOUD_P5_RF14_cr02_l01',
    'start': datetime.datetime(2017, 6, 8, 12, 5, 14)},
   {'end': datetime.datetime(2017, 6, 8, 12, 14, 41),
    'kinds': ['cross_pattern_turn'],
    'name': 'cross pattern turn',
    'start': datetime.datetime(2017, 6, 8, 12, 10, 14)},
   {'end': datetime.datetime(2017, 6, 8, 12, 18, 50),
    'irregularities': [],
    'kinds': ['high_level'],
    'levels': [9800],
    'name': 'cross pattern 2 leg 2',
    'segment_id': 'ACLOUD_P5_RF14_cr02_l02',
    'start': datetime.datetime(2017, 6, 8, 12, 14, 42)},
   {'end': datetime.datetime(2017, 6, 8, 12, 24, 14),
    'kinds': ['cross_pattern_turn'],
    'name': 'cross pattern turn',
    'start': datetime.datetime(2017, 6, 8, 12, 18, 51)},
   {'end': datetime.datetime(2017, 6, 8, 12, 25, 39),
    'irregularities': [],
    'kinds': ['high_level'],
    'levels': [9800],
    'name': 'cross pattern 2 leg 3',
    'segment_id': 'ACLOUD_P5_RF14_cr02_l03',
    'start': datetime.datetime(2017, 6, 8, 12, 24, 15)}],
  'segment_id': 'ACLOUD_P5_RF14_cr02',
  'start': datetime.datetime(2017, 6, 8, 12, 5, 14)},
 {'end': datetime.datetime(2017, 6, 8, 10, 3, 13),
  'irregularities': [],
  'kinds': ['high_level'],
  'levels': [9600],
  'name': 'cross pattern 1 leg 1',
  'segment_id': 'ACLOUD_P5_RF14_cr01_l01',
  'start': datetime.datetime(2017, 6, 8, 10, 0, 14)},
 {'end': datetime.datetime(2017, 6, 8, 10, 8, 12),
  'kinds': ['cross_pattern_turn'],
  'name': 'cross pattern turn',
  'start': datetime.datetime(2017, 6, 8, 10, 3, 14)},
 {'end': datetime.datetime(2017, 6, 8, 10, 10, 50),
  'irregularities': [],
  'kinds': ['high_level'],
  'levels': [9700],
  'name': 'cross pattern 1 leg 2',
  'segment_id': 'ACLOUD_P5_RF14_cr01_l02',
  'start': datetime.datetime(2017, 6, 8, 10, 8, 13)},
 {'end': datetime.datetime(2017, 6, 8, 10, 29, 20),
  'irregularities': [],
  'kinds': ['low_level'],
  'levels': [200],
  'name': 'racetrack pattern 1 leg 1',
  'segment_id': 'ACLOUD_P5_RF14_rt01_l01',
  'start': datetime.datetime(2017, 6, 8, 10, 22, 44)},
 {'end': datetime.datetime(2017, 6, 8, 10, 31, 40),
  'irregularities': [],
  'kinds': ['procedure_turn', 'small_ascent'],
  'levels': [200, 300],
  'name': 'racetrack pattern 1 ascent 1',
  'segment_id': 'ACLOUD_P5_RF14_rt01_a01',
  'start': datetime.datetime(2017, 6, 8, 10, 29, 21)},
 {'end': datetime.datetime(2017, 6, 8, 10, 40, 26),
  'irregularities': [],
  'kinds': ['low_level'],
  'levels': [300],
  'name': 'racetrack pattern 1 leg 2',
  'segment_id': 'ACLOUD_P5_RF14_rt01_l02',
  'start': datetime.datetime(2017, 6, 8, 10, 31, 41)},
 {'end': datetime.datetime(2017, 6, 8, 10, 42, 40),
  'irregularities': [],
  'kinds': ['procedure_turn', 'small_ascent'],
  'levels': [300, 1500],
  'name': 'racetrack pattern 1 ascent 2',
  'segment_id': 'ACLOUD_P5_RF14_rt01_a02',
  'start': datetime.datetime(2017, 6, 8, 10, 40, 27)},
 {'end': datetime.datetime(2017, 6, 8, 10, 50, 3),
  'irregularities': [],
  'kinds': ['low_level'],
  'levels': [1500],
  'name': 'racetrack pattern 1 leg 3',
  'segment_id': 'ACLOUD_P5_RF14_rt01_l03',
  'start': datetime.datetime(2017, 6, 8, 10, 42, 41)},
 {'end': datetime.datetime(2017, 6, 8, 10, 52, 53),
  'irregularities': [],
  'kinds': ['procedure_turn', 'small_ascent'],
  'levels': [1500, 2400],
  'name': 'racetrack pattern 1 ascent 3',
  'segment_id': 'ACLOUD_P5_RF14_rt01_a03',
  'start': datetime.datetime(2017, 6, 8, 10, 50, 4)},
 {'end': datetime.datetime(2017, 6, 8, 11, 2, 1),
  'irregularities': [],
  'kinds': ['low_level'],
  'levels': [2400],
  'name': 'racetrack pattern 1 leg 4',
  'segment_id': 'ACLOUD_P5_RF14_rt01_l04',
  'start': datetime.datetime(2017, 6, 8, 10, 52, 54)},
 {'end': datetime.datetime(2017, 6, 8, 12, 10, 13),
  'irregularities': [],
  'kinds': ['high_level'],
  'levels': [9800],
  'name': 'cross pattern 2 leg 1',
  'segment_id': 'ACLOUD_P5_RF14_cr02_l01',
  'start': datetime.datetime(2017, 6, 8, 12, 5, 14)},
 {'end': datetime.datetime(2017, 6, 8, 12, 14, 41),
  'kinds': ['cross_pattern_turn'],
  'name': 'cross pattern turn',
  'start': datetime.datetime(2017, 6, 8, 12, 10, 14)},
 {'end': datetime.datetime(2017, 6, 8, 12, 18, 50),
  'irregularities': [],
  'kinds': ['high_level'],
  'levels': [9800],
  'name': 'cross pattern 2 leg 2',
  'segment_id': 'ACLOUD_P5_RF14_cr02_l02',
  'start': datetime.datetime(2017, 6, 8, 12, 14, 42)},
 {'end': datetime.datetime(2017, 6, 8, 12, 24, 14),
  'kinds': ['cross_pattern_turn'],
  'name': 'cross pattern turn',
  'start': datetime.datetime(2017, 6, 8, 12, 18, 51)},
 {'end': datetime.datetime(2017, 6, 8, 12, 25, 39),
  'irregularities': [],
  'kinds': ['high_level'],
  'levels': [9800],
  'name': 'cross pattern 2 leg 3',
  'segment_id': 'ACLOUD_P5_RF14_cr02_l03',
  'start': datetime.datetime(2017, 6, 8, 12, 24, 15)}]

Plot the selected segments:

for l in lines:
    ll = l.pop(0)
    ll.remove()
    
lines = []
for q in queried:
    start = q['start']
    end   = q['end']
    
    line = ax.plot(ds_gps.lon.sel(time=slice(start, end)),
                   ds_gps.lat.sel(time=slice(start, end)),
                   transform=ccrs.PlateCarree())
    lines.append(line)
    
fig
../_images/ae6b1482c05489911df3bd3fc9586aae188bce44260b4feaa71100d50124e731.png

Query a segment with a specific value in a specific attribute#

Example 1: Select element with specific name#

attribute = 'name'
value = 'racetrack pattern 1'

queried = flight_query.select(attribute, value) 
queried
[{'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 11, 2, 1),
  'irregularities': [],
  'kinds': ['racetrack_pattern'],
  'levels': [200, 300, 1500, 2400],
  'name': 'racetrack pattern 1',
  'parts': [{'end': datetime.datetime(2017, 6, 8, 10, 29, 20),
    'irregularities': [],
    'kinds': ['low_level'],
    'levels': [200],
    'name': 'racetrack pattern 1 leg 1',
    'segment_id': 'ACLOUD_P5_RF14_rt01_l01',
    'start': datetime.datetime(2017, 6, 8, 10, 22, 44)},
   {'end': datetime.datetime(2017, 6, 8, 10, 31, 40),
    'irregularities': [],
    'kinds': ['procedure_turn', 'small_ascent'],
    'levels': [200, 300],
    'name': 'racetrack pattern 1 ascent 1',
    'segment_id': 'ACLOUD_P5_RF14_rt01_a01',
    'start': datetime.datetime(2017, 6, 8, 10, 29, 21)},
   {'end': datetime.datetime(2017, 6, 8, 10, 40, 26),
    'irregularities': [],
    'kinds': ['low_level'],
    'levels': [300],
    'name': 'racetrack pattern 1 leg 2',
    'segment_id': 'ACLOUD_P5_RF14_rt01_l02',
    'start': datetime.datetime(2017, 6, 8, 10, 31, 41)},
   {'end': datetime.datetime(2017, 6, 8, 10, 42, 40),
    'irregularities': [],
    'kinds': ['procedure_turn', 'small_ascent'],
    'levels': [300, 1500],
    'name': 'racetrack pattern 1 ascent 2',
    'segment_id': 'ACLOUD_P5_RF14_rt01_a02',
    'start': datetime.datetime(2017, 6, 8, 10, 40, 27)},
   {'end': datetime.datetime(2017, 6, 8, 10, 50, 3),
    'irregularities': [],
    'kinds': ['low_level'],
    'levels': [1500],
    'name': 'racetrack pattern 1 leg 3',
    'segment_id': 'ACLOUD_P5_RF14_rt01_l03',
    'start': datetime.datetime(2017, 6, 8, 10, 42, 41)},
   {'end': datetime.datetime(2017, 6, 8, 10, 52, 53),
    'irregularities': [],
    'kinds': ['procedure_turn', 'small_ascent'],
    'levels': [1500, 2400],
    'name': 'racetrack pattern 1 ascent 3',
    'segment_id': 'ACLOUD_P5_RF14_rt01_a03',
    'start': datetime.datetime(2017, 6, 8, 10, 50, 4)},
   {'end': datetime.datetime(2017, 6, 8, 11, 2, 1),
    'irregularities': [],
    'kinds': ['low_level'],
    'levels': [2400],
    'name': 'racetrack pattern 1 leg 4',
    'segment_id': 'ACLOUD_P5_RF14_rt01_l04',
    'start': datetime.datetime(2017, 6, 8, 10, 52, 54)}],
  'segment_id': 'ACLOUD_P5_RF14_rt01',
  'start': datetime.datetime(2017, 6, 8, 10, 22, 44)}]

Plot the selected elements:

for l in lines:
    ll = l.pop(0)
    ll.remove()
    
lines = []
for q in queried:
    start = q['start']
    end   = q['end']
    
    line = ax.plot(ds_gps.lon.sel(time=slice(start, end)),
                   ds_gps.lat.sel(time=slice(start, end)),
                   transform=ccrs.PlateCarree())
    lines.append(line)
    
fig
../_images/dafebc4d47f38781c6d5c23221757e35033d1ec772ebef7d55856aeea6b0ce95.png

Also with inverted selection:

queried = flight_query.select(attribute, value, invertSelection=True) 
queried
[{'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 8, 8, 53),
  'irregularities': ['whale-watching loop'],
  'kinds': ['major_ascent', 'nya_overflight', 'sveabreen_glacier_overflight'],
  'levels': [100, 9700],
  'name': 'major ascent',
  'segment_id': 'ACLOUD_P5_RF14_ma',
  'start': datetime.datetime(2017, 6, 8, 7, 36, 50)},
 {'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 8, 25, 56),
  'irregularities': [],
  'kinds': ['high_level', 'nya_overflight'],
  'levels': [9800],
  'name': 'high level 1',
  'segment_id': 'ACLOUD_P5_RF14_hl01',
  'start': datetime.datetime(2017, 6, 8, 8, 8, 54)},
 {'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 8, 36, 29),
  'irregularities': [],
  'kinds': ['holding_pattern'],
  'levels': [9800, 9800],
  'name': 'holding pattern 1',
  'parts': [{'end': datetime.datetime(2017, 6, 8, 8, 27, 32),
    'kinds': ['short_turn'],
    'name': 'short turn',
    'start': datetime.datetime(2017, 6, 8, 8, 25, 57)},
   {'end': datetime.datetime(2017, 6, 8, 8, 29, 27),
    'irregularities': [],
    'kinds': ['high_level'],
    'levels': [9800],
    'name': 'holding pattern 1 leg 1',
    'segment_id': 'ACLOUD_P5_RF14_ho01_l01',
    'start': datetime.datetime(2017, 6, 8, 8, 27, 33)},
   {'end': datetime.datetime(2017, 6, 8, 8, 31, 9),
    'kinds': ['short_turn'],
    'name': 'short turn',
    'start': datetime.datetime(2017, 6, 8, 8, 29, 28)},
   {'end': datetime.datetime(2017, 6, 8, 8, 33, 20),
    'irregularities': [],
    'kinds': ['high_level'],
    'levels': [9800],
    'name': 'holding pattern 1 leg 2',
    'segment_id': 'ACLOUD_P5_RF14_ho01_l02',
    'start': datetime.datetime(2017, 6, 8, 8, 31, 10)},
   {'end': datetime.datetime(2017, 6, 8, 8, 36, 29),
    'kinds': ['360_turn'],
    'name': '360 turn',
    'start': datetime.datetime(2017, 6, 8, 8, 33, 21)}],
  'segment_id': 'ACLOUD_P5_RF14_ho01',
  'start': datetime.datetime(2017, 6, 8, 8, 25, 57)},
 {'dropsondes': ['ACLOUD_P5_RF14_DS01'],
  'end': datetime.datetime(2017, 6, 8, 8, 58, 25),
  'irregularities': [],
  'kinds': ['high_level'],
  'levels': [9800],
  'name': 'high level 2',
  'segment_id': 'ACLOUD_P5_RF14_hl02',
  'start': datetime.datetime(2017, 6, 8, 8, 36, 30)},
 {'end': datetime.datetime(2017, 6, 8, 8, 59, 7),
  'kinds': ['short_turn'],
  'name': 'short turn',
  'start': datetime.datetime(2017, 6, 8, 8, 58, 26)},
 {'dropsondes': ['ACLOUD_P5_RF14_DS02', 'ACLOUD_P5_RF14_DS03'],
  'end': datetime.datetime(2017, 6, 8, 9, 30, 29),
  'irregularities': [],
  'kinds': ['high_level', 'a-train_underflight'],
  'levels': [9700],
  'name': 'high level 3',
  'segment_id': 'ACLOUD_P5_RF14_hl03',
  'start': datetime.datetime(2017, 6, 8, 8, 59, 8)},
 {'end': datetime.datetime(2017, 6, 8, 9, 31, 40),
  'kinds': ['short_turn'],
  'name': 'short turn',
  'start': datetime.datetime(2017, 6, 8, 9, 30, 30)},
 {'dropsondes': ['ACLOUD_P5_RF14_DS04'],
  'end': datetime.datetime(2017, 6, 8, 9, 51, 3),
  'irregularities': [],
  'kinds': ['high_level'],
  'levels': [9700],
  'name': 'high level 4',
  'segment_id': 'ACLOUD_P5_RF14_hl04',
  'start': datetime.datetime(2017, 6, 8, 9, 31, 41)},
 {'end': datetime.datetime(2017, 6, 8, 9, 51, 32),
  'kinds': ['short_turn'],
  'name': 'short turn',
  'start': datetime.datetime(2017, 6, 8, 9, 51, 4)},
 {'dropsondes': ['ACLOUD_P5_RF14_DS05'],
  'end': datetime.datetime(2017, 6, 8, 10, 0, 13),
  'irregularities': [],
  'kinds': ['high_level', 'polarstern_overflight'],
  'levels': [9800],
  'name': 'high level 5',
  'segment_id': 'ACLOUD_P5_RF14_hl05',
  'start': datetime.datetime(2017, 6, 8, 9, 51, 33)},
 {'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 10, 10, 50),
  'irregularities': [],
  'kinds': ['cross_pattern', 'polarstern_overflight'],
  'levels': [9600, 9700],
  'name': 'cross pattern 1',
  'parts': [{'end': datetime.datetime(2017, 6, 8, 10, 3, 13),
    'irregularities': [],
    'kinds': ['high_level'],
    'levels': [9600],
    'name': 'cross pattern 1 leg 1',
    'segment_id': 'ACLOUD_P5_RF14_cr01_l01',
    'start': datetime.datetime(2017, 6, 8, 10, 0, 14)},
   {'end': datetime.datetime(2017, 6, 8, 10, 8, 12),
    'kinds': ['cross_pattern_turn'],
    'name': 'cross pattern turn',
    'start': datetime.datetime(2017, 6, 8, 10, 3, 14)},
   {'end': datetime.datetime(2017, 6, 8, 10, 10, 50),
    'irregularities': [],
    'kinds': ['high_level'],
    'levels': [9700],
    'name': 'cross pattern 1 leg 2',
    'segment_id': 'ACLOUD_P5_RF14_cr01_l02',
    'start': datetime.datetime(2017, 6, 8, 10, 8, 13)}],
  'segment_id': 'ACLOUD_P5_RF14_cr01',
  'start': datetime.datetime(2017, 6, 8, 10, 0, 14)},
 {'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 10, 22, 43),
  'irregularities': ['not along straight line'],
  'kinds': ['large_descent', 'polarstern_overflight'],
  'levels': [9700, 200],
  'name': 'large descent 1',
  'segment_id': 'ACLOUD_P5_RF14_ld01',
  'start': datetime.datetime(2017, 6, 8, 10, 10, 51)},
 {'end': datetime.datetime(2017, 6, 8, 11, 2, 24),
  'kinds': ['short_turn'],
  'name': 'short turn',
  'start': datetime.datetime(2017, 6, 8, 11, 2, 2)},
 {'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 11, 11, 19),
  'irregularities': [],
  'kinds': ['large_ascent', 'polarstern_overflight'],
  'levels': [2400, 9700],
  'name': 'large ascent 1',
  'segment_id': 'ACLOUD_P5_RF14_la01',
  'start': datetime.datetime(2017, 6, 8, 11, 2, 25)},
 {'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 11, 52, 56),
  'irregularities': [],
  'kinds': ['high_level'],
  'levels': [9700],
  'name': 'high level 6',
  'segment_id': 'ACLOUD_P5_RF14_hl06',
  'start': datetime.datetime(2017, 6, 8, 11, 11, 20)},
 {'end': datetime.datetime(2017, 6, 8, 11, 53, 37),
  'kinds': ['short_turn'],
  'name': 'short turn',
  'start': datetime.datetime(2017, 6, 8, 11, 52, 57)},
 {'dropsondes': ['ACLOUD_P5_RF14_DS06'],
  'end': datetime.datetime(2017, 6, 8, 12, 5, 13),
  'irregularities': [],
  'kinds': ['high_level'],
  'levels': [9800],
  'name': 'high level 7',
  'segment_id': 'ACLOUD_P5_RF14_hl07',
  'start': datetime.datetime(2017, 6, 8, 11, 53, 38)},
 {'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 12, 25, 39),
  'irregularities': [],
  'kinds': ['cross_pattern', 'nya_overflight'],
  'levels': [9800, 9800, 9800],
  'name': 'cross pattern 2',
  'parts': [{'end': datetime.datetime(2017, 6, 8, 12, 10, 13),
    'irregularities': [],
    'kinds': ['high_level'],
    'levels': [9800],
    'name': 'cross pattern 2 leg 1',
    'segment_id': 'ACLOUD_P5_RF14_cr02_l01',
    'start': datetime.datetime(2017, 6, 8, 12, 5, 14)},
   {'end': datetime.datetime(2017, 6, 8, 12, 14, 41),
    'kinds': ['cross_pattern_turn'],
    'name': 'cross pattern turn',
    'start': datetime.datetime(2017, 6, 8, 12, 10, 14)},
   {'end': datetime.datetime(2017, 6, 8, 12, 18, 50),
    'irregularities': [],
    'kinds': ['high_level'],
    'levels': [9800],
    'name': 'cross pattern 2 leg 2',
    'segment_id': 'ACLOUD_P5_RF14_cr02_l02',
    'start': datetime.datetime(2017, 6, 8, 12, 14, 42)},
   {'end': datetime.datetime(2017, 6, 8, 12, 24, 14),
    'kinds': ['cross_pattern_turn'],
    'name': 'cross pattern turn',
    'start': datetime.datetime(2017, 6, 8, 12, 18, 51)},
   {'end': datetime.datetime(2017, 6, 8, 12, 25, 39),
    'irregularities': [],
    'kinds': ['high_level'],
    'levels': [9800],
    'name': 'cross pattern 2 leg 3',
    'segment_id': 'ACLOUD_P5_RF14_cr02_l03',
    'start': datetime.datetime(2017, 6, 8, 12, 24, 15)}],
  'segment_id': 'ACLOUD_P5_RF14_cr02',
  'start': datetime.datetime(2017, 6, 8, 12, 5, 14)},
 {'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 12, 51, 25),
  'irregularities': [],
  'kinds': ['major_descent', 'nya_overflight'],
  'levels': [9800, 100],
  'name': 'major descent',
  'segment_id': 'ACLOUD_P5_RF14_md',
  'start': datetime.datetime(2017, 6, 8, 12, 25, 40)}]

Plot the selected elements:

for l in lines:
    ll = l.pop(0)
    ll.remove()
    
lines = []
for q in queried:
    start = q['start']
    end   = q['end']
    
    line = ax.plot(ds_gps.lon.sel(time=slice(start, end)),
                   ds_gps.lat.sel(time=slice(start, end)),
                   transform=ccrs.PlateCarree())
    lines.append(line)
    
fig
../_images/2e6ae7773a2509918dc5042b7682f094cb83628cd288a7b506f7d440b42065c2.png

Example 2: Specific level#

attribute = 'levels'
value = 9800

queried = flight_query.select(attribute, value)
queried
[{'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 8, 25, 56),
  'irregularities': [],
  'kinds': ['high_level', 'nya_overflight'],
  'levels': [9800],
  'name': 'high level 1',
  'segment_id': 'ACLOUD_P5_RF14_hl01',
  'start': datetime.datetime(2017, 6, 8, 8, 8, 54)},
 {'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 8, 36, 29),
  'irregularities': [],
  'kinds': ['holding_pattern'],
  'levels': [9800, 9800],
  'name': 'holding pattern 1',
  'parts': [{'end': datetime.datetime(2017, 6, 8, 8, 27, 32),
    'kinds': ['short_turn'],
    'name': 'short turn',
    'start': datetime.datetime(2017, 6, 8, 8, 25, 57)},
   {'end': datetime.datetime(2017, 6, 8, 8, 29, 27),
    'irregularities': [],
    'kinds': ['high_level'],
    'levels': [9800],
    'name': 'holding pattern 1 leg 1',
    'segment_id': 'ACLOUD_P5_RF14_ho01_l01',
    'start': datetime.datetime(2017, 6, 8, 8, 27, 33)},
   {'end': datetime.datetime(2017, 6, 8, 8, 31, 9),
    'kinds': ['short_turn'],
    'name': 'short turn',
    'start': datetime.datetime(2017, 6, 8, 8, 29, 28)},
   {'end': datetime.datetime(2017, 6, 8, 8, 33, 20),
    'irregularities': [],
    'kinds': ['high_level'],
    'levels': [9800],
    'name': 'holding pattern 1 leg 2',
    'segment_id': 'ACLOUD_P5_RF14_ho01_l02',
    'start': datetime.datetime(2017, 6, 8, 8, 31, 10)},
   {'end': datetime.datetime(2017, 6, 8, 8, 36, 29),
    'kinds': ['360_turn'],
    'name': '360 turn',
    'start': datetime.datetime(2017, 6, 8, 8, 33, 21)}],
  'segment_id': 'ACLOUD_P5_RF14_ho01',
  'start': datetime.datetime(2017, 6, 8, 8, 25, 57)},
 {'dropsondes': ['ACLOUD_P5_RF14_DS01'],
  'end': datetime.datetime(2017, 6, 8, 8, 58, 25),
  'irregularities': [],
  'kinds': ['high_level'],
  'levels': [9800],
  'name': 'high level 2',
  'segment_id': 'ACLOUD_P5_RF14_hl02',
  'start': datetime.datetime(2017, 6, 8, 8, 36, 30)},
 {'dropsondes': ['ACLOUD_P5_RF14_DS05'],
  'end': datetime.datetime(2017, 6, 8, 10, 0, 13),
  'irregularities': [],
  'kinds': ['high_level', 'polarstern_overflight'],
  'levels': [9800],
  'name': 'high level 5',
  'segment_id': 'ACLOUD_P5_RF14_hl05',
  'start': datetime.datetime(2017, 6, 8, 9, 51, 33)},
 {'dropsondes': ['ACLOUD_P5_RF14_DS06'],
  'end': datetime.datetime(2017, 6, 8, 12, 5, 13),
  'irregularities': [],
  'kinds': ['high_level'],
  'levels': [9800],
  'name': 'high level 7',
  'segment_id': 'ACLOUD_P5_RF14_hl07',
  'start': datetime.datetime(2017, 6, 8, 11, 53, 38)},
 {'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 12, 25, 39),
  'irregularities': [],
  'kinds': ['cross_pattern', 'nya_overflight'],
  'levels': [9800, 9800, 9800],
  'name': 'cross pattern 2',
  'parts': [{'end': datetime.datetime(2017, 6, 8, 12, 10, 13),
    'irregularities': [],
    'kinds': ['high_level'],
    'levels': [9800],
    'name': 'cross pattern 2 leg 1',
    'segment_id': 'ACLOUD_P5_RF14_cr02_l01',
    'start': datetime.datetime(2017, 6, 8, 12, 5, 14)},
   {'end': datetime.datetime(2017, 6, 8, 12, 14, 41),
    'kinds': ['cross_pattern_turn'],
    'name': 'cross pattern turn',
    'start': datetime.datetime(2017, 6, 8, 12, 10, 14)},
   {'end': datetime.datetime(2017, 6, 8, 12, 18, 50),
    'irregularities': [],
    'kinds': ['high_level'],
    'levels': [9800],
    'name': 'cross pattern 2 leg 2',
    'segment_id': 'ACLOUD_P5_RF14_cr02_l02',
    'start': datetime.datetime(2017, 6, 8, 12, 14, 42)},
   {'end': datetime.datetime(2017, 6, 8, 12, 24, 14),
    'kinds': ['cross_pattern_turn'],
    'name': 'cross pattern turn',
    'start': datetime.datetime(2017, 6, 8, 12, 18, 51)},
   {'end': datetime.datetime(2017, 6, 8, 12, 25, 39),
    'irregularities': [],
    'kinds': ['high_level'],
    'levels': [9800],
    'name': 'cross pattern 2 leg 3',
    'segment_id': 'ACLOUD_P5_RF14_cr02_l03',
    'start': datetime.datetime(2017, 6, 8, 12, 24, 15)}],
  'segment_id': 'ACLOUD_P5_RF14_cr02',
  'start': datetime.datetime(2017, 6, 8, 12, 5, 14)},
 {'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 12, 51, 25),
  'irregularities': [],
  'kinds': ['major_descent', 'nya_overflight'],
  'levels': [9800, 100],
  'name': 'major descent',
  'segment_id': 'ACLOUD_P5_RF14_md',
  'start': datetime.datetime(2017, 6, 8, 12, 25, 40)}]

Plot the selected elements:

for l in lines:
    ll = l.pop(0)
    ll.remove()
    
lines = []
for q in queried:
    start = q['start']
    end   = q['end']
    
    line = ax.plot(ds_gps.lon.sel(time=slice(start, end)),
                   ds_gps.lat.sel(time=slice(start, end)),
                   transform=ccrs.PlateCarree())
    lines.append(line)
    
fig
../_images/ba43971f92e81788ad0b0537bbb44eb8c44d369fac89f20c1cc099deec531452.png

But what if we want only a specific level without ascent and descent? We can require that the attribute value is strictly equal to the one, that we give, i.e. there are no other values:

queried = flight_query.select(attribute, value, strict=True)
queried
[{'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 8, 25, 56),
  'irregularities': [],
  'kinds': ['high_level', 'nya_overflight'],
  'levels': [9800],
  'name': 'high level 1',
  'segment_id': 'ACLOUD_P5_RF14_hl01',
  'start': datetime.datetime(2017, 6, 8, 8, 8, 54)},
 {'dropsondes': ['ACLOUD_P5_RF14_DS01'],
  'end': datetime.datetime(2017, 6, 8, 8, 58, 25),
  'irregularities': [],
  'kinds': ['high_level'],
  'levels': [9800],
  'name': 'high level 2',
  'segment_id': 'ACLOUD_P5_RF14_hl02',
  'start': datetime.datetime(2017, 6, 8, 8, 36, 30)},
 {'dropsondes': ['ACLOUD_P5_RF14_DS05'],
  'end': datetime.datetime(2017, 6, 8, 10, 0, 13),
  'irregularities': [],
  'kinds': ['high_level', 'polarstern_overflight'],
  'levels': [9800],
  'name': 'high level 5',
  'segment_id': 'ACLOUD_P5_RF14_hl05',
  'start': datetime.datetime(2017, 6, 8, 9, 51, 33)},
 {'dropsondes': ['ACLOUD_P5_RF14_DS06'],
  'end': datetime.datetime(2017, 6, 8, 12, 5, 13),
  'irregularities': [],
  'kinds': ['high_level'],
  'levels': [9800],
  'name': 'high level 7',
  'segment_id': 'ACLOUD_P5_RF14_hl07',
  'start': datetime.datetime(2017, 6, 8, 11, 53, 38)}]

This works only if the attribute has more values, as for level or kind. Now plot the selected elements:

for l in lines:
    ll = l.pop(0)
    ll.remove()
    
lines = []
for q in queried:
    start = q['start']
    end   = q['end']
    
    line = ax.plot(ds_gps.lon.sel(time=slice(start, end)),
                   ds_gps.lat.sel(time=slice(start, end)),
                   transform=ccrs.PlateCarree())
    lines.append(line)
    
fig
../_images/142461ed711ee3fae235f14679f8431d4276317b5a1222cb8dd585c4327b6f55.png

Warnings#

In the previous cells warnings were intentionally suppressed. But the flightphase tools normally also show a warning if some of the selected segments contain so-called “irregularities”. So we first reactivate the warnings:

warnings.simplefilter("always")

We repeat one of the previous examples in order to show how the warnings of the flightphase tools look like:

kinds = ['a-train_underflight', 'nya_overflight', 'polarstern_overflight']

queried = flight_query.selectKind(kinds)
queried
/home/mech/.local/lib/python3.8/site-packages/ac3airborne/tools/flightphase.py:27: UserWarning: the segment ACLOUD_P5_RF14_ma contains following irregularities: whale-watching loop
  warnings.warn(str)
/home/mech/.local/lib/python3.8/site-packages/ac3airborne/tools/flightphase.py:27: UserWarning: the segment ACLOUD_P5_RF14_ld01 contains following irregularities: not along straight line
  warnings.warn(str)
[{'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 8, 8, 53),
  'irregularities': ['whale-watching loop'],
  'kinds': ['major_ascent', 'nya_overflight', 'sveabreen_glacier_overflight'],
  'levels': [100, 9700],
  'name': 'major ascent',
  'segment_id': 'ACLOUD_P5_RF14_ma',
  'start': datetime.datetime(2017, 6, 8, 7, 36, 50)},
 {'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 8, 25, 56),
  'irregularities': [],
  'kinds': ['high_level', 'nya_overflight'],
  'levels': [9800],
  'name': 'high level 1',
  'segment_id': 'ACLOUD_P5_RF14_hl01',
  'start': datetime.datetime(2017, 6, 8, 8, 8, 54)},
 {'dropsondes': ['ACLOUD_P5_RF14_DS02', 'ACLOUD_P5_RF14_DS03'],
  'end': datetime.datetime(2017, 6, 8, 9, 30, 29),
  'irregularities': [],
  'kinds': ['high_level', 'a-train_underflight'],
  'levels': [9700],
  'name': 'high level 3',
  'segment_id': 'ACLOUD_P5_RF14_hl03',
  'start': datetime.datetime(2017, 6, 8, 8, 59, 8)},
 {'dropsondes': ['ACLOUD_P5_RF14_DS05'],
  'end': datetime.datetime(2017, 6, 8, 10, 0, 13),
  'irregularities': [],
  'kinds': ['high_level', 'polarstern_overflight'],
  'levels': [9800],
  'name': 'high level 5',
  'segment_id': 'ACLOUD_P5_RF14_hl05',
  'start': datetime.datetime(2017, 6, 8, 9, 51, 33)},
 {'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 10, 10, 50),
  'irregularities': [],
  'kinds': ['cross_pattern', 'polarstern_overflight'],
  'levels': [9600, 9700],
  'name': 'cross pattern 1',
  'parts': [{'end': datetime.datetime(2017, 6, 8, 10, 3, 13),
    'irregularities': [],
    'kinds': ['high_level'],
    'levels': [9600],
    'name': 'cross pattern 1 leg 1',
    'segment_id': 'ACLOUD_P5_RF14_cr01_l01',
    'start': datetime.datetime(2017, 6, 8, 10, 0, 14)},
   {'end': datetime.datetime(2017, 6, 8, 10, 8, 12),
    'kinds': ['cross_pattern_turn'],
    'name': 'cross pattern turn',
    'start': datetime.datetime(2017, 6, 8, 10, 3, 14)},
   {'end': datetime.datetime(2017, 6, 8, 10, 10, 50),
    'irregularities': [],
    'kinds': ['high_level'],
    'levels': [9700],
    'name': 'cross pattern 1 leg 2',
    'segment_id': 'ACLOUD_P5_RF14_cr01_l02',
    'start': datetime.datetime(2017, 6, 8, 10, 8, 13)}],
  'segment_id': 'ACLOUD_P5_RF14_cr01',
  'start': datetime.datetime(2017, 6, 8, 10, 0, 14)},
 {'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 10, 22, 43),
  'irregularities': ['not along straight line'],
  'kinds': ['large_descent', 'polarstern_overflight'],
  'levels': [9700, 200],
  'name': 'large descent 1',
  'segment_id': 'ACLOUD_P5_RF14_ld01',
  'start': datetime.datetime(2017, 6, 8, 10, 10, 51)},
 {'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 11, 11, 19),
  'irregularities': [],
  'kinds': ['large_ascent', 'polarstern_overflight'],
  'levels': [2400, 9700],
  'name': 'large ascent 1',
  'segment_id': 'ACLOUD_P5_RF14_la01',
  'start': datetime.datetime(2017, 6, 8, 11, 2, 25)},
 {'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 12, 25, 39),
  'irregularities': [],
  'kinds': ['cross_pattern', 'nya_overflight'],
  'levels': [9800, 9800, 9800],
  'name': 'cross pattern 2',
  'parts': [{'end': datetime.datetime(2017, 6, 8, 12, 10, 13),
    'irregularities': [],
    'kinds': ['high_level'],
    'levels': [9800],
    'name': 'cross pattern 2 leg 1',
    'segment_id': 'ACLOUD_P5_RF14_cr02_l01',
    'start': datetime.datetime(2017, 6, 8, 12, 5, 14)},
   {'end': datetime.datetime(2017, 6, 8, 12, 14, 41),
    'kinds': ['cross_pattern_turn'],
    'name': 'cross pattern turn',
    'start': datetime.datetime(2017, 6, 8, 12, 10, 14)},
   {'end': datetime.datetime(2017, 6, 8, 12, 18, 50),
    'irregularities': [],
    'kinds': ['high_level'],
    'levels': [9800],
    'name': 'cross pattern 2 leg 2',
    'segment_id': 'ACLOUD_P5_RF14_cr02_l02',
    'start': datetime.datetime(2017, 6, 8, 12, 14, 42)},
   {'end': datetime.datetime(2017, 6, 8, 12, 24, 14),
    'kinds': ['cross_pattern_turn'],
    'name': 'cross pattern turn',
    'start': datetime.datetime(2017, 6, 8, 12, 18, 51)},
   {'end': datetime.datetime(2017, 6, 8, 12, 25, 39),
    'irregularities': [],
    'kinds': ['high_level'],
    'levels': [9800],
    'name': 'cross pattern 2 leg 3',
    'segment_id': 'ACLOUD_P5_RF14_cr02_l03',
    'start': datetime.datetime(2017, 6, 8, 12, 24, 15)}],
  'segment_id': 'ACLOUD_P5_RF14_cr02',
  'start': datetime.datetime(2017, 6, 8, 12, 5, 14)},
 {'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 12, 51, 25),
  'irregularities': [],
  'kinds': ['major_descent', 'nya_overflight'],
  'levels': [9800, 100],
  'name': 'major descent',
  'segment_id': 'ACLOUD_P5_RF14_md',
  'start': datetime.datetime(2017, 6, 8, 12, 25, 40)}]

The first part of the warning tells us which segment is generating the warning. In this case we have two warnings generated by the segments ACLOUD_P5_RF14_ma and ACLOUD_P5_RF14_ld01. The second part is the value of the attribute irregularities. A warning is generated when this attribute is not empty. You can access the content of this attribute even if the warnings are suppressed, as you can see in the examples above.

Select a segment at a specific time or within a specific time range#

If you want to select all the segments within a specific time range you can do it with the function findSegments which takes as parameters the start time and the end time in the %Y-%m-%d %H:%M:%S format.

starttime = '2017-06-08 12:15:00'
endtime   = '2017-06-08 12:45:00'

queried = flight_query.findSegments(starttime, endtime)
queried
[{'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 12, 25, 39),
  'irregularities': [],
  'kinds': ['cross_pattern', 'nya_overflight'],
  'levels': [9800, 9800, 9800],
  'name': 'cross pattern 2',
  'parts': [{'end': datetime.datetime(2017, 6, 8, 12, 10, 13),
    'irregularities': [],
    'kinds': ['high_level'],
    'levels': [9800],
    'name': 'cross pattern 2 leg 1',
    'segment_id': 'ACLOUD_P5_RF14_cr02_l01',
    'start': datetime.datetime(2017, 6, 8, 12, 5, 14)},
   {'end': datetime.datetime(2017, 6, 8, 12, 14, 41),
    'kinds': ['cross_pattern_turn'],
    'name': 'cross pattern turn',
    'start': datetime.datetime(2017, 6, 8, 12, 10, 14)},
   {'end': datetime.datetime(2017, 6, 8, 12, 18, 50),
    'irregularities': [],
    'kinds': ['high_level'],
    'levels': [9800],
    'name': 'cross pattern 2 leg 2',
    'segment_id': 'ACLOUD_P5_RF14_cr02_l02',
    'start': datetime.datetime(2017, 6, 8, 12, 14, 42)},
   {'end': datetime.datetime(2017, 6, 8, 12, 24, 14),
    'kinds': ['cross_pattern_turn'],
    'name': 'cross pattern turn',
    'start': datetime.datetime(2017, 6, 8, 12, 18, 51)},
   {'end': datetime.datetime(2017, 6, 8, 12, 25, 39),
    'irregularities': [],
    'kinds': ['high_level'],
    'levels': [9800],
    'name': 'cross pattern 2 leg 3',
    'segment_id': 'ACLOUD_P5_RF14_cr02_l03',
    'start': datetime.datetime(2017, 6, 8, 12, 24, 15)}],
  'segment_id': 'ACLOUD_P5_RF14_cr02',
  'start': datetime.datetime(2017, 6, 8, 12, 5, 14)},
 {'dropsondes': [],
  'end': datetime.datetime(2017, 6, 8, 12, 51, 25),
  'irregularities': [],
  'kinds': ['major_descent', 'nya_overflight'],
  'levels': [9800, 100],
  'name': 'major descent',
  'segment_id': 'ACLOUD_P5_RF14_md',
  'start': datetime.datetime(2017, 6, 8, 12, 25, 40)}]

For a single time point you just take the end time to be the same as the start time

starttime = '2017-06-08 12:00:00'
endtime   = starttime

queried = flight_query.findSegments(starttime, endtime)
queried
[{'dropsondes': ['ACLOUD_P5_RF14_DS06'],
  'end': datetime.datetime(2017, 6, 8, 12, 5, 13),
  'irregularities': [],
  'kinds': ['high_level'],
  'levels': [9800],
  'name': 'high level 7',
  'segment_id': 'ACLOUD_P5_RF14_hl07',
  'start': datetime.datetime(2017, 6, 8, 11, 53, 38)}]