hector-ts 3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. hector_ts-3.0/LICENSE +78 -0
  2. hector_ts-3.0/MANIFEST.in +4 -0
  3. hector_ts-3.0/PKG-INFO +135 -0
  4. hector_ts-3.0/README.md +103 -0
  5. hector_ts-3.0/pyproject.toml +10 -0
  6. hector_ts-3.0/setup.cfg +4 -0
  7. hector_ts-3.0/setup.py +147 -0
  8. hector_ts-3.0/src/hector/__init__.py +0 -0
  9. hector_ts-3.0/src/hector/_epoch_scan_gaps.c +35176 -0
  10. hector_ts-3.0/src/hector/_epoch_scan_gaps.pyx +334 -0
  11. hector_ts-3.0/src/hector/_gap_correction.c +30199 -0
  12. hector_ts-3.0/src/hector/_gap_correction.pyx +95 -0
  13. hector_ts-3.0/src/hector/_ggm.c +30782 -0
  14. hector_ts-3.0/src/hector/_ggm.pyx +97 -0
  15. hector_ts-3.0/src/hector/_levinson.c +30357 -0
  16. hector_ts-3.0/src/hector/_levinson.pyx +89 -0
  17. hector_ts-3.0/src/hector/_schur_gsa.c +34429 -0
  18. hector_ts-3.0/src/hector/_schur_gsa.pyx +390 -0
  19. hector_ts-3.0/src/hector/_schur_multiply.c +30671 -0
  20. hector_ts-3.0/src/hector/_schur_multiply.pyx +100 -0
  21. hector_ts-3.0/src/hector/ammargrag.py +490 -0
  22. hector_ts-3.0/src/hector/ar1.py +157 -0
  23. hector_ts-3.0/src/hector/control.py +113 -0
  24. hector_ts-3.0/src/hector/convert_rlrdata2mom.py +71 -0
  25. hector_ts-3.0/src/hector/covariance.py +261 -0
  26. hector_ts-3.0/src/hector/datasnooping.py +109 -0
  27. hector_ts-3.0/src/hector/date2mjd.py +45 -0
  28. hector_ts-3.0/src/hector/designmatrix.py +464 -0
  29. hector_ts-3.0/src/hector/estimate_all_trends.py +261 -0
  30. hector_ts-3.0/src/hector/estimatespectrum.py +382 -0
  31. hector_ts-3.0/src/hector/estimatetrend.py +187 -0
  32. hector_ts-3.0/src/hector/find_all_offsets.py +181 -0
  33. hector_ts-3.0/src/hector/findoffsets.py +126 -0
  34. hector_ts-3.0/src/hector/fullcov.py +87 -0
  35. hector_ts-3.0/src/hector/ggm.py +364 -0
  36. hector_ts-3.0/src/hector/levinson.py +80 -0
  37. hector_ts-3.0/src/hector/matern.py +253 -0
  38. hector_ts-3.0/src/hector/mjd2date.py +40 -0
  39. hector_ts-3.0/src/hector/mle.py +316 -0
  40. hector_ts-3.0/src/hector/msf.py +156 -0
  41. hector_ts-3.0/src/hector/msfdump.py +112 -0
  42. hector_ts-3.0/src/hector/msfgen.py +110 -0
  43. hector_ts-3.0/src/hector/my_calendar.py +117 -0
  44. hector_ts-3.0/src/hector/observations.py +602 -0
  45. hector_ts-3.0/src/hector/ols.py +71 -0
  46. hector_ts-3.0/src/hector/powerlaw.py +152 -0
  47. hector_ts-3.0/src/hector/predicttrenderror.py +241 -0
  48. hector_ts-3.0/src/hector/removeoutliers.py +143 -0
  49. hector_ts-3.0/src/hector/replace_version.py +28 -0
  50. hector_ts-3.0/src/hector/run_schur.py +5 -0
  51. hector_ts-3.0/src/hector/schur.py +363 -0
  52. hector_ts-3.0/src/hector/simulatenoise.py +364 -0
  53. hector_ts-3.0/src/hector/test_Schur.py +378 -0
  54. hector_ts-3.0/src/hector/varyingannual.py +178 -0
  55. hector_ts-3.0/src/hector/white.py +105 -0
  56. hector_ts-3.0/src/hector_ts.egg-info/PKG-INFO +135 -0
  57. hector_ts-3.0/src/hector_ts.egg-info/SOURCES.txt +59 -0
  58. hector_ts-3.0/src/hector_ts.egg-info/dependency_links.txt +1 -0
  59. hector_ts-3.0/src/hector_ts.egg-info/entry_points.txt +16 -0
  60. hector_ts-3.0/src/hector_ts.egg-info/requires.txt +7 -0
  61. hector_ts-3.0/src/hector_ts.egg-info/top_level.txt +1 -0
