shipgrav 1.0.0__tar.gz → 1.0.3__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 (55) hide show
  1. {shipgrav-1.0.0 → shipgrav-1.0.3}/.github/workflows/test.yml +5 -24
  2. shipgrav-1.0.3/CHANGELOG +25 -0
  3. shipgrav-1.0.3/CONTRIBUTORS.md +27 -0
  4. {shipgrav-1.0.0 → shipgrav-1.0.3}/PKG-INFO +9 -3
  5. {shipgrav-1.0.0 → shipgrav-1.0.3}/example-scripts/RMBA_calc.py +1 -1
  6. {shipgrav-1.0.0 → shipgrav-1.0.3}/example-scripts/download_data.sh +5 -5
  7. {shipgrav-1.0.0 → shipgrav-1.0.3}/joss/paper.md +2 -2
  8. {shipgrav-1.0.0 → shipgrav-1.0.3}/pyproject.toml +4 -2
  9. {shipgrav-1.0.0 → shipgrav-1.0.3}/readme.md +5 -1
  10. {shipgrav-1.0.0 → shipgrav-1.0.3}/shipgrav/__init__.py +9 -9
  11. {shipgrav-1.0.0 → shipgrav-1.0.3}/shipgrav/io.py +25 -22
  12. {shipgrav-1.0.0 → shipgrav-1.0.3}/shipgrav/tests/__init__.py +4 -3
  13. shipgrav-1.0.0/CHANGELOG +0 -10
  14. shipgrav-1.0.0/CONTRIBUTORS +0 -1
  15. {shipgrav-1.0.0 → shipgrav-1.0.3}/.github/test_conda_env.yml +0 -0
  16. {shipgrav-1.0.0 → shipgrav-1.0.3}/.github/workflows/draft-pdf.yml +0 -0
  17. {shipgrav-1.0.0 → shipgrav-1.0.3}/.github/workflows/release-publish.yml +0 -0
  18. {shipgrav-1.0.0 → shipgrav-1.0.3}/.gitignore +0 -0
  19. {shipgrav-1.0.0 → shipgrav-1.0.3}/.readthedocs.yml +0 -0
  20. {shipgrav-1.0.0 → shipgrav-1.0.3}/LICENSE +0 -0
  21. {shipgrav-1.0.0 → shipgrav-1.0.3}/docs/Makefile +0 -0
  22. {shipgrav-1.0.0 → shipgrav-1.0.3}/docs/_static/SR2312_serial_laptop.png +0 -0
  23. {shipgrav-1.0.0 → shipgrav-1.0.3}/docs/_static/TN400_FAA.png +0 -0
  24. {shipgrav-1.0.0 → shipgrav-1.0.3}/docs/_static/TN400_ccp.png +0 -0
  25. {shipgrav-1.0.0 → shipgrav-1.0.3}/docs/_static/cursor.png +0 -0
  26. {shipgrav-1.0.0 → shipgrav-1.0.3}/docs/_static/rmba.png +0 -0
  27. {shipgrav-1.0.0 → shipgrav-1.0.3}/docs/_static/roll_coherence.png +0 -0
  28. {shipgrav-1.0.0 → shipgrav-1.0.3}/docs/_templates/mynavigation.html +0 -0
  29. {shipgrav-1.0.0 → shipgrav-1.0.3}/docs/conf.py +0 -0
  30. {shipgrav-1.0.0 → shipgrav-1.0.3}/docs/index.rst +0 -0
  31. {shipgrav-1.0.0 → shipgrav-1.0.3}/docs/make.bat +0 -0
  32. {shipgrav-1.0.0 → shipgrav-1.0.3}/docs/requirements.txt +0 -0
  33. {shipgrav-1.0.0 → shipgrav-1.0.3}/example-scripts/dgs_bgm_comp.py +0 -0
  34. {shipgrav-1.0.0 → shipgrav-1.0.3}/example-scripts/dgs_ccp_calc.py +0 -0
  35. {shipgrav-1.0.0 → shipgrav-1.0.3}/example-scripts/dgs_raw_comp.py +0 -0
  36. {shipgrav-1.0.0 → shipgrav-1.0.3}/example-scripts/interactive_line_pick.py +0 -0
  37. {shipgrav-1.0.0 → shipgrav-1.0.3}/example-scripts/mru_coherence.py +0 -0
  38. {shipgrav-1.0.0 → shipgrav-1.0.3}/joss/paper.bib +0 -0
  39. {shipgrav-1.0.0 → shipgrav-1.0.3}/shipgrav/database.toml +0 -0
  40. {shipgrav-1.0.0 → shipgrav-1.0.3}/shipgrav/grav.py +0 -0
  41. {shipgrav-1.0.0 → shipgrav-1.0.3}/shipgrav/nav.py +0 -0
  42. {shipgrav-1.0.0 → shipgrav-1.0.3}/shipgrav/tests/__main__.py +0 -0
  43. {shipgrav-1.0.0 → shipgrav-1.0.3}/shipgrav/tests/ex_files/AT05_01_bgm.RGS +0 -0
  44. {shipgrav-1.0.0 → shipgrav-1.0.3}/shipgrav/tests/ex_files/DGStest_laptop.dat +0 -0
  45. {shipgrav-1.0.0 → shipgrav-1.0.3}/shipgrav/tests/ex_files/IXBlue.yaml +0 -0
  46. {shipgrav-1.0.0 → shipgrav-1.0.3}/shipgrav/tests/ex_files/SR2312_dgs_raw.txt +0 -0
  47. {shipgrav-1.0.0 → shipgrav-1.0.3}/shipgrav/tests/ex_files/SR2312_mru.txt +0 -0
  48. {shipgrav-1.0.0 → shipgrav-1.0.3}/shipgrav/tests/ex_files/TN400_bgm.Raw +0 -0
  49. {shipgrav-1.0.0 → shipgrav-1.0.3}/shipgrav/tests/ex_files/TN400_nav.Raw +0 -0
  50. {shipgrav-1.0.0 → shipgrav-1.0.3}/shipgrav/tests/test_grav_data.py +0 -0
  51. {shipgrav-1.0.0 → shipgrav-1.0.3}/shipgrav/tests/test_grav_nodata.py +0 -0
  52. {shipgrav-1.0.0 → shipgrav-1.0.3}/shipgrav/tests/test_io.py +0 -0
  53. {shipgrav-1.0.0 → shipgrav-1.0.3}/shipgrav/tests/test_nav.py +0 -0
  54. {shipgrav-1.0.0 → shipgrav-1.0.3}/shipgrav/tests/test_utils.py +0 -0
  55. {shipgrav-1.0.0 → shipgrav-1.0.3}/shipgrav/utils.py +0 -0
