[Git][debian-gis-team/pysolid][upstream] New upstream version 0.2.3
Antonio Valentino (@antonio.valentino)
gitlab at salsa.debian.org
Fri Oct 28 08:02:12 BST 2022
Antonio Valentino pushed to branch upstream at Debian GIS Project / pysolid
Commits:
0e4e5b70 by Antonio Valentino at 2022-10-28T06:50:49+00:00
New upstream version 0.2.3
- - - - -
10 changed files:
- + .github/workflows/publish-to-test-pypi.yml
- README.md
- docs/plot_grid_SET.ipynb
- docs/plot_point_SET.ipynb
- setup.py
- src/pysolid/__init__.py
- src/pysolid/grid.py
- src/pysolid/point.py
- src/pysolid/solid.for
- src/pysolid/version.py
Changes:
=====================================
.github/workflows/publish-to-test-pypi.yml
=====================================
@@ -0,0 +1,72 @@
+# link: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
+name: publish distributions 📦 to PyPI and TestPyPI
+
+on:
+ push:
+ branches:
+ - main
+ tags:
+ - v*
+
+# activate miniconda environment
+# link: https://github.com/marketplace/actions/provision-with-micromamba#IMPORTANT
+defaults:
+ run:
+ shell: bash -l {0}
+
+jobs:
+ build-n-publish:
+ if: github.repository_owner == 'insarlab'
+
+ name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout at v3
+ with:
+ fetch-depth: 0
+
+ - name: Set up Python 3.10
+ uses: actions/setup-python at v3
+ with:
+ python-version: "3.10"
+
+ # link: https://github.com/marketplace/actions/provision-with-micromamba
+ - name: Install Conda environment with Micromamba
+ uses: mamba-org/provision-with-micromamba at main
+ with:
+ environment-file: environment.yml
+
+ - name: Install pypa/build
+ run: >-
+ python -m
+ pip install
+ build
+ --user
+
+ - name: Build a binary wheel and a source tarball
+ run: >-
+ python -m
+ build
+ --sdist
+ --no-isolation # not install in an isolated environment
+ --outdir dist/
+ .
+ # skip due to the bad request error from pypi:
+ # binary wheel has an unsupported platform tag 'linux_x86_64'
+ #--wheel
+
+ - name: Publish developed version 📦 to Test PyPI
+ if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main'
+ uses: pypa/gh-action-pypi-publish at release/v1
+ with:
+ password: ${{ secrets.TEST_PYPI_API_TOKEN }}
+ repository_url: https://test.pypi.org/legacy/
+ skip_existing: false
+ verbose: true
+
+ - name: Publish released version 📦 to PyPI
+ if: startsWith(github.ref, 'refs/tags/v')
+ uses: pypa/gh-action-pypi-publish at release/v1
+ with:
+ password: ${{ secrets.PYPI_API_TOKEN }}
+ verbose: true
=====================================
README.md
=====================================
@@ -1,7 +1,7 @@
[](https://www.python.org/)
[](https://circleci.com/gh/insarlab/PySolid)
[](https://github.com/insarlab/PySolid/releases)
-[](https://github.com/insarlab/PySolid/blob/main/LICENSE)
+[](https://github.com/insarlab/PySolid/blob/main/LICENSE)
[](https://doi.org/10.1109/TGRS.2022.3168509)
## PySolid
@@ -82,7 +82,7 @@ PySolid could compute solid Earth tides in two modes: **point** and **grid**. Bo
+ **Point mode:** compute 1D tides time-series at a specific point for a given time period
+ **Grid mode:** compute 2D tides grid at a specific time for a given spatial grid
-#### 2.1 Point Mode [[nbviewer](https://nbviewer.jupyter.org/github/insarlab/PySolid/blob/main/docs/plot_point_SET.ipynb)]
+#### 2.1 Point Mode [[notebook](./docs/plot_point_SET.ipynb)]
```python
import datetime as dt
@@ -95,13 +95,12 @@ dt0 = dt.datetime(2020, 1, 1, 4, 0, 0) # start date and time
dt1 = dt.datetime(2021, 1, 1, 2, 0, 0) # end date and time
# compute SET via pysolid
-(dt_out,
- tide_e,
- tide_n,
- tide_u) = pysolid.calc_solid_earth_tides_point(lat, lon, dt0, dt1,
- step_sec=step_sec,
- display=False,
- verbose=False)
+dt_out, tide_e, tide_n, tide_u = pysolid.calc_solid_earth_tides_point(
+ lat, lon, dt0, dt1,
+ step_sec=step_sec,
+ display=False,
+ verbose=False,
+)
# plot the power spectral density of SET up component
pysolid.plot_power_spectral_density4tides(tide_u, sample_spacing=step_sec)
@@ -112,7 +111,7 @@ pysolid.plot_power_spectral_density4tides(tide_u, sample_spacing=step_sec)
<img width="600" src="https://yunjunzhang.files.wordpress.com/2021/01/set_psd-1.png">
</p>
-#### 2.2 Grid Mode [[nbviewer](https://nbviewer.jupyter.org/github/insarlab/PySolid/blob/main/docs/plot_grid_SET.ipynb)]
+#### 2.2 Grid Mode [[notebook](./docs/plot_grid_SET.ipynb)]
```python
import datetime as dt
@@ -121,7 +120,7 @@ import pysolid
# prepare inputs
dt_obj = dt.datetime(2020, 12, 25, 14, 7, 44)
-atr = {
+meta = {
'LENGTH' : 500, # number of rows
'WIDTH' : 450, # number of columns
'X_FIRST': -126, # min longitude in degree (upper left corner of the upper left pixel)
@@ -131,17 +130,19 @@ atr = {
}
# compute SET via pysolid
-(tide_e,
- tide_n,
- tide_u) = pysolid.calc_solid_earth_tides_grid(dt_obj, atr,
- display=False,
- verbose=True)
+tide_e, tide_n, tide_u = pysolid.calc_solid_earth_tides_grid(
+ dt_obj, meta,
+ display=False,
+ verbose=True,
+)
# project SET from ENU to radar line-of-sight (LOS) direction with positive for motion towards satellite
-inc_angle = 34.0 / 180. * np.pi # radian, typical value for Sentinel-1
-head_angle = -168.0 / 180. * np.pi # radian, typical value for Sentinel-1 desc track
-tide_los = ( tide_e * np.sin(inc_angle) * np.cos(head_angle) * -1
- + tide_n * np.sin(inc_angle) * np.sin(head_angle)
+# inc_angle : incidence angle of the LOS vector (from ground to radar platform) measured from vertical.
+# az_angle : azimuth angle of the LOS vector (from ground to radar platform) measured from the north, with anti-clockwirse as positive.
+inc_angle = np.deg2rad(34) # radian, typical value for Sentinel-1
+az_angle = np.deg2rad(-102) # radian, typical value for Sentinel-1 descending track
+tide_los = ( tide_e * np.sin(inc_angle) * np.sin(az_angle) * -1
+ + tide_n * np.sin(inc_angle) * np.cos(az_angle)
+ tide_u * np.cos(inc_angle))
```
=====================================
docs/plot_grid_SET.ipynb
=====================================
The diff for this file was not included because it is too large.
=====================================
docs/plot_point_SET.ipynb
=====================================
@@ -68,13 +68,12 @@
"dt1 = dt.datetime(2021,1,1,2,0,0)\n",
"\n",
"# run\n",
- "(dt_out,\n",
- " tide_e,\n",
- " tide_n,\n",
- " tide_u) = pysolid.calc_solid_earth_tides_point(lat, lon, dt0, dt1,\n",
- " step_sec=step_sec,\n",
- " display=False,\n",
- " verbose=False)"
+ "dt_out, tide_e, tide_n, tide_u = pysolid.calc_solid_earth_tides_point(\n",
+ " lat, lon, dt0, dt1,\n",
+ " step_sec=step_sec,\n",
+ " display=False,\n",
+ " verbose=False,\n",
+ ")"
]
},
{
@@ -331,7 +330,7 @@
],
"metadata": {
"kernelspec": {
- "display_name": "Python 3",
+ "display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
@@ -345,7 +344,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.7.9"
+ "version": "3.8.13"
}
},
"nbformat": 4,
=====================================
setup.py
=====================================
@@ -1,48 +1,61 @@
# Author: Zhang Yunjun, Jan 2021
# Copyright 2020, by the California Institute of Technology.
+# Note by Yunjun, Oct 2022: "pip install pysolid" does not work,
+# because a Fortran compiler is required but not available via pip
+import os
+import sys
+
# always prefer setuptools over distutils
import setuptools
from numpy.distutils.core import setup, Extension
-# Grab from version.py file: version
-with open("src/pysolid/version.py", "r") as f:
- lines = f.readlines()
- line = [line for line in lines if line.strip().startswith("Tag(")][0].strip()
- version = line.replace("'",'"').split('"')[1]
+# Grab from pysolid.version: version
+# link: https://stackoverflow.com/questions/53648900
+sys.path.append(os.path.join(os.path.dirname(__file__), 'src'))
+from pysolid.version import version
-# specify fortran extensions to build with numpy.f2py
-solid_ext = Extension(name='pysolid.solid', sources=['src/pysolid/solid.for'])
+# Grab from README file: long_description
+with open("README.md", "r") as f:
+ long_description = f.read()
setup(
name='pysolid',
version=version,
description="A Python wrapper for solid to compute solid Earth tides",
url="https://github.com/insarlab/PySolid",
-
+ download_url=("https://github.com/insarlab/PySolid/archive/v{}.tar.gz".format(version)),
+ long_description=long_description,
+ long_description_content_type="text/markdown",
author="Zhang Yunjun, Dennis Milbert",
author_email="yunjunzgeo at gmail.com",
-
- license='GPL-3.0-or-later',
- license_files=('LICENSE',),
+ license="GPL-3.0-or-later",
+ license_files=("LICENSE",),
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering",
- "License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
+ "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
],
keywords="solid Eartth tides, deformation, geodesy, geophysics",
+ project_urls={
+ "Bug Reports": "https://github.com/insarlab/PySolid/issues",
+ "Source": "https://github.com/insarlab/PySolid",
+ },
+
# package discovery
packages=setuptools.find_packages("src"), # include all packages under src
package_dir={"": "src"}, # tell distutils packages are under src
# build fortran deps with numpy.f2py
- ext_modules=[solid_ext],
+ ext_modules=[
+ Extension(name='pysolid.solid', sources=['src/pysolid/solid.for']),
+ ],
# dependencies
python_requires=">=3.6",
@@ -58,9 +71,4 @@ setup(
package_data={
"pysolid": ["solid.for"],
},
-
- project_urls={
- "Bug Reports": "https://github.com/insarlab/PySolid/issues",
- "Source": "https://github.com/insarlab/PySolid",
- },
)
=====================================
src/pysolid/__init__.py
=====================================
@@ -1,5 +1,5 @@
# get version info
-from pysolid.version import release_version as __version__
+from pysolid.version import version as __version__
# top-level functions
from pysolid.grid import (
=====================================
src/pysolid/grid.py
=====================================
@@ -11,19 +11,12 @@
# pysolid.calc_solid_earth_tides_grid()
+import datetime as dt
import os
+
import numpy as np
-import datetime as dt
from skimage.transform import resize
-try:
- from pysolid.solid import solid_grid
-except ImportError:
- msg = "Cannot import name 'solid' from 'pysolid'!"
- msg += '\n Maybe solid.for is NOT compiled yet.'
- msg += '\n Check instruction at: https://github.com/insarlab/PySolid.'
- raise ImportError(msg)
-
################################## Earth tides - grid mode ###################################
def calc_solid_earth_tides_grid(dt_obj, atr, step_size=1e3, display=False, verbose=True):
@@ -49,6 +42,14 @@ def calc_solid_earth_tides_grid(dt_obj, atr, step_size=1e3, display=False, verbo
Examples: atr = readfile.read_attribute('geo_velocity.h5')
tide_e, tide_n, tide_u = calc_solid_earth_tides_grid('20180219', atr)
"""
+ try:
+ from pysolid.solid import solid_grid
+ except ImportError:
+ msg = "Cannot import name 'solid' from 'pysolid'!"
+ msg += '\n Maybe solid.for is NOT compiled yet.'
+ msg += '\n Check instruction at: https://github.com/insarlab/PySolid.'
+ raise ImportError(msg)
+
vprint = print if verbose else lambda *args, **kwargs: None
# location
=====================================
src/pysolid/point.py
=====================================
@@ -11,20 +11,13 @@
# pysolid.calc_solid_earth_tides_point()
-import os
import collections
import datetime as dt
+import os
+
import numpy as np
-from scipy import signal
from matplotlib import pyplot as plt, ticker, dates as mdates
-
-try:
- from pysolid.solid import solid_point
-except ImportError:
- msg = "Cannot import name 'solid' from 'pysolid'!"
- msg += '\n Maybe solid.for is NOT compiled yet.'
- msg += '\n Check instruction at: https://github.com/insarlab/PySolid.'
- raise ImportError(msg)
+from scipy import signal
## Tidal constituents
@@ -168,6 +161,13 @@ def calc_solid_earth_tides_point_per_day(lat, lon, date_str, step_sec=60):
tide_n,
tide_u) = calc_solid_earth_tides_point_per_day(34.0, -118.0, '20180219')
"""
+ try:
+ from pysolid.solid import solid_point
+ except ImportError:
+ msg = "Cannot import name 'solid' from 'pysolid'!"
+ msg += '\n Maybe solid.for is NOT compiled yet.'
+ msg += '\n Check instruction at: https://github.com/insarlab/PySolid.'
+ raise ImportError(msg)
## calc solid Earth tides and write to text file
txt_file = os.path.abspath('solid.txt')
=====================================
src/pysolid/solid.for
=====================================
@@ -1549,9 +1549,9 @@
***** http://www.csgnetwork.com/julianmodifdateconv.html
implicit double precision(a-h,o-z)
- !*** upper limit, leap second table, 2022dec28
+ !*** upper limit, leap second table, 2023jun28
!*** lower limit, leap second table, 1972jan01
- parameter(MJDUPPER=59941)
+ parameter(MJDUPPER=60123)
parameter(MJDLOWER=41317)
!*** leap second table limit flag
@@ -1632,7 +1632,7 @@
***** other leap second references at:
***** http://hpiers.obspm.fr/eoppc/bul/bulc/Leap_Second_History.dat
***** http://hpiers.obspm.fr/eoppc/bul/bulc/bulletinc.dat
-***** File expires on 28 December 2022
+***** File expires on 28 June 2023
*** test against newest leaps first
=====================================
src/pysolid/version.py
=====================================
@@ -4,10 +4,15 @@
import collections
+import os
+import subprocess
+
+###########################################################################
# release history
Tag = collections.namedtuple('Tag', 'version date')
release_history = (
+ Tag('0.2.3', '2022-10-23'),
Tag('0.2.2', '2022-07-20'),
Tag('0.2.1', '2022-01-05'),
Tag('0.2.0', '2021-11-10'),
@@ -17,5 +22,41 @@ release_history = (
)
# latest release
-release_version = 'v{}'.format(release_history[0].version)
+release_version = release_history[0].version
release_date = release_history[0].date
+
+# get development version info
+def get_version_info():
+ """Grab version and date of the latest commit from a git repository"""
+ # go to the repository directory
+ dir_orig = os.getcwd()
+ os.chdir(os.path.dirname(os.path.dirname(__file__)))
+
+ try:
+ # grab from git cmd
+ cmd = "git describe --tags"
+ version = subprocess.check_output(cmd.split(), stderr=subprocess.DEVNULL)
+ version = version.decode('utf-8').strip()[1:]
+
+ # if there are new commits after the latest release
+ if '-' in version:
+ version, num_commit = version.split('-')[:2]
+ version += f'-{num_commit}'
+
+ cmd = "git log -1 --date=short --format=%cd"
+ date = subprocess.check_output(cmd.split(), stderr=subprocess.DEVNULL)
+ date = date.decode('utf-8').strip()
+
+ except:
+ # use the latest release version/date
+ version = release_version
+ date = release_date
+
+ # go back to the original directory
+ os.chdir(dir_orig)
+ return version, date
+
+
+###########################################################################
+version, version_date = get_version_info()
+
View it on GitLab: https://salsa.debian.org/debian-gis-team/pysolid/-/commit/0e4e5b709f1bc5f8c7ec8d1b05c004984ef97cd6
--
View it on GitLab: https://salsa.debian.org/debian-gis-team/pysolid/-/commit/0e4e5b709f1bc5f8c7ec8d1b05c004984ef97cd6
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20221028/3e8cbe42/attachment-0001.htm>
More information about the Pkg-grass-devel
mailing list