Plot all radar calibration patterns using halo-flight-phase-separation

Posted on Do 06 August 2020 in radar calibration • by Florian Ewald

open in binder
view on github
download notebook

Plot all radar calibration patterns using halo-flight-phase-separation

In [1]:
!pip install pydap --user
Requirement already satisfied: pydap in /Users/ewi/.local/lib/python3.7/site-packages (3.2.2)
Requirement already satisfied: Webob in /Users/ewi/.local/lib/python3.7/site-packages (from pydap) (1.8.6)
Requirement already satisfied: beautifulsoup4 in /Users/ewi/.local/lib/python3.7/site-packages (from pydap) (4.9.1)
Requirement already satisfied: numpy in /Users/ewi/anaconda3/envs/wradlib/lib/python3.7/site-packages (from pydap) (1.19.1)
Requirement already satisfied: six>=1.4.0 in /Users/ewi/anaconda3/envs/wradlib/lib/python3.7/site-packages (from pydap) (1.15.0)
Requirement already satisfied: docopt in /Users/ewi/.local/lib/python3.7/site-packages (from pydap) (0.6.2)
Requirement already satisfied: Jinja2 in /Users/ewi/anaconda3/envs/wradlib/lib/python3.7/site-packages (from pydap) (2.11.2)
Requirement already satisfied: soupsieve>1.2 in /Users/ewi/.local/lib/python3.7/site-packages (from beautifulsoup4->pydap) (2.0.1)
Requirement already satisfied: MarkupSafe>=0.23 in /Users/ewi/anaconda3/envs/wradlib/lib/python3.7/site-packages (from Jinja2->pydap) (1.1.1)
In [2]:
%pylab inline
Populating the interactive namespace from numpy and matplotlib
In [3]:
import yaml
import urllib.request
import xarray as xr

Get all flight segments from github and BAHAMAS data from AERIS

In [4]:
seg_base_url = "https://raw.githubusercontent.com/eurec4a/halo-flight-phase-separation/master/flight_phase_files/"
nav_base_url = "http://eurec4a:barbados@observations.ipsl.fr/thredds/dodsC/EUREC4A/AIRCRAFT/HALO/UNIFIED/"
In [5]:
seg_urls = [seg_base_url+"EUREC4A_HALO_Flight-Segments_20200119_v1.0.yaml", 
            seg_base_url+"EUREC4A_HALO_Flight-Segments_20200122_v1.0.yaml",
            seg_base_url+"EUREC4A_HALO_Flight-Segments_20200124_v1.0.yaml",
            seg_base_url+"EUREC4A_HALO_Flight-Segments_20200126_v1.0.yaml",
            seg_base_url+"EUREC4A_HALO_Flight-Segments_20200128_v1.0.yaml",
            seg_base_url+"EUREC4A_HALO_Flight-Segments_20200130_v1.0.yaml",
            seg_base_url+"EUREC4A_HALO_Flight-Segments_20200131_v1.0.yaml",
            seg_base_url+"EUREC4A_HALO_Flight-Segments_20200202_v1.0.yaml",
            seg_base_url+"EUREC4A_HALO_Flight-Segments_20200205_v1.0.yaml",
            seg_base_url+"EUREC4A_HALO_Flight-Segments_20200207_v1.0.yaml",
            seg_base_url+"EUREC4A_HALO_Flight-Segments_20200209_v1.0.yaml",
            seg_base_url+"EUREC4A_HALO_Flight-Segments_20200211_v1.0.yaml",
            seg_base_url+"EUREC4A_HALO_Flight-Segments_20200213_v1.0.yaml",
            seg_base_url+"EUREC4A_HALO_Flight-Segments_20200215_v1.0.yaml",
            seg_base_url+"EUREC4A_HALO_Flight-Segments_20200218_v1.0.yaml"]
In [6]:
nav_urls = [nav_base_url+'EUREC4A_HALO_bahamas_20200119_v0.4.nc',
            nav_base_url+'EUREC4A_HALO_bahamas_20200122_v0.4.nc',
            nav_base_url+'EUREC4A_HALO_bahamas_20200124_v0.4.nc',
            nav_base_url+'EUREC4A_HALO_bahamas_20200126_v0.4.nc',
            nav_base_url+'EUREC4A_HALO_bahamas_20200128_v0.4.nc',
            nav_base_url+'EUREC4A_HALO_bahamas_20200130_v0.4.nc',
            nav_base_url+'EUREC4A_HALO_bahamas_20200131_v0.4.nc',
            nav_base_url+'EUREC4A_HALO_bahamas_20200202_v0.4.nc',
            nav_base_url+'EUREC4A_HALO_bahamas_20200205_v0.4.nc',
            nav_base_url+'EUREC4A_HALO_bahamas_20200207_v0.4.nc',
            nav_base_url+'EUREC4A_HALO_bahamas_20200209_v0.4.nc',
            nav_base_url+'EUREC4A_HALO_bahamas_20200211_v0.4.nc',
            nav_base_url+'EUREC4A_HALO_bahamas_20200213_v0.4.nc',
            nav_base_url+'EUREC4A_HALO_bahamas_20200215_v0.4.nc',
            nav_base_url+'EUREC4A_HALO_bahamas_20200218_v0.4.nc']

Loop over all flights and extract radar calibration flight segments

In [8]:
nav_ct = []
nav_cw = []
nav_al = []

for i, (seg_url, nav_url) in enumerate(zip(seg_urls, nav_urls)):
    
    flight = yaml.load(urllib.request.urlopen(seg_url), Loader=yaml.SafeLoader)

    seg_ct = [s for s in flight["segments"] if s["kinds"] == ["radar_calibration_tilted"]]
    seg_cw = [s for s in flight["segments"] if s["kinds"] == ["radar_calibration_wiggle"]]

    store = xr.backends.PydapDataStore.open(nav_url)
    ds = xr.open_dataset(store)
    
    if len(seg_ct)>0:
        for ct in seg_ct:
            nav_ct.append(ds.sel(time=slice(ct["start"], ct["end"])))
    if len(seg_cw)>0:
        for cw in seg_cw:
            nav_cw.append(ds.sel(time=slice(cw["start"], cw["end"])))
            
    nav_al.append(ds)

Plot all flights and mark radar calibration flight segments

In [10]:
import cartopy
import cartopy.crs as ccrs
import matplotlib.pyplot as plt

fig = figure(figsize=(15,8))
ax = plt.axes(projection=ccrs.PlateCarree())
ax.coastlines(resolution='50m', color='black', linewidth=1)

for al in nav_al:
    plt.plot(al.lon[::10], al.lat[::10], color='white')
    
for ct in nav_ct:
    plt.plot(ct.lon, ct.lat, color='red')

for cw in nav_cw:
    plt.plot(cw.lon, cw.lat, color='red')
    
ax.add_feature(cartopy.feature.OCEAN, zorder=0)
ax.add_feature(cartopy.feature.LAND, zorder=1, edgecolor='black')

plt.xlim(-60, -48.)
plt.ylim(10, 17)

xticks=[-60, -58, -56, -54, -52, -50, -48]
yticks=[10, 12, 14, 16, 18]
gl = ax.gridlines(draw_labels=True, xlocs=xticks, ylocs=yticks, color='black', linestyle='--')

gl.xlabel_style = {'size': 16}
gl.ylabel_style = {'size': 16}