kolibril13 commited on
Commit
35b0dd6
1 Parent(s): 74f8403
Files changed (3) hide show
  1. Dockerfile +1 -1
  2. pages/01_wave_packet.ipynb +16 -78
  3. requirements.txt +1 -1
Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM jupyter/base-notebook:latest
2
 
3
  RUN mamba install -c conda-forge leafmap geopandas localtileserver -y && \
4
  fix-permissions "${CONDA_DIR}" && \
 
1
+ FROM jupyter/base-notebook:4d70cf8da953
2
 
3
  RUN mamba install -c conda-forge leafmap geopandas localtileserver -y && \
4
  fix-permissions "${CONDA_DIR}" && \
pages/01_wave_packet.ipynb CHANGED
@@ -6,49 +6,10 @@
6
  "metadata": {},
7
  "outputs": [],
8
  "source": [
9
- "import ipyreact\n",
10
- "from traitlets import List, Any\n",
11
- "import numpy as np\n",
12
- "\n",
13
- "class TldrawSineWidget(ipyreact.ReactWidget):\n",
14
- " points = List(List(Any())).tag(sync=True)\n",
15
- " _esm = \"\"\"\n",
16
- " import { TDShapeType, Tldraw } from \"@tldraw/tldraw\";\n",
17
- " import * as React from \"react\";\n",
18
- "\n",
19
- " export default function App({ points }) {\n",
20
- "\n",
21
- " const [app, setApp] = React.useState()\n",
22
- "\n",
23
- " const handleMount = React.useCallback((app: Tldraw) => {\n",
24
- " setApp(app)\n",
25
- " }, []);\n",
26
  "\n",
27
- " React.useEffect(() => {\n",
28
- " if (app) {\n",
29
- " app.createShapes({\n",
30
- " type: \"draw\",\n",
31
- " id: \"draw1\",\n",
32
- " color: 'red',\n",
33
- " points: points,\n",
34
- " });\n",
35
- " }\n",
36
- " }, [points, app])\n",
37
  "\n",
38
- " return (\n",
39
- " <div\n",
40
- " style={{\n",
41
- " position: \"relative\",\n",
42
- " width: \"800px\",\n",
43
- " height: \"450px\",\n",
44
- " }}\n",
45
- " >\n",
46
- " <Tldraw onMount={handleMount} onChange={e => console.log(\"hii\")} />\n",
47
- " </div>\n",
48
- " );\n",
49
- "}\n",
50
- "\n",
51
- " \"\"\"\n",
52
  "\n",
53
  "import solara\n",
54
  "import numpy as np\n",
@@ -57,46 +18,23 @@
57
  "\n",
58
  "@solara.component\n",
59
  "def Page():\n",
60
- " dispersion = \"high\" # \"high\", \"low\", \"const\"\n",
61
- " def n(wj):\n",
62
- " if dispersion == \"high\":\n",
63
- " return 1 + wj * 0.1\n",
64
- " if dispersion == \"low\":\n",
65
- " return 1.1 - wj * 0.01\n",
66
- " if dispersion == \"const\":\n",
67
- " return 1\n",
68
- "\n",
69
- " c = 1\n",
70
- " num_of_waves = 121\n",
71
- " start_w = 1\n",
72
- " end_w = 7\n",
73
- " x = np.linspace(-2, 10, 1001)\n",
74
- " \n",
75
- " def g(x, t):\n",
76
- " u1 = 0\n",
77
- " for wj in np.linspace(start_w, end_w, num_of_waves):\n",
78
- " u1 += np.exp(1j * (wj * n(wj) / c * x - t * wj))\n",
79
- " return u1.real\n",
80
- "\n",
81
- " ooo = 38 \n",
82
- " points = np.column_stack((x*50+ooo, g(x, float_value.value)+150)).tolist()\n",
83
- " points = points[100:]\n",
84
- " points[0] = [ooo-40, 0]\n",
85
- "\n",
86
- "\n",
87
- " # solara.Markdown(\" \\psi(x, t) = \\sum \\limits_j C_j \\cdot e^{\\mathrm{i}( - k_j \\cdot x + \\omega_j \\cdot t )}, \\omega_j= \\frac{k_j}{c(k_j)} $\")\n",
88
- " # solara.Markdown(f\"**t**: {float_value.value}\")\n",
89
- "\n",
90
- "\n",
91
- " with solara.Row():\n",
92
- " solara.Button(\"Reset\", on_click=lambda: float_value.set(0))\n",
93
- " solara.FloatSlider(\"Time t\", value=float_value, min=0, max=4*np.pi, step=0.1)\n",
94
- " TldrawSineWidget.element(points=points)\n",
95
- "\n",
96
  "\n",
97
  "\n",
98
  "Page()"
99
  ]
 
 
 
 
 
 
 
100
  }
101
  ],
102
  "metadata": {
@@ -115,7 +53,7 @@
115
  "name": "python",
116
  "nbconvert_exporter": "python",
117
  "pygments_lexer": "ipython3",
118
- "version": "3.9.15"
119
  },
120
  "orig_nbformat": 4
121
  },
 
6
  "metadata": {},
7
  "outputs": [],
8
  "source": [
9
+ "import bpy\n",
10
+ "from IPython.display import display, Image\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  "\n",
 
 
 
 
 
 
 
 
 
 
12
  "\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  "\n",
14
  "import solara\n",
15
  "import numpy as np\n",
 
18
  "\n",
19
  "@solara.component\n",
20
  "def Page():\n",
21
+ " path = \"test.png\"\n",
22
+ " bpy.context.scene.render.resolution_x = 500\n",
23
+ " bpy.context.scene.render.resolution_y = 200\n",
24
+ " bpy.ops.render.render()\n",
25
+ " bpy.data.images[\"Render Result\"].save_render(filepath=path)\n",
26
+ " display(Image(filename=path))\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  "\n",
28
  "\n",
29
  "Page()"
30
  ]
31
+ },
32
+ {
33
+ "cell_type": "code",
34
+ "execution_count": null,
35
+ "metadata": {},
36
+ "outputs": [],
37
+ "source": []
38
  }
39
  ],
40
  "metadata": {
 
53
  "name": "python",
54
  "nbconvert_exporter": "python",
55
  "pygments_lexer": "ipython3",
56
+ "version": "3.10.13"
57
  },
58
  "orig_nbformat": 4
59
  },
requirements.txt CHANGED
@@ -1,2 +1,2 @@
1
- ipyreact
2
  solara
 
1
+ bpy
2
  solara