Skip to content
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

feat: Add telemac support #28

Merged
merged 2 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ on:
- main
- master
paths:
- '**.py'
- '.github/workflows/test*.yml'
- 'pyproject.toml'
- 'poetry.lock'
- 'conda-lock.yml'
- 'requirements/*'
- "**.py"
- ".github/workflows/test*.yml"
- "pyproject.toml"
- "poetry.lock"
- "conda-lock.yml"
- "requirements/*"
pull_request:
paths:
- '**.py'
- '.github/workflows/test*.yml'
- 'pyproject.toml'
- 'poetry.lock'
- 'conda-lock.yml'
- 'requirements/*'
- "**.py"
- ".github/workflows/test*.yml"
- "pyproject.toml"
- "poetry.lock"
- "conda-lock.yml"
- "requirements/*"

jobs:
run_tests:
Expand All @@ -30,11 +30,14 @@ jobs:
matrix:
os:
- "ubuntu"
- "macos"
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
include:
- os: "macos"
python-version: "3.9"
runs-on: "${{ matrix.os }}-latest"
defaults:
run:
Expand All @@ -53,7 +56,7 @@ jobs:
path: "~/conda_pkgs_dir"
key: "conda-${{ runner.os }}-${{ hashFiles( env.LOCK_FILE ) }}-${{ env.CACHE_NUMBER }}"
- name: "Setup conda"
uses: "conda-incubator/setup-miniconda@v2"
uses: "conda-incubator/setup-miniconda@v3"
with:
activate-environment: "inspectds_ci"
# python-version: ${{ matrix.python-version }}
Expand Down
43 changes: 34 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

---
ci:
skip: ["mypy"]
Expand Down Expand Up @@ -54,7 +53,7 @@ repos:

- repo: "https://github.com/charliermarsh/ruff-pre-commit"
# Ruff version.
rev: 'v0.4.7'
rev: "v0.4.7"
hooks:
- id: "ruff"

Expand All @@ -70,18 +69,44 @@ repos:
- id: "poetry-lock"
args: ["--check"]
- id: "poetry-export"
name: 'poetry export main'
args: ["--without-hashes", "-f", "requirements.txt", "-o", "requirements/requirements.txt"]
name: "poetry export main"
args:
[
"--without-hashes",
"-f",
"requirements.txt",
"-o",
"requirements/requirements.txt",
]
- id: "poetry-export"
name: 'poetry export main + grib'
args: ["--without-hashes", "-E", "grib", "-f", "requirements.txt", "-o", "requirements/requirements-extras.txt"]
name: "poetry export main + grib"
args:
[
"--without-hashes",
"-E",
"all",
"-f",
"requirements.txt",
"-o",
"requirements/requirements-extras.txt",
]
- id: "poetry-export"
name: 'poetry export dev'
args: ["--without-hashes", "--with", "dev", "-E", "grib", "-f", "requirements.txt", "-o", "requirements/requirements-dev.txt"]
name: "poetry export dev"
args:
[
"--without-hashes",
"--with",
"dev",
"-E",
"all",
"-f",
"requirements.txt",
"-o",
"requirements/requirements-dev.txt",
]

- repo: "local"
hooks:

