-
Notifications
You must be signed in to change notification settings - Fork 5
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
base: master
Are you sure you want to change the base?
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
There was a problem hiding this 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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"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" |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"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" |
"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()`" |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
" 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", |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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
No description provided.