-
Notifications
You must be signed in to change notification settings - Fork 10
Add Parcels meeting presentation material to developer-content #246
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
781bc4a
add presentation material to teacher-content
j-atkins 25d76c3
remove presentation_files, render presentation as self-contained
j-atkins dec7fb2
move to developer-content
j-atkins 529e026
remove from teacher-content
j-atkins 4de3c21
attempt prettier pre-commit fix
j-atkins a13256d
attempt #2 to fix prettier pre-commit hook
j-atkins 295e6a4
Merge branch 'main' into add-parcels-presentation
j-atkins a84099c
ignore html for prettier hooks
j-atkins File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
docs/user-guide/developer-content/parcels-meeting-Nov2025/performance/performance_v03.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import csv | ||
| import subprocess | ||
| import time | ||
|
|
||
| import psutil | ||
|
|
||
| DIRS = ["CTD", "plus_CTD_BGC", "plus_DRIFTER", "plus_ARGO", "plus_UNDERWAY"] | ||
| RESULTS_FILE = "performance_results.csv" | ||
|
|
||
| # Write header once at the start | ||
| with open(RESULTS_FILE, "w", newline="") as csvfile: | ||
| writer = csv.writer(csvfile) | ||
| writer.writerow(["Directory", "Time (s)", "Peak RAM (MB)"]) | ||
|
|
||
|
|
||
| def run_and_trace(cmd): | ||
| start_time = time.time() | ||
| process = subprocess.Popen(cmd, shell=True) | ||
| proc = psutil.Process(process.pid) | ||
| peak_mem = 0 | ||
|
|
||
| while process.poll() is None: | ||
| try: | ||
| mem = proc.memory_info().rss / (1024 * 1024) # MB | ||
| if mem > peak_mem: | ||
| peak_mem = mem | ||
| except psutil.NoSuchProcess: | ||
| break | ||
| time.sleep(0.1) | ||
|
|
||
| end_time = time.time() | ||
| return end_time - start_time, peak_mem | ||
|
|
||
|
|
||
| for dir_name in DIRS: | ||
| cmd = f"virtualship run ../{dir_name}" | ||
| print(f"Running: {cmd}") | ||
| elapsed, peak_mem = run_and_trace(cmd) | ||
| # Write result after each iteration | ||
| with open(RESULTS_FILE, "a", newline="") as csvfile: | ||
| writer = csv.writer(csvfile) | ||
| writer.writerow([dir_name, f"{elapsed:.2f}", f"{peak_mem:.2f}"]) | ||
|
|
||
| print(f"\nResults written to {RESULTS_FILE}") |
44 changes: 44 additions & 0 deletions
44
...r-guide/developer-content/parcels-meeting-Nov2025/performance/performance_v03_fromdata.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import csv | ||
| import subprocess | ||
| import time | ||
|
|
||
| import psutil | ||
|
|
||
| DIRS = ["CTD", "plus_CTD_BGC", "plus_DRIFTER", "plus_ARGO", "plus_UNDERWAY"] | ||
| RESULTS_FILE = "performance_results_fromdata.csv" | ||
|
|
||
| # Write header once at the start | ||
| with open(RESULTS_FILE, "w", newline="") as csvfile: | ||
| writer = csv.writer(csvfile) | ||
| writer.writerow(["Directory", "Time (s)", "Peak RAM (MB)"]) | ||
|
|
||
|
|
||
| def run_and_trace(cmd): | ||
| start_time = time.time() | ||
| process = subprocess.Popen(cmd, shell=True) | ||
| proc = psutil.Process(process.pid) | ||
| peak_mem = 0 | ||
|
|
||
| while process.poll() is None: | ||
| try: | ||
| mem = proc.memory_info().rss / (1024 * 1024) # MB | ||
| if mem > peak_mem: | ||
| peak_mem = mem | ||
| except psutil.NoSuchProcess: | ||
| break | ||
| time.sleep(0.1) | ||
|
|
||
| end_time = time.time() | ||
| return end_time - start_time, peak_mem | ||
|
|
||
|
|
||
| for dir_name in DIRS: | ||
| cmd = f"virtualship run ../{dir_name} --from-data ../data" | ||
| print(f"Running: {cmd}") | ||
| elapsed, peak_mem = run_and_trace(cmd) | ||
| # Write result after each iteration | ||
| with open(RESULTS_FILE, "a", newline="") as csvfile: | ||
| writer = csv.writer(csvfile) | ||
| writer.writerow([dir_name, f"{elapsed:.2f}", f"{peak_mem:.2f}"]) | ||
|
|
||
| print(f"\nResults written to {RESULTS_FILE}") |
94 changes: 94 additions & 0 deletions
94
docs/user-guide/developer-content/parcels-meeting-Nov2025/performance/plot_performance.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| import numpy as np | ||
| import pandas as pd | ||
| from matplotlib import pyplot as plt | ||
|
|
||
| # data | ||
| df_default = pd.read_csv("results/performance_results.csv") | ||
| df_fromdata = pd.read_csv("results/performance_results_fromdata.csv") | ||
|
|
||
| ## plot | ||
| fig, ax = plt.subplots(1, 1, figsize=(12, 7), dpi=96) | ||
|
|
||
| MARKERSIZE = 75 | ||
| LINEWIDTH = 2.5 | ||
| ymin, ymax, interval = 0, 800, 100 | ||
|
|
||
| FROM_DATA = True | ||
| LAST_POINT = True | ||
|
|
||
| SHOW_UNDERWAY_FROMDATA = False | ||
|
|
||
| xticks = [ | ||
| "Just CTD", | ||
| "CTD + CTD_BGC", | ||
| "CTD + CTD_BGC \n+ Drifters", | ||
| "CTD + CTD_BGC \n+ Drifters + Argo Floats", | ||
| "CTD + CTD_BGC \n+ Drifters + Argo Floats \n+ ADCP/Underway S/T", | ||
| ] | ||
|
|
||
| # default | ||
| ax.scatter( | ||
| df_default["Directory"], | ||
| df_default["Time (s)"], | ||
| label="on-the-fly (via copernicusmarine)", | ||
| color="dodgerblue", | ||
| s=MARKERSIZE, | ||
| zorder=3, | ||
| ) | ||
| ax.plot( | ||
| df_default["Directory"], | ||
| df_default["Time (s)"], | ||
| lw=LINEWIDTH, | ||
| ls="dotted", | ||
| color="dodgerblue", | ||
| zorder=3, | ||
| ) | ||
|
|
||
| # fromdata | ||
| if FROM_DATA: | ||
| ax.scatter( | ||
| df_fromdata["Directory"] if LAST_POINT else df_fromdata["Directory"][:-1], | ||
| df_fromdata["Time (s)"] if LAST_POINT else df_fromdata["Time (s)"][:-1], | ||
| label="from-data (pre-downloaded data)", | ||
| color="crimson", | ||
| s=MARKERSIZE, | ||
| zorder=3, | ||
| ) | ||
| ax.plot( | ||
| df_fromdata["Directory"] if LAST_POINT else df_fromdata["Directory"][:-1], | ||
| df_fromdata["Time (s)"] if LAST_POINT else df_fromdata["Time (s)"][:-1], | ||
| lw=LINEWIDTH, | ||
| ls="dotted", | ||
| color="crimson", | ||
| zorder=3, | ||
| ) | ||
|
|
||
| # x/y ticks/lims | ||
| if not SHOW_UNDERWAY_FROMDATA: | ||
| ax.set_ylim(ymin, ymax + interval) | ||
| yticks = np.arange(ymin, ymax + 1, interval) | ||
| elif SHOW_UNDERWAY_FROMDATA: | ||
| ax.set_ylim(ymin, ymax * 5 + interval) | ||
| yticks = np.arange(ymin, ymax * 5 + 1, 5 * interval) | ||
| ax.set_yticks(yticks) | ||
| ax.set_yticklabels([round(val, 0) for val in yticks / 60.0]) # [minutes] | ||
| ax.set_xticks(range(len(xticks))) | ||
| ax.set_xticklabels(xticks, rotation=45, ha="right") | ||
|
|
||
| # axes labels | ||
| ax.set_ylabel("Time (minutes)") | ||
|
|
||
| # grid | ||
| ax.set_facecolor("gainsboro") | ||
| ax.grid(True, alpha=1.0, color="white") | ||
|
|
||
| # title | ||
| # ax.set_title("MHW expedition performance [64GB RAM, 8 cores]") | ||
|
|
||
| plt.legend(loc="upper left") | ||
|
|
||
| plt.tight_layout() | ||
| plt.show() | ||
|
|
||
|
|
||
| # TODO: add machine spec info to plot (annotate or whatever) |
6 changes: 6 additions & 0 deletions
6
...ide/developer-content/parcels-meeting-Nov2025/performance/results/performance_results.csv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| Directory,Time (s),Peak RAM (MB) | ||
| CTD,39.49,0.95 | ||
| plus_CTD_BGC,132.87,0.93 | ||
| plus_DRIFTER,155.63,0.95 | ||
| plus_ARGO,506.98,0.96 | ||
| plus_UNDERWAY,796.10,0.97 |
6 changes: 6 additions & 0 deletions
6
...oper-content/parcels-meeting-Nov2025/performance/results/performance_results_fromdata.csv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| Directory,Time (s),Peak RAM (MB) | ||
| CTD,13.73,0.98 | ||
| plus_CTD_BGC,24.85,0.99 | ||
| plus_DRIFTER,32.48,0.95 | ||
| plus_ARGO,96.63,0.95 | ||
| plus_UNDERWAY,3969.64,0.99 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Make more generic?