Skip to content

Commit

Permalink
Example notebook, minor fixes, docs
Browse files Browse the repository at this point in the history
  • Loading branch information
oyvfoss committed Sep 2, 2024
1 parent 160c37b commit bafe7d5
Show file tree
Hide file tree
Showing 14 changed files with 1,229 additions and 34 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#### Øyvind's:
#### Custom

misc/laura/
docs/build/
docs/example_notebooks_basic_example/test_data/.mat
docs/example_notebooks_basic_example/test_data/.nc

tests/test_data/*.mat
examples/
graphics/
Expand Down
26 changes: 1 addition & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
![](docs/images/logos_illustrations/kobbe_header.png)


Version 0.0.1: *Under development.*
Version 0.1: *In development.*


Overview
--------
#### [Documentation page](https://kobbe.readthedocs.io/) *(in development)*


Expand All @@ -19,25 +17,3 @@ the ocean surface.

![](docs/images/logos_illustrations/sea_ice_illustration.png)


_____

### **GOAL:**

**Easy and explicit post-processing to obtain scientific-quality estimates of:**

- **Sea ice draft**
- **Sea ice drift velocity**
- **Upper ocean current velocity**
______


Inputs to the process are:

- *.mat* files exported by Norteks [SignatureDeployment](https://www.nortekgroup.com/software) software *(required)*
- Time series of atmospheric pressure during the deployment *(strongly
recommended)*
- Time series of ocean temperature/salinity in the upper ocean *(recommended)*
- Magnetic declination correction (single value or time series) *(necessary for
correct velocity directions)*
______

Large diffs are not rendered by default.

Empty file.
Binary file not shown.
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
sphinx>=5.0.0
myst-parser>=0.18.0
nbsphinx
git+https://github.com/oyvfoss/kobbe.git#egg=kobbe
3 changes: 2 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
'sphinx.ext.coverage',
'sphinx.ext.napoleon',
'myst_parser',
'sphinx.ext.mathjax',] # For LaTeX support]
'sphinx.ext.mathjax',
'nbsphinx'] # For LaTeX support]


myst_enable_extensions = [
Expand Down
3 changes: 2 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
``kobbe``
---------

*Post-processing of ice and ocean data from Nortek Signature ADCPs*
*Post-processing of ice and ocean data from Nortek Signature ADCPs in Python*

Preliminary documentation page.

Expand All @@ -13,4 +13,5 @@ ____
pipeline/pipeline
functions/functions

- `Example notebook <notebooks/Example_notebook_Sig500_ice_draft.ipynb>`_
- `Source code GitHub repository <https://github.com/oyvfoss/kobbe>`_
3 changes: 2 additions & 1 deletion src/kobbe/calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ def footprint(signature: Union[xr.Dataset, str],
Examples
--------
>>> ds = xr.Dataset(attrs={"instrument": "Signature500", "depth": (["time"], [50, 60, 55])})
>>> ds = xr.Dataset(attrs={"instrument": "Signature500",
"depth": (["time"], [50, 60, 55])})
>>> footprint(ds)
Beam width at surface: 2.5 m.
For depth 55.0 m and beam width angle 2.9 degrees (Signature500).
Expand Down
26 changes: 22 additions & 4 deletions src/kobbe/icedraft.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from kobbe import append
import xarray as xr
from typing import Tuple

import pandas as pd

def calculate_draft(
ds: xr.Dataset,
Expand Down Expand Up @@ -374,9 +374,27 @@ def get_open_water_surface_depth_LP(
# 5. Smooth with running mean
RS = runningstat(owds_med_daily_interp, run_window_days)

# Export filtered, ensemble median, daily averaged, smoothed daily owsd.
# Store filtered, ensemble median, daily averaged, smoothed daily owsd.
# Also daily time array (td+0.5) of the midpoint of the daily estimates.
return RS["mean"], time_daily + 0.5
RS_mean = RS["mean"]
timestamp_day = time_daily + 0.5

# 6. Forward and backward fill if we have Nans at the start
# or end (using nice pandas functionlity for this)

if np.isnan(RS_mean).any():

# Create a DataFrame
df_RS = pd.DataFrame(
{'timestamp_day': timestamp_day, 'RS_mean': RS_mean})

# Use ffill and bfill
df_RS['RS_mean'] = df_RS['RS_mean'].ffill().bfill()

# Convert the filled RS_mean column back to a NumPy array
RS_mean = df_RS['RS_mean'].to_numpy()

return RS_mean, timestamp_day


###########
Expand Down Expand Up @@ -743,7 +761,7 @@ def compare_open_water_correction(
leg = axn.legend(ncol=3, fontsize=10, loc=1,
bbox_to_anchor=(0.7, 0.1))
# Set the legend symbols to 100% opacity and make them bigger
for legend_handle in leg.legendHandles:
for legend_handle in leg.legend_handles:
legend_handle.set_alpha(1.0)
legend_handle._sizes = [50]
axn.grid()
Expand Down
2 changes: 1 addition & 1 deletion src/kobbe/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ def to_nc(
"SEA_ICE_DRAFT_LE",
"SEA_ICE_DRAFT_MEDIAN_LE",
"SEA_ICE_DRAFT_AST",
"SEA_ICE_DRAFT_LE",
"SEA_ICE_DRAFT_MEDIAN_AST",
]
if icevel:
varlist += ["uice", "vice", "Uice", "Vice"]
Expand Down

0 comments on commit bafe7d5

Please sign in to comment.