shipgrav 1.0.0__py2.py3-none-any.whl
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.
- shipgrav/__init__.py +147 -0
- shipgrav/database.toml +24 -0
- shipgrav/grav.py +1260 -0
- shipgrav/io.py +749 -0
- shipgrav/nav.py +91 -0
- shipgrav/tests/__init__.py +16 -0
- shipgrav/tests/__main__.py +3 -0
- shipgrav/tests/ex_files/AT05_01_bgm.RGS +4 -0
- shipgrav/tests/ex_files/DGStest_laptop.dat +1001 -0
- shipgrav/tests/ex_files/IXBlue.yaml +160 -0
- shipgrav/tests/ex_files/SR2312_dgs_raw.txt +2 -0
- shipgrav/tests/ex_files/SR2312_mru.txt +12 -0
- shipgrav/tests/ex_files/TN400_bgm.Raw +2 -0
- shipgrav/tests/ex_files/TN400_nav.Raw +2 -0
- shipgrav/tests/test_grav_data.py +75 -0
- shipgrav/tests/test_grav_nodata.py +47 -0
- shipgrav/tests/test_io.py +55 -0
- shipgrav/tests/test_nav.py +41 -0
- shipgrav/tests/test_utils.py +33 -0
- shipgrav/utils.py +275 -0
- shipgrav-1.0.0.dist-info/METADATA +44 -0
- shipgrav-1.0.0.dist-info/RECORD +24 -0
- shipgrav-1.0.0.dist-info/WHEEL +5 -0
- shipgrav-1.0.0.dist-info/licenses/LICENSE +675 -0
shipgrav/__init__.py
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Introduction
|
|
3
|
+
---------------------
|
|
4
|
+
|
|
5
|
+
shipgrav is a Python package with utilities for reading and processing marine gravity data from UNOLS ships. At time of writing, the UNOLS fleet is transitioning away from BGM3 gravimeters to DGS AT1M meters managed by the Potential Field Pool Equipment (PFPE) facility. shipgrav is able to read files from both types of meters, as well as navigation data and other vessel feeds. shipgrav functions can then be used to process gravity data to FAA, MBA, RMBA, and crustal thickness estimates.
|
|
6
|
+
|
|
7
|
+
DGS gravimeters output two types of files: serial, or 'raw' files; and 'laptop' files. Raw files are written from the serial port, and contain counts values that can be calibrated to retrieve the gravity signal. In this documentation we use the terms 'serial' and 'raw' interchangeably. What we refer to as laptop files are lightly processed onboard the meter and output with (biased) gravity values alongside other information.
|
|
8
|
+
|
|
9
|
+
Installation
|
|
10
|
+
------------
|
|
11
|
+
|
|
12
|
+
shipgrav can be installed from the source files (`available on github <https://github.com/PFPE/shipgrav>`_) using ``pip``.
|
|
13
|
+
|
|
14
|
+
shipgrav's dependencies are
|
|
15
|
+
|
|
16
|
+
* Python 3.9+
|
|
17
|
+
* numpy
|
|
18
|
+
* scipy
|
|
19
|
+
* pandas 2.0+
|
|
20
|
+
* statsmodels
|
|
21
|
+
* tomli
|
|
22
|
+
* pyyaml
|
|
23
|
+
* matplotlib (optional, needed to run some of the example scripts)
|
|
24
|
+
|
|
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 .
|
|
33
|
+
|
|
34
|
+
Modules and files
|
|
35
|
+
-----------------
|
|
36
|
+
|
|
37
|
+
shipgrav consists of the modules ``io``, ``nav``, ``grav``, and ``utils``, along with the file ``database.toml`` and a set of example scripts.
|
|
38
|
+
|
|
39
|
+
* ``io`` contains functions for reading different kinds of gravimeter files and associated navigation files.
|
|
40
|
+
* ``nav`` contains functions for handling coordinate systems.
|
|
41
|
+
* ``grav`` contains functions for processing gravity data and calculating various anomalies.
|
|
42
|
+
* ``utils`` is a catch-all of other things we need.
|
|
43
|
+
* ``database.toml`` holds some ship-specific constants and other information for UNOLS vessels.
|
|
44
|
+
* the scripts in ``example-scripts/`` walk through the steps of reading and processing UNOLS gravimeter data for a set of data files that are publicly available via `R2R (Rolling Deck to Repository) <https://www.rvdata.us>`_.
|
|
45
|
+
|
|
46
|
+
Data directories
|
|
47
|
+
----------------
|
|
48
|
+
|
|
49
|
+
You can organize your data however you like; shipgrav does not care as long as you tell it where to look. However, to run the example scripts, you will need to download some data and ensure that the scripts are pointed to the paths where you put that data. A shell script ``download_data.sh`` is provided in ``example-scripts/`` to help download and organize the data.
|
|
50
|
+
|
|
51
|
+
Ties and bias
|
|
52
|
+
-------------
|
|
53
|
+
|
|
54
|
+
The ``database.toml`` file contains some bias values for UNOLS vessels. These are provided for your convenience, but are not necessarily up-to-date with recent gravity ties.
|
|
55
|
+
|
|
56
|
+
Navigation data
|
|
57
|
+
---------------
|
|
58
|
+
|
|
59
|
+
Which navigation data should you use to process gravimeter data?
|
|
60
|
+
|
|
61
|
+
In an ideal world, the gravimeter pulls navigation info from the ship's feed and synchronizes it perfectly with acquisition such that the output files have the correct geographic coordinates in them at the start. In practice, this synchronization doesn't always work as expected (see ``example-scripts/dgs_raw_comp.py`` for a case where the serial files do not have GPS info). So, we like to take the timestamped navigation data directly from the ship's feed and match up the gravimeter timestamps to obtain more accurate coordinates.
|
|
62
|
+
|
|
63
|
+
The database file included in shipgrav lists the navigation talkers that we expect are good to use for specific UNOLS vessels. Find the files that contain those feeds, and you should be able to read in timestamped coordinates from them.
|
|
64
|
+
|
|
65
|
+
Example scripts
|
|
66
|
+
---------------
|
|
67
|
+
|
|
68
|
+
The scripts in the ``example-scripts/`` directory use publicly available data files to run through some common workflows for marine gravity processing. The data files can be downloaded from R2R and Zenodo. The ``download_data.sh`` shell script in ``example-scripts/`` uses ``curl``, ``tar``, and ``unzip`` to download all the data files for you and unpack them into a directory structure that matches what the examples expect. You can also download and unpack the files on your own from the sources listed below:
|
|
69
|
+
|
|
70
|
+
* https://doi.org/10.7284/151470 - TN400 BGM3 data
|
|
71
|
+
* https://doi.org/10.7284/151457 - TN400 nav data
|
|
72
|
+
* https://doi.org/10.7284/157179 - SR2312 DGS laptop data
|
|
73
|
+
* https://doi.org/10.7284/157188 - SR2312 nav data
|
|
74
|
+
* https://doi.org/10.7284/157177 - SR2312 mru data
|
|
75
|
+
* https://doi.org/10.5281/zenodo.12733929 - TN400 DGS raw and laptop data, SR2312 DGS raw data, R/V Ride DGS meter and Hydrins metadata, satellite FAA tracks for comparison, example file for RMBA calculation
|
|
76
|
+
|
|
77
|
+
If you are not using the download script provided, we recommend looking at what it does and mimicking the directory structure it sets up for the data files. Otherwise, you will have to edit the examples to point to the correct filepaths for wherever you put the data in your system.
|
|
78
|
+
|
|
79
|
+
``dgs_bgm_comp.py`` reads data from DGS and BGM gravimeter files from R/V Thompson cruise TN400. The files are lightly processed to obtain the FAA (including syncing with navigation data for more accurate locations), and the FAA is plotted alongside corresponding satellite-derived FAA.
|
|
80
|
+
|
|
81
|
+
.. image:: _static/TN400_FAA.png
|
|
82
|
+
:alt: FAA for TN400 data from BGM3 and DGS, compared to satellite data.
|
|
83
|
+
:height: 250px
|
|
84
|
+
:align: center
|
|
85
|
+
|
|
86
|
+
``dgs_raw_comp.py`` reads laptop and serial data from R/V Sally Ride cruise SR2312. The serial data are calibrated and compared to the laptop data. The laptop data are processed to FAA and plotted alongside satellite-derived FAA.
|
|
87
|
+
|
|
88
|
+
.. image:: _static/SR2312_serial_laptop.png
|
|
89
|
+
:alt: SR2312 raw gravity from serial and laptop files.
|
|
90
|
+
:height: 250px
|
|
91
|
+
:align: center
|
|
92
|
+
|
|
93
|
+
``dgs_ccp_calc.py`` reads DGS files from R/V Thompson cruise TN400, calculates the FAA and various kinematic variables, and fits for cross-coupling coefficients. The cross-coupling correction is applied and the data are plotted with and without correction.
|
|
94
|
+
|
|
95
|
+
.. image:: _static/TN400_ccp.png
|
|
96
|
+
:alt: FAA for TN400, with and without cross-coupling correction applied.
|
|
97
|
+
:height: 250px
|
|
98
|
+
:align: center
|
|
99
|
+
|
|
100
|
+
``mru_coherence.py`` reads laptop data and other feeds from R/V Sally Ride cruise SR2312. The FAA is calculated, and MRU info is read to obtain time series of pitch, roll, and heave. Coherence is caluclated between those and each of the four monitors output by the gravimeter for the cross-coupling correction.
|
|
101
|
+
|
|
102
|
+
.. image:: _static/roll_coherence.png
|
|
103
|
+
:alt: Coherence between monitors and roll for SR2312.
|
|
104
|
+
:height: 250px
|
|
105
|
+
:align: center
|
|
106
|
+
|
|
107
|
+
``interactive_line_pick.py`` reads laptop data and navigation data from R/V Sally Ride cruise SR2312. The script generates an interactive plot with a cursor for users to select segments of the time series data based on mapped locations, in order to extract straight line segments from a cruise track. The selected segments are written to files that can be re-read by the next script...
|
|
108
|
+
|
|
109
|
+
.. image:: _static/cursor.png
|
|
110
|
+
:alt: Interactive line segment picker window.
|
|
111
|
+
:height: 250px
|
|
112
|
+
:align: center
|
|
113
|
+
|
|
114
|
+
``RMBA_calc.py`` reads an example of data from a line segment (from the interactive line picker) and calculates the residual mantle bouger anomaly (RMBA) as well as estimated crustal thickness variations.
|
|
115
|
+
|
|
116
|
+
.. image:: _static/rmba.png
|
|
117
|
+
:alt: RMBA for a segment of SR2312, with back-calculated "recovered" signal.
|
|
118
|
+
:height: 250px
|
|
119
|
+
:align: center
|
|
120
|
+
|
|
121
|
+
Help!
|
|
122
|
+
-----
|
|
123
|
+
|
|
124
|
+
``FileNotFound`` **errors:** check the filepaths in your scripts and make sure that (a) there are no typos, and (b) you are pointing toward the actual locations of your data files.
|
|
125
|
+
|
|
126
|
+
**Other file reading errors:** shipgrav does its best to read a variety of file formats from UNOLS gravimeters, but we can't read files that we don't know enough about ahead of time. In some cases, a file cannot be read because we don't yet know how to pass the file to the correct parsing function. Most primary i/o functions in shipgrav have an option where users can supply their own file-parsing function, so one option is to write such a function (following the examples in shipgrav for known vessel file formats) and plug that in via the appropriate kwarg (usually named ``ship_function``). You can also send an example file and information to PFPE so that we can update shipgrav.
|
|
127
|
+
|
|
128
|
+
**The anomaly I've calculated looks really weird:** a good first step is to compare your (lowpass filtered) FAA to satellite data (e.g., `Sandwell et al. 2014 <https://doi.org/10.1126/science.1258213>`_). If that looks very different, you can start checking whether the data is being read properly; whether the sample rate of the data is consistent with your expectations; whether there are anomalous spikes or dropouts in the data that need to be cleaned out; and whether the corrections used to calculate the FAA seem to have reasonable magnitudes.
|
|
129
|
+
|
|
130
|
+
**I want to use shipgrav, but my data is not from a UNOLS vessel:** the functions and workflows in shipgrav are entirely adaptable to use with data from other sources. You will need to determine the data format for your gravimeter files, and write or adapt a function to read that data. There are examples in the ``io`` module. If you have raw data files, you will also need to know the calibration constants and apply those. Once the data have been read (and calibrated), you should be able to apply all of the other shipgrav functions for processing.
|
|
131
|
+
|
|
132
|
+
**I'm going to sea and want to be able to access this documentation offline:** this is all auto-generated from text included in the shipgrav source files! So one option is just to go read those (the main part of the documentation is in ``shipgrav/__init__.py``). To view it as a nice webpage, you can build the documentation locally using ``sphinx``. Install ``sphinx`` in your conda environment, run the command ``make html`` in the ``docs/`` directory, and then open ``docs/_build/html/index.html`` in your browser to view the documentation.
|
|
133
|
+
|
|
134
|
+
**If you have some other question that's not answered here:** you can try contacting PFPE at pfpe-internal(at)whoi.edu for specific assistance with processing UNOLS gravimeter data.
|
|
135
|
+
|
|
136
|
+
Testing
|
|
137
|
+
-------
|
|
138
|
+
|
|
139
|
+
shipgrav comes with a set of unit tests. To run them for yourself, navigate to the ``tests/`` directory and run ``__main__.py`` (in an environment with dependencies installed, naturally).
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
Contributing
|
|
143
|
+
------------
|
|
144
|
+
|
|
145
|
+
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
|
+
|
|
147
|
+
"""
|
shipgrav/database.toml
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
[bias-values]
|
|
2
|
+
Atlantis = {'dgs'=969758.4968, 'bgm'=855580.65}
|
|
3
|
+
Thompson = {'dgs'=969527.3497, 'bgm'=855489.8}
|
|
4
|
+
Revelle = {'dgs'=968888.6465, 'bgm'=855240.81987}
|
|
5
|
+
NBP = {'dgs'=968634.2514, 'bgm'=-999}
|
|
6
|
+
Ride = {'dgs'=968895.7718, 'bgm'=-999}
|
|
7
|
+
Langseth = {'dgs'=-999, 'bgm'=854974.4}
|
|
8
|
+
|
|
9
|
+
[nav-talkers]
|
|
10
|
+
Atlantis = 'GPGGA'
|
|
11
|
+
Thompson = 'INGGA'
|
|
12
|
+
NBP = 'GPGGA'
|
|
13
|
+
Ride = 'INGGA'
|
|
14
|
+
Revelle = 'GPGGA'
|
|
15
|
+
Langseth = 'INGGA'
|
|
16
|
+
|
|
17
|
+
[BGM-scale]
|
|
18
|
+
Atlantis = 4.994070552
|
|
19
|
+
Thompson = 5.003353363
|
|
20
|
+
Revelle = 4.99980755
|
|
21
|
+
Langseth = 5.0
|
|
22
|
+
|
|
23
|
+
[dgs-stuff]
|
|
24
|
+
calibration_factor = 8388607
|