Skip to content

Commit

Permalink
wip: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jaanphare committed Apr 6, 2024
0 parents commit 83d652d
Show file tree
Hide file tree
Showing 13 changed files with 3,797 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.DS_Store
dist/
docs/.observablehq/cache/
node_modules/
yarn-error.log
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Synthetic Healthcare Data

This is an [Observable Framework](https://observablehq.com/framework) project. To start the local preview server, run:

```
yarn dev
```

Then visit <http:https://localhost:3000> to preview your project.

For more, see <https://observablehq.com/framework/getting-started>.

## Project structure

A typical Framework project looks like this:

```ini
.
├─ docs
│ ├─ components
│ │ └─ timeline.js # an importable module
│ ├─ data
│ │ ├─ launches.csv.js # a data loader
│ │ └─ events.json # a static data file
│ ├─ example-dashboard.md # a page
│ ├─ example-report.md # another page
│ └─ index.md # the home page
├─ .gitignore
├─ observablehq.config.js # the project config file
├─ package.json
└─ README.md
```

**`docs`** - This is the “source root” — where your source files live. Pages go here. Each page is a Markdown file. Observable Framework uses [file-based routing](https://observablehq.com/framework/routing), which means that the name of the file controls where the page is served. You can create as many pages as you like. Use folders to organize your pages.

**`docs/index.md`** - This is the home page for your site. You can have as many additional pages as you’d like, but you should always have a home page, too.

**`docs/data`** - You can put [data loaders](https://observablehq.com/framework/loaders) or static data files anywhere in your source root, but we recommend putting them here.

**`docs/components`** - You can put shared [JavaScript modules](https://observablehq.com/framework/javascript/imports) anywhere in your source root, but we recommend putting them here. This helps you pull code out of Markdown files and into JavaScript modules, making it easier to reuse code across pages, write tests and run linters, and even share code with vanilla web applications.

**`observablehq.config.js`** - This is the [project configuration](https://observablehq.com/framework/config) file, such as the pages and sections in the sidebar navigation, and the project’s title.

## Command reference

| Command | Description |
| ----------------- | -------------------------------------------------------- |
| `yarn install` | Install or reinstall dependencies |
| `yarn dev` | Start local preview server |
| `yarn build` | Build your static site, generating `./dist` |
| `yarn deploy` | Deploy your project to Observable |
| `yarn clean` | Clear the local data loader cache |
| `yarn observable` | Run commands like `observable help` |
1,261 changes: 1,261 additions & 0 deletions docs/aapl.csv

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions docs/components/timeline.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as Plot from "npm:@observablehq/plot";

export function timeline(events, {width, height} = {}) {
return Plot.plot({
width,
height,
marginTop: 30,
x: {nice: true, label: null, tickFormat: ""},
y: {axis: null},
marks: [
Plot.ruleX(events, {x: "year", y: "y", markerEnd: "dot", strokeWidth: 2.5}),
Plot.ruleY([0]),
Plot.text(events, {x: "year", y: "y", text: "name", lineAnchor: "bottom", dy: -10, lineWidth: 10, fontSize: 12})
]
});
}
8 changes: 8 additions & 0 deletions docs/data/events.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{"name": "Sputnik 1", "year": 1957, "y": 10},
{"name": "Apollo 11", "year": 1969, "y": 20},
{"name": "Viking 1 and 2", "year": 1975, "y": 30},
{"name": "Space Shuttle Columbia", "year": 1981, "y": 40},
{"name": "Hubble Space Telescope", "year": 1990, "y": 50},
{"name": "ISS Construction", "year": 1998, "y": 60}
]
61 changes: 61 additions & 0 deletions docs/data/launches.csv.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import {csvFormat, tsvParse} from "d3-dsv";
import {utcParse} from "d3-time-format";

async function text(url) {
const response = await fetch(url);
if (!response.ok) throw new Error(`fetch failed: ${response.status}`);
return response.text();
}

// “Top” vehicles
const TOP_LAUNCH_VEHICLES = new Set([
"Falcon9",
"R-7",
"R-14",
"Thor",
"DF5",
"R-36",
"Proton",
"Titan",
"Zenit",
"Atlas"
]);

// “Top” launching states
const TOP_STATES_MAP = new Map([
["US", "United States"],
["SU", "Soviet Union"],
["RU", "Russia"],
["CN", "China"]
]);

// Load and parse launch vehicles.
const launchVehicles = tsvParse(await text("https://planet4589.org/space/gcat/tsv/tables/lv.tsv"));

// Construct map to lookup vehicle family from name.
const launchVehicleFamilyMap = new Map(launchVehicles.map((d) => [d["#LV_Name"], d.LV_Family.trim()]));

// Reduce cardinality by mapping smaller states to “Other”.
function normalizeState(d) {
return TOP_STATES_MAP.get(d) ?? "Other";
}

// Reduce cardinality by mapping smaller launch families to “Other”.
function normalizeFamily(d) {
const family = launchVehicleFamilyMap.get(d);
return TOP_LAUNCH_VEHICLES.has(family) ? family : "Other";
}

// Parse dates!
const parseDate = utcParse("%Y %b %_d");

// Load and parse launch-log and trim down to smaller size.
const launchHistory = tsvParse(await text("https://planet4589.org/space/gcat/tsv/derived/launchlog.tsv"), (d) => ({
date: parseDate(d.Launch_Date.slice(0, 11)),
state: normalizeState(d.LVState),
stateId: d.LVState,
family: normalizeFamily(d.LV_Type)
})).filter((d) => d.date != null);

// Write out csv formatted data.
process.stdout.write(csvFormat(launchHistory));
99 changes: 99 additions & 0 deletions docs/example-dashboard.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
---
theme: dashboard
title: Example dashboard
toc: false
---

# Rocket launches 🚀

<!-- Load and transform the data -->

```js
const launches = FileAttachment("data/launches.csv").csv({typed: true});
```

<!-- A shared color scale for consistency, sorted by the number of launches -->

```js
const color = Plot.scale({
color: {
type: "categorical",
domain: d3.groupSort(launches, (D) => -D.length, (d) => d.state).filter((d) => d !== "Other"),
unknown: "var(--theme-foreground-muted)"
}
});
```

<!-- Cards with big numbers -->

<div class="grid grid-cols-4">
<div class="card">
<h2>United States 🇺🇸</h2>
<span class="big">${launches.filter((d) => d.stateId === "US").length.toLocaleString("en-US")}</span>
</div>
<div class="card">
<h2>Russia 🇷🇺 <span class="muted">/ Soviet Union</span></h2>
<span class="big">${launches.filter((d) => d.stateId === "SU" || d.stateId === "RU").length.toLocaleString("en-US")}</span>
</div>
<div class="card">
<h2>China 🇨🇳</h2>
<span class="big">${launches.filter((d) => d.stateId === "CN").length.toLocaleString("en-US")}</span>
</div>
<div class="card">
<h2>Other</h2>
<span class="big">${launches.filter((d) => d.stateId !== "US" && d.stateId !== "SU" && d.stateId !== "RU" && d.stateId !== "CN").length.toLocaleString("en-US")}</span>
</div>
</div>

<!-- Plot of launch history -->

```js
function launchTimeline(data, {width} = {}) {
return Plot.plot({
title: "Launches over the years",
width,
height: 300,
y: {grid: true, label: "Launches"},
color: {...color, legend: true},
marks: [
Plot.rectY(data, Plot.binX({y: "count"}, {x: "date", fill: "state", interval: "year", tip: true})),
Plot.ruleY([0])
]
});
}
```

<div class="grid grid-cols-1">
<div class="card">
${resize((width) => launchTimeline(launches, {width}))}
</div>
</div>

<!-- Plot of launch vehicles -->

```js
function vehicleChart(data, {width}) {
return Plot.plot({
title: "Popular launch vehicles",
width,
height: 300,
marginTop: 0,
marginLeft: 50,
x: {grid: true, label: "Launches"},
y: {label: null},
color: {...color, legend: true},
marks: [
Plot.rectX(data, Plot.groupY({x: "count"}, {y: "family", fill: "state", tip: true, sort: {y: "-x"}})),
Plot.ruleX([0])
]
});
}
```

<div class="grid grid-cols-1">
<div class="card">
${resize((width) => vehicleChart(launches, {width}))}
</div>
</div>

Data: Jonathan C. McDowell, [General Catalog of Artificial Space Objects](https://planet4589.org/space/gcat)
75 changes: 75 additions & 0 deletions docs/example-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
title: Example report
---

# A brief history of space exploration

This report is a brief overview of the history and current state of rocket launches and space exploration.

## Background

The history of rocket launches dates back to ancient China, where gunpowder-filled tubes were used as primitive forms of propulsion.

Fast-forward to the 20th century during the Cold War era, the United States and the Soviet Union embarked on a space race, a competition to innovate and explore beyond Earth.

This led to the launch of the first artificial satellite, Sputnik 1, and the crewed moon landing by Apollo 11. As technology advanced, rocket launches became synonymous with space exploration and satellite deployment.

## The Space Shuttle era

```js
import {timeline} from "./components/timeline.js";
```

```js
const events = FileAttachment("./data/events.json").json();
```

```js
timeline(events, {height: 300})
```

### Sputnik 1 (1957)

This was the first artificial satellite. Launched by the Soviet Union, it marked the beginning of the space age.

### Apollo 11 (1969)

The historic Apollo 11 mission, led by NASA, marked the first successful human landing on the Moon. Astronauts Neil Armstrong and Buzz Aldrin became the first humans to set foot on the lunar surface.

### Viking 1 and 2 (1975)

NASA’s Viking program successfully launched two spacecraft, Viking 1 and Viking 2, to Mars. These missions were the first to successfully land and operate on the Martian surface, conducting experiments to search for signs of life.

### Space Shuttle Columbia (1981)

The first orbital space shuttle mission, STS-1, launched the Space Shuttle Columbia on April 12, 1981. The shuttle program revolutionized space travel, providing a reusable spacecraft for a variety of missions.

### Hubble Space Telescope (1990)

The Hubble Space Telescope has provided unparalleled images and data, revolutionizing our understanding of the universe and contributing to countless astronomical discoveries.

### International Space Station (ISS) construction (1998—2011)

The ISS, a collaborative effort involving multiple space agencies, began construction with the launch of its first module, Zarya, in 1998. Over the following years, various modules were added, making the ISS a symbol of international cooperation in space exploration.

## Commercial spaceflight

After the Space Shuttle program, a new era emerged with a shift towards commercial spaceflight.

Private companies like Blue Origin, founded by Jeff Bezos in 2000, and SpaceX, founded by Elon Musk in 2002, entered the scene. These companies focused on developing reusable rocket technologies, significantly reducing launch costs.

SpaceX, in particular, achieved milestones like the first privately developed spacecraft to reach orbit (Dragon in 2010) and the first privately funded spacecraft to dock with the ISS (Dragon in 2012).

## Recent launch activity

The proliferation of commercial space companies has driven a surge in global launch activity within the last few years.

SpaceX’s Falcon 9 and Falcon Heavy, along with other vehicles from companies like Rocket Lab, have become workhorses for deploying satellites, conducting scientific missions, and ferrying crew to the ISS.

The advent of small satellite constellations, such as Starlink by SpaceX, has further fueled this increase in launches. The push for lunar exploration has added momentum to launch activities, with initiatives like NASA’s Artemis program and plans for crewed missions to the Moon and Mars.

## Looking forward

As technology continues to advance and global interest in space exploration grows, the future promises even more exciting developments in the realm of rocket launches and space travel.

Exploration will not only be limited to the Moon or Mars, but extend to other parts of our solar system such as Jupiter and Saturn’s moons, and beyond.
Loading

0 comments on commit 83d652d

Please sign in to comment.