@@ -1,7 +1,7 @@
1
1
  name: tests
2
2
  on:
3
- #push:
4
- workflow_dispatch:
3
+ push:
4
+ #workflow_dispatch:
5
5
  pull_request:
6
6
  branches:
7
7
  # only branches from forks which have the form 'user:branch-name'
@@ -13,29 +13,10 @@ jobs:
13
13
  strategy:
14
14
  fail-fast: false
15
15
  matrix:
16
- os: [ubuntu-latest]
17
- python: [3.9, "3.10"]
16
+ os: [ubuntu-latest, macos-latest, windows-latest]
17
+ python: [3.9, "3.10","3.13"]
18
18
  add_package: [""]
19
19
  continue-on-error: [false]
20
- include:
21
- - os: macos-latest
22
- python: 3.9
23
- continue-on-error: false
24
- - os: windows-latest
25
- python: 3.9
26
- continue-on-error: false
27
- - os: ubuntu-latest
28
- python: 3.9
29
- add_package: features
30
- continue-on-error: true
31
- - os: macos-latest
32
- python: 3.9
33
- add_package: features
34
- continue-on-error: true
35
- - os: windows-latest
36
- python: 3.9
37
- add_package: features
38
- continue-on-error: true
39
20
  runs-on: ${{ matrix.os }}
40
21
  continue-on-error: ${{ matrix.continue-on-error }}
41
22
  defaults:
@@ -63,6 +44,6 @@ jobs:
63
44
  coverage run --include='*/shipgrav/*' -m shipgrav.tests
64
45
  coverage xml -o ../coverage.xml
