[Git][debian-gis-team/pysolid][upstream] New upstream version 0.3.0

Antonio Valentino (@antonio.valentino) gitlab at salsa.debian.org
Sun Jun 11 17:13:15 BST 2023



Antonio Valentino pushed to branch upstream at Debian GIS Project / pysolid


Commits:
e5b9d495 by Antonio Valentino at 2023-06-11T08:51:22+00:00
New upstream version 0.3.0
- - - - -


14 changed files:

- .circleci/config.yml
- + .github/dependabot.yml
- + .github/workflows/build-and-publish-to-pypi.yml
- − .github/workflows/publish-to-test-pypi.yml
- README.md
- environment.yml
- + pyproject.toml
- requirements.txt
- setup.py
- src/pysolid/__init__.py
- src/pysolid/grid.py
- src/pysolid/point.py
- src/pysolid/solid.for
- − src/pysolid/version.py


Changes:

=====================================
.circleci/config.yml
=====================================
@@ -36,7 +36,7 @@ jobs:
           command: |
             apt update
             apt-get update --yes && apt-get upgrade --yes
-            apt-get install --yes wget
+            apt-get install --yes wget git
             # download and install miniconda3
             mkdir -p ${HOME}/tools
             cd ${HOME}/tools


=====================================
.github/dependabot.yml
=====================================
@@ -0,0 +1,11 @@
+# To get started with Dependabot version updates, you'll need to specify which
+# package ecosystems to update and where the package manifests are located.
+# Please see the documentation for all configuration options:
+# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
+
+version: 2
+updates:
+  - package-ecosystem: "github-actions"      # see doc for possible values
+    directory: "/"                           # location of package manifests
+    schedule:
+      interval: "weekly"


