From 33692509752bb34341655d8e4ea9913c71c936b6 Mon Sep 17 00:00:00 2001 From: ZetkoOfficial Date: Mon, 10 Jul 2023 17:41:14 +0200 Subject: [PATCH] =?UTF-8?q?odpravljene=20kriti=C4=8Dne=20napake,=20ki=20so?= =?UTF-8?q?=20onemogo=C4=8Dale=20zagon=20nekaterih=20celic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + aplikacija.ipynb | 54 +++++++++++++++++++++--------------------------- requirements.txt | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 30 deletions(-) create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore index d312800..caf955c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ testiranje/ __pycache__/ .vscode/ .ipynb_checkpoints +.venv makefile simulacija diff --git a/aplikacija.ipynb b/aplikacija.ipynb index 176b985..21e2f0b 100644 --- a/aplikacija.ipynb +++ b/aplikacija.ipynb @@ -6,21 +6,22 @@ "metadata": {}, "outputs": [], "source": [ - "import matplotlib.pyplot as plt\n", - "from matplotlib.colors import rgb2hex\n", - "import plotly.graph_objects as go\n", - "import ipywidgets as widgets\n", - "import horizon_api\n", "import json\n", + "import math\n", "import os\n", "import subprocess\n", "\n", - "layout = widgets.Layout(description_width=\"initial\")\n", - "MAPA_TELES = \"telesa/\"\n" + "import ipywidgets as widgets\n", + "import matplotlib.pyplot as plt\n", + "import plotly.graph_objects as go\n", + "from matplotlib.colors import rgb2hex\n", + "\n", + "import horizon_api\n", + "\n", + "MAPA_TELES = \"telesa/\"" ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -28,7 +29,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -43,9 +43,9 @@ "outputs": [], "source": [ "slovar_teles = horizon_api.search_body()\n", - "datum = input(\"zapišite izbran datum v formatu yyyy-mm-dd\")\n", + "datum = input(\"zapišite izbran datum v formatu yyyy-mm-dd: \")\n", "\n", - "text_ime_telesa = widgets.Text(description=\"Ime telesa\")\n", + "text_ime_telesa = widgets.Text(description=\"Ime telesa\",continuous_update=False)\n", "dropdown_izbira = widgets.Dropdown(\n", " options=[],\n", " description='Izbira telesa:',\n", @@ -54,12 +54,12 @@ "\n", "# populira dropdown z najdenimi ključi za iskan niz\n", "def najdi_telo(t):\n", - " ime_telesa = str(t.value).capitalize()\n", + " ime_telesa = str(text_ime_telesa.value).capitalize()\n", " \n", " if ime_telesa in slovar_teles.keys(): najdeno = {ime_telesa: slovar_teles[ime_telesa]}\n", - " else: najdeno = horizon_api.search_body(ime_telesa)\n", + " else: najdeno = horizon_api.search_body(ime_telesa.strip())\n", " \n", - " out.clear_output(); dropdown_izbira.value=None\n", + " out.clear_output(); dropdown_izbira.value=None; dropdown_izbira.options = []\n", " if not najdeno: \n", " with out: print(\"Žal nismo našli nobeno telo z tem ključem...\") \n", " else:\n", @@ -82,16 +82,13 @@ " with out: print(\"Telo ustvarjeno!\") \n", " \n", "\n", - "text_ime_telesa.on_submit(najdi_telo)\n", + "text_ime_telesa.observe(najdi_telo, names=\"value\")\n", "dropdown_izbira.observe(ustvari_telo, names=\"value\")\n", "\n", - "display(text_ime_telesa)\n", - "display(dropdown_izbira)\n", - "display(out)" + "display(text_ime_telesa); display(dropdown_izbira); display(out)" ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -163,12 +160,11 @@ " graf_mase.set_figwidth(15); graf_mase_axis.autoscale()\n", " graf_mase_axis.set_ylabel(\"20*log(kg)\")\n", "\n", - "display(dropdown_grafike); display(btn_narisi)\n", - "btn_narisi.on_click(ustvari_primerjavo)" + "btn_narisi.on_click(ustvari_primerjavo)\n", + "display(dropdown_grafike); display(btn_narisi)" ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -232,9 +228,7 @@ "text_G = widgets.FloatText(value=6.674, description='Gravitacijska konstanta * 10^(-11): ', style={'description_width': 'initial'})\n", "text_obdobje_casa = widgets.FloatText(value=3600*24*365, description='Obdobje simulacije (v sekundah): ', style={'description_width': 'initial'})\n", "slider_dolzina_slicice = widgets.IntSlider(value=40, min=1, max=200, step=1, description='Dolžina sličice (v ms): ', style={'description_width': 'initial'})\n", - "\n", "btn_simuliraj = widgets.Button(description='Simuliraj telesa')\n", - "display(dropdown_simulacija); display(text_G); display(text_obdobje_casa); display(slider_dolzina_slicice); display(btn_simuliraj)\n", "\n", "def ustvari_prikaz_simulacije(t):\n", " # izbiro uredimo po masi, da bo telo z največjo maso center simulacije \n", @@ -243,11 +237,11 @@ "\n", " barve_izbire = list(map(lambda t: rgb2hex(t[\"color\"]), izbira))\n", "\n", - " # pridobimo simuliramo na minuto natačno gibanje izbranih teles\n", + " # pridobimo na minuto natačno simulirano gibanje izbranih teles\n", " G,t,dframe = float(text_G.value), float(text_obdobje_casa.value), float(slider_dolzina_slicice.value)\n", " podatki = simuliraj(izbira, G, t, koraki)\n", "\n", - " # ustvarimo prazeno figuro za prikaz simulacije\n", + " # ustvarimo prazno figuro za prikaz simulacije\n", " prikaz_simulacije = go.Figure(\n", " layout=go.Layout(\n", " scene=dict(\n", @@ -275,7 +269,7 @@ "\n", " frames.append(go.Frame(data=data))\n", "\n", - " # dodamo časovne korake v simulacijo\n", + " # dodamo časovne korake v simulacijo in dodamo gumbe v layout\n", " prikaz_simulacije.update(frames=frames)\n", " prikaz_simulacije.update_layout(\n", " updatemenus=[\n", @@ -296,14 +290,14 @@ " \n", " prikaz_simulacije.show()\n", " \n", - "\n", - "btn_simuliraj.on_click(ustvari_prikaz_simulacije)\n" + "btn_simuliraj.on_click(ustvari_prikaz_simulacije)\n", + "display(dropdown_simulacija); display(text_G); display(text_obdobje_casa); display(slider_dolzina_slicice); display(btn_simuliraj)" ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3", "language": "python", "name": "python3" }, diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..6445fbd --- /dev/null +++ b/requirements.txt @@ -0,0 +1,53 @@ +asttokens==2.2.1 +backcall==0.2.0 +certifi==2023.5.7 +charset-normalizer==3.2.0 +comm==0.1.3 +contourpy==1.1.0 +cycler==0.11.0 +debugpy==1.6.7 +decorator==5.1.1 +executing==1.2.0 +fonttools==4.40.0 +idna==3.4 +importlib-metadata==6.8.0 +importlib-resources==6.0.0 +ipykernel==6.24.0 +ipython==8.12.2 +ipywidgets==8.0.7 +jedi==0.18.2 +jupyter-client==8.3.0 +jupyter-core==5.3.1 +jupyterlab-widgets==3.0.8 +kiwisolver==1.4.4 +matplotlib==3.7.2 +matplotlib-inline==0.1.6 +nest-asyncio==1.5.6 +numpy==1.24.4 +packaging==23.1 +parso==0.8.3 +pexpect==4.8.0 +pickleshare==0.7.5 +Pillow==10.0.0 +platformdirs==3.8.1 +plotly==5.15.0 +prompt-toolkit==3.0.39 +psutil==5.9.5 +ptyprocess==0.7.0 +pure-eval==0.2.2 +Pygments==2.15.1 +pyparsing==3.0.9 +python-dateutil==2.8.2 +pyzmq==25.1.0 +requests==2.31.0 +six==1.16.0 +stack-data==0.6.2 +tenacity==8.2.2 +tornado==6.3.2 +traitlets==5.9.0 +typing-extensions==4.7.1 +urllib3==2.0.3 +wcwidth==0.2.6 +widgetsnbextension==4.0.8 +zipp==3.16.0 +nbformat==5.9.0 \ No newline at end of file