Skip to content

Commit

Permalink
use pyproject.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Mar 21, 2024
1 parent 8b46ad5 commit 75e6b57
Show file tree
Hide file tree
Showing 20 changed files with 65 additions and 212 deletions.
20 changes: 0 additions & 20 deletions .coveragerc

This file was deleted.

2 changes: 0 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@
max-line-length = 132
ignore = E501,W504, W503
exclude = .git,__pycache__,.eggs/,doc/,docs/,build/,dist/,archive/
per-file-ignores =
__init__.py:F401
20 changes: 0 additions & 20 deletions .gitattributes

This file was deleted.

36 changes: 15 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,29 @@ on:
push:
paths:
- "*.py"
pull_request:
paths:
- "*.py"
- ".github/workflows/ci.yml"

jobs:

linux:
runs-on: ubuntu-latest
core:

strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/setup-python@v5
with:
python-version: '3.x'

- uses: actions/checkout@v4

- run: pip install .[tests,lint]

- run: flake8

- run: mypy
- run: pytest
working-directory: tests

integration:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, macos-latest]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.x'
- run: pip install .[tests]
- run: pytest
working-directory: tests
4 changes: 0 additions & 4 deletions .lgtm.yml

This file was deleted.

13 changes: 2 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# Digital Meridian Spectrometer

[![image](https://zenodo.org/badge/DOI/10.5281/zenodo.167565.svg)](https://doi.org/10.5281/zenodo.167565)
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/space-physics/digital-meridian-spectrometer.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/space-physics/digital-meridian-spectrometer/context:python)
![ci](https://github.com/space-physics/digital-meridian-spectrometer/workflows/ci/badge.svg)
[![PyPi version](https://img.shields.io/pypi/pyversions/dmsp.svg)](https://pypi.python.org/pypi/dmsp)
[![PyPi Download stats](http://pepy.tech/badge/dmsp)](http://pepy.tech/project/dmsp)
[![ci](https://github.com/space-physics/digital-meridian-spectrometer/actions/workflows/ci.yml/badge.svg)](https://github.com/space-physics/digital-meridian-spectrometer/actions/workflows/ci.yml)
[![PyPI Download stats](http://pepy.tech/badge/dmsp)](http://pepy.tech/project/dmsp)

For Geophysical Institute's Poker Flat Digital Meridian Spectrometer, which uses NetCDF

Expand All @@ -25,13 +23,6 @@ This library is also usable from Matlab, as seen in `dmsp.m`.
python -m pip install -e .
```

### Matlab

Matlab users need:

* Matlab ≥ R2018b
* `dmsp` package installed into the [Python environment associated with Matlab](https://www.scivision.dev/matlab-python-user-module-import/#switching-python-version)

## Usage

`LoadMSPdata.py` creates many plots.
Expand Down
19 changes: 0 additions & 19 deletions archive/.appveyor.yml

This file was deleted.

33 changes: 0 additions & 33 deletions archive/.travis.yml

This file was deleted.

17 changes: 0 additions & 17 deletions dmsp/__init__.py

This file was deleted.

12 changes: 0 additions & 12 deletions mypy.ini

This file was deleted.

26 changes: 25 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
[build-system]
requires = ["setuptools", "wheel"]
requires = ["setuptools>=61.0.0", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "dmsp"
description = "Load and plot UAF Geophysical Institute Digital Meridian Spectrometer data"
keywords = [ "aurora", "spectrograph" ]
classifiers = [
"Development Status :: 4 - Beta",
"Environment :: Console",
"Intended Audience :: Science/Research",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering :: Atmospheric Science"
]
dependencies = ["netCDF4", "xarray", "numpy", "python-dateutil"]
requires-python = ">=3.8"
dynamic = ["version", "readme"]

[tool.setuptools.dynamic]
readme = {file = ["README.md"], content-type = "text/markdown"}
version = {attr = "dmsp.__version__"}

[tool.mypy]
files = ["src"]
ignore_missing_imports = true

[tool.black]
line-length = 99
43 changes: 0 additions & 43 deletions setup.cfg

This file was deleted.

4 changes: 0 additions & 4 deletions setup.py

This file was deleted.

5 changes: 5 additions & 0 deletions src/dmsp/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .io import load

__version__ = "1.0.0"

__all__ = ["load"]
11 changes: 9 additions & 2 deletions dmsp/io.py → src/dmsp/io.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import annotations
from pathlib import Path
from typing import Tuple
import typing

from netCDF4 import Dataset
import xarray
import numpy as np
Expand All @@ -8,7 +10,9 @@


def load(
fn: Path, tlim: Tuple[datetime, datetime] = None, elevlim: Tuple[float, float] = None
fn: Path,
tlim: tuple[datetime, datetime] | None = None,
elevlim: tuple[float, float] | None = None,
) -> xarray.Dataset:
"""
This function works with 1983-2010 netCDF3 as well as 2011-present netCDF4 files.
Expand All @@ -28,6 +32,8 @@ def load(
secdayutc = f["Time"][:]
# convert to datetimes -- need as ndarray for next line
t = np.array([d0 + timedelta(seconds=int(s)) for s in secdayutc])

tind: typing.Any
if tlim is not None and len(tlim) == 2:
if isinstance(tlim[0], str):
tlim = [parse(t) for t in tlim]
Expand All @@ -39,6 +45,7 @@ def load(
elevation is not stored anywhere in the data files...
"""
elv = np.arange(181.0)
elind: typing.Any
if elevlim is not None and len(elevlim) == 2:
elind = (elevlim[0] <= elv) & (elv <= elevlim[1])
else:
Expand Down
7 changes: 5 additions & 2 deletions dmsp/plots.py → src/dmsp/plots.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from datetime import datetime
import typing

import numpy as np
import xarray
from matplotlib.pyplot import figure
Expand Down Expand Up @@ -109,7 +111,7 @@ def plotratio(
ratio = ratio.T

fg = figure(figsize=(20, 12))
ax = fg.subplots(3, 1, sharex=True)
ax: typing.Any = fg.subplots(3, 1, sharex=True)

spectrasubplot(dat, fg, ax[:2], elfid, True, [1e3, 1e4]) # FIXME make ratlim based

Expand Down Expand Up @@ -149,7 +151,8 @@ def plotratio(
nrow = nsub // ncol

fg = figure()
axs = fg.subplots(nrow, ncol, sharey=True, sharex=True)
axs: typing.Any = fg.subplots(nrow, ncol, sharey=True, sharex=True)

for i, ax in enumerate(axs.ravel()):
if i == nsub:
break
Expand Down
File renamed without changes.
File renamed without changes
File renamed without changes.
5 changes: 4 additions & 1 deletion dmsp/ticks.py → src/dmsp/ticks.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
"""These functions separated due to time-consuming imports"""

from datetime import timedelta

import numpy as np
import xarray

from matplotlib.dates import DateFormatter
from matplotlib.dates import MinuteLocator, SecondLocator


def tickfix(t, fg, ax, tfmt: str = "%H:%M:%S"):
def tickfix(t, fg, ax, tfmt: str = "%H:%M:%S") -> None:
majtick, mintick = timeticks(t[-1] - t[0])
if majtick:
ax.xaxis.set_major_locator(majtick)
Expand Down

0 comments on commit 75e6b57

Please sign in to comment.