Skip to content

Commit

Permalink
wrap up for version 0.2.2 (#34)
Browse files Browse the repository at this point in the history
+ `version.py`: add release tag for v0.2.2

* `__init__`: explicit list of top-level functions

+ `tests`: remove "test_SET_" prefix for the testing scripts, to reflect the same naming in the src directory.

+ `tests`: add `__main__` function in the testing scripts.

+ `circleci/README`: update the new testing script names
  • Loading branch information
yunjunz authored Jul 21, 2022
1 parent 9a0ce9a commit 6c12499
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 110 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ jobs:
# setup environment variables
export PATH=${CONDA_PREFIX}/bin:${PATH}
# run tests
python ${HOME}/tools/PySolid/tests/test_SET_point.py
python ${HOME}/tools/PySolid/tests/test_SET_grid.py
python ${HOME}/tools/PySolid/tests/point.py
python ${HOME}/tools/PySolid/tests/grid.py
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
*.DS_Store
tests/*.png
tests/*/*.png
solid.txt

# Byte-compiled / optimized / DLL files
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ To test the installation, run the following:

```bash
python -c "import pysolid; print(pysolid.__version__)"
python PySolid/tests/test_SET_grid.py
python PySolid/tests/test_SET_point.py
python PySolid/tests/grid.py
python PySolid/tests/point.py
```

### 2. Usage
Expand Down
5 changes: 0 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,7 @@
"Topic :: Scientific/Engineering",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
],
keywords="solid Eartth tides, deformation, geodesy, geophysics",

Expand Down
18 changes: 13 additions & 5 deletions src/pysolid/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
from pysolid.grid import *
from pysolid.point import *

# get version info
from pysolid.version import *
__version__ = release_version
from pysolid.version import release_version as __version__

# top-level functions
from pysolid.grid import (
calc_solid_earth_tides_grid,
plot_solid_earth_tides_grid,
)
from pysolid.point import (
TIDES,
calc_solid_earth_tides_point,
plot_solid_earth_tides_point,
plot_power_spectral_density4tides,
)
1 change: 1 addition & 0 deletions src/pysolid/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# release history
Tag = collections.namedtuple('Tag', 'version date')
release_history = (
Tag('0.2.2', '2022-07-20'),
Tag('0.2.1', '2022-01-05'),
Tag('0.2.0', '2021-11-10'),
Tag('0.1.2', '2021-02-24'),
Expand Down
53 changes: 53 additions & 0 deletions tests/grid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env python3
# Author: Zhang Yunjun, Jan 2021
# Copyright 2020, by the California Institute of Technology.


import os
import sys
import datetime as dt

import pysolid


if __name__ == '__main__':

# print the file/module path
print('-'*50)
print(os.path.abspath(__file__))

# prepare inputs
dt_obj = dt.datetime(2020, 12, 25, 14, 7, 44)
atr = {
'LENGTH' : 400,
'WIDTH' : 500,
'X_FIRST' : -118.2,
'Y_FIRST' : 33.8,
'X_STEP' : 0.000833333,
'Y_STEP' : -0.000833333,
}

# calculate
(tide_e,
tide_n,
tide_u) = pysolid.calc_solid_earth_tides_grid(dt_obj, atr, verbose=True)

# plot
out_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), 'pic'))
os.makedirs(out_dir, exist_ok=True)

out_fig = os.path.join(out_dir, 'grid.png')
pysolid.plot_solid_earth_tides_grid(
tide_e, tide_n, tide_u, dt_obj,
out_fig=out_fig,
display=False)

# open the plotted figures
if sys.platform in ['linux']:
os.system(f'display {out_fig}')
elif sys.platform in ['darwin']:
os.system(f'open {out_fig}')
elif sys.platform.startswith('win'):
os.system(out_fig)
else:
print(f'Unknown OS system ({sys.platform}). Check results in file: {out_fig}.')
49 changes: 49 additions & 0 deletions tests/point.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env python3
# Author: Zhang Yunjun, Jan 2021
# Copyright 2020, by the California Institute of Technology.


import os
import sys
import datetime as dt

import pysolid


if __name__ == '__main__':

# print the file/module path
print('-'*50)
print(os.path.abspath(__file__))

# prepare inputs
lat, lon = 34.0, -118.0 # Los Angles, CA
dt_obj0 = dt.datetime(2020, 11, 1, 4, 0, 0)
dt_obj1 = dt.datetime(2020, 12, 31, 2, 0, 0)

# calculate
(dt_out,
tide_e,
tide_n,
tide_u) = pysolid.calc_solid_earth_tides_point(lat, lon, dt_obj0, dt_obj1, verbose=False)

# plot
out_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), 'pic'))
os.makedirs(out_dir, exist_ok=True)

out_fig = os.path.join(out_dir, 'point.png')
pysolid.plot_solid_earth_tides_point(
dt_out, tide_e, tide_n, tide_u,
lalo=[lat, lon],
out_fig=out_fig,
display=False)

# open the saved figure
if sys.platform in ['linux']:
os.system(f'display {out_fig}')
elif sys.platform in ['darwin']:
os.system(f'open {out_fig}')
elif sys.platform.startswith('win'):
os.system(out_fig)
else:
print(f'Unknown OS system ({sys.platform}). Check results in file: {out_fig}.')
50 changes: 0 additions & 50 deletions tests/test_SET_grid.py

This file was deleted.

45 changes: 0 additions & 45 deletions tests/test_SET_point.py

This file was deleted.

0 comments on commit 6c12499

Please sign in to comment.