Skip to content

Commit

Permalink
odpravljene kritične napake, ki so onemogočale zagon nekaterih celic
Browse files Browse the repository at this point in the history
  • Loading branch information
ZetkoOfficial committed Jul 10, 2023
1 parent 436acf4 commit 3369250
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 30 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ testiranje/
__pycache__/
.vscode/
.ipynb_checkpoints
.venv
makefile

simulacija
Expand Down
54 changes: 24 additions & 30 deletions aplikacija.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@
"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": [
"# Simulacija nebesnih teles"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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": [
Expand Down Expand Up @@ -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": [
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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"
},
Expand Down
53 changes: 53 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3369250

Please sign in to comment.