Skip to content

Commit

Permalink
update: add tutorial notebook and include new detection criteria in s…
Browse files Browse the repository at this point in the history
…idebar
  • Loading branch information
Beforerr committed Nov 8, 2024
1 parent 9a9f9a5 commit 3842ea8
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 0 deletions.
2 changes: 2 additions & 0 deletions notebooks/_quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ website:
href: index.qmd
- text: "About"
href: about.qmd
- text: Tutorial
href: notebooks/tutorial.qmd
tools:
- icon: github
href: "https://github.com/Beforerr/discontinuitypy"
Expand Down
4 changes: 4 additions & 0 deletions notebooks/sidebar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ website:
- section: detection
contents:
- detection/01_variance.ipynb
- detection/02_TS_criterion.ipynb
- section: missions
contents:
- missions/solo.ipynb
Expand All @@ -27,6 +28,9 @@ website:
contents:
- properties/00_duration.ipynb
- properties/00_mva.ipynb
- section: tutorials
contents:
- tutorials/tutorial.qmd
- section: utils
contents:
- utils/00_basic.ipynb
Expand Down
73 changes: 73 additions & 0 deletions notebooks/tutorials/tutorial.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
jupyter: python3
---

A step-by-step guide to using the package

```{python}
%load_ext autoreload
%autoreload 2
```

```{python}
from datetime import timedelta
from space_analysis.utils.speasy import get_polars_ldf
from discontinuitypy.mission.wind import WindConfigBase, wi_mfi_h2_bgse
from discontinuitypy.config import SpeasyIDsConfig
from discontinuitypy.core.pipeline import ids_finder
from discontinuitypy.detection import detect_variance, detect_gradient
from rich import print
```

```{python}
timerange = ["2021-05-03", "2021-05-04"]
tau = timedelta(seconds=30)
```

```{python}
data = get_polars_ldf(wi_mfi_h2_bgse, 'cda', timerange)
data
```

```{python}
bcols = data.collect_schema().names()
bcols.remove("time")
detect_gradient(data, bcols)
```

```{python}
ids_finder(data, detect_kwargs={"tau": tau})
```

```{python}
detect_variance(data, tau, bcols)
```

We could use the print from rich to print the output in a more readable way.

```{python}
class WindConfig(WindConfigBase, SpeasyIDsConfig):
pass
config = WindConfig(
timerange = timerange,
tau = 30
)
```

```{python}
print(config.model_dump(exclude_none=True))
```

```{python}
config.produce_or_load()
```

```{python}
config.get_data()
```

```{python}
config.mag_meta.data[0].plot()
```

0 comments on commit 3842ea8

Please sign in to comment.