hector_ts-3.0/LICENSE ADDED
@@ -0,0 +1,78 @@
1
+ HECTOR SOFTWARE LICENSE AGREEMENT
2
+ --------------------------------
3
+
4
+ Version 1.0
5
+
6
+ Copyright (c) 2026
7
+ TeroMovigo – Earth Innovation Lda ("Licensor")
8
+
9
+ 1. DEFINITIONS
10
+
11
+ "Software" means the Hector software package, including source code,
12
+ documentation, and any associated materials provided by the Licensor.
13
+
14
+ "Non-Commercial Use" means use solely for research, academic, educational,
15
+ or other purposes that are not primarily intended for or directed toward
16
+ commercial advantage or monetary compensation.
17
+
18
+ "Commercial Use" means any use that does not qualify as Non-Commercial Use,
19
+ including use by for-profit entities, use in connection with revenue-generating
20
+ activities, or use in proprietary products or services.
21
+
22
+ 2. GRANT OF LICENSE
23
+
24
+ Subject to the terms of this Agreement, the Licensor hereby grants a
25
+ non-exclusive, non-transferable, royalty-free license to use, reproduce,
26
+ modify, and distribute the Software for Non-Commercial Use.
27
+
28
+ 3. COMMERCIAL USE
29
+
30
+ Commercial Use of the Software is not permitted under this license.
31
+ Any Commercial Use requires a separate written agreement with the Licensor.
32
+
33
+ Commercial entities or individuals intending to use the Software for
34
+ Commercial Use must contact:
35
+
36
+ TeroMovigo – Earth Innovation Lda
37
+ info@teromovigo.com / https://teromovigo.com
38
+
39
+ 4. RESTRICTIONS
40
+
41
+ Except as expressly permitted under this Agreement, you may not:
42
+
43
+ (a) use the Software for Commercial Use;
44
+ (b) sublicense, sell, lease, or otherwise distribute the Software
45
+ for Commercial Use;
46
+ (c) remove or alter any copyright or attribution notices.
47
+
48
+ 5. ATTRIBUTION
49
+
50
+ Any redistribution of the Software, in whole or in part, must retain
51
+ this license text and provide appropriate attribution to the Licensor.
52
+
53
+ 6. OWNERSHIP
54
+
55
+ The Software is licensed, not sold. All intellectual property rights,
56
+ including copyright, remain with the Licensor.
57
+
58
+ 7. NO WARRANTY
59
+
60
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
61
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
62
+ FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
63
+
64
+ 8. LIMITATION OF LIABILITY
65
+
66
+ IN NO EVENT SHALL THE LICENSOR BE LIABLE FOR ANY CLAIM, DAMAGES, OR
67
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE,
68
+ ARISING FROM OR IN CONNECTION WITH THE SOFTWARE OR ITS USE.
69
+
70
+ 9. TERMINATION
71
+
72
+ This license terminates automatically if you breach any of its terms.
73
+ Upon termination, you must cease all use of the Software.
74
+
75
+ 10. GOVERNING LAW
76
+
77
+ This Agreement shall be governed by and construed in accordance with
78
+ the laws of [Portugal], without regard to conflict-of-law principles.
@@ -0,0 +1,4 @@
1
+ include src/hector/*.pyx
2
+ include src/hector/*.pxd
3
+ include LICENSE
4
+ include README.md
hector_ts-3.0/PKG-INFO ADDED
@@ -0,0 +1,135 @@
1
+ Metadata-Version: 2.4
2
+ Name: hector-ts
3
+ Version: 3.0
4
+ Summary: A collection of programs to analyse geodetic time series
5
+ Home-page: https://gitlab.com/machielsimonbos/hector-ts
6
+ Author: Machiel Bos
7
+ Author-email: machielbos@protonmail.com
8
+ Project-URL: Bug Tracker, https://gitlab.com/machielsimonbos/hector-ts/issues
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.6
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: pandas
15
+ Requires-Dist: numpy
16
+ Requires-Dist: matplotlib
17
+ Requires-Dist: scipy
18
+ Requires-Dist: mpmath
19
+ Requires-Dist: cython
20
+ Requires-Dist: pyfftw
21
+ Dynamic: author
22
+ Dynamic: author-email
23
+ Dynamic: classifier
24
+ Dynamic: description
25
+ Dynamic: description-content-type
26
+ Dynamic: home-page
27
+ Dynamic: license-file
28
+ Dynamic: project-url
29
+ Dynamic: requires-dist
30
+ Dynamic: requires-python
31
+ Dynamic: summary
32
+
33
+ ### Hector
34
+
35
+ ### Table of Contents
36
+
37
+ 1. [Introduction](#introduction)
38
+ 2. [Code Description](#code)
39
+ 1. [Installation](#installation)
40
+ 2. [Directory Structure](#directories)
41
+ 3. [Bugs/Future Work](#bugs)
42
+
43
+
44
+ ### 1. Introduction <a name="introduction"></a>
45
+
46
+ <p>Hector is a software package that can be used to estimate a trend in time series with temporal correlated noise. Trend estimation is a common task in geophysical research where one is interested in phenomena such as the increase in temperature, sea level or GNSS derived station position over time. The trend can be linear or a higher degree polynomial and in addition one can estimate periodic signals, offsets and post-seismic deformation. Together they represent the model that is fitted to the observations.</p>
47
+
48
+ <p>It is well known that in most geophysical time series the noise is correlated in time ([Agnew, 1992](https://agupubs.onlinelibrary.wiley.com/doi/10.1029/91GL02832); [Beran, 1992](https://www.amazon.com/Statistics-Long-Memory-Processes-Monographs-Probability/dp/0412049015)) and this has a significant influence on the accuracy by which the model parameters can be estimated. Therefore, the use of a computer program such as Hector is advisable. Hector assumes that the user knows what type of temporal correlated noise exists in the observations and estimates both the model parameters and the parameters of the chosen noise model using the Restricted Maximum Likelihood Estimation (RMLE) method. Since for most observations the choice of noise model can be found from literature or by looking at the power spectral density, this is sufficient in most cases.</p>
49
+
50
+ <p>Instead of using Hector, one can also use the [CATS](https://www.ngs.noaa.gov/gps-toolbox/cats.htm) software of Williams (2008). Another alternative is the program [est_noise](https://github.com/langbein-usgs/est_noise) of Langbein (2010). Recent versions include some tricks from Bos et al. (2013) to deal with missing data but with a different way to construct the covariance matrix (Langbein, 2017). Hector is a complete rewrite of [Hector](https://teromovigo.com/hector/) which is written in C++. The reason for changing the programming language was the need to make maintenance of the code easier. The Hector (P for Python) has around 8 times less lines of code than Hector (C++). In addition, Hector could not run on Windows and installation on a Mac computer was difficult. Hector is a truly cross-platform application. I have tried to keep the way Hector works similar to that of the C++ version to smooth the transition</p>
51
+
52
+ The reason Hector is fast is because it makes use of the symmetry in the covariance matrix (i.e., a Toeplitz matrix) to apply fast methods to compute its inverse. Non-stationary noise is approximated by a noise model that becomes stationary at the very, very low frequencies and in this way also a Toeplitz covariance matrix is generated. This is a nutshell the core reason why Hector is fast. Another part is due to clever usage of the Fast Fourier Transform (FFT).
53
+
54
+ <p> In the book by [Montillet and Bos (2020)](https://link.springer.com/book/10.1007/978-3-030-21718-1#about) more examples on the analysis of geodetic time series with temporal correlated noise can be found.</p>
55
+
56
+ <p> The next secion explains how to install Hector on your computer, the best way to organise your files and the recommended work flow to analyse the time series. For more detailed information, see the Wiki pages on this site.</p>
57
+
58
+ ### 2. Code Description <a name="code"></a>
59
+
60
+ List of programs provided by the Hector software package. Details can be found in the Wiki-pages.
61
+
62
+ | Name | Description |
63
+ |:--- |:--- |
64
+ | estimatetrend | Main program to estimate a linear trend. |
65
+ | estimatespectrum | Program to estimate the power spectral density from the data or residuals using the Welch periodogram method. |
66
+ | modelspectrum | Given a noise model and values of the noise parameters, this program computed the associated power spectral density for given frequency range. |
67
+ | removeoutliers | Program to remove outliers from the data. |
68
+ | findoffsets | Program to find the epoch of a possible offset in the time series. |
69
+ | simulatenoise | Program to files with synthetic coloured noise. |
70
+ | date2mjd | Small program to convert calendar date into Modified Julian Date. |
71
+ | mjd2date | The inverse of date2mjd. |
72
+ | msfgen | MSF: MJD - SOD - Format. Small program to combine a json file with metadata and a text file with data in columns into a single binary file. |
73
+ | msfdump | Inverse of msfgen. Small program that reads a msf-file and creates a json file with metadata and a text file with data in columns. |
74
+
75
+
76
+ #### 2.i Installation <a name="installation"></a>
77
+
78
+ Following Python customs, it is best to create a virtual environment by typing on the command line:
79
+ ```
80
+ python3 -m venv env
81
+ source env/bin/activate
82
+ ```
83
+
84
+ This creates the virtual environment (called and stored in `env`) which is then activated. Next, on the command line type:
85
+ ```
86
+ (env) pip install hectorp
87
+ ```
88
+
89
+ That should be it. You can now go to the directory where you have your project and run the hectorp executables. Once you are done, you can exit your virtual environment with:
90
+ ```
91
+ deactivate
92
+ ```
93
+
94
+
95
+ #### 2.ii Directory Structure <a name="directories"></a>
96
+
97
+ The following directory structure is recommended to automate the analysis of your time series with Hector:
98
+ ```
99
+ ori_files
100
+ obs_files
101
+ pre_files
102
+ fin_files
103
+ ```
104
+
105
+ The `ori_files` directory is needed if your time series does follow the Hector formats. Hector comes with scripts to convert formats
106
+ (e.g., enu, pos, sol) into the mom-format which are then stored in the
107
+ `obs_files` directory.
108
+
109
+ The `obs_files` directory contains the time series files in mom/msf-format.
110
+ Normally one wants to remove outliers and the cleaned time series are stored in
111
+ `pre_files`. These are then analysed with 'estimatetrend' to create a copy of
112
+ the observations with the fitted model in the `fin_files` directory. If you
113
+ look at [example/ex1](./examples/ex1) then this will become clearer.
114
+
115
+ The advantage of adapting this directory structure is that you can just type `estimate_all_trends` which will look for all files in the `obs_files` directory, remove the outliers, estimate the trends and finally estimates the power spectral density of the residuals.
116
+
117
+
118
+
119
+ ### 3. Bugs/Future Work <a name="bugs"></a>
120
+
121
+ Of course, one selling point of Hector is its speed. Having a source code that is easy to maintain is all very well for me, but the user does not care about that. Fortunately, the numpy and scipy libraries are optimised which results in good comparison with the C++ version, see table below.
122
+
123
+ | N | C++ (s) | Python (s) |
124
+ |:--- | ---:| ---:|
125
+ | 1000 | 5 | 2.4 |
126
+ | 3000 | 6 | 6.7 |
127
+ | 5000 | 7 | 13.6 |
128
+ | 8000 | 12 | 56.5 |
129
+ | 5000 10% | 16 | 63.8 |
130
+ | 8000 10% | 33 | 81.0 |
131
+ | 5000 20% | 26 | 70.0 |
132
+ | 8000 20% | 60 | 140.0 |
133
+
134
+
135
+
@@ -0,0 +1,103 @@
1
+ ### Hector
2
+
3
+ ### Table of Contents
4
+
5
+ 1. [Introduction](#introduction)
6
+ 2. [Code Description](#code)
7
+ 1. [Installation](#installation)
8
+ 2. [Directory Structure](#directories)
9
+ 3. [Bugs/Future Work](#bugs)
10
+
11
+
12
+ ### 1. Introduction <a name="introduction"></a>
13
+
14
+ <p>Hector is a software package that can be used to estimate a trend in time series with temporal correlated noise. Trend estimation is a common task in geophysical research where one is interested in phenomena such as the increase in temperature, sea level or GNSS derived station position over time. The trend can be linear or a higher degree polynomial and in addition one can estimate periodic signals, offsets and post-seismic deformation. Together they represent the model that is fitted to the observations.</p>
15
+
16
+ <p>It is well known that in most geophysical time series the noise is correlated in time ([Agnew, 1992](https://agupubs.onlinelibrary.wiley.com/doi/10.1029/91GL02832); [Beran, 1992](https://www.amazon.com/Statistics-Long-Memory-Processes-Monographs-Probability/dp/0412049015)) and this has a significant influence on the accuracy by which the model parameters can be estimated. Therefore, the use of a computer program such as Hector is advisable. Hector assumes that the user knows what type of temporal correlated noise exists in the observations and estimates both the model parameters and the parameters of the chosen noise model using the Restricted Maximum Likelihood Estimation (RMLE) method. Since for most observations the choice of noise model can be found from literature or by looking at the power spectral density, this is sufficient in most cases.</p>
17
+
18
+ <p>Instead of using Hector, one can also use the [CATS](https://www.ngs.noaa.gov/gps-toolbox/cats.htm) software of Williams (2008). Another alternative is the program [est_noise](https://github.com/langbein-usgs/est_noise) of Langbein (2010). Recent versions include some tricks from Bos et al. (2013) to deal with missing data but with a different way to construct the covariance matrix (Langbein, 2017). Hector is a complete rewrite of [Hector](https://teromovigo.com/hector/) which is written in C++. The reason for changing the programming language was the need to make maintenance of the code easier. The Hector (P for Python) has around 8 times less lines of code than Hector (C++). In addition, Hector could not run on Windows and installation on a Mac computer was difficult. Hector is a truly cross-platform application. I have tried to keep the way Hector works similar to that of the C++ version to smooth the transition</p>
19
+
20
+ The reason Hector is fast is because it makes use of the symmetry in the covariance matrix (i.e., a Toeplitz matrix) to apply fast methods to compute its inverse. Non-stationary noise is approximated by a noise model that becomes stationary at the very, very low frequencies and in this way also a Toeplitz covariance matrix is generated. This is a nutshell the core reason why Hector is fast. Another part is due to clever usage of the Fast Fourier Transform (FFT).
21
+
22
+ <p> In the book by [Montillet and Bos (2020)](https://link.springer.com/book/10.1007/978-3-030-21718-1#about) more examples on the analysis of geodetic time series with temporal correlated noise can be found.</p>
23
+
24
+ <p> The next secion explains how to install Hector on your computer, the best way to organise your files and the recommended work flow to analyse the time series. For more detailed information, see the Wiki pages on this site.</p>
25
+
26
+ ### 2. Code Description <a name="code"></a>
27
+
28
+ List of programs provided by the Hector software package. Details can be found in the Wiki-pages.
29
+
30
+ | Name | Description |
31
+ |:--- |:--- |
32
+ | estimatetrend | Main program to estimate a linear trend. |
33
+ | estimatespectrum | Program to estimate the power spectral density from the data or residuals using the Welch periodogram method. |
34
+ | modelspectrum | Given a noise model and values of the noise parameters, this program computed the associated power spectral density for given frequency range. |
35
+ | removeoutliers | Program to remove outliers from the data. |
36
+ | findoffsets | Program to find the epoch of a possible offset in the time series. |
37
+ | simulatenoise | Program to files with synthetic coloured noise. |
38
+ | date2mjd | Small program to convert calendar date into Modified Julian Date. |
39
+ | mjd2date | The inverse of date2mjd. |
40
+ | msfgen | MSF: MJD - SOD - Format. Small program to combine a json file with metadata and a text file with data in columns into a single binary file. |
41
+ | msfdump | Inverse of msfgen. Small program that reads a msf-file and creates a json file with metadata and a text file with data in columns. |
42
+
43
+
44
+ #### 2.i Installation <a name="installation"></a>
45
+
46
+ Following Python customs, it is best to create a virtual environment by typing on the command line:
47
+ ```
48
+ python3 -m venv env
49
+ source env/bin/activate
50
+ ```
51
+
52
+ This creates the virtual environment (called and stored in `env`) which is then activated. Next, on the command line type:
53
+ ```
54
+ (env) pip install hectorp
55
+ ```
56
+
57
+ That should be it. You can now go to the directory where you have your project and run the hectorp executables. Once you are done, you can exit your virtual environment with:
58
+ ```
59
+ deactivate
60
+ ```
61
+
62
+
63
+ #### 2.ii Directory Structure <a name="directories"></a>
64
+
65
+ The following directory structure is recommended to automate the analysis of your time series with Hector:
66
+ ```
67
+ ori_files
68
+ obs_files
69
+ pre_files
70
+ fin_files
71
+ ```
72
+
73
+ The `ori_files` directory is needed if your time series does follow the Hector formats. Hector comes with scripts to convert formats
74
+ (e.g., enu, pos, sol) into the mom-format which are then stored in the
75
+ `obs_files` directory.
76
+
77
+ The `obs_files` directory contains the time series files in mom/msf-format.
78
+ Normally one wants to remove outliers and the cleaned time series are stored in
79
+ `pre_files`. These are then analysed with 'estimatetrend' to create a copy of
80
+ the observations with the fitted model in the `fin_files` directory. If you
81
+ look at [example/ex1](./examples/ex1) then this will become clearer.
82
+
83
+ The advantage of adapting this directory structure is that you can just type `estimate_all_trends` which will look for all files in the `obs_files` directory, remove the outliers, estimate the trends and finally estimates the power spectral density of the residuals.
84
+
85
+
86
+
87
+ ### 3. Bugs/Future Work <a name="bugs"></a>
88
+
89
+ Of course, one selling point of Hector is its speed. Having a source code that is easy to maintain is all very well for me, but the user does not care about that. Fortunately, the numpy and scipy libraries are optimised which results in good comparison with the C++ version, see table below.
90
+
91
+ | N | C++ (s) | Python (s) |
92
+ |:--- | ---:| ---:|
93
+ | 1000 | 5 | 2.4 |
94
+ | 3000 | 6 | 6.7 |
95
+ | 5000 | 7 | 13.6 |
96
+ | 8000 | 12 | 56.5 |
97
+ | 5000 10% | 16 | 63.8 |
98
+ | 8000 10% | 33 | 81.0 |
99
+ | 5000 20% | 26 | 70.0 |
100
+ | 8000 20% | 60 | 140.0 |
101
+
102
+
103
+
@@ -0,0 +1,10 @@
1
+ [build-system]
2
+ requires = [
3
+ "setuptools>=42",
4
+ "wheel",
5
+ "cython",
6
+ "numpy",
7
+ "pyfftw",
8
+ ]
9
+ build-backend = "setuptools.build_meta"
10
+
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
hector_ts-3.0/setup.py ADDED
@@ -0,0 +1,147 @@
1
+ import os
2
+ import sys
3
+ import subprocess
4
+ import setuptools
5
+ from setuptools import Extension
6
+ from Cython.Build import cythonize
7
+ import numpy as np
8
+ import pyfftw
9
+
10
+
11
+ def _fftw_include_dirs():
12
+ """Return a list of include directories that contain fftw3.h, portably."""
13
+ # 1. Honour an explicit override (useful on Windows or exotic installs).
14
+ fftw_dir = os.environ.get('FFTW_DIR')
15
+ if fftw_dir:
16
+ return [fftw_dir]
17
+
18
+ # 2. Ask pkg-config (works on Linux and macOS with Homebrew/MacPorts).
19
+ try:
20
+ out = subprocess.check_output(
21
+ ['pkg-config', '--cflags-only-I', 'fftw3'],
22
+ stderr=subprocess.DEVNULL, text=True,
23
+ )
24
+ dirs = [tok[2:] for tok in out.split() if tok.startswith('-I')]
25
+ if dirs:
26
+ return dirs
27
+ except (subprocess.CalledProcessError, FileNotFoundError):
28
+ pass
29
+
30
+ # 3. Search common platform-specific locations.
31
+ candidates = [
32
+ '/usr/include',
33
+ '/usr/local/include',
34
+ ]
35
+ if sys.platform == 'darwin':
36
+ candidates += [
37
+ '/opt/homebrew/include', # Apple Silicon Homebrew
38
+ '/usr/local/include', # Intel Homebrew / MacPorts
39
+ ]
40
+ elif sys.platform == 'win32':
41
+ candidates += [
42
+ r'C:\vcpkg\installed\x64-windows\include',
43
+ r'C:\fftw3',
44
+ r'C:\Program Files\fftw3\include',
45
+ r'C:\Program Files (x86)\fftw3\include',
46
+ ]
47
+
48
+ found = [d for d in candidates if os.path.isfile(os.path.join(d, 'fftw3.h'))]
49
+ if found:
50
+ return found
51
+
52
+ raise RuntimeError(
53
+ "fftw3.h not found. Install FFTW3 (e.g. 'brew install fftw', "
54
+ "'apt install libfftw3-dev', or 'conda install -c conda-forge fftw') "
55
+ "or set the FFTW_DIR environment variable to its include directory."
56
+ )
57
+
58
+
59
+ def _fftw_ext_kwargs():
60
+ """Return Extension kwargs for Cython modules that link against FFTW3."""
61
+ inc = [np.get_include(), os.path.dirname(pyfftw.__file__)] + _fftw_include_dirs()
62
+ kwargs = {'include_dirs': inc}
63
+ if sys.platform == 'win32':
64
+ # Derive lib dir from the include dir (FFTW_DIR points to …/include,
65
+ # sibling …/lib holds fftw3.lib; vcpkg layout assumed as fallback).
66
+ inc_dirs = _fftw_include_dirs()
67
+ if inc_dirs:
68
+ lib_dir = os.path.join(os.path.dirname(inc_dirs[0]), 'lib')
69
+ else:
70
+ lib_dir = r'C:\vcpkg\installed\x64-windows\lib'
71
+ kwargs['library_dirs'] = [lib_dir]
72
+ # vcpkg names the import lib fftw3.lib (links to fftw3-3.dll at runtime)
73
+ kwargs['libraries'] = ['fftw3']
74
+ return kwargs
75
+
76
+ with open("README.md", "r", encoding="utf-8") as fh:
77
+ long_description = fh.read()
78
+
79
+ setuptools.setup(
80
+ name="hector-ts",
81
+ version="3.0",
82
+ author="Machiel Bos",
83
+ author_email="machielbos@protonmail.com",
84
+ description="A collection of programs to analyse geodetic time series",
85
+ long_description=long_description,
86
+ long_description_content_type="text/markdown",
87
+ url="https://gitlab.com/machielsimonbos/hector-ts",
88
+ project_urls={
89
+ "Bug Tracker": "https://gitlab.com/machielsimonbos/hector-ts/issues",
90
+ },
91
+ classifiers=[
92
+ "Programming Language :: Python :: 3",
93
+ "Operating System :: OS Independent",
94
+ ],
95
+ package_dir={"": "src"},
96
+ packages=setuptools.find_packages(where="src"),
97
+ package_data={"hector": ["*.pyx", "*.pxd"]},
98
+ python_requires=">=3.6",
99
+ install_requires=[
100
+ 'pandas',
101
+ 'numpy',
102
+ 'matplotlib',
103
+ 'scipy',
104
+ 'mpmath',
105
+ 'cython',
106
+ 'pyfftw',
107
+ ],
108
+ ext_modules=cythonize(
109
+ [
110
+ "src/hector/_epoch_scan_gaps.pyx",
111
+ "src/hector/_gap_correction.pyx",
112
+ "src/hector/_ggm.pyx",
113
+ "src/hector/_levinson.pyx",
114
+ Extension(
115
+ "hector._schur_gsa",
116
+ sources=["src/hector/_schur_gsa.pyx"],
117
+ **_fftw_ext_kwargs(),
118
+ ),
119
+ Extension(
120
+ "hector._schur_multiply",
121
+ sources=["src/hector/_schur_multiply.pyx"],
122
+ **_fftw_ext_kwargs(),
123
+ ),
124
+ ],
125
+ language_level="3",
126
+ ),
127
+ include_dirs=[np.get_include()],
128
+ entry_points ={
129
+ 'console_scripts': [
130
+ 'estimatespectrum = hector.estimatespectrum:main',
131
+ 'modelspectrum = hector.modelspectrum:main',
132
+ 'estimatetrend = hector.estimatetrend:main',
133
+ 'estimate_all_trends = hector.estimate_all_trends:main',
134
+ 'removeoutliers = hector.removeoutliers:main',
135
+ 'findoffsets = hector.findoffsets:main',
136
+ 'find_all_offsets = hector.find_all_offsets:main',
137
+ 'simulatenoise = hector.simulatenoise:main',
138
+ 'mjd2date = hector.mjd2date:main',
139
+ 'date2mjd = hector.date2mjd:main',
140
+ 'convert_rlrdata2mom = hector.convert_rlrdata2mom:main',
141
+ 'predict_error = hector.predict_error:main',
142
+ 'test_Schur = hector.test_Schur:main',
143
+ 'msfgen= hector.msfgen:main',
144
+ 'msfdump= hector.msfdump:main',
145
+ ],
146
+ }
147
+ )
File without changes