-
Notifications
You must be signed in to change notification settings - Fork 17
Add Region Browser with interactive editing functionality (#220, #219) #226
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
Open
Safwannn89
wants to merge
11
commits into
OSOceanAcoustics:main
Choose a base branch
from
Safwannn89:feature/region-browser
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ad68a21
Add Region Browser with interactive editing functionality (#220, #219)
Safwannn89 ef393e4
Refactor Region Browser into modular function
Safwannn89 3770e4f
Fix flake8 errors: remove unused imports and nonlocal declarations
Safwannn89 d43563c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] ff40936
Remove unused nonlocal declarations and fix end of file
Safwannn89 409dc37
Address mentor feedback: rename notebook, remove emojis, clarify work…
Safwannn89 8886d97
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 66e9944
style: Fix PEP8 line length and add missing EOF newline to sample CSV
Safwannn89 b5f7113
Merge branch 'feature/region-browser' of https://github.com/Safwannn8…
Safwannn89 2c3ae11
fix: Remove unused nonlocal declaration to pass Flake8
Safwannn89 2dccea1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| { | ||
|
||
| "cells": [ | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "4c500ef8", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "import xarray as xr\n", | ||
| "import fsspec\n", | ||
| "import pandas as pd\n", | ||
| "import numpy as np\n", | ||
| "import echoshader\n", | ||
| "\n", | ||
| "# S3 Connection\n", | ||
| "S3_URL = \"s3://agr230002-bucket01/hake_data/data_zarr/MVBS/2017/x0062_8_wt_20170731_180848_f0002.zarr\"\n", | ||
| "storage_options = {\"endpoint_url\": \"https://sdsc.osn.xsede.org\"}\n", | ||
| "fs = fsspec.filesystem(\"s3\", anon=True, client_kwargs=storage_options)\n", | ||
| "\n", | ||
| "# Load data\n", | ||
| "ds_ooi = xr.open_zarr(fs.get_mapper(S3_URL), consolidated=False)\n", | ||
| "\n", | ||
| "print(\"\u2705 Data loaded successfully\")\n", | ||
| "print(f\" Echoshader version: {echoshader.__version__}\")" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "cec7ced9", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "import pandas as pd\n", | ||
| "import numpy as np\n", | ||
| "\n", | ||
| "# Create sample hake school regions in Echoregions standard format\n", | ||
| "# Format: region_id (int), time (datetime64[ns] array), depth (float array)\n", | ||
| "\n", | ||
| "sample_df = pd.DataFrame({\n", | ||
| " 'region_id': [1, 2, 3, 4],\n", | ||
| " 'time': [\n", | ||
| " # Region 1: 18:10 - 18:15\n", | ||
| " np.array([\n", | ||
| " '2017-07-31T18:10:00',\n", | ||
| " '2017-07-31T18:15:00',\n", | ||
| " '2017-07-31T18:15:00',\n", | ||
| " '2017-07-31T18:10:00'\n", | ||
| " ], dtype='datetime64[ns]'),\n", | ||
| " \n", | ||
| " # Region 2: 18:20 - 18:25\n", | ||
| " np.array([\n", | ||
| " '2017-07-31T18:20:00',\n", | ||
| " '2017-07-31T18:25:00',\n", | ||
| " '2017-07-31T18:25:00',\n", | ||
| " '2017-07-31T18:20:00'\n", | ||
| " ], dtype='datetime64[ns]'),\n", | ||
| " \n", | ||
| " # Region 3: 18:30 - 18:35\n", | ||
| " np.array([\n", | ||
| " '2017-07-31T18:30:00',\n", | ||
| " '2017-07-31T18:35:00',\n", | ||
| " '2017-07-31T18:35:00',\n", | ||
| " '2017-07-31T18:30:00'\n", | ||
| " ], dtype='datetime64[ns]'),\n", | ||
| " \n", | ||
| " # Region 4: 18:12 - 18:17\n", | ||
| " np.array([\n", | ||
| " '2017-07-31T18:12:00',\n", | ||
| " '2017-07-31T18:17:00',\n", | ||
| " '2017-07-31T18:17:00',\n", | ||
| " '2017-07-31T18:12:00'\n", | ||
| " ], dtype='datetime64[ns]')\n", | ||
| " ],\n", | ||
| " 'depth': [\n", | ||
| " np.array([40.0, 40.0, 80.0, 80.0]), # Region 1 depth bounds\n", | ||
| " np.array([100.0, 100.0, 150.0, 150.0]), # Region 2 depth bounds\n", | ||
| " np.array([50.0, 50.0, 90.0, 90.0]), # Region 3 depth bounds\n", | ||
| " np.array([60.0, 60.0, 100.0, 100.0]) # Region 4 depth bounds\n", | ||
| " ]\n", | ||
| "})\n", | ||
| "\n", | ||
| "print(f\"\u2705 Loaded {len(sample_df)} hake school regions (Echoregions format)\")\n", | ||
| "print(f\" Region IDs: {list(sample_df['region_id'].values)}\")\n", | ||
| "print(\"\\nDataFrame structure:\")\n", | ||
| "print(sample_df)\n", | ||
| "print(\"\\nData types:\")\n", | ||
| "print(f\" region_id: {sample_df['region_id'].dtype}\")\n", | ||
| "print(f\" time: {type(sample_df['time'].iloc[0])}, dtype={sample_df['time'].iloc[0].dtype}\")\n", | ||
| "print(f\" depth: {type(sample_df['depth'].iloc[0])}, dtype={sample_df['depth'].iloc[0].dtype}\")" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "33b74475", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "browser = echoshader.region_browser(\n", | ||
| " ds=ds_ooi,\n", | ||
| " regions_df=sample_df,\n", | ||
| " cache_backgrounds=True\n", | ||
| ")\n", | ||
| "\n", | ||
| "browser.show()\n", | ||
| "\n", | ||
| "print(\"\u2705 Browser ready!\")" | ||
| ] | ||
| } | ||
| ], | ||
| "metadata": { | ||
| "kernelspec": { | ||
| "display_name": "echoshader-dev", | ||
| "language": "python", | ||
| "name": "python3" | ||
| }, | ||
| "language_info": { | ||
| "codemirror_mode": { | ||
| "name": "ipython", | ||
| "version": 3 | ||
| }, | ||
| "file_extension": ".py", | ||
| "mimetype": "text/x-python", | ||
| "name": "python", | ||
| "nbconvert_exporter": "python", | ||
| "pygments_lexer": "ipython3", | ||
| "version": "3.11.14" | ||
| } | ||
| }, | ||
| "nbformat": 4, | ||
| "nbformat_minor": 5 | ||
| } | ||
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 |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| from .core import Echoshader | ||
| from .region_browser import region_browser | ||
|
|
||
| __all__ = ["Echoshader"] | ||
| __all__ = ["Echoshader", "region_browser"] | ||
|
|
||
|
|
||
| from ._echoshader_version import version as __version__ # noqa | ||
| # from .echoshader_version import version as __version__ # noqa | ||
| __version__ = "0.1.0" # Temporary version |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Reply via ReviewNB