65
46
  - name: upload coverage
66
- uses: codecov/codecov-action@v3
47
+ uses: codecov/codecov-action@v4
67
48
  env:
68
49
  CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
@@ -0,0 +1,25 @@
1
+ 2024-10-25 Hannah F Mark <hmark@whoi.edu>
2
+
3
+ * update pkg_resources (deprecated from 3.13) to importlib.resources for test suite
4
+ * fix download_data.sh curl by adding -L to follow R2R links
5
+ * fix SyntaxWarning for regular expressions in io.py by making raw strings
6
+ * fix DeprecationWarning for parse_dates with nested sequences, sub in pd.to_datetime
7
+ * fix FutureWarning for to_numeric, apply by column instead of whole DataFrame
8
+ * add geographiclib as dependency for RMBA example script (used for line extension)
9
+ * set tests to run on push (keeping scheduled ones too)
10
+ * add Python 3.13 to the test matrix, simplify the os matrix logic
11
+ * update codecov action to v4 for nodejs version
12
+ * update CONTRIBUTORS -> to markdown, with info on who did what prior to github upload
13
+ * fix indexing in one part of RMBA example script for future deprecation of chained assignment
14
+ * add detail to contributor guidelines
15
+
16
+ 2024-07-15 Hannah F Mark <hmark@whoi.edu>
17
+
18
+ * PEP8 reformat, typos
19
+ * include some 2D functions for Parker method, rename the 1D one
20
+ * repo is now in PFPE org instead of WHOIGit
21
+
22
+ 2024-04-23 Hannah F Mark <hmark@whoi.edu>
23
+
24
+ * docs/conf.py, readme.md, shipgrav/__init__.py: updated repo URLS
25
+ after repo tranfered to WHOIGit
@@ -0,0 +1,27 @@
1
+ # Contributors
2
+ Contributors to shipgrav are listed and described using the [Contributor Role Taxonomoy (CRediT)](https://credit.niso.org/)
3
+
4
+ ## Hannah F. Mark
5
+ - Conceptualization
6
+ - Data curation
7
+ - Software
8
+ - Visualization
9
+ - Writing -- original draft (JOSS)
10
+ - Writing -- review and editing (JOSS)
11
+
12
+ ## Masako Tominaga
13
+ - Conceptualization
14
+ - Funding acquisition
15
+ - Supervision
16
+ - Validation
17
+ - Writing -- review and editing (JOSS)
18
+
19
+ ## Jasmine Zhu
20
+ - Software
21
+
22
+ ## Maurice Tivey
23
+ - Funding acquisition
24
+ - Writing -- review and editing (JOSS)
25
+
26
+ ## Daniel Aliod
27
+ - Software
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: shipgrav
3
- Version: 1.0.0
3
+ Version: 1.0.3
4
4
  Summary: Functions for marine gravity data processing and reduction
5
5
  Author-email: "Hannah F. Mark" <hmark@whoi.edu>
6
6
  Maintainer-email: "Hannah F. Mark" <hmark@whoi.edu>
@@ -9,13 +9,15 @@ Keywords: UNOLS,gravimetry,marine gravity
9
9
  Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
10
10
  Classifier: Operating System :: OS Independent
11
11
  Classifier: Programming Language :: Python :: 3
12
- Requires-Dist: matplotlib
13
12
  Requires-Dist: numpy
14
13
  Requires-Dist: pandas
15
14
  Requires-Dist: pyyaml
16
15
  Requires-Dist: scipy
17
16
  Requires-Dist: statsmodels
18
17
  Requires-Dist: tomli
18
+ Provides-Extra: examples
19
+ Requires-Dist: geographiclib; extra == 'examples'
20
+ Requires-Dist: matplotlib; extra == 'examples'
19
21
  Description-Content-Type: text/markdown
20
22
 
21
23
  # shipgrav
@@ -35,10 +37,14 @@ pyyaml
35
37
  To run the example scripts, you will also need matplotlib.
36
38
 
37
39
  ## Installation
38
- shipgrav can be installed using `pip`. Detailed instructions are in the [documentation](https://shipgrav.readthedocs.io/).
40
+ shipgrav can be installed from PyPI using `pip`. Detailed instructions are in the [documentation](https://shipgrav.readthedocs.io/).
39
41
 
40
42
  ## Documentation and usage
41
43
  The shipgrav documentation is available online at [shipgrav.readthedocs.io](https://shipgrav.readthedocs.io/). It can also be accessed offline by building the contents of the `docs` folder using sphinx.
42
44
 
43
45
  ## Contributing to shipgrav
44
46
  Please do! If you have ideas for how to make shipgrav better, you can raise an issue on github or contact PFPE.
47
+
48
+ If you raise an issue on github, please include as much detail as possible about any errors you are encountering or any proposed enhancements to the code. Include the text of any error messages, and if the issue is unexpected behavior from the code without any visible error messages, describe both what the code is doing and what you think it *should* be doing instead. PFPE may ask for additional details and/or copies of data files in order to reproduce and diagnose an issue.
49
+
50
+ Additions or enhancements to the code are also welcome. Contributors are invited to fork the repository and submit pull requests for the maintainers to review.
@@ -142,7 +142,7 @@ B = firwin(taps, wn, window='blackman') # approx equivalent to matlab fir1
142
142
  ffaa = filtfilt(B, 1, data['faa'])
143
143
 
144
144
  # embed our FAA in the tracked line (everything else remains tracked)
145
- track['faa'].iloc[n_ext+taps:-n_ext-taps] = ffaa[taps:-taps]
145
+ track.loc[n_ext+taps:n_ext+taps+len(ffaa[taps:-taps])-1,'faa'] = ffaa[taps:-taps]
146
146
  # NOTE you may want to check your embedded FAA for large jumps at the ends
147
147
  # and smooth them out into the gridded data. Not bothering here because
148
148
  # the jumps aren't *too* big* and also we don't care that much about the
@@ -41,9 +41,9 @@ cd temp
41
41
  # TN400 data: BGM3 and nav
42
42
  # https://doi.org/10.7284/151470 (grav)
43
43
  # https://doi.org/10.7284/151457 (nav)
44
- curl -X GET https://service.rvdata.us/data/cruise/TN400/fileset/151470 --output TN400-grav.tar.gz
44
+ curl -L -X GET https://service.rvdata.us/data/cruise/TN400/fileset/151470 --output TN400-grav.tar.gz
45
45
  tar -xvzf TN400-grav.tar.gz
46
- curl -X GET https://service.rvdata.us/data/cruise/TN400/fileset/151457 --output TN400-nav.tar.gz
46
+ curl -L -X GET https://service.rvdata.us/data/cruise/TN400/fileset/151457 --output TN400-nav.tar.gz
47
47
  tar -xvzf TN400-nav.tar.gz
48
48
  for e in 20220313 20220314; do
49
49
  mv TN400/151470/data/*$e* ../data/Thompson/TN400/gravimeter/BGM3/serial
@@ -58,11 +58,11 @@ rm TN400-nav.tar.gz
58
58
  # https://doi.org/10.7284/157179 (grav)
59
59
  # https://doi.org/10.7284/157188 (nav)
60
60
  # https://doi.org/10.7284/157177 (mru)
61
- curl -X GET https://service.rvdata.us/data/cruise/SR2312/fileset/157179 --output SR2312-grav.tar.gz
61
+ curl -L -X GET https://service.rvdata.us/data/cruise/SR2312/fileset/157179 --output SR2312-grav.tar.gz
62
62
  tar -xvzf SR2312-grav.tar.gz
63
- curl -X GET https://service.rvdata.us/data/cruise/SR2312/fileset/157188 --output SR2312-nav.tar.gz
63
+ curl -L -X GET https://service.rvdata.us/data/cruise/SR2312/fileset/157188 --output SR2312-nav.tar.gz
64
64
  tar -xvzf SR2312-nav.tar.gz
65
- curl -X GET https://service.rvdata.us/data/cruise/SR2312/fileset/157177 --output SR2312-mru.tar.gz
65
+ curl -L -X GET https://service.rvdata.us/data/cruise/SR2312/fileset/157177 --output SR2312-mru.tar.gz
66
66
  tar -xvzf SR2312-mru.tar.gz
67
67
  for e in 16 17 18 19 20; do
68
68
  mv SR2312/157179/data/*_202306$e*.dat ../data/Ride/SR2312/gravimeter/DGS
@@ -38,7 +38,7 @@ Here we present a Python package implementing the calibrations and corrections c
38
38
 
39
39
  # Statement of need
40
40
 
41
- `shipgrav` is a Python package for marine gravimetry, designed as a tool for the marine geophysical research community. Marine gravity data is routinely collected on UNOLS vessels and archived for public access (after an embargo period) through the [Rolling Deck to Repository](https://www.rvdata.us) program, but researchers who work with this data have traditionally used their own personal processing tools for data analysis. One major goal of `shipgrav` is to make marine gravity data more accessible to the broader community, including researchers who want to incorporate gravity into other geophysical analyses without re-writing implementations of the standard workflow. The package includes a suite of example scripts demonstrating all the steps for marine gravity processing using publicly available data. These examples can be used as teaching tools, and as a starting framework for research applications.
41
+ `shipgrav` is a Python package for marine gravimetry, designed as a tool for the marine geophysical research community. Marine gravity data is routinely collected on UNOLS vessels and archived for public access (after an embargo period) through the [Rolling Deck to Repository](https://www.rvdata.us) program, but researchers who work with this data have traditionally used their own personal processing tools for data analysis. There are some public software tools that handle parts of the processing workflow, such as @jrleeman's [Longman tide correction](https://github.com/jrleeman/LongmanTide) package and a [MATLAB toolkit](https://github.com/MAG-tominaga/DgSGravCode) that does some AT1M data processing, but the authors are not aware of any complete processing workflows for this type of data that are publicly available and entirely open-source. One major goal of `shipgrav` is to make marine gravity data more accessible to the broader community, including researchers who want to incorporate gravity into other geophysical analyses without re-writing implementations of the standard workflow or needing a MATLAB license. The package includes a suite of example scripts demonstrating all the steps for marine gravity processing using publicly available data. These examples can be used as teaching tools, and as a starting framework for research applications.
42
42
 
43
43
  `shipgrav` includes a set of vessel-specific input functions which take into account the differences in file formats between different instruments and operators. While shipboard gravimeters are commonly configured to output the same or similar sets of data fields in ASCII files, there is not a standard data string format. Known formats for gravimeters on UNOLS vessels are built into `shipgrav` so that users can easily read in data. The framework is designed so that users can plug in their own functions to read and parse files for vessels or formats that are not yet included. There are also functions for reading separately recorded navigation data and synchronizing geographic coordinates with gravimeter records based on timestamps, which is necessary for integrating gravity data with other geophysical analyses.
44
44
 
@@ -57,6 +57,6 @@ Figure sizes can be customized by adding an optional second parameter:
57
57
 
58
58
  # Acknowledgements
59
59
 
60
- The development of shipgrav was supported by the Potential Field Pool Equipment (PFPE) facility, which is funded by the National Science Foundation under grants OCE-2234277 and OCE-1824508; and by the Office of Naval Research under DURIP grant N00014-23-1-2475. Functions for calculating thermal structure were adapted from scripts provided by Mark Behn.
60
+ The development of shipgrav was supported by the Potential Field Pool Equipment (PFPE) facility, which is funded by the National Science Foundation under grants OCE-2234277 and OCE-1824508; and by the Office of Naval Research under DURIP grant N00014-23-1-2475. Functions for calculating thermal structure were adapted from scripts provided by Mark Behn. Nigel Brady at DGS helpfully answered many questions about the AT1M system.
61
61
 
62
62
  # References
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "shipgrav"
7
- version = "1.0.0"
7
+ version = "1.0.3"
8
8
  authors = [
9
9
  {name = "Hannah F. Mark", email = "hmark@whoi.edu"},
10
10
  ]
@@ -24,7 +24,9 @@ dependencies = [
24
24
  "pandas",
25
25
  "scipy",
26
26
  "tomli",
27
- "matplotlib",
28
27
  "statsmodels",
29
28
  "pyyaml"
30
29
  ]
30
+
31
+ [project.optional-dependencies]
32
+ examples = ["matplotlib", "geographiclib"]
@@ -15,10 +15,14 @@ pyyaml
15
15
  To run the example scripts, you will also need matplotlib.
16
16
 
17
17
  ## Installation
18
- shipgrav can be installed using `pip`. Detailed instructions are in the [documentation](https://shipgrav.readthedocs.io/).
18
+ shipgrav can be installed from PyPI using `pip`. Detailed instructions are in the [documentation](https://shipgrav.readthedocs.io/).
19
19
 
20
20
  ## Documentation and usage
21
21
  The shipgrav documentation is available online at [shipgrav.readthedocs.io](https://shipgrav.readthedocs.io/). It can also be accessed offline by building the contents of the `docs` folder using sphinx.
22
22
 
23
23
  ## Contributing to shipgrav
24
24
  Please do! If you have ideas for how to make shipgrav better, you can raise an issue on github or contact PFPE.
25
+
26
+ If you raise an issue on github, please include as much detail as possible about any errors you are encountering or any proposed enhancements to the code. Include the text of any error messages, and if the issue is unexpected behavior from the code without any visible error messages, describe both what the code is doing and what you think it *should* be doing instead. PFPE may ask for additional details and/or copies of data files in order to reproduce and diagnose an issue.
27
+
28
+ Additions or enhancements to the code are also welcome. Contributors are invited to fork the repository and submit pull requests for the maintainers to review.
@@ -9,7 +9,11 @@ DGS gravimeters output two types of files: serial, or 'raw' files; and 'laptop'
9
9
  Installation
10
10
  ------------
11
11
 
12
- shipgrav can be installed from the source files (`available on github <https://github.com/PFPE/shipgrav>`_) using ``pip``.
12
+ shipgrav can be installed from `PyPI <https://pypi.org/project/shipgrav/>`_ using ``pip``. we recommend using an environment management tool like `conda <https://anaconda.org>`_. An exemplary set of commands to make a conda enviroment with shipgrav would be: ::
13
+
14
+ conda create --name shipgrav numpy scipy pandas statsmodels tomli pyyaml matplotlib geographiclib
15
+ conda activate shipgrav
16
+ pip install shipgrav
13
17
 
14
18
  shipgrav's dependencies are
15
19
 
@@ -21,15 +25,9 @@ shipgrav's dependencies are
21
25
  * tomli
22
26
  * pyyaml
23
27
  * matplotlib (optional, needed to run some of the example scripts)
28
+ * geographiclib (optional, needed to run one of the example scripts)
24
29
 
25
- To install shipgrav, we recommend using an environment management tool like `conda <https://anaconda.org>`_. An exemplary set of commands to make a conda enviroment with shipgrav would be: ::
26
-
27
- conda create --name shipgrav numpy scipy pandas statsmodels tomli pyyaml matplotlib
28
- conda activate shipgrav
29
- cd /path/to/put/source/files
30
- git clone https://github.com/PFPE/shipgrav.git
31
- cd shipgrav/
32
- pip install .
30
+ The example scripts are `available on github <https://github.com/PFPE/shipgrav>`_. They are not packaged with the PyPI package and must be downloaded separately.
33
31
 
34
32
  Modules and files
35
33
  -----------------
@@ -144,4 +142,6 @@ Contributing
144
142
 
145
143
  Do you have ideas for making this software better? Go ahead and `raise an issue <https://github.com/PFPE/shipgrav/issues>`_ on the github page or, if you're a savvy Python programmer, submit a pull request. You can also email PFPE at pfpe-interal(at)whoi.edu.
146
144
 
145
+ If you raise an issue on github, please include as much detail as possible, such as the text of error messages. If there are no visible errors but you think the code is behaving oddly, provide a description of what the code is doing and what you think it *should* be doing instead. PFPE may ask for additional details or copies of data files in order to reproduce and diagnose an issue.
146
+
147
147
  """
@@ -169,7 +169,7 @@ def _navdate_Atlantis(allnav, talker):
169
169
 
170
170
  for i in range(N):
171
171
  pre = subnav[i].split(talker)[0]
172
- date = re.findall('NAV (\d{4})/(\d{2})/(\d{2})', pre)[0]
172
+ date = re.findall(r'NAV (\d{4})/(\d{2})/(\d{2})', pre)[0]
173
173
  year = int(date[0]) # year
174
174
  mon = int(date[1]) # month
175
175
  day = int(date[2]) # day
@@ -191,7 +191,7 @@ def _navdate_NBP(allnav, talker):
191
191
 
192
192
  for i in range(N):
193
193
  pre = subnav[i].split(talker)[0]
194
- date = re.findall('(\d{2})\+(\d{2,3}):.*', pre)[0]
194
+ date = re.findall(r'(\d{2})\+(\d{2,3}):.*', pre)[0]
195
195
  # year (NBP didn't exist before 2000 so this is ok)
196
196
  year = '20' + date[0]
197
197
  doy = date[1] # doy
@@ -216,7 +216,7 @@ def _navdate_Thompson(allnav, talker):
216
216
 
217
217
  for i in range(N):
218
218
  pre = subnav[i].split(talker)[0]
219
- date = re.findall('(\d{2})/(\d{2})/(\d{4}),*', pre)[0]
219
+ date = re.findall(r'(\d{2})/(\d{2})/(\d{4}),*', pre)[0]
220
220
  year = int(date[2])
221
221
  mon = int(date[0])
222
222
  day = int(date[1])
@@ -247,8 +247,8 @@ def _navdate_Revelle(allnav, talker):
247
247
  for k in range(inds[i]-1, j, -1): # step backwards toward the last talker line
248
248
  before = allnav[k]
249
249
  # date is at the start of this line
250
- if re.match('(\d{4})-(\d{2})-(\d{2})T*', before):
251
- date = re.findall('(\d{4})-(\d{2})-(\d{2})T*', before)[0]
250
+ if re.match(r'(\d{4})-(\d{2})-(\d{2})T*', before):
251
+ date = re.findall(r'(\d{4})-(\d{2})-(\d{2})T*', before)[0]
252
252
  year = int(date[0])
253
253
  mon = int(date[1])
254
254
  day = int(date[2])
@@ -269,12 +269,12 @@ def _navdate_Ride(allnav, talker):
269
269
 
270
270
  for i in range(N):
271
271
  if talker == 'INGGA': # on Ride, uses posix timestamps
272
- date = re.findall('(\d+(\.\d*)?) \$%s' % talker, subnav[i])[0]
272
+ date = re.findall(r'(\d+(\.\d*)?) \$%s' % talker, subnav[i])[0]
273
273
  timest[i] = datetime.fromtimestamp(
274
274
  float(date[0]), tzinfo=timezone.utc)
275
275
  elif talker == 'GPGGA': # includes time only with date, unlike other GPGGAs
276
276
  date = re.findall(
277
- '(\d{4})\-(\d{2})\-(\d{2})T(\d{2}):(\d{2}):(\d{2})\.(\d.*?)Z', subnav[i])[0]
277
+ r'(\d{4})\-(\d{2})\-(\d{2})T(\d{2}):(\d{2}):(\d{2})\.(\d.*?)Z', subnav[i])[0]
278
278
  year = int(date[0])
279
279
  mon = int(date[1])
280
280
  day = int(date[2])
@@ -383,9 +383,8 @@ def read_bgm_rgs(fp, ship):
383
383
  dats = []
384
384
  for path in fp:
385
385
  dat = pd.read_csv(path, delimiter=' ', names=['date', 'time', 'grav', 'lat', 'lon'],
386
- usecols=(1, 2, 3, 11, 12), parse_dates=[[0, 1]])
387
- ndt = [e.tz_localize(timezone.utc) for e in dat['date_time']]
388
- dat['date_time'] = ndt
386
+ usecols=(1, 2, 3, 11, 12))
387
+ dat['date_time'] = pd.to_datetime(dat.pop('date')+' '+dat.pop('time'),utc=True)
389
388
  dats.append(dat)
390
389
 
391
390
  return pd.concat(dats, ignore_index=True)
@@ -456,10 +455,8 @@ def _bgmserial_Atlantis(path):
456
455
  def count(x): return (
457
456
  int(x.split(':')[-1])) # function to parse counts column
458
457
  dat = pd.read_csv(path, delimiter=' ', names=['date', 'time', 'counts'], usecols=(1, 2, 4),
459
- parse_dates=[[0, 1]], converters={'counts': count})
460
- ndt = [e.tz_localize(timezone.utc)
461
- for e in dat['date_time']] # timestamps cannot be naive
462
- dat['date_time'] = ndt
458
+ converters={'counts': count})
459
+ dat['date_time'] = pd.to_datetime(dat.pop('date')+' '+dat.pop('time'),utc=True)
463
460
  return dat
464
461
 
465
462
 
@@ -468,9 +465,8 @@ def _bgmserial_Thompson(path):
468
465
  """
469
466
  def count(x): return (int(x.split(' ')[0].split(':')[-1]))
470
467
  dat = pd.read_csv(path, delimiter=',', names=['date', 'time', 'counts'],
471
- parse_dates=[[0, 1]], converters={'counts': count})
472
- ndt = [e.tz_localize(timezone.utc) for e in dat['date_time']]
473
- dat['date_time'] = ndt
468
+ converters={'counts': count})
469
+ dat['date_time'] = pd.to_datetime(dat.pop('date')+' '+dat.pop('time'),utc=True)
474
470
  return dat
475
471
 
476
472
 
@@ -575,10 +571,8 @@ def _dgs_laptop_Thompson(path):
575
571
  """
576
572
  dat = pd.read_csv(path, delimiter=',', names=['date', 'time', 'rgrav', 've', 'vcc',
577
573
  'al', 'ax', 'lat', 'lon'],
578
- usecols=(0, 1, 3, 12, 13, 14, 15, 16, 17),
579
- parse_dates=[[0, 1]])
580
- ndt = [e.tz_localize(timezone.utc) for e in dat['date_time']]
581
- dat['date_time'] = ndt
574
+ usecols=(0, 1, 3, 12, 13, 14, 15, 16, 17))
575
+ dat['date_time'] = pd.to_datetime(dat.pop('date')+' '+dat.pop('time'),utc=True)
582
576
  return dat
583
577
 
584
578
 
@@ -746,4 +740,13 @@ def read_other_stuff(yaml_file, data_file, tag):
746
740
  except KeyError:
747
741
  pass
748
742
 
749
- return df.apply(pd.to_numeric, errors='ignore'), col_info
743
+ def numeric(col):
744
+ try:
745
+ return pd.to_numeric(col)
746
+ except:
747
+ return col
748
+
749
+ for ckey in df.columns: # to_numeric by column so errors for datetimes are skipped
750
+ df[ckey] = df[ckey].apply(numeric) # slower than applying to whole df, but avoids errors
751
+
752
+ return df, col_info
@@ -2,15 +2,16 @@
2
2
  Tests for shipgrav
3
3
  """
4
4
 
5
- from pkg_resources import resource_filename
6
5
  import sys
7
6
  import unittest
7
+ import importlib.resources as importlib_resources
8
8
 
9
9
 
10
10
  def run():
11
11
  loader = unittest.TestLoader()
12
- test_dir = resource_filename('shipgrav', 'tests')
13
- suite = loader.discover(test_dir)
12
+ ref = importlib_resources.files('shipgrav') / 'tests'
13
+ with importlib_resources.as_file(ref) as path:
14
+ suite = loader.discover(ref)
14
15
  runner = unittest.runner.TextTestRunner() # verbosity=2)
15
16
  ret = not runner.run(suite).wasSuccessful()
16
17
  sys.exit(ret)
shipgrav-1.0.0/CHANGELOG DELETED
@@ -1,10 +0,0 @@
1
- 2024-07-15 Hannah F Mark <hmark@whoi.edu>
2
-
3
- * PEP8 reformat, typos
4
- * include some 2D functions for Parker method, rename the 1D one
5
- * repo is now in PFPE org instead of WHOIGit
6
-
7
- 2024-04-23 Hannah F Mark <hmark@whoi.edu>
8
-
9
- * docs/conf.py, readme.md, shipgrav/__init__.py: updated repo URLS
10
- after repo tranfered to WHOIGit
@@ -1 +0,0 @@
1
- Mark, Hannah F.
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes