Skip to content

Commit

Permalink
Merge pull request #4 from klaundal/installable
Browse files Browse the repository at this point in the history
restructured so the code is installable (thanks to @jvierine)
  • Loading branch information
klaundal authored Jul 15, 2022
2 parents a240eb8 + 5a0e836 commit a61cc18
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 3 deletions.
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,21 @@ See https://www.ngdc.noaa.gov/IAGA/vmod/igrf.html for details and https://doi.or

The code is vectorized, so calculations should be pretty fast.

TODO: Some more testing

## How?
The only dependencies are Numpy and Pandas. There is no install. Just copy ppigrf.py and IGRF13.shc to your working directory and you are good to go. Or have the ppigrf directory somewhere that Python can find it. Then you should be able to import like this:
## Install
The only dependencies are Numpy and Pandas. Install by either
```
pip install ppigrf
```
or clone the repository and run
```
python setup.py install
```

Also, if you don't want to install a module but use the code in your project, just grap ppigrf.py and the .shc file (from src/ppigrf) and place it in your working directory. That's all.

## Example
All the above choices should enable you to import like this:
```python
import ppigrf
```
Expand Down Expand Up @@ -57,6 +68,7 @@ It should be straightforward to swap the IGRF .shc file with another model, but

The code is vectorized, so it will be quite fast, but probably not as fast as compiled Fortran code. One application which may require more optimization is field line tracing: In the current implementation, the coefficients are loaded and interpolated in time for every function call, which gives a lot of unnecessary overhead.

Thanks to Juha Vierinen for the setup script, and for making ppigrf available via PyPI.

## Contact
If you find errors, please let me know!
Expand Down
39 changes: 39 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import setuptools

# Howto
#
#This is how to upload a project to pipy. This is mainly a note to self, as this is the first project I have uplo#aded to pypi:
#
#python3 -m venv /tmp/venv
#source /tmp/venv/bin/activate
#pip install build
#pip install twine
#python3 -m build
#python3 -m twine upload dist/ppigrf-1.0.0.tar.gz

#Genrate long description using readme file
with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()

setuptools.setup(
name="ppigrf",
version="1.0.0",
author="Karl Laundal",
author_email="readme@file.md",
description="Pure Python IGRF",
long_description=long_description,
long_description_content_type="text/markdown",
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Science/Research",
"Natural Language :: English",
"Programming Language :: Python :: 3",
],
install_requires=[
'numpy>=0.13.1',
],
package_dir={"": "src"},
package_data={'':['IGRF13.shc']},
packages=setuptools.find_packages(where="src"),
python_requires=">=3.6",
)
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit a61cc18

Please sign in to comment.