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 2a98a78
Show file tree
Hide file tree
Showing 21 changed files with 108 additions and 295 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.

82 changes: 33 additions & 49 deletions LoadMSPdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@
import dmsp
import dmsp.plots as dmp

try:
import seaborn as sns

sns.set_context("talk", font_scale=1.25)
sns.set_style("ticks")
except ImportError:
pass

"""
Note: elevation from North Horizon, so to get near magnetic zenith at Poker Flat we use elevation angles
FROM NORTH of 95-110 degrees corresponding to symmetric about 77.5 elevation angle
Expand All @@ -36,44 +28,36 @@
-r 0.5 1 3 is a starting point for 6300/4278 ratio
"""


def main():
p = ArgumentParser(
description="reading Poker Flat Research Range Meridian Scanning Photometer"
)
p.add_argument("ncfn", help="netCDF data file name to read")
p.add_argument("-t", "--tlim", help="time window to zoom plot in on", nargs=2)
p.add_argument(
"-e", "--elim", help="elevation limits to plot FROM NORTH HORIZON", nargs=2, type=float
)
p.add_argument(
"-r",
"--ratlim",
help="min,mid,max of ratio plot colormap",
nargs=3,
type=float,
default=[0.5, 1, 3],
)
p.add_argument("--wl", help="wavelengths to ratio [A]", nargs=2)
p.add_argument(
"--elfid",
help="elevation angles at which to place fiducials (for other camera)",
type=float,
nargs=2,
default=[],
)
p.add_argument("-v", "--verbose", action="store_true")
p = p.parse_args()

Intensity = dmsp.load(p.ncfn, p.tlim, p.elim)
dmp.plotmspspectra(Intensity, p.elfid)
# %% ratios
if p.wl:
ratio = Intensity[p.wl[0]] / Intensity[p.wl[1]]
dmp.plotratio(ratio, p.wl, Intensity, p.elfid, p.ratlim, p.verbose)

show()


if __name__ == "__main__":
main()
p = ArgumentParser(description="reading Poker Flat Research Range Meridian Scanning Photometer")
p.add_argument("ncfn", help="netCDF data file name to read")
p.add_argument("-t", "--tlim", help="time window to zoom plot in on", nargs=2)
p.add_argument(
"-e", "--elim", help="elevation limits to plot FROM NORTH HORIZON", nargs=2, type=float
)
p.add_argument(
"-r",
"--ratlim",
help="min,mid,max of ratio plot colormap",
nargs=3,
type=float,
default=[0.5, 1, 3],
)
p.add_argument("--wl", help="wavelengths to ratio [A]", nargs=2)
p.add_argument(
"--elfid",
help="elevation angles at which to place fiducials (for other camera)",
type=float,
nargs=2,
default=[],
)
p.add_argument("-v", "--verbose", action="store_true")
a = p.parse_args()

Intensity = dmsp.load(a.ncfn, a.tlim, a.elim)
dmp.plotmspspectra(Intensity, a.elfid)
# %% ratios
if a.wl:
ratio = Intensity[a.wl[0]] / Intensity[a.wl[1]]
dmp.plotratio(ratio, a.wl, Intensity, a.elfid, a.ratlim, a.verbose)

show()
52 changes: 7 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# 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

![example of PF-DMSP data](tests/demo.png)
![example of PF-DMSP data](src/dmsp/tests/demo.png)

This library is also usable from Matlab, as seen in `dmsp.m`.

Expand All @@ -19,56 +17,20 @@ This library is also usable from Matlab, as seen in `dmsp.m`.
* [other dates](http://optics.gi.alaska.edu/realtime/data/archive/PKR_MSP_X/)
* FTP: ftp://optics.gi.alaska.edu/PKR/DMSP

## Install
Install:

```sh
python -m pip install -e .
```

### Matlab
[LoadMSPdata.py](./LoadMSPdata.py) creates many plots.

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.

Use as a Python module is like:
Use as a Python module:

```python
import dmsp

dat = dmsp.load('~/data/myfile.PF')
```

which returns [xarray.Dataset](http://xarray.pydata.org/en/stable/generated/xarray.Dataset.html)

## Notes

Graphically browse the files with the `ncview` program:

```sh
apt install ncview
```

### Error: libnetcdf.so.7

if you get

> ImportError: libnetcdf.so.7: cannot open shared object file: No such file or directory
try:

```sh
apt install libnetcdf-dev
python -m pip install netcdf4
```

or

```sh
conda install netcdf4
```
which returns [xarray.Dataset](https://docs.xarray.dev/en/stable/generated/xarray.Dataset.html)
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.

31 changes: 30 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
[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__"}

[project.optional-dependencies]
tests = ["pytest"]
lint = ["flake8", "flake8-bugbear", "flake8-builtins", "flake8-blind-except", "mypy",
"types-python-dateutil", "types-requests"]

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

[tool.black]
line-length = 99
Loading

0 comments on commit 2a98a78

Please sign in to comment.