Array of Two Rectangular Detectors for Localization of Radioactive Sources
Directional model and its parameters
Enter the coefficients for the model:
packages = ["matplotlib"]
import micropip
import asyncio
from js import console, document, fetch
from pyodide.ffi import create_proxy
import matplotlib.pyplot as plt
async def load_script(url):
response = await fetch(url)
if not response.ok:
raise RuntimeError(f"Failed to fetch {url}: {response.status}")
script_content = await response.text()
exec(script_content, globals())
async def main():
await micropip.install("matplotlib")
await load_script('2x1_rectangularModel.py')
console.log("2x1_rectangularModel module loaded.")
parameterPlotting = globals()['parameterPlotting']
console.log("Setting up plot function...")
def plot_model(event=None):
console.log("Button clicked.")
try:
a = float(document.getElementById("a-input").value)
b = float(document.getElementById("b-input").value)
w = float(document.getElementById("w-input").value)
h = float(document.getElementById("h-input").value)
console.log(f"Values entered: a={a}, b={b}, w={w}, h={h}")
plot_div = document.getElementById("plot")
plot_div.innerHTML = ""
fig = parameterPlotting(a, b, w, h)
display(fig, target="plot")
except Exception as e:
console.error(f"Error plotting model: {e}")
plot_proxy = create_proxy(plot_model)
button = document.getElementById("plot-button")
button.addEventListener("click", plot_proxy)
console.log("Setup complete.")
# Plot the model with default values when the page loads
plot_model()
asyncio.ensure_future(main())