Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c2027e6
Generate yaml files with interactive_flight_track.py
Jul 31, 2020
fb9ff3f
Input empty lists by default for entries that should be lists
Aug 27, 2020
e0af2f4
Use .yaml files in other scripts instead of .csv
Aug 28, 2020
1c80f53
Refactor variable names and documentation to reflect use of segments …
Aug 28, 2020
4d9a2c7
Update tests for previous commit
Aug 28, 2020
c4f02c9
Add shading to selected flight track segments
Oct 14, 2020
05f1544
Move .yaml flight phase file to testdata folder. Need to use twinotte…
Mar 1, 2021
5f0317f
Add simple loading test for flight legs
Mar 2, 2021
12c5f10
Merge branch 'master' into flight_phase_separation
Mar 12, 2021
7406822
Use yaml files for quicklook including testing
Mar 15, 2021
b1c63d4
Allow for extra segment categories with undefined colors in heights_a…
Mar 15, 2021
a456fbd
Put altitude/flight level on the left axis
Mar 15, 2021
8789b0e
Test having an extra category in a flight segment
Mar 15, 2021
10a86a8
Add extra tests for flight segment functionality
Mar 15, 2021
26038b8
Update docstrings for the new flight segment functions
Mar 15, 2021
4dd44c6
Update version number
Mar 15, 2021
38f5653
Use newer "zeroth" time in MASIN files for interactive_flight_track.p…
Mar 16, 2021
444dc3d
Run black on all code
Mar 16, 2021
676dd4d
Remove cartopy version restriction (which allows using matplotlib 3)
Mar 16, 2021
fefb2f6
Update README to be consistent with removing cartopy version restriction
Mar 17, 2021
a4c5549
Add function for loading EUREC4A flight segments from github reposito…
Mar 18, 2021
002eea6
Add docstring for EUREC4A load_segments function
Mar 18, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
python-version: ${{ matrix.python-version }}
conda-channels: anaconda, conda-forge
- name: Install dependencies (conda)
run: conda install -y cartopy"<=0.17"
run: conda install -y cartopy
- name: Install dependencies (pip)
run: |
python -m pip install --upgrade pip
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
.ipynb_checkpoints/
.idea/
docs/build
tests/testdata/
tests/testdata/goes/
tests/testdata/obs/

*.nc
*.png
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ You can:

install cartopy first via conda

$> conda install -c conda-forge cartopy"<=0.17"
$> conda install -c conda-forge cartopy

or manually install the cartopy dependencies (Following [this stack overflow answer](https://stackoverflow.com/a/56956172))

$> apt-get install libproj-dev proj-data proj-bin
$> apt-get install libgeos-dev
$> pip install cython
$> pip install cartopy"<=0.17"
$> pip install cartopy



Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
"matplotlib",
"pandas",
"metpy>=1.0",
"cartopy<=0.17",
"cartopy",
"parse",
"tqdm",
"cftime",
"worldview_dl",
"docopt",
"netcdf4",
"pyyaml",
]

setup_requirements = []
Expand Down Expand Up @@ -58,5 +59,5 @@
test_suite="tests",
tests_require=test_requirements,
url="",
version="0.2.2",
version="0.3.0",
)
17 changes: 13 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

# A testdata folder in this directory
testdata_dir = Path(__file__).parent / "testdata"
testdata_twinotter_dir = testdata_dir / "obs"
testdata_goes_dir = testdata_dir / "goes"


Expand All @@ -43,8 +44,8 @@ def download_goes_testdata():
@pytest.fixture
def testdata(scope="session"):
# Download testdata if it is not there yet
if not testdata_dir.exists():
testdata_dir.mkdir()
if not testdata_twinotter_dir.exists():
testdata_twinotter_dir.mkdir()
download_testdata()

