hydrogeoscience / pygtide

A Python module and wrapper for ETERNA PREDICT to compute gravitational tides on Earth
Mozilla Public License 2.0
55 stars 19 forks source link

Compile fortran source #22

Closed trichter closed 2 years ago

trichter commented 2 years ago

This PR reverts the head of master to commit https://github.com/hydrogeoscience/pygtide/commit/a91223903f182c8607aac0a10b9e7e61a1a8d25d. This is the commit where the master branch and the branch in PR #16 started to diverge. It then replays the changes from #16. After that it adds the newest modified fortran sources obtained from @hydrogeoscience. Finally, I added some code to set the nullfile and comdat directory depending on OS from inside python. I also added a github actions workflow which runs a simple test on Linux, Windows and MacOS.

All changes since https://github.com/hydrogeoscience/pygtide/commit/a91223903f182c8607aac0a10b9e7e61a1a8d25d are still in the history of the repository, but not present in the head of this branch. The branch in PR #16 adds convenient functions predict_series, predict_spectrum, predict_table for obtaining series and spectra, plot_series, plot_spectrum for plotting and update_data_files for updating the data files. The extensions are compiled directly from the Fortran source and it is therefore not necessary to upload extensions for new python versions, etc.

TODO before merging: [x] set resonable version number [x] check that the test is passing on all most platforms

trichter commented 2 years ago

See CI results for this branch here.

Compilation appeared to be successful on all platforms. Though, for Windows the following error appears:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Miniconda\envs\test\lib\site-packages\pygtide\__init__.py", line 1, in <module>
    from pygtide.core import pygtide
  File "C:\Miniconda\envs\test\lib\site-packages\pygtide\core.py", line 96, in <module>
    from pygtide import etpred
ImportError: DLL load failed while importing etpred: The specified module could not be found.
trichter commented 2 years ago

CI is working for Linux and MacOS. I tried hard, but it is still not working for Windows. Probably the windows installation has to be fixed user-side by passing specific command-line flags to pip install or pip build_ext. I excluded Windows for several other f2py projects from the test matrix.

trichter commented 2 years ago

@hydrogeoscience I updated the head of this branch with the files you sent me. Some files are with Windows line endings, some with Linux line endings, but for now I think this is OK. I had to fix an import to get the updated update routine working. When using the new routine it removes the last entry from etddt.dat (compared to the update routine provided by @strawpants):

 2017.00000 2457754.50000   69.184
-2022.31684 2459696.14833   69.184

This leads to the following warning in the etpred routines:

UserWarning: Prediction timeframe exceeds the end of the available time database (2017-01-01 00:00:00) plus 1 year. For best accuracy, please consider updating 'b'etddt.dat        ''.

Can you have a look?

I uploaded a dist based on this branch to testpypi (with alpha version number) using python setup.py sdist upload command. Installation can be tested with

pip install --pre -i https://test.pypi.org/simple/ pygtide
python -c 'import pygtide; pygtide.test()'

Update routines can be tested with

python -c 'import pygtide; pygtide.update()'
python -c 'import pygtide; pygtide.test()'

Please check if installation is working on your Windows platform with Mingw32 with compiler work-arounds, e.g. with pip install flags --global-option build_ext --global-option --compiler=mingw32 or similar or with a user configuration file distutils.cfg. (See https://github.com/pypa/pip/issues/18)

hydrogeoscience commented 2 years ago

Thanks for all your work on this @trichter.

Note the following:

(a) the last entry by @strawpants in 'etddt.dat' is not required. The Fortran code was changed to scan the file for the last update after 1972.

(b) This error message was misleading and I have changed it to "Please consider updating the leap second database '%s' (last value is from %s).". Please re-download "core.py" from Dropbox.