Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jupyter kernel (WIP) #147

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1,835 changes: 1,669 additions & 166 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ members = [
"numbat",
"numbat-exchange-rates",
"numbat-cli",
"numbat-jupyter-kernel",
]

exclude = [
Expand Down
Binary file added assets/numbat-32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/numbat-64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions numbat-jupyter-kernel/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.ipynb_checkpoints
13 changes: 13 additions & 0 deletions numbat-jupyter-kernel/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "numbat-jupyter-kernel"
version = "0.1.0"
edition = "2021"

[dependencies]
clap = "4.4.2"
clap_derive = "4.2.0"
image = { version = "0.24.7", no-default-features = true, features = ["png"] }
jupyter = { version = "0.2.0", features = ["image"] }
#jupyter-derive = "0.0.2"
numbat = { version = "1.5.0", path = "../numbat" }
plotters = "0.3.5"
138 changes: 138 additions & 0 deletions numbat-jupyter-kernel/plot-example.ipynb

Large diffs are not rendered by default.

121 changes: 121 additions & 0 deletions numbat-jupyter-kernel/solar_panel.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# Solar panel placement\n",
"\n",
"https://xkcd.com/2812/"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"vscode": {
"languageId": "numbat"
}
},
"outputs": [],
"source": [
"unit $: Money\n",
"\n",
"let net_metering_rate = $ 0.20 / kWh\n",
"let panel_area = 1 m²\n",
"let panel_efficiency = 20 %\n",
"\n",
"fn savings(i: Irradiance) -> Money / Time =\n",
" net_metering_rate × i × panel_area × panel_efficiency -> $/year"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"### Option A: On the roof, south facing"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"vscode": {
"languageId": "numbat"
}
},
"outputs": [
{
"data": {
"text/html": [
"<code> </code><span style=\"color: #43a17e\">58</span><code> </code><span style=\"color: #0a0afe\">$/year</span>"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"savings(4 kWh/m²/day) // round"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"### Option B: On the sun, downward facing"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"vscode": {
"languageId": "numbat"
}
},
"outputs": [
{
"data": {
"text/html": [
"<code> </code><span style=\"color: #43a17e\">22039776</span><code> </code><span style=\"color: #0a0afe\">$/year</span>"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dimension Luminosity = Power\n",
"\n",
"let sun_luminosity: Luminosity = 3.828e26 W\n",
"let sun_area: Area = 6.09e12 km^2\n",
"\n",
"savings(sun_luminosity / sun_area) // round"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Numbat",
"language": "numbat",
"name": "numbat"
},
"language_info": {
"codemirror_mode": "rust",
"file_extension": "*.nbt",
"mimetype": "python",
"name": "Numbat",
"nbconvert_exporter": "rust",
"pygment_lexer": "python",
"version": "0.1.0"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Loading
Loading