if not testdata_goes_dir.exists():
Expand Down Expand Up @@ -72,9 +73,17 @@ def testdata(scope="session"):
flight_data_file=str(
flight_data_path / "MASIN" / "core_masin_20200124_r004_flight330_1hz.nc"
),
flight_legs_data_path=str(flight_data_path / "flight330-legs.csv"),
flight_segments_file=str(
testdata_dir / "EUREC4A_TO_Flight-Segments_20200124a_0.1.yaml"
),
goes_path=str(p_root / "goes"),
goes_time=datetime.datetime(year=2020, month=1, day=24, hour=14, minute=0,),
goes_time=datetime.datetime(
year=2020,
month=1,
day=24,
hour=14,
minute=0,
),
)


Expand Down
18 changes: 18 additions & 0 deletions tests/test_eurec4a.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import pytest

import twinotter.external.eurec4a


@pytest.mark.parametrize(
"platform,flight_number,flight_id",
[
("TO", 330, "TO-0330"),
("HALO", 119, "HALO-0119"),
("P3", 117, "P3-0117"),
],
)
def test_load_segments(platform, flight_number, flight_id):
flight_segments = twinotter.external.eurec4a.load_segments(
flight_number, platform=platform
)
assert flight_segments["flight_id"] == flight_id
3 changes: 2 additions & 1 deletion tests/test_goes.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

def test_load_nc(testdata):
ds = twinotter.external.goes.load_nc(
path=testdata["goes_path"], time=testdata["goes_time"],
path=testdata["goes_path"],
time=testdata["goes_time"],
)

assert len(ds) == 93
Expand Down
21 changes: 11 additions & 10 deletions tests/test_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def test_basic_flight_path(mock_savefig, testdata):

def test_flight_track_frame(testdata):
ds = twinotter.external.goes.load_nc(
path=testdata["goes_path"], time=testdata["goes_time"],
path=testdata["goes_path"],
time=testdata["goes_time"],
)
fig, ax = twinotter.plots.flight_track_frames.make_frame(ds)

Expand All @@ -50,7 +51,7 @@ def test_vertical_profile_plot(mock_showfig, testdata):
def test_heights_and_legs_plot(mock_savefig, testdata):
twinotter.plots.heights_and_legs.generate(
flight_data_path=testdata["flight_data_path"],
legs_file=testdata["flight_legs_data_path"],
flight_segments_file=testdata["flight_segments_file"],
)
mock_savefig.assert_called_once()

Expand All @@ -59,23 +60,23 @@ def test_heights_and_legs_plot(mock_savefig, testdata):
def test_quicklook_plot(mock_savefig, testdata):
twinotter.quicklook.generate(
flight_data_path=testdata["flight_data_path"],
legs_file=testdata["flight_legs_data_path"],
flight_segments_file=testdata["flight_segments_file"],
)

with open(testdata["flight_legs_data_path"]) as fh:
with open(testdata["flight_segments_file"]) as fh:
file_content = fh.read()
n_legs = len(file_content.split("Leg")) - 1
n_profiles = len(file_content.split("Profile")) - 1
n_levels = len(file_content.split("level")) - 1
n_profiles = len(file_content.split("profile")) - 1

for n in range(n_legs):
fn_fig = "flight330_Leg{}_quicklook.png".format(n)
for n in range(n_levels):
fn_fig = "flight330_level{}_quicklook.png".format(n)
mock_savefig.assert_any_call(fn_fig)

fn_fig = "flight330_Leg{}_paluch.png".format(n)
fn_fig = "flight330_level{}_paluch.png".format(n)
mock_savefig.assert_any_call(fn_fig)

for n in range(n_profiles):
fn_fig = "flight330_Profile{}_skewt.png".format(n)
fn_fig = "flight330_profile{}_skewt.png".format(n)
mock_savefig.assert_any_call(fn_fig)


Expand Down
18 changes: 18 additions & 0 deletions tests/test_twinotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,21 @@ def test_load_flight_empty_fails(testdata_empty):
with pytest.raises(FileNotFoundError):
twinotter.load_flight(flight_data_path=testdata_empty["flight_data_path"])
return


def test_load_segments(testdata):
flight_segments = twinotter.load_segments(testdata["flight_segments_file"])


def test_count_segments(testdata):
flight_segments = twinotter.load_segments(testdata["flight_segments_file"])
assert twinotter.count_segments(flight_segments, "level") == 10
assert twinotter.count_segments(flight_segments, "profile") == 7


def test_extract_segments(testdata):
ds = twinotter.load_flight(flight_data_path=testdata["flight_data_path"])
flight_segments = twinotter.load_segments(testdata["flight_segments_file"])

ds_segs = twinotter.extract_segments(ds, flight_segments, "level")
assert len(ds_segs.Time) == 5684
134 changes: 134 additions & 0 deletions tests/testdata/EUREC4A_TO_Flight-Segments_20200124a_0.1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: RF01
mission: EUREC4A
platform: TO
flight_id: TO-0330
contacts: []
date: 2020-01-24
flight_report: ''
takeoff: 2020-01-24 11:06:37
landing: 2020-01-24 14:02:53
events: []
remarks:
- HUM_ROSE is not well calibrated to absolute values - reference against TDEW_BUCK
or H2O_LICOR.
segments:
- kinds:
- profile
name: ''
irregularities: []
segment_id: TO-0330_
start: 2020-01-24 11:25:13
end: 2020-01-24 11:34:58
- kinds:
- level
name: ''
irregularities: []
segment_id: TO-0330_
start: 2020-01-24 11:34:58
end: 2020-01-24 11:45:28
- kinds:
- profile
name: ''
irregularities: []
segment_id: TO-0330_
start: 2020-01-24 11:45:28
end: 2020-01-24 11:50:21
- kinds:
- level
name: ''
irregularities: []
segment_id: TO-0330_
start: 2020-01-24 11:50:21
end: 2020-01-24 12:01:37
- kinds:
- level
name: ''
irregularities: []
segment_id: TO-0330_
start: 2020-01-24 12:02:44
end: 2020-01-24 12:18:52
- kinds:
- calibration
- profile
name: ''
irregularities: []
segment_id: TO-0330_
start: 2020-01-24 12:17:45
end: 2020-01-24 12:27:53
- kinds:
- level
name: ''
irregularities: []
segment_id: TO-0330_
start: 2020-01-24 12:28:15
end: 2020-01-24 12:42:53
- kinds:
- level
name: ''
irregularities: []
segment_id: TO-0330_
start: 2020-01-24 12:47:24
end: 2020-01-24 12:54:09
- kinds:
- level
name: ''
irregularities: []
segment_id: TO-0330_
start: 2020-01-24 12:56:46
end: 2020-01-24 13:06:09
- kinds:
- profile
name: ''
irregularities: []
segment_id: TO-0330_
start: 2020-01-24 13:06:09
end: 2020-01-24 13:08:24
- kinds:
- profile
name: ''
irregularities: []
segment_id: TO-0330_
start: 2020-01-24 13:08:47
end: 2020-01-24 13:12:32
- kinds:
- level
name: ''
irregularities: []
segment_id: TO-0330_
start: 2020-01-24 13:17:47
end: 2020-01-24 13:29:03
- kinds:
- level
name: ''
irregularities: []
segment_id: TO-0330_
start: 2020-01-24 13:32:03
end: 2020-01-24 13:36:11
- kinds:
- profile
name: ''
irregularities: []
segment_id: TO-0330_
start: 2020-01-24 13:36:33
end: 2020-01-24 13:43:41
- kinds:
- profile
name: ''
irregularities: []
segment_id: TO-0330_
start: 2020-01-24 13:44:03
end: 2020-01-24 13:47:26
- kinds:
- level
name: ''
irregularities: []
segment_id: TO-0330_
start: 2020-01-24 13:47:49
end: 2020-01-24 13:56:04
- kinds:
- level
name: ''
irregularities: []
segment_id: TO-0330_
start: 2020-01-24 13:59:27
end: 2020-01-24 14:01:42
Loading