shipgrav 1.0.2__py2.py3-none-any.whl → 1.0.3__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 +4 -1
- shipgrav/io.py +25 -22
- shipgrav/tests/__init__.py +4 -3
- {shipgrav-1.0.2.dist-info → shipgrav-1.0.3.dist-info}/METADATA +6 -1
- {shipgrav-1.0.2.dist-info → shipgrav-1.0.3.dist-info}/RECORD +7 -7
- {shipgrav-1.0.2.dist-info → shipgrav-1.0.3.dist-info}/WHEEL +0 -0
- {shipgrav-1.0.2.dist-info → shipgrav-1.0.3.dist-info}/licenses/LICENSE +0 -0
shipgrav/__init__.py
CHANGED
|
@@ -11,7 +11,7 @@ Installation
|
|
|
11
11
|
|
|
12
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
13
|
|
|
14
|
-
conda create --name shipgrav numpy scipy pandas statsmodels tomli pyyaml matplotlib
|
|
14
|
+
conda create --name shipgrav numpy scipy pandas statsmodels tomli pyyaml matplotlib geographiclib
|
|
15
15
|
conda activate shipgrav
|
|
16
16
|
pip install shipgrav
|
|
17
17
|
|
|
@@ -25,6 +25,7 @@ shipgrav's dependencies are
|
|
|
25
25
|
* tomli
|
|
26
26
|
* pyyaml
|
|
27
27
|
* matplotlib (optional, needed to run some of the example scripts)
|
|
28
|
+
* geographiclib (optional, needed to run one of the example scripts)
|
|
28
29
|
|
|
29
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.
|
|
30
31
|
|
|
@@ -141,4 +142,6 @@ Contributing
|
|
|
141
142
|
|
|
142
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.
|
|
143
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
|
+
|
|
144
147
|
"""
|
shipgrav/io.py
CHANGED
|
@@ -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)
|
|
387
|
-
|
|
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
|
-
|
|
460
|
-
|
|
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
|
-
|
|
472
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
shipgrav/tests/__init__.py
CHANGED
|
@@ -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
|
-
|
|
13
|
-
|
|
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)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: shipgrav
|
|
3
|
-
Version: 1.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>
|
|
@@ -16,6 +16,7 @@ Requires-Dist: scipy
|
|
|
16
16
|
Requires-Dist: statsmodels
|
|
17
17
|
Requires-Dist: tomli
|
|
18
18
|
Provides-Extra: examples
|
|
19
|
+
Requires-Dist: geographiclib; extra == 'examples'
|
|
19
20
|
Requires-Dist: matplotlib; extra == 'examples'
|
|
20
21
|
Description-Content-Type: text/markdown
|
|
21
22
|
|
|
@@ -43,3 +44,7 @@ The shipgrav documentation is available online at [shipgrav.readthedocs.io](http
|
|
|
43
44
|
|
|
44
45
|
## Contributing to shipgrav
|
|
45
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.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
shipgrav/__init__.py,sha256=
|
|
1
|
+
shipgrav/__init__.py,sha256=VUDa7_eQMngYnvi0059W2Il7BVUWT2QoNHud6962xB4,11529
|
|
2
2
|
shipgrav/database.toml,sha256=qRSZBRsoMsbyhjkaYlXsWtVDz3JAhoW-cYfSoo8U3K4,532
|
|
3
3
|
shipgrav/grav.py,sha256=OQK2HNiZtLlycjVwidpD902K08NaWbZXnjZSbjyPF8I,43410
|
|
4
|
-
shipgrav/io.py,sha256=
|
|
4
|
+
shipgrav/io.py,sha256=vCSyE2q4Dp4H-mqpg1xWuVu_bpeI0x5o1KXUq3kYsiE,29352
|
|
5
5
|
shipgrav/nav.py,sha256=3E2Il-PhTEPVv8_8PrLVe7h6slHq-2HYX_Q8PdpB6X4,2895
|
|
6
6
|
shipgrav/utils.py,sha256=h5gd8cnWlO1pyAqLkJIVrbFRRLbZzHj-xJ9pWchaHtI,9521
|
|
7
|
-
shipgrav/tests/__init__.py,sha256=
|
|
7
|
+
shipgrav/tests/__init__.py,sha256=ljlA5qi9b7PQCzxzlNRc1QdGvA9A2mv66z53kNLSL44,427
|
|
8
8
|
shipgrav/tests/__main__.py,sha256=iJ8xSU8ucCmIDcOuv8uasZ9iV5dNR0DDuFRZrG0o2hE,38
|
|
9
9
|
shipgrav/tests/test_grav_data.py,sha256=OnPNW8XIG3DvWOr_trQY71XLzA0rff8VfGd4Az3B37Q,3403
|
|
10
10
|
shipgrav/tests/test_grav_nodata.py,sha256=0z5KUTzT9cJPko_bhyDG4EFm4i5xgOdVhJVKU2cPxX8,1493
|
|
@@ -18,7 +18,7 @@ shipgrav/tests/ex_files/SR2312_dgs_raw.txt,sha256=rTlIn75MBICBjnkjcn9SPCwpC5J3lM
|
|
|
18
18
|
shipgrav/tests/ex_files/SR2312_mru.txt,sha256=YBM4qy4BS_D0U4ngEyoIFZr4QQbMWQgEO681fVEmgYM,1060
|
|
19
19
|
shipgrav/tests/ex_files/TN400_bgm.Raw,sha256=DL7T2aJednjGLMKJo6K8KcUYLMjQCiv6bsUiczlVwKw,74
|
|
20
20
|
shipgrav/tests/ex_files/TN400_nav.Raw,sha256=66dgRQTXjf0JItMWE1ZGUO6NptrGqV6JyN2wdYe5bW8,194
|
|
21
|
-
shipgrav-1.0.
|
|
22
|
-
shipgrav-1.0.
|
|
23
|
-
shipgrav-1.0.
|
|
24
|
-
shipgrav-1.0.
|
|
21
|
+
shipgrav-1.0.3.dist-info/METADATA,sha256=IS9pbX283aH8u4XToZXBq3u9CRAIhuLXVj-GSfRsg-k,2493
|
|
22
|
+
shipgrav-1.0.3.dist-info/WHEEL,sha256=fl6v0VwpzfGBVsGtkAkhILUlJxROXbA3HvRL6Fe3140,105
|
|
23
|
+
shipgrav-1.0.3.dist-info/licenses/LICENSE,sha256=5X8cMguM-HmKfS_4Om-eBqM6A1hfbgZf6pfx2G24QFI,35150
|
|
24
|
+
shipgrav-1.0.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|