Notebooks for Watchdog demo and drive.pv() demo#76
Notebooks for Watchdog demo and drive.pv() demo#76N-3ielo wants to merge 8 commits intoubermag:masterfrom
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
lang-m
left a comment
There was a problem hiding this comment.
- 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.
| "source": [ | ||
| "## System Setup\n", | ||
| "\n", | ||
| "First we import our modules" |
There was a problem hiding this comment.
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.
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.
| "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" |
| "outputs": [], | ||
| "source": [ | ||
| "class DirectoryMonitorHandler(FileSystemEventHandler):\n", | ||
| " def __init__(self, observer, stop_flag):\n", |
There was a problem hiding this comment.
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.
| " 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.
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", |
| " 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.
You should not need to stop the observer here. It will be stopped in main
No description provided.