- id: "mypy"
name: "mypy"
entry: "make mypy"
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ list:
@LC_ALL=C $(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | grep -E -v -e '^[^[:alnum:]]' -e '^$@$$'

init:
poetry install --with=dev -E grib
poetry install --with=dev -E all
pre-commit install

style:
Expand All @@ -27,18 +27,23 @@ conda_lock_ci:
conda-lock lock --mamba --check-input-hash --platform linux-64 --platform osx-64 -f ci/py3.9.yml --lockfile ci/conda-lock-py3.9.yml
conda-lock lock --mamba --check-input-hash --platform linux-64 --platform osx-64 -f ci/py3.10.yml --lockfile ci/conda-lock-py3.10.yml
conda-lock lock --mamba --check-input-hash --platform linux-64 --platform osx-64 -f ci/py3.11.yml --lockfile ci/conda-lock-py3.11.yml
conda-lock lock --mamba --check-input-hash --platform linux-64 --platform osx-64 -f ci/py3.12.yml --lockfile ci/conda-lock-py3.12.yml
conda-lock render --platform linux-64 --filename-template ci/conda-lock-{platform}-py3.9 ci/conda-lock-py3.9.yml
conda-lock render --platform linux-64 --filename-template ci/conda-lock-{platform}-py3.10 ci/conda-lock-py3.10.yml
conda-lock render --platform linux-64 --filename-template ci/conda-lock-{platform}-py3.11 ci/conda-lock-py3.11.yml
conda-lock render --platform linux-64 --filename-template ci/conda-lock-{platform}-py3.12 ci/conda-lock-py3.12.yml
conda-lock render --platform osx-64 --filename-template ci/conda-lock-{platform}-py3.9 ci/conda-lock-py3.9.yml
conda-lock render --platform osx-64 --filename-template ci/conda-lock-{platform}-py3.10 ci/conda-lock-py3.10.yml
conda-lock render --platform osx-64 --filename-template ci/conda-lock-{platform}-py3.11 ci/conda-lock-py3.11.yml
conda-lock render --platform osx-64 --filename-template ci/conda-lock-{platform}-py3.12 ci/conda-lock-py3.12.yml
mv ci/conda-lock-linux-64-py3.9 ci/conda-lock-Linux-64-py3.9
mv ci/conda-lock-linux-64-py3.10 ci/conda-lock-Linux-64-py3.10
mv ci/conda-lock-linux-64-py3.11 ci/conda-lock-Linux-64-py3.11
mv ci/conda-lock-linux-64-py3.12 ci/conda-lock-Linux-64-py3.12
mv ci/conda-lock-osx-64-py3.9 ci/conda-lock-macOS-64-py3.9
mv ci/conda-lock-osx-64-py3.10 ci/conda-lock-macOS-64-py3.10
mv ci/conda-lock-osx-64-py3.11 ci/conda-lock-macOS-64-py3.11
mv ci/conda-lock-osx-64-py3.12 ci/conda-lock-macOS-64-py3.12

conda_lock:
conda-lock lock --mamba --check-input-hash -f pyproject.toml --lockfile conda-lock.yml
Expand Down
48 changes: 43 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,41 @@

A CLI utility to print metadata of datasets in various formats (e.g. NetCDF, zarr, GRIB etc)

*powered by [xarray](https://github.com/pydata/xarray)*
_powered by [xarray](https://github.com/pydata/xarray)_

## Prerequisites

You need the following binary dependencies:

- Python >= 3.9
- Optionally, [eccodes](https://github.com/ecmwf/eccodes), which is necessary for GRIB support.
- Optionally, [eccodes](https://github.com/ecmwf/eccodes), which is necessary for GRIB support.

## Installation

The recommended way of installation is [pipx](https://github.com/pypa/pipx):

```
pipx install inspectds
```

# or if you want support for GRIB
or if you want support for GRIB, SELAFIN or both:

```
pipx install 'inspectds[grib]'
pipx install 'inspectds[selafin]'
pipx install 'inspectds[all]'
```

If you want to install the latest development version from git, then use:

```
pipx install 'git+https://github.com/pmav99/inspectds.git#egg=inspectds[grib]'
pipx install 'git+https://github.com/pmav99/inspectds.git#egg=inspectds[all]'
```

## Usage

### Netcdf

```
$ inspectds tests/data/example_1.nc

Expand Down Expand Up @@ -63,6 +69,7 @@ Data variables:
```

### GRIB

```
$ inspectds tests/data/example.grib

Expand All @@ -80,10 +87,41 @@ Data variables:
t (number, time, isobaricInhPa, latitude, longitude) float32 ...
```

### SELAFIN

```
$ inspectds tests/data/iceland.slf
Dimensions: (time: 13, node: 3526)
Coordinates:
x (node) float32 14kB -13.99 -14.97 -15.89 ... -13.52 -16.31 -12.28
y (node) float32 14kB 57.38 60.19 69.79 63.11 ... 66.37 69.34 63.52
* time (time) datetime64[ns] 104B 2017-10-01 ... 2017-10-01T12:00:00
Data variables:
S (time, node) float32 183kB ...
```

### More info:

```
inspectds --help
$ inspectds --help

Usage: inspectds [OPTIONS] PATH

╭─ Arguments ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ * path PATH The path to the dataset [default: None] [required] │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Options ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --dataset-type [auto|netcdf|zarr|grib|selafin] The dataset type. If 'auto', then it gets inferred from PATH [default: auto] │
│ --mask-and-scale --no-mask-and-scale Whether to mask and scale the dataset [default: no-mask-and-scale] │
│ --dimensions --no-dimensions Whether to include 'Dimensions' in the output [default: dimensions] │
│ --coordinates --no-coordinates Whether to include 'Coordinates' in the output [default: coordinates] │
│ --variables --no-variables Whether to include 'Variables' in the output [default: variables] │
│ --variable-attributes --no-variable-attributes Whether to include the variable attributes in the output [default: no-variable-attributes] │
│ --global-attributes --no-global-attributes Whether to include the global attributes in the output [default: no-global-attributes] │
│ --full --no-full Display full output. Overrides any other option [default: no-full] │
│ --version Display the version │
│ --help Show this message and exit. │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
```

## Development
Expand Down
Loading