=====================================
.github/workflows/build-and-publish-to-pypi.yml
=====================================
@@ -0,0 +1,104 @@
+name: Publish 📦 to PyPI
+
+# Build on every branch push, tag push, and pull request change:
+on:
+  push:
+    branches:
+      - main
+    tags:
+      - v*
+  pull_request:
+
+jobs:
+  build_wheels:
+    name: Build 🐍 wheels 📦 on ${{ matrix.os }}
+    runs-on: ${{ matrix.os }}
+    strategy:
+      fail-fast: false
+      matrix:
+        os: [ubuntu-20.04, macos-11]  #windows-2019
+
+    steps:
+      - uses: actions/checkout at v3
+        with:
+          fetch-depth: 0
+
+      - name: Provide gfortran (macOS)
+        if: runner.os == 'macOS'
+        run: |
+          # https://github.com/actions/virtual-environments/issues/2524
+          # https://github.com/cbg-ethz/dce/blob/master/.github/workflows/pkgdown.yaml
+          sudo ln -s /usr/local/bin/gfortran-11 /usr/local/bin/gfortran
+          sudo mkdir /usr/local/gfortran
+          sudo ln -s /usr/local/Cellar/gcc at 11/*/lib/gcc/11 /usr/local/gfortran/lib
+          gfortran --version
+
+      - name: Provide gfortran (Windows)
+        if: runner.os == 'Windows'
+        uses: msys2/setup-msys2 at v2
+
+      - name: Tell distutils to use mingw (Windows)
+        if: runner.os == 'Windows'
+        run: |
+          echo "[build]`ncompiler=mingw32" | Out-File -Encoding ASCII ~/pydistutils.cfg
+
+      - name: Build wheels
+        uses: pypa/cibuildwheel at v2.12.1
+        env:
+          # Disable building for PyPy and 32bit.
+          CIBW_SKIP: pp* *-win32 *-manylinux_i686
+          # Fix error for python 3.11 on macOS
+          CIBW_ENVIRONMENT_MACOS: SETUPTOOLS_USE_DISTUTILS=stdlib
+          # Package the DLL dependencies in the wheel for windows (done by default for the other platforms).
+          # delvewheel cannot mangle the libraries, stripping does not work.
+          CIBW_BEFORE_BUILD_WINDOWS: pip install delvewheel
+          CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel show {wheel} && delvewheel repair -w {dest_dir} {wheel} --no-mangle-all"
+
+      - uses: actions/upload-artifact at v3
+        with:
+          path: ./wheelhouse/*.whl
+
+  build_sdist:
+    name: Build 🐍 source distribution 📦
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout at v3
+        with:
+          fetch-depth: 0
+
+      - name: Build sdist
+        run: pipx run build --sdist
+
+      - uses: actions/upload-artifact at v3
+        with:
+          path: dist/*.tar.gz
+
+  upload_pypi:
+    name: Upload 📦 to PyPI
+    needs: [build_wheels, build_sdist]
+    runs-on: ubuntu-latest
+    if: github.repository_owner == 'insarlab' && github.event_name == 'push'
+    steps:
+      - uses: actions/download-artifact at v3
+        with:
+          # unpacks default artifact into dist/
+          # if `name: artifact` is omitted, the action will create extra parent dir
+          name: artifact
+          path: dist
+
+      - name: Publish developed version 📦 to Test PyPI
+        uses: pypa/gh-action-pypi-publish at release/v1
+        with:
+          user: __token__
+          password: ${{ secrets.TEST_PYPI_API_TOKEN }}
+          repository_url: https://test.pypi.org/legacy/
+          skip_existing: false
+          verbose: true
+
+      - name: Publish released version 📦 to PyPI
+        uses: pypa/gh-action-pypi-publish at release/v1
+        if: startsWith(github.ref, 'refs/tags/v')
+        with:
+          user: __token__
+          password: ${{ secrets.PYPI_API_TOKEN }}
+          verbose: true


=====================================
.github/workflows/publish-to-test-pypi.yml deleted
=====================================
@@ -1,72 +0,0 @@
-# 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,12 +1,13 @@
-[![Language](https://img.shields.io/badge/python-3.6%2B-blue.svg)](https://www.python.org/)
-[![CircleCI](https://img.shields.io/circleci/build/github/insarlab/PySolid.svg?logo=circleci&label=test)](https://circleci.com/gh/insarlab/PySolid)
-[![Version](https://img.shields.io/github/v/release/insarlab/PySolid?color=green)](https://github.com/insarlab/PySolid/releases)
-[![License](https://img.shields.io/badge/license-GPLv3+-yellow.svg)](https://github.com/insarlab/PySolid/blob/main/LICENSE)
-[![Citation](https://img.shields.io/badge/doi-10.1109%2FTGRS.2022.3168509-blue)](https://doi.org/10.1109/TGRS.2022.3168509)
+[![Language](https://img.shields.io/badge/python-3.8%2B-blue.svg?style=flat-square)](https://www.python.org/)
+[![CircleCI](https://img.shields.io/circleci/build/github/insarlab/PySolid.svg?logo=circleci&label=test&style=flat-square)](https://circleci.com/gh/insarlab/PySolid)
+[![Version](https://img.shields.io/github/v/release/insarlab/PySolid?color=brightgreen&label=version&style=flat-square)](https://github.com/insarlab/PySolid/releases)
+[![Conda Download](https://img.shields.io/conda/dn/conda-forge/pysolid?color=green&style=flat-square)](https://anaconda.org/conda-forge/pysolid)
+[![License](https://img.shields.io/badge/license-GPLv3+-yellow.svg?style=flat-square)](https://github.com/insarlab/PySolid/blob/main/LICENSE)
+[![Citation](https://img.shields.io/badge/doi-10.1109%2FTGRS.2022.3168509-blue?style=flat-square)](https://doi.org/10.1109/TGRS.2022.3168509)
 
 ## PySolid
 
-The Python based solid Earth tides (PySolid) is a thin Python wrapper of the [`solid.for`](http://geodesyworld.github.io/SOFTS/solid.htm) program (by Dennis Milbert based on [_dehanttideinelMJD.f_](https://iers-conventions.obspm.fr/content/chapter7/software/dehanttideinel/) from V. Dehant, S. Mathews, J. Gipson and C. Bruyninx) to calculate [solid Earth tides](https://en.wikipedia.org/wiki/Earth_tide) in east/north/up direction (section 7.1.1 in the [2010 IERS Conventions](https://www.iers.org/IERS/EN/Publications/TechnicalNotes/tn36.html)). Solid Earth tides introduces very long spatial wavelength components in SAR/InSAR observations, as shown in the Sentinel-1 data with regular acquisitions and large swaths (Yunjun et al., 2022).
+The Python based solid Earth tides (PySolid) is a thin Python wrapper of the [`solid.for`](http://geodesyworld.github.io/SOFTS/solid.htm) program (by Dennis Milbert based on [_dehanttideinelMJD.f_](https://iers-conventions.obspm.fr/content/chapter7/software/dehanttideinel/) from V. Dehant, S. Mathews, J. Gipson and C. Bruyninx) to calculate [solid Earth tides](https://en.wikipedia.org/wiki/Earth_tide) in east, north and up directions (section 7.1.1 in the [2010 IERS Conventions](https://www.iers.org/IERS/EN/Publications/TechnicalNotes/tn36.html)). Solid Earth tides introduce large offsets in SAR observations and long spatial wavelength ramps in InSAR observations, as shown in the Sentinel-1 data with regular acquisitions and large swaths ([Yunjun et al., 2022](https://doi.org/10.1109/TGRS.2022.3168509)).
 
 This is research code provided to you "as is" with NO WARRANTIES OF CORRECTNESS. Use at your own risk.
 
@@ -25,9 +26,8 @@ or via `apt` (or other package managers) for [Debian-derivative OS](https://wiki
 apt install python3-pysolid
 ```
 
-Installing via `conda` and `apt` is recomended because PySolid contains Fortran source code, which required compilcation. Otherwise, you may build it from source as described below.
-
-#### 1.1 Build from source
+<details>
+<p><summary>Or build from source:</summary></p>
 
 PySolid relies on a few Python modules as described in [requirements.txt](./requirements.txt) and [NumPy's f2py](https://numpy.org/doc/stable/f2py/) to build the Fortran source code. You could use `conda` to install all the dependencies, including the Fortran compiler, or use your own installed Fortran compiler and `pip` to install the rest.
 
@@ -56,16 +56,20 @@ python -m pip install -r PySolid/requirements.txt
 
 ```bash
 # option 1: use pip to install pysolid into the current environment
-# use "pip install -e" to install in the development mode
 python -m pip install PySolid
 
-# option 2: manually compile the Fortran code and setup environment variable
+# option 2: use pip to install pysolid in develop mode (editable) into the current environment
+# setting an environmental variable as below is required for editable installs via pyproject.toml
+export SETUPTOOLS_ENABLE_FEATURES="legacy-editable"
+python -m pip install -e PySolid
+
+# option 3: manually compile the Fortran code and setup environment variable
 cd PySolid/src/pysolid
 f2py -c -m solid solid.for
 export PYTHONPATH=${PYTHONPATH}:~/tools/PySolid
 ```
 
-#### 1.2 Test the installation
+##### d. Test the installation
 
 To test the installation, run the following:
 
@@ -74,10 +78,11 @@ python -c "import pysolid; print(pysolid.__version__)"
 python PySolid/tests/grid.py
 python PySolid/tests/point.py
 ```
+</details>
 
 ### 2. Usage
 
-PySolid could compute solid Earth tides in two modes: **point** and **grid**. Both modes produce displacement in east, north and up direction.
+PySolid could compute solid Earth tides in two modes: **point** and **grid**. Both modes produce displacement in east, north and up directions.
 
 +   **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
@@ -136,7 +141,7 @@ tide_e, tide_n, tide_u = pysolid.calc_solid_earth_tides_grid(
     verbose=True,
 )
 
-# project SET from ENU to radar line-of-sight (LOS) direction with positive for motion towards satellite
+# project SET from ENU to satellite line-of-sight (LOS) direction with positive for motion towards the satellite
 # 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


=====================================
environment.yml
=====================================
@@ -3,8 +3,15 @@ channels:
   - conda-forge
   - defaults
 dependencies:
+  - python>=3.8
+  # for running
   - numpy
   - scipy
   - matplotlib
   - scikit-image
-  - fortran-compiler    # A generic way to obtain the Fortran compiler across platforms through conda-forge channel
+  # for packaging and installation
+  - fortran-compiler    # Fortran compiler across platforms through conda-forge channel
+  - pip
+  - setuptools
+  - setuptools_scm
+  - wheel


=====================================
pyproject.toml
=====================================
@@ -0,0 +1,48 @@
+[build-system]
+requires = ["setuptools<60.0", "setuptools_scm[toml]>=6.2", "numpy<1.23.0", "wheel"]
+build-backend = "setuptools.build_meta"
+
+[project]
+name = "pysolid"
+description = "A Python wrapper for solid to compute solid Earth tides"
+authors = [
+    {name="Zhang Yunjun", email="yunjunzgeo at gmail.com"},
+    {name="Dennis Milbert"},
+]
+readme = "README.md"
+requires-python = ">=3.8"
+keywords = ["solid Earth tides", "deformation", "geodesy", "geophysics"]
+license = {text = "GPL-3.0-or-later"}
+classifiers=[
+    "Development Status :: 4 - Beta",
+    "Intended Audience :: Science/Research",
+    "Topic :: Scientific/Engineering",
+    "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
+    "Operating System :: OS Independent",
+    "Programming Language :: Python :: 3",
+]
+dependencies = [
+    "numpy",
+    "scipy",
+    "matplotlib",
+    "scikit-image",
+]
+dynamic = ["version"]
+
+[project.urls]
+"Homepage" = "https://github.com/insarlab/PySolid"
+"Bug Tracker" = "https://github.com/insarlab/PySolid/issues"
+
+[tool.setuptools]
+include-package-data = true
+zip-safe = false
+
+[tool.setuptools.packages.find]
+where = ["src"]
+
+[tool.setuptools.package-data]
+pysolid = ["*.for"]
+
+[tool.setuptools_scm]
+version_scheme = "post-release"
+local_scheme = "no-local-version"


=====================================
requirements.txt
=====================================
@@ -1,4 +1,11 @@
+# for running
 numpy
 scipy
 matplotlib
 scikit-image
+# for packaging and installation
+#fortran-compiler   # Fortran compiler across platforms through conda-forge channel
+pip
+setuptools
+setuptools_scm
+wheel


=====================================
setup.py
=====================================
@@ -1,32 +1,21 @@
 # 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 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
-
-# Grab from README file: long_description
-with open("README.md", "r") as f:
-    long_description = f.read()
+# read the contents of README file
+def readme():
+    with open("README.md") as f:
+        return f.read()
 
 setup(
-    name='pysolid',
-    version=version,
+    ## add the following redundant setup for setuptools<60, the latter is required for numpy.distutils
+    name="pysolid",
     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=readme(),
     long_description_content_type="text/markdown",
     author="Zhang Yunjun, Dennis Milbert",
     author_email="yunjunzgeo at gmail.com",
@@ -48,27 +37,27 @@ setup(
         "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=[
-        Extension(name='pysolid.solid', sources=['src/pysolid/solid.for']),
-    ],
-
     # dependencies
-    python_requires=">=3.6",
+    python_requires=">=3.8",
     install_requires=[
-        'numpy',
-        'scipy',
-        'matplotlib',
-        'scikit-image',
+        "numpy",
+        "scipy",
+        "matplotlib",
+        "scikit-image",
     ],
 
+    # package discovery
+    packages=setuptools.find_packages("src"),  # include all packages under src
+    package_dir={"": "src"},                   # tell distutils packages are under src
+
     # data files
     include_package_data=True,
     package_data={
         "pysolid": ["solid.for"],
     },
+
+    ## fortran extensions to build with numpy.f2py
+    ext_modules=[
+        Extension(name="pysolid.solid", sources=["src/pysolid/solid.for"])
+    ],
 )


=====================================
src/pysolid/__init__.py
=====================================
@@ -1,5 +1,14 @@
+from importlib.metadata import PackageNotFoundError, version
+
 # get version info
-from pysolid.version import version as __version__
+try:
+    __version__ = version(__name__)
+except PackageNotFoundError:
+    print('package is not installed!\n'
+          'Please follow the installation instructions in the README.md.\n'
+          'Or, to just get the version number, use:\n'
+          '   python -m setuptools_scm')
+
 
 # top-level functions
 from pysolid.grid import (
@@ -12,3 +21,13 @@ from pysolid.point import (
     plot_solid_earth_tides_point,
     plot_power_spectral_density4tides,
 )
+
+__all__ = [
+    '__version__',
+    'calc_solid_earth_tides_grid',
+    'plot_solid_earth_tides_grid',
+    'TIDES',
+    'calc_solid_earth_tides_point',
+    'plot_solid_earth_tides_point',
+    'plot_power_spectral_density4tides',
+]


=====================================
src/pysolid/grid.py
=====================================
@@ -11,7 +11,6 @@
 #   pysolid.calc_solid_earth_tides_grid()
 
 
-import datetime as dt
 import os
 
 import numpy as np
@@ -73,35 +72,11 @@ def calc_solid_earth_tides_grid(dt_obj, atr, step_size=1e3, display=False, verbo
     vprint('SOLID  : shape: {s}, step size: {la:.4f} by {lo:.4f} deg'.format(
         s=(length, width), la=lat_step, lo=lon_step))
 
-    ## calc solid Earth tides and write to text file
-    txt_file = os.path.abspath('solid.txt')
-    if os.path.isfile(txt_file):
-        os.remove(txt_file)
-
-    vprint('SOLID  : calculating / writing data to txt file: {}'.format(txt_file))
-
-    # Run twice to circumvent fortran bug which cuts off last file in loop - Simran, Jun 2020
-    for _ in range(2):
-        solid_grid(dt_obj.year, dt_obj.month, dt_obj.day,
-                   dt_obj.hour, dt_obj.minute, dt_obj.second,
-                   lat0, lat_step, length-1,
-                   lon0, lon_step, width-1)
-
-    ## read data from text file
-    vprint('PYSOLID: read data from text file: {}'.format(txt_file))
-    grid_size = int(length * width)
-    fc = np.loadtxt(txt_file,
-                    dtype=float,
-                    usecols=(2,3,4),
-                    delimiter=',',
-                    skiprows=0,
-                    max_rows=grid_size+100)[:grid_size]
-    tide_e = fc[:, 0].reshape(length, width)
-    tide_n = fc[:, 1].reshape(length, width)
-    tide_u = fc[:, 2].reshape(length, width)
-
-    # remove the temporary text file
-    os.remove(txt_file)
+    ## calc solid Earth tides
+    tide_e, tide_n, tide_u = solid_grid(dt_obj.year, dt_obj.month, dt_obj.day,
+                                        dt_obj.hour, dt_obj.minute, dt_obj.second,
+                                        lat0, lat_step, length,
+                                        lon0, lon_step, width)
 
     # resample to the input size
     if num_step > 1:


=====================================
src/pysolid/point.py
=====================================
@@ -169,35 +169,15 @@ def calc_solid_earth_tides_point_per_day(lat, lon, date_str, step_sec=60):
         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')
-    if os.path.isfile(txt_file):
-        os.remove(txt_file)
-
-    # Run twice to circumvent fortran bug which cuts off last file in loop - Simran, Jun 2020
+    # calc solid Earth tides
     t = dt.datetime.strptime(date_str, '%Y%m%d')
-    for _ in range(2):
-        solid_point(lat, lon, t.year, t.month, t.day, step_sec)
-
-    ## read data from text file
-    num_row = int(24 * 60 * 60 / step_sec)
-    fc = np.loadtxt(txt_file,
-                    dtype=float,
-                    delimiter=',',
-                    skiprows=0,
-                    max_rows=num_row)
-
-    tide_e = fc[:, 1].flatten()
-    tide_n = fc[:, 2].flatten()
-    tide_u = fc[:, 3].flatten()
-
-    secs   = fc[:, 0].flatten()
+    secs, tide_e, tide_n, tide_u  = solid_point(
+        lat, lon, t.year, t.month, t.day, step_sec
+    )
+
     dt_out = [t + dt.timedelta(seconds=sec) for sec in secs]
     dt_out = np.array(dt_out)
 
-    # remove the temporary text file
-    os.remove(txt_file)
-
     return dt_out, tide_e, tide_n, tide_u
 
 


=====================================
src/pysolid/solid.for
=====================================
@@ -7,17 +7,17 @@
 ***     J. Gipson and C. Bruyninx. The latest version of dehanttideinel.f and its 
 ***     dependent subroutines can be download from IERS conventions website as:
 ***     wget -r -l1 --no-parent -R "index.html*" -nH --cut-dirs=3 https://iers-conventions.obspm.fr/content/chapter7/software/dehanttideinel
-*** Z. Yunjun and S. Sangha, Sep 2020: modify solid() to solid_point/grid() as subroutines.
+*** Sep 2020: modify solid() to solid_point/grid() as subroutines, Z. Yunjun and S. Sangha.
+*** Apr 2023: return numpy arrays instead of writing txt file, S. Staniewicz.
 
       subroutine solid_grid(iyr,imo,idy,ihh,imm,iss,
-     * glad0,steplat,nlat,
-     * glod0,steplon,nlon)
-
+     * glad0,steplat,nlat,glod0,steplon,nlon,tide_e,tide_n,tide_u)
+ 
 *** calculate solid earth tides (SET) for one spatial grid given the date/time
 *** Arguments: iyr/imo/idy/ihh/imm/iss - int, date/time for YYYY/MM/DD/HH/MM/SS
 ***            glad0/glad1/steplat     - float, north(Y_FIRST)/south/step(negative) in deg
-***            glod0/glod1/steplon     - float, west(X_FIRST) /east /step(positive) in deg
-*** Returns:   latitude,  longitude,  SET_east,  SET_north,  SET_up
+***            glod0/glod1/steplon     - float, west (X_FIRST)/east /step(positive) in deg
+*** Returns:   tide_e/tide_n/tide_u    - 2D np.ndarray, east/north/up component of SET in m
 
       implicit double precision(a-h,o-z)
       dimension rsun(3),rmoon(3),etide(3),xsta(3)
@@ -25,16 +25,15 @@
       integer nlat,nlon
       double precision glad0,steplat
       double precision glod0,steplon
+      real(8), intent(out), dimension(nlat,nlon) :: tide_e
+      real(8), intent(out), dimension(nlat,nlon) :: tide_n
+      real(8), intent(out), dimension(nlat,nlon) :: tide_u
       !***^ leap second table limit flag
       logical lflag
       common/stuff/rad,pi,pi2
       common/comgrs/a,e2
-
-*** open output file
-
-      lout=1
-      open(lout,file='solid.txt',form='formatted',status='unknown')
-      write(lout,'(a)') '# program solid -- UTC version -- 2018jun01'
+      !f2py intent(in) iyr,imo,idy,ihh,imm,iss,glad0,steplat,nlat,glod0,steplon,nlon
+      !f2py intent(out) tide_e,tide_n,tide_u
 
 *** constants
 
@@ -50,63 +49,55 @@
 *** input section
 
       if(iyr.lt.1901.or.iyr.gt.2099) then
-        write(lout,'(a,i5)') 'ERROR: year NOT in [1901-2099]:',iyr
-        go to 98
+        print *, 'ERROR: year NOT in [1901-2099]:',iyr
+        return
       endif
 
       if(imo.lt.1.or.imo.gt.12) then
-        write(lout,'(a,i3)') 'ERROR: month NOT in [1-12]:',imo
-        go to 98
+        print *, 'ERROR: month NOT in [1-12]:',imo
+        return
       endif
 
       if(idy.lt.1.or.idy.gt.31) then
-        write(lout,'(a,i3)') 'ERROR: day NOT in [1-31]:',idy
-        go to 98
+        print *, 'ERROR: day NOT in [1-31]:',idy
+        return
       endif
 
       if(ihh.lt.0.or.ihh.gt.23) then
-        write(lout,'(a,i3)') 'ERROR: hour NOT in [0-23]:',ihh
-        go to 98
+        print *, 'ERROR: hour NOT in [0-23]:',ihh
+        return
       endif
 
       if(imm.lt.0.or.imm.gt.59) then
-        write(lout,'(a,i3)') 'ERROR: minute NOT in [0-59]:',imm
-        go to 98
+        print *, 'ERROR: minute NOT in [0-59]:',imm
+        return
       endif
 
       if(iss.lt.0.or.iss.gt.59) then
-        write(lout,'(a,i3)') 'ERROR: second NOT in [0-59]:',iss
-        go to 98
+        print *, 'ERROR: second NOT in [0-59]:',iss
+        return
       endif
 
       if(glad0.lt.-90.d0.or.glad0.gt.90.d0) then
-        write(lout,'(a,G0.9)') 'ERROR: lat0 NOT in [-90,+90]:',glad0
-        go to 98
+        print *, 'ERROR: lat0 NOT in [-90,+90]:',glad0
+        return
       endif
 
       if(glod0.lt.-360.d0.or.glod0.gt.360.d0) then
-        write(lout,'(a,G0.9)') 'ERROR: lon0 NOT in [-360,+360]',glod0
-        go to 98
+        print *, 'ERROR: lon0 NOT in [-360,+360]',glod0
+        return
       endif
 
-*** output header
-
       glad1=glad0+nlat*steplat
       glod1=glod0+nlon*steplon
 
-      write(lout,'(a,i5,2i3)') '# year, month, day =',iyr,imo,idy
-      write(lout,'(a,3i3)') '# hour, minute, second =',ihh,imm,iss
-      write(lout,'(a,4f15.9)') '# S, N, W, E =',glad1,glad0,glod0,glod1
-      write(lout,'(a,f15.9,i6)') '# step_lat, num_lat =',steplat,nlat
-      write(lout,'(a,f15.9,i6)') '# step_lon, num_lon =',steplon,nlon
-
 *** loop over the grid
 
-      do ilat=0,nlat
-        do ilon=0,nlon
+      do ilat=1,nlat
+        do ilon=1,nlon
 
-        glad=glad0+ilat*steplat
-        glod=glod0+ilon*steplon
+        glad = glad0 + (ilat-1)*steplat
+        glod = glod0 + (ilon-1)*steplon
 
 *** position of observing point (positive East)
 
@@ -153,8 +144,10 @@
         call mjdciv(mjd,fmjd               +0.001d0/86400.d0,
      *              iyr,imo,idy,ihr,imn,sec-0.001d0)
 
-        !*** write output to file
-        write(lout,'(*(G0.9,:,",  "))') glad,glod,vt,ut,wt
+        !*** write output respective arrays
+        tide_e(ilat, ilon) = vt
+        tide_n(ilat, ilon) = ut
+        tide_u(ilat, ilon) = wt
 
         enddo
       enddo
@@ -162,25 +155,24 @@
 *** end of processing and flag for leap second
 
       if(lflag) then
-        write(*,'(a)') 'Mild Warning -- time crossed leap second table'
-        write(*,'(a)') '  boundaries.  Boundary edge value used instead'
+        print *, 'Mild Warning -- time crossed leap second table'
+        print *, '  boundaries.  Boundary edge value used instead'
       endif
-      close(lout)
 
-      go to 99
-   98 write(*,'(a)') 'Check arguments.'
 
       return
-   99 end
+      end
 
 *-----------------------------------------------------------------------
-      subroutine solid_point(glad,glod,iyr,imo,idy,step_sec)
+      subroutine solid_point(glad,glod,iyr,imo,idy,step_sec,
+     * secs,tide_e,tide_n,tide_u)
 
 *** calculate SET at given location for one day with step_sec seconds resolution
-*** Arguments: glad/glod   - float, latitude/longitude in deg
-***            iyr/imo/idy - int, start date/time in UTC
-***            step_sec    - int, time step in seconds
-*** Returns:   seconds,  SET_east,  SET_north,  SET_up
+*** Arguments: glad/glod            - float, latitude/longitude in deg
+***            iyr/imo/idy          - int, start date/time in UTC
+***            step_sec             - int, time step in seconds
+*** Returns:   secs                 - 1D np.ndarray, seconds since start
+***            tide_e/tide_n/tide_u - 1D np.ndarray, east/north/up component of SET in m
 
       implicit double precision(a-h,o-z)
       dimension rsun(3),rmoon(3),etide(3),xsta(3)
@@ -188,16 +180,16 @@
       integer iyr,imo,idy
       integer nloop, step_sec
       double precision tdel2
+      real(8), intent(out), dimension(60*60*24/step_sec) :: secs
+      real(8), intent(out), dimension(60*60*24/step_sec) :: tide_e
+      real(8), intent(out), dimension(60*60*24/step_sec) :: tide_n
+      real(8), intent(out), dimension(60*60*24/step_sec) :: tide_u
       !*** leap second table limit flag
       logical lflag
       common/stuff/rad,pi,pi2
       common/comgrs/a,e2
-
-*** open output file
-
-      lout=1
-      open(lout,file='solid.txt',form='formatted',status='unknown')
-      write(lout,'(a)') '# program solid -- UTC version -- 2018jun01'
+      !f2py intent(in) glad,glod,iyr,imo,idy,step_sec
+      !f2py intent(out) secs,tide_e,tide_n,tide_u
 
 *** constants
 
@@ -213,34 +205,30 @@
 *** check inputs section
 
       if(glad.lt.-90.d0.or.glad.gt.90.d0) then
-        write(lout,'(a,G0.9)') 'ERROR: lat NOT in [-90,+90]:',glad
-        go to 98
+        print *, 'ERROR: lat NOT in [-90,+90]:',glad
+        return
       endif
 
       if(glod.lt.-360.d0.or.glod.gt.360.d0) then
-        write(lout,'(a,G0.9)') 'ERROR: lon NOT in [-360,+360]:',glod
-        go to 98
+        print *, 'ERROR: lon NOT in [-360,+360]:',glod
+        return
       endif
 
       if(iyr.lt.1901.or.iyr.gt.2099) then
-        write(lout,'(a,i5)') 'ERROR: year NOT in [1901-2099]:',iyr
-        go to 98
+        print *, 'ERROR: year NOT in [1901-2099]:',iyr
+        return
       endif
 
       if(imo.lt.1.or.imo.gt.12) then
-        write(lout,'(a,i3)') 'ERROR: month NOT in [1-12]:',imo
-        go to 98
+        print *, 'ERROR: month NOT in [1-12]:',imo
+        return
       endif
 
       if(idy.lt.1.or.idy.gt.31) then
-        write(lout,'(a,i3)') 'ERROR: day NOT in [1-31]:',idy
-        go to 98
+        print *, 'ERROR: day NOT in [1-31]:',idy
+        return
       endif
 
-*** output header
-
-      write(lout,'(a,i5,2i3)') '# year, month, day =',iyr,imo,idy
-      write(lout,'(a,2f15.9)') '# lat, lon =',glad,glod
 
 *** position of observing point (positive East)
 
@@ -268,11 +256,9 @@
 
 *** loop over time
 
-      !*** tdel2=1.d0/60.d0/24.d0
-      !*** do iloop=0,60*24
       nloop=60*60*24/step_sec
       tdel2=1.d0/DFLOAT(nloop)
-      do iloop=0,nloop
+      do iloop=1,nloop
         !*** false means flag not raised
         !*** mjd/fmjd in UTC
         !*** mjd/fmjd in UTC
@@ -292,9 +278,12 @@
 
         call mjdciv(mjd,fmjd,iyr,imo,idy,ihr,imn,sec)
 
-        !*** write output to file
         tsec=ihr*3600.d0+imn*60.d0+sec
-        write(lout,'((f8.1,:,",  "),*(f10.6,:,",  "))') tsec,vt,ut,wt
+
+        secs(iloop) = tsec
+        tide_e(iloop) = vt
+        tide_n(iloop) = ut
+        tide_u(iloop) = wt
 
         !*** update fmjd for the next round
         fmjd=fmjd+tdel2
@@ -305,16 +294,12 @@
 *** end of processing and flag of leap second
 
       if(lflag) then
-        write(*,'(a)') 'Mild Warning -- time crossed leap second table'
-        write(*,'(a)') '  boundaries.  Boundary edge value used instead'
+        print *, 'Mild Warning -- time crossed leap second table'
+        print *, '  boundaries.  Boundary edge value used instead'
       endif
-      close(lout)
-
-      go to 99
-   98 write(*,'(a)') 'Check arguments.'
 
       return
-   99 end
+      end
 
 *@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
       subroutine detide(xsta,mjd,fmjd,xsun,xmon,dxtide,lflag)
@@ -361,7 +346,8 @@
 
       implicit double precision(a-h,o-z)
       double precision xsta(3),xsun(3),xmon(3),dxtide(3),xcorsta(3)
-      double precision h20,l20,h3,l3,h2,l2
+      double precision h20,l20,h3,l3,h2,l2,fmjd
+      integer mjd
       double precision mass_ratio_sun,mass_ratio_moon
       logical lflag,leapflag
       !*** leap second table limit flag
@@ -533,8 +519,8 @@
 *** output: xcorsta
 
       implicit double precision (a-h,o-z)
-      dimension xsta(3),xsun(3),xmon(3),xcorsta(3)
-      double precision l1,l1d,l1sd
+      double precision xsta(3),xsun(3),xmon(3),xcorsta(3)
+      double precision l1,l1d,l1sd,fac2sun,fac2mon
       data l1d/0.0012d0/,l1sd/0.0024d0/
 
       rsta=enorm8(xsta)
@@ -593,7 +579,7 @@
 
       implicit double precision (a-h,o-z)
       double precision xsta(3),xcorsta(3),datdi(9,31)
-      double precision deg2rad
+      double precision deg2rad, fhr, t
       data deg2rad/0.017453292519943295769d0/
 
 *** note, following table is derived from dehanttideinelMJD.f (2000oct30 16:10)
@@ -750,7 +736,7 @@
       subroutine step2lon(xsta,fhr,t,xcorsta)
 
       implicit double precision (a-h,o-z)
-      double precision deg2rad
+      double precision deg2rad,fhr,t
       double precision xsta(3),xcorsta(3),datdi(9,5)
       data deg2rad/0.017453292519943295769d0/
 
@@ -836,7 +822,8 @@
 *** output: xcorsta
 
       implicit double precision (a-h,o-z)
-      dimension xsta(3),xsun(3),xmon(3),xcorsta(3)
+      double precision xsta(3),xsun(3),xmon(3),xcorsta(3)
+      double precision fac2sun,fac2mon
       data dhi/-0.0025d0/,dli/-0.0007d0/
 
       rsta=enorm8(xsta)
@@ -878,7 +865,8 @@
 *** output: xcorsta
 
       implicit double precision (a-h,o-z)
-      dimension xsta(3),xsun(3),xmon(3),xcorsta(3)
+      double precision xsta(3),xsun(3),xmon(3),xcorsta(3)
+      double precision fac2sun, fac2mon
       data dhi/-0.0022d0/,dli/-0.0007d0/
 
       rsta=enorm8(xsta)
@@ -923,6 +911,7 @@
 
       implicit double precision (a-h,o-z)
       double precision x(3),y(3)
+      double precision r1,r2,scal
 
       r1=dsqrt(x(1)*x(1) + x(2)*x(2) + x(3)*x(3))
       r2=dsqrt(y(1)*y(1) + y(2)*y(2) + y(3)*y(3))
@@ -969,7 +958,9 @@
 *** section 3.2, pg. 38-39  routine MiniMoon
 
       implicit double precision(a-h,o-z)
-      dimension rm(3)
+      double precision rm(3)
+      integer mjd
+      double precision fmjd
       logical lflag,leapflag
       !*** leap second table limit flag
       !*** leap second table limit flag
@@ -1105,6 +1096,8 @@
 *** section 2.3.1, pg. 33
 
       implicit double precision(a-h,o-z)
+      integer mjd
+      double precision fmjd,ghar
       common/stuff/rad,pi,pi2
 
 *** need UTC to get sidereal time ("astronomy on the personal computer", 4th ed)
@@ -1156,7 +1149,9 @@
 *** section 3.2, pg. 39  routine MiniSun
 
       implicit double precision(a-h,o-z)
-      dimension rs(3)
+      double precision rs(3)
+      double precision fmjd
+      integer mjd
       logical lflag,leapflag
       !*** leap second table limit flag
       !*** leap second table limit flag
@@ -1239,6 +1234,7 @@
 *** determine range,azimuth,vertical angle from local horizon coord.
 
       implicit double precision(a-h,o-z)
+      double precision u,v,w,ra,az,va
       
       s2=u*u+v*v
       r2=s2+w*w
@@ -1257,6 +1253,7 @@
 *** convert geodetic lat, long, ellip ht. to x,y,z
 
       implicit double precision(a-h,o-z)
+      double precision gla,glo,eht,x,y,z
       common/comgrs/a,e2
 
       sla=dsin(gla)
@@ -1278,6 +1275,7 @@
 *** compute a geodetic h cartesian sys   (u,v,w)
 
       implicit double precision(a-h,o-z)
+      double precision gla,glo,u,v,w,x,y,z
 
       sb=dsin(gla)
       cb=dcos(gla)
@@ -1297,6 +1295,7 @@
 *** x,y,z transformed into u,v,w
 
       implicit double precision(a-h,o-z)
+      double precision theta,x,y,z,u,v,w
       
       s=dsin(theta)
       c=dcos(theta)
@@ -1314,6 +1313,7 @@
 *** x,y,z transformed into u,v,w
 
       implicit double precision(a-h,o-z)
+      double precision theta,x,y,z,u,v,w
       
       s=dsin(theta)
       c=dcos(theta)
@@ -1334,7 +1334,7 @@
 *** allows single number expression of time in seconds w.r.t. mjd0
 
       implicit double precision(a-h,o-z)
-      integer y
+      integer y,iyr,imo,idy
       save /mjdoff/
       common/mjdoff/mjd0
 
@@ -1369,7 +1369,8 @@
 *** adapted from civmjd()
 
       implicit double precision(a-h,o-z)
-      integer y
+      integer y,iyr,imo,idy,ihr,imn
+      double precision sec,tsec
       save /mjdoff/
       common/mjdoff/mjd0
 
@@ -1402,6 +1403,8 @@
 *** adapted from mjdciv()
 
       implicit double precision(a-h,o-z)
+      integer iyr,imo,idy,ihr,imn
+      double precision sec,tsec
       save /mjdoff/
       common/mjdoff/mjd0
 
@@ -1445,7 +1448,8 @@
 *** operation confirmed against table 3.3 values on pg.34
 
       implicit double precision(a-h,o-z)
-      integer y
+      integer y,iyr,imo,idy,ihr,imn,mjd
+      double precision sec,fmjd
 
       if(iyr.lt.1900) stop 34588
 
@@ -1476,6 +1480,8 @@
 *** operation confirmed for leap years (incl. year 2000)
 
       implicit double precision(a-h,o-z)
+      integer mjd,iyr,imo,idy,ihr,imn
+      double precision fmjd,sec
 
       rjd=mjd+fmjd+2400000.5d0
       ia=(rjd+0.5d0)
@@ -1510,6 +1516,7 @@
 *** convert utc (sec) to terrestrial time (sec)
 
       implicit double precision(a-h,o-z)
+      double precision tutc
 
       ttai   = utc2tai(tutc)
       utc2ttt= tai2tt(ttai)
@@ -1522,6 +1529,7 @@
 *** convert gps time (sec) to terrestrial time (sec)
 
       implicit double precision(a-h,o-z)
+      double precision tgps
 
       ttai   = gps2tai(tgps)
       gps2ttt= tai2tt(ttai)
@@ -1534,6 +1542,7 @@
 *** convert utc (sec) to tai (sec)
 
       implicit double precision(a-h,o-z)
+      double precision tutc
 
       utc2tai = tutc - getutcmtai(tutc)
 
@@ -1549,9 +1558,10 @@
 ***** http://www.csgnetwork.com/julianmodifdateconv.html
 
       implicit double precision(a-h,o-z)
-      !*** upper limit, leap second table, 2023jun28
+      double precision tsec
+      !*** upper limit, leap second table, 2023dec28
       !*** lower limit, leap second table, 1972jan01
-      parameter(MJDUPPER=60123)
+      parameter(MJDUPPER=60306)
       parameter(MJDLOWER=41317)
 
       !*** leap second table limit flag
@@ -1632,7 +1642,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 June 2023
+***** File expires on 28 December 2023
 
 *** test against newest leaps first
 
@@ -1741,6 +1751,7 @@
 *** convert tai (sec) to terrestrial time (sec)
 
       implicit double precision(a-h,o-z)
+      double precision ttai
 
 ***** http://tycho.usno.navy.mil/systime.html
       tai2tt = ttai + 32.184d0
@@ -1753,6 +1764,7 @@
 *** convert gps time (sec) to tai (sec)
 
       implicit double precision(a-h,o-z)
+      double precision tgps
 
 ***** http://leapsecond.com/java/gpsclock.htm
 ***** http://tycho.usno.navy.mil/leapsec.html


=====================================
src/pysolid/version.py deleted
=====================================
@@ -1,62 +0,0 @@
-#!/usr/bin/env python3
-# Author: Zhang Yunjun, Jan 2021
-# Copyright 2020, by the California Institute of Technology.
-
-
-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'),
-    Tag('0.1.2', '2021-02-24'),
-    Tag('0.1.1', '2021-02-01'),
-    Tag('0.1.0', '2021-01-22'),
-)
-
-# latest release
-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/e5b9d495e10ab54c717ec95df2cf52933b5ab50f

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/pysolid/-/commit/e5b9d495e10ab54c717ec95df2cf52933b5ab50f
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/20230611/d0e2a270/attachment-0001.htm>


More information about the Pkg-grass-devel mailing list