Skip to content

Commit

Permalink
Merge branch 'main' into eleanor-patch-5
Browse files Browse the repository at this point in the history
  • Loading branch information
eleanorfrajka authored Oct 31, 2024
2 parents f9de956 + 8dff4a4 commit 7d76da0
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 24 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,3 @@ jobs:
- name: Full Tests
run: |
python -m pytest -rxs tests/
- name: run notebook
run: |
jupyter nbconvert --to notebook --execute notebooks/demo.ipynb --output=demo-output.ipynb
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ This is a repo to diagnose issues in glider data such as CTD thermal lag.

This is a work in progress, all contributions welcome!


### Usage
### Instal

Install from PyPI with

Expand All @@ -21,6 +20,10 @@ pip install -e .
```
This installs glidertest locally. -e ensures that any edits you make in the files will be picked up by scripts that import functions from glidertest.

### Documentation

Documentation website at [https://callumrollo.github.io/glidertest/](https://callumrollo.github.io/glidertest/)

Check out the example notebook `notebooks/demo.ipynb` for example functionality

As input, glidertest takes [OceanGliders format files](https://github.com/OceanGlidersCommunity/OG-format-user-manual)
Expand Down
Binary file removed docs/source/_static/glider.jpg
Binary file not shown.
Binary file added docs/source/_static/glider.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# General information about the project.
project = 'glidertest'
author = 'Callum Rollo'
author = 'Eleanor Frajka-Williams, Chiara Monforte, Callum Rollo'
copyright = f"{year}, {author}"
release = 'v0.0.1'

Expand Down Expand Up @@ -39,3 +39,5 @@
html_static_path = ['_static']

source_suffix = [".rst", ".md"]

html_logo = "_static/glider.png"
5 changes: 4 additions & 1 deletion docs/source/glidertest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
.. automodule:: glidertest.tools
:members:
:undoc-members:
:show-inheritance:

.. automodule:: glidertest.fetchers
:members:
:undoc-members:
16 changes: 14 additions & 2 deletions glidertest/fetchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,26 @@
"sea076_20230906T0852_delayed.nc": "sha256:bd50b2c1019b49f8c14381de8f78aa67d66e9d9e89607bbcedff246be60e6c92",
"sea055_20220104T1536_R.nc": "sha256:5687c9d7b383713ff730ad4a570689622fe6eb9807e340919d59a83a437773b9",
"sea055_20220104T1536_delayed.nc": "sha256:7f72f8a0398c3d339687d7b7dcf0311036997f6855ed80cae5bbf877e09975a6",
"sea045_20230530T0832_delayed.nc": "sha256:9a97b5b212e9ad751909e175bc01fdc75fd7b7fd784cc59d8e9f29e8bdfb829f",
},
)


def load_sample_dataset(dataset_name="sea076_20230906T0852_delayed.nc"):
def load_sample_dataset(dataset_name="sea045_20230530T0832_delayed.nc"):
"""Download sample datasets for use with glidertest
Args:
dataset_name (str, optional): _description_. Defaults to "sea076_20230906T0852_delayed.nc".
Raises:
ValueError: If the requests dataset is not known, raises a value error
Returns:
xarray.Dataset: Requested sample dataset
"""
if dataset_name in data_source_og.registry.keys():
file_path = data_source_og.fetch(dataset_name)
return xr.open_dataset(file_path)
else:
msg = f"Requested sample dataset {dataset_name} not known"
msg = f"Requested sample dataset {dataset_name} not known. Specify one of the following available datasets: {list(data_source_og.registry.keys())}"
raise ValueError(msg)
20 changes: 10 additions & 10 deletions notebooks/demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"metadata": {},
"outputs": [],
"source": [
"ds\n"
"ds"
]
},
{
Expand Down Expand Up @@ -101,7 +101,7 @@
"outputs": [],
"source": [
"# Basic diagnostics of the watermass properties\n",
"tools.plot_ts_histograms(ds)\n"
"tools.plot_ts_histograms(ds)"
]
},
{
Expand Down Expand Up @@ -228,7 +228,7 @@
"# Let's visually check a section of chlorphyll and see if we observe any NPQ\n",
"fig, ax = plt.subplots(1, 1, figsize=(15, 5))\n",
"\n",
"tools.plot_section_with_srss(ds, 'CHLA', ax, start_time = '2023-09-06', end_time = '2023-09-10', ylim=35)"
"tools.plot_section_with_srss(ds, 'CHLA', ax, start_time = '2023-06-04', end_time = '2023-06-06', ylim=35)"
]
},
{
Expand All @@ -239,9 +239,9 @@
"outputs": [],
"source": [
"# Compute day and night average for chlorophylla and temeparture\n",
"dayT, nightT = tools.day_night_avg(ds, sel_var='TEMP',start_time = '2023-09-06', end_time = '2023-09-10')\n",
"dayS, nightS = tools.day_night_avg(ds, sel_var='PSAL',start_time = '2023-09-06', end_time = '2023-09-10')\n",
"dayC, nightC = tools.day_night_avg(ds, sel_var='CHLA',start_time = '2023-09-06', end_time = '2023-09-10')"
"dayT, nightT = tools.day_night_avg(ds, sel_var='TEMP',start_time = '2023-06-03', end_time = '2023-06-07')\n",
"dayS, nightS = tools.day_night_avg(ds, sel_var='PSAL',start_time = '2023-06-03', end_time = '2023-06-07')\n",
"dayC, nightC = tools.day_night_avg(ds, sel_var='CHLA',start_time = '2023-06-03', end_time = '2023-06-07')"
]
},
{
Expand All @@ -253,9 +253,9 @@
"source": [
"fig, ax = plt.subplots(1, 3, figsize=(15, 5))\n",
"\n",
"tools.plot_daynight_avg( dayT, nightT, ax[0],sel_day='2023-09-08', xlabel='Temperature [C]')\n",
"tools.plot_daynight_avg( dayS, nightS, ax[1],sel_day='2023-09-08', xlabel='Salinity [PSU]')\n",
"tools.plot_daynight_avg( dayC, nightC, ax[2],sel_day='2023-09-08', xlabel='Chlorophyll [mg m-3]')"
"tools.plot_daynight_avg( dayT, nightT, ax[0],sel_day='2023-06-04', xlabel='Temperature [C]')\n",
"tools.plot_daynight_avg( dayS, nightS, ax[1],sel_day='2023-06-04', xlabel='Salinity [PSU]')\n",
"tools.plot_daynight_avg( dayC, nightC, ax[2],sel_day='2023-06-04', xlabel='Chlorophyll [mg m-3]')"
]
},
{
Expand Down Expand Up @@ -372,7 +372,7 @@
"\n",
"* Check for any possible drift in the data that might look suspicious. The great temporal and spatial variability may not allow for such check to be succesful. Evaluation using reference CTD cast data or any other data available in the stufy area is recommended.\n",
"\n",
"Oxygen SOP provides a great summary of the needed processing of salinity data and the vaious difference based on sensor modela nd platform type https://oceangliderscommunity.github.io/Salinity_SOP/sections/salinity_dmqc.html"
"Oxygen SOP provides a great summary of the needed processing of salinity data and the vaious difference based on sensor model and platform type https://oceangliderscommunity.github.io/Salinity_SOP/sections/salinity_dmqc.html"
]
},
{
Expand Down
8 changes: 4 additions & 4 deletions tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ def test_quench_sequence():
if not "TIME" in ds.indexes.keys():
ds = ds.set_xindex('TIME')
fig, ax = plt.subplots()
tools.plot_section_with_srss(ds, 'CHLA', ax,start_time = '2023-09-06', end_time = '2023-09-10', ylim=35)
dayT, nightT = tools.day_night_avg(ds, sel_var='TEMP',start_time = '2023-09-06', end_time = '2023-09-10')
tools.plot_section_with_srss(ds, 'CHLA', ax,start_time = '2023-06-04', end_time = '2023-06-06', ylim=35)
dayT, nightT = tools.day_night_avg(ds, sel_var='TEMP',start_time = '2023-06-04', end_time = '2023-06-06')
fig, ax = plt.subplots()
tools.plot_daynight_avg( dayT, nightT,ax,sel_day='2023-09-08', xlabel='Temperature [C]')
tools.plot_daynight_avg( dayT, nightT,ax,sel_day='2023-06-04', xlabel='Temperature [C]')

def test_temporal_drift():
ds = fetchers.load_sample_dataset()
Expand All @@ -42,4 +42,4 @@ def test_temporal_drift():
def test_profile_check():
ds = fetchers.load_sample_dataset()
tools.check_monotony(ds.PROFILE_NUMBER)
tools.plot_profIncrease(ds)
tools.plot_profIncrease(ds)

0 comments on commit 7d76da0

Please sign in to comment.