Skip to content

Commit

Permalink
Merge pull request #54 from orcestra-campaign/flight-planning
Browse files Browse the repository at this point in the history
Extend infrastructure for monitoring operations
  • Loading branch information
lkluft authored Jul 30, 2024
2 parents ba0f88c + 6552d92 commit 359213b
Show file tree
Hide file tree
Showing 12 changed files with 113 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ __pycache__/
.ipynb_checkpoints

# Auto-generated files
orcestra_book/operation.md
orcestra_book/operation/*
2 changes: 1 addition & 1 deletion orcestra_book/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ sphinx:
local_extensions:
apastyle: _ext/
bracket_citation_style: _ext/
flight_reports: _ext/
reports: _ext/
config:
bibtex_default_style: myapastyle
bibtex_reference_style: author_year_round
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ def load_frontmatter(path, derive_flight=False):
frontmatter["expr_takeoff"] = takeoff.strftime("%X")
frontmatter["expr_landing"] = landing.strftime("%X")
frontmatter["expr_categories"] = map(
lambda s: f"{{cat}}`{s}`", frontmatter.get("categories", [])
lambda s: f"{{flight-cat}}`{s}`", frontmatter.get("categories", [])
)

return frontmatter


@lru_cache
def create_badge(src, cat_id):
"""Return an HTML node based on a category id."""
with open(src / "flight_reports" / "categories.yaml", "r") as fp:
def create_flight_badge(src, cat_id):
"""Return an HTML node based on a flight category id."""
with open(src / "reports" / "flight_categories.yaml", "r") as fp:
cat_tier = {
key: attrs["tier"]
for key, attrs in yaml.safe_load(fp)["categories"].items()
Expand All @@ -49,10 +49,10 @@ def create_badge(src, cat_id):
return node


class CategoryRole(SphinxRole):
class FlightCategoryRole(SphinxRole):
def run(self):
src = pathlib.Path(self.env.srcdir)
node = create_badge(src, self.text)
node = create_flight_badge(src, self.text)

return [node], []

Expand All @@ -63,7 +63,7 @@ def run(self):
fm = load_frontmatter(self.env.doc2path(self.env.docname))
categories = fm.get("categories", [])

node_list = [create_badge(src, cat_id) for cat_id in categories]
node_list = [create_flight_badge(src, cat_id) for cat_id in categories]

node = nodes.raw(
text=" ".join(n.astext() for n in node_list),
Expand All @@ -82,29 +82,41 @@ def run(self):


def collect_frontmatter(src):
flights = (src / "flight_reports").glob("*[0-9]*[a-z].md")
flights = (src / "reports").glob("*[0-9]*[a-z].md")
func = partial(load_frontmatter, derive_flight=True)

return {fm["flight_id"]: fm for fm in map(func, sorted(flights))}


def collect_halo_refs(src, flight_id):
refs = ", ".join(
f"[{t}](../{t}s/{flight_id})" for t in ("plan", "report")
if (src / f"{t}s" / f"{flight_id}.md").is_file()
)

return f"{flight_id} ({refs})"


def write_flight_table(app):
src = pathlib.Path(app.srcdir)

frontmatters = collect_frontmatter(src)

with open(src / "_templates" / "operation.md", "r") as fp:
for flight_id in frontmatters:
frontmatters[flight_id]["expr_refs"] = collect_halo_refs(src, flight_id)

with open(src / "_templates" / "operation_halo.md", "r") as fp:
templ = fp.read()

with open(src / "operation.md", "w") as fp:
with open(src / "operation" / "halo.md", "w") as fp:
t = Template(templ)
fp.write(t.render(flights=frontmatters))


def setup(app):
app.connect("builder-inited", write_flight_table)

app.add_role("cat", CategoryRole())
app.add_role("flight-cat", FlightCategoryRole())
app.add_role("badges", BadgesRole())
app.add_role("front", FrontmatterRole())

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!-- This file was created automatically -->
# Operation
# HALO

Flight-ID | Date | Takeoff | Landing | PI | Nickname | Categories
--- | --- | --- | --- | --- | --- | ---
{% for k, v in flights.items() -%}
[](flight_reports/{{ k }}) | {{ v["expr_date"] }} | {{ v["expr_takeoff"] }} | {{ v["expr_landing"] }} | {{ v["pi"] }} | {{ v["nickname"] }} | {{ v["expr_categories"]|join(' ') }}
{{ v["expr_refs"] }} | {{ v["expr_date"] }} | {{ v["expr_takeoff"] }} | {{ v["expr_landing"] }} | {{ v["pi"] }} | {{ v["nickname"] }} | {{ v["expr_categories"]|join(' ') }}
{% endfor -%}
2 changes: 2 additions & 0 deletions orcestra_book/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ chapters:
- file: temperature_example
- file: virtual_campaign
- file: operation
sections:
- file: operation/halo
- file: data
sections:
- file: data_policy
Expand Down
13 changes: 13 additions & 0 deletions orcestra_book/operation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Operation

````{grid} 3
```{grid-item-card} HALO
:img-bottom: figures/HALO.jpg
:img-alt: HALO
:link: operation/halo
:link-type: doc
```
````
1 change: 1 addition & 0 deletions orcestra_book/operation/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
69 changes: 69 additions & 0 deletions orcestra_book/plans/HALO-20240810a.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
jupytext:
text_representation:
extension: .md
format_name: myst
format_version: 0.12
jupytext_version: 1.7.1
kernelspec:
display_name: Python 3
language: python
name: python3
platform: HALO
flight_id: HALO-20240810a
takeoff: 2024-01-01 00:00
landing: 2020-01-01 01:00
crew:
- name: John Doe
job: PI
- name: Emily Taylor
job: WALES
- name: Liam Brooks
job: HAMP
- name: Ava Reyes
job: Dropsondes
- name: Ethan Wallace
job: Smart/VELOX
- name: Ruby Patel
job: SpecMACS
- name: Logan Nguyen
job: Scientist
- name: Julia Santos
job: Ground contact
orphan: true
---

# Flight plan - {front}`flight_id`

## Crew

The flight is planned to take off at {front}`takeoff`.

Name | Job
--- | ---
John Doe | PI
Emily Taylor | WALES
Liam Brooks | HAMP
Ava Reyes | Dropsondes
Ethan Wallace | Smart/VELOX
Ruby Patel | SpecMACS
Logan Nguyen | Scientist
Julia Santos | Ground contact

## Flight plan

```{code-cell} python3
:tags: [hide-input]
from orcestra.flightplan import sal, bco, LatLon, IntoCircle, path_preview
A = LatLon(10, -25, "A")
B = LatLon(14, -25, "B")
ax = path_preview([sal, A, IntoCircle(A, 220e3, 360), B, sal])
ax.set_extent([-35, -10, 5, 20]);
```

* After take-off, super curtain with ATR
* 3.5 h circles, clockwise, in FL 320, dropping sondes (36)
* Excursion in direction of NTAS Buoy in FL 320, dropping sondes (5)
* Radar calibration circle around Ron Brown
* 3.5 h circles, clockwise, in FL 320, dropping sondes (36)
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ docutils==0.17.1 # see https://github.com/executablebooks/jupyter-book/issues/1
easygems>=0.0.3
cmocean
jinja2
orcestra

0 comments on commit 359213b

Please sign in to comment.