Skip to content

Commit

Permalink
v0.7.4 (#31)
Browse files Browse the repository at this point in the history
* Removed scardb/phyto module. Removed unecessary dependencies. Updated to 7.4.0

* Updated tests to fix warnings

* Changed mapping to use months instead of seasons for mapbox.

* Updated changelog

* Removed socket.dev badge. Added badge for coverage to testing workflow.

* Made tests run for every push

* Coverage badge bugfix

* Coverage badge bugfix

* Coverage badge bugfix

* Coverage badge bugfix

* Coverage badge bugfix

* Coverage badge bugfix
  • Loading branch information
nikothomas committed Aug 11, 2024
1 parent eaf19b4 commit a565fc7
Show file tree
Hide file tree
Showing 28 changed files with 319 additions and 925 deletions.
32 changes: 0 additions & 32 deletions .github/workflows/sphinxdocs.yml

This file was deleted.

20 changes: 19 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:
branches: [main]
push:
branches: [main]
branches: ['*']

jobs:
run-with-coverage:
Expand Down Expand Up @@ -59,3 +59,21 @@ jobs:
with:
name: coverage-report
path: htmlcov

- name: Get coverage percentage
id: get-coverage
run: |
coverage=$(poetry run pytest --cov=ctdfjorder --cov-report=term | grep TOTAL | awk '{print $4}' | sed 's/%//')
echo "ANSWER=$coverage" >> $GITHUB_ENV
- name: Create the Badge
uses: schneegans/dynamic-badges-action@v1.7.0
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 5ceb7e714da5151b751f668c4cc49013
filename: answer.json
label: Coverage
message: ${{ env.ANSWER }} %
valColorRange: ${{ env.ANSWER }}
maxColorRange: 100
minColorRange: 0
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.13293668.svg#2)](https://doi.org/10.5281/zenodo.13293668)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.13293665.svg#3)](https://doi.org/10.5281/zenodo.13293665)
![Tests](https://github.com/nikothomas/ctdfjorder/actions/workflows/tests.yml/badge.svg?branch=main)
[![PyPI version](https://badge.fury.io/py/ctdfjorder.svg#2)](https://badge.fury.io/py/ctdfjorder)
[![Socket Badge](https://socket.dev/api/badge/pypi/package/ctdfjorder/0.7.3#2)](https://socket.dev/pypi/package/ctdfjorder/overview/0.7.32)
![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/nikothomas/5ceb7e714da5151b751f668c4cc49013/raw/answer.json)
[![PyPI version](https://badge.fury.io/py/ctdfjorder.svg#3)](https://badge.fury.io/py/ctdfjorder)

<p style=text-align:center;>
<img src="https://raw.githubusercontent.com/nikothomas/ctdfjorder/main/logo.png" alt="CTDFjorder Logo"/>
Expand All @@ -15,6 +15,7 @@ Documentation: [Read the docs](https://nikothomas.github.io/ctdfjorder/)
- [<code>🚀 Usage</code>](#-usage)
- [<code>⚠️ Issues</code>](#-issues)
- [<code>📝 License</code>](#-license)
- [<code>📑 Citing CTDFjorder</code>](#-license)
- [<code>📢 Acknowledgments</code>](#-acknowledgments)

## ⭐ Features
Expand Down Expand Up @@ -49,8 +50,11 @@ If you encounter an issue while running or using CTDFjorder, please submit a rep
## 📝 License
CTDFjorder is released under the MIT License.

## 📑 Citing CTDFjorder
Citation information for CTDFjorder can be found here [zenodo.13293665](https://dx.doi.org10/zenodo.13293665>).

## 📢 Acknowledgments
CTDFjorder was developed for the [Fjord Phyto](https://fjordphyto.ucsd.edu) project. The gsw library was used for certain dervied calculations.
CTDFjorder was developed for the [Fjord Phyto](https://fjordphyto.ucsd.edu) project. The [GSW-python](https://github.com/TEOS-10/GSW-Python) library was used for certain dervied calculations.

## Citations
McDougall, T. J., & Barker, P. M. (2011). Getting started with TEOS-10 and the Gibbs Seawater (GSW) Oceanographic Toolbox. SCOR/IAPSO WG127.
Expand Down
37 changes: 22 additions & 15 deletions ctdfjorder/CTD.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,11 @@ def remove_upcasts(self) -> None:
self._is_empty(CTD.remove_upcasts.__name__)

def filter_columns_by_range(
self,
filters: zip = None,
columns: list[str] = None,
upper_bounds: list[float | int] = None,
lower_bounds: list[float | int] = None,
self,
filters: zip = None,
columns: list[str] = None,
upper_bounds: list[float | int] = None,
lower_bounds: list[float | int] = None,
):
"""
Filters columns of the dataset based on specified upper and lower bounds.
Expand Down Expand Up @@ -371,6 +371,7 @@ def filter_columns_by_range(
--------
remove_non_positive_samples : Method to remove rows with non-positive values for specific parameters.
"""

def apply_bounds(profile, column, upper_bound, lower_bound):
if upper_bound is not None:
profile = profile.filter(pl.col(column) <= upper_bound)
Expand All @@ -379,27 +380,31 @@ def apply_bounds(profile, column, upper_bound, lower_bound):
return profile

for profile_id in (
self._data.select(PROFILE_ID_LABEL)
.unique(keep="first")
.to_series()
.to_list()
self._data.select(PROFILE_ID_LABEL)
.unique(keep="first")
.to_series()
.to_list()
):
profile = self._data.filter(pl.col(PROFILE_ID_LABEL) == profile_id)

if filters:
for column, upper_bound, lower_bound in filters:
if column in profile.columns:
profile = apply_bounds(profile, column, upper_bound, lower_bound)
profile = apply_bounds(
profile, column, upper_bound, lower_bound
)
elif columns and upper_bounds and lower_bounds:
for column, upper_bound, lower_bound in zip(columns, upper_bounds, lower_bounds):
for column, upper_bound, lower_bound in zip(
columns, upper_bounds, lower_bounds
):
profile = apply_bounds(profile, column, upper_bound, lower_bound)

self._data = self._data.filter(pl.col(PROFILE_ID_LABEL) != profile_id).vstack(profile)
self._data = self._data.filter(
pl.col(PROFILE_ID_LABEL) != profile_id
).vstack(profile)

self._is_empty(CTD.filter_columns_by_range.__name__)



def remove_non_positive_samples(self) -> None:
r"""
Removes rows with non-positive values for depth, pressure, practical salinity, absolute salinity, or density.
Expand Down Expand Up @@ -1196,7 +1201,9 @@ def add_haline_contraction_coefficient(self) -> None:

self._is_empty(CTD.add_haline_contraction_coefficient.__name__)

def add_mld(self, reference: int, method: str = "potential_density_avg", delta: float = 0.05):
def add_mld(
self, reference: int, method: str = "potential_density_avg", delta: float = 0.05
):
r"""
Calculates and adds the mixed layer depth (MLD) using the density threshold method.
Expand Down
Loading

0 comments on commit a565fc7

Please sign in to comment.