Skip to content

Notebooks for Watchdog demo and drive.pv() demo #76

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

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

N-3ielo
Copy link

@N-3ielo N-3ielo commented Mar 26, 2025

No description provided.

@N-3ielo N-3ielo changed the title This notebook is a demo for live plots whilst TD sim is running Notebooks for Watchdog demo and drive.pv() demo Apr 7, 2025
Copy link
Member

@lang-m lang-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Aways use PyVista spelling with capital P and V
  • The four functions in the pyvista notebook are nearly identical. The only difference is in the implementation of the callback function. I would combine the functions. We can discuss different options how to do this.

"\n",
"In Ubermag we can visualise micromagnetic (mm) systems with Holoviews using the function `drive.hv()`. `Drive.hv()` allows us to view the change in time of a mm system when a Time Driver simulation is run. \n",
"\n",
"We can also use Pyvista which is a 3D visualisation tool to also visual mm systems, however we currently do not have the ability to visualise all the time steps at once. Instead the user has to specify which time step they want to see by indexing the drive object as shown below: \n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"We can also use Pyvista which is a 3D visualisation tool to also visual mm systems, however we currently do not have the ability to visualise all the time steps at once. Instead the user has to specify which time step they want to see by indexing the drive object as shown below: \n",
"We can also use Pyvista, which is a 3D visualisation tool, to visual mm systems, however we currently do not have the ability to visualise all time steps at once. Instead the user has to specify which time step they want to see by indexing the drive object as shown below: \n",

"source": [
"## System Setup\n",
"\n",
"First we import our modules"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a brief comment what panel is needed for (maybe just refer to a more detailed explanation further down in the notebook).

"id": "b60581e3",
"metadata": {},
"source": [
"Below we initialise our system"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Say where the example is taken from/what physical system we simulate.

"id": "25e93571",
"metadata": {},
"source": [
"We run our `TimeDriver` simulation below for **5** ns and save our magnetisation in **50** steps"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"We run our `TimeDriver` simulation below for **5** ns and save our magnetisation in **50** steps"
"We run our `TimeDriver` simulation below for 5 ns and save our magnetisation in 50 steps"

Comment on lines +360 to +365
"Below we have functions for four pyvista plotting functions. These are:\n",
"\n",
"1. `drive.pyvista.vector()`\n",
"2. `drive.pyvista.volume()`\n",
"3. `drive.pyvista.contour()`\n",
"4. `drive.pyvista.streamlines()`"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just listing the functions is not particularly useful, I can read the function names myself. Maybe write a (few) sentence(s) about what these functions are doing.

"outputs": [],
"source": [
"class DirectoryMonitorHandler(FileSystemEventHandler):\n",
" def __init__(self, observer, stop_flag):\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to pass working_directory to ensure you are looking for filesystem events in the right place.

"\n",
" def process_file(self, file_path):\n",
" # Only process files with specific extensions\n",
" if file_path.endswith(r\".omf\"):\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
" if file_path.endswith(r\".omf\"):\n",
" if file_path.endswith(\".omf\"):\n",

No need for a raw string here.

" def process_file(self, file_path):\n",
" # Only process files with specific extensions\n",
" if file_path.endswith(r\".omf\"):\n",
" field = df.Field.from_file(rf\"{file_path}\")\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also should not need a raw string here.

" angle = np.arctan2(yxa, xxa) # angle of vector line\n",
" mag = np.sqrt(xxa**2 + yxa**2) # magnitude of vector\n",
"\n",
" table = xr.Dataset(\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename object

" def check_observer(self):\n",
" if self.file_count >= self.n + 1:\n",
" print(\"All files produced, stopping monitoring...\")\n",
" self.observer.stop()\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not need to stop the observer here. It will be stopped in main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants