Skip to content

Commit 82b39dd

Browse files
valgurscivision
authored andcommitted
use the external hatanaka lib for crx2rnx
1 parent 27cb3e0 commit 82b39dd

File tree

4 files changed

+10
-16
lines changed

4 files changed

+10
-16
lines changed

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ cd georinex
5757
python -m pip install -e .
5858
```
5959

60-
The Hatanaka CRINEX converter automatically compiles if needed and a C compiler is available.
61-
6260
### Selftest
6361

6462
It can be useful to check the setup of your system with:
@@ -400,8 +398,8 @@ UNAVCO RINEX 2 data:
400398

401399

402400
### Hatanaka compressed RINEX .crx
403-
The compressed Hatanaka `.crx` or `.crx.gz` files are supported seamlessly via `crx2rnx` as noted in the Install section.
404-
There are distinct from the supported `.rnx`, `.gz`, or `.zip` RINEX files.
401+
The compressed Hatanaka `.crx` or `.crx.gz` files are supported seamlessly via `crx2rnx`.
402+
These are distinct from the supported `.rnx`, `.gz`, or `.zip` RINEX files.
405403

406404
Hatanaka, Y. (2008), A Compression Format and Tools for GNSS Observation
407405
Data, Bulletin of the Geospatioal Information Authority of Japan, 55, 21-30.

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ install_requires =
3131
python-dateutil
3232
numpy
3333
xarray>=0.11
34+
hatanaka
3435
package_dir=
3536
=src
3637

src/georinex/rio.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
from contextlib import contextmanager
77
import io
88
import logging
9+
910
import xarray
1011

12+
from hatanaka import crx2rnx
13+
1114
try:
1215
from unlzw3 import unlzw
1316
except ImportError:
@@ -45,7 +48,9 @@ def opener(fn: T.TextIO | Path, header: bool = False) -> T.Iterator[T.TextIO]:
4548
f.seek(0)
4649

4750
if is_crinex and not header:
48-
f = io.StringIO(opencrx(f))
51+
# Conversion to string is necessary because of a quirk where gzip.open()
52+
# even with 'rt' doesn't decompress until read.
53+
f = io.StringIO(crx2rnx(f.read()))
4954
yield f
5055
elif suffix == ".zip":
5156
with zipfile.ZipFile(fn, "r") as z:
@@ -68,7 +73,7 @@ def opener(fn: T.TextIO | Path, header: bool = False) -> T.Iterator[T.TextIO]:
6873
f.seek(0)
6974

7075
if is_crinex and not header:
71-
f = io.StringIO(opencrx(f))
76+
f = io.StringIO(crx2rnx(f))
7277
yield f
7378
else:
7479
raise OSError(f"Unsure what to do with input of type: {type(fn)}")

src/georinex/tests/test_hatanaka.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,10 @@
33
from datetime import datetime
44

55
import georinex as gr
6-
from georinex.hatanaka import crxexe
76

87
R = Path(__file__).parent / "data"
98

109

11-
try:
12-
exe = crxexe()
13-
except RuntimeError:
14-
exe = None
15-
16-
17-
@pytest.mark.skipif(exe is None, reason="Hatanaka converter not working")
1810
def test_obs2():
1911

2012
fn = R / "york0440.15d"
@@ -29,7 +21,6 @@ def test_obs2():
2921
assert obs["S1"].values[0, :3] == pytest.approx([44.0, 41.0, 51.0])
3022

3123

32-
@pytest.mark.skipif(exe is None, reason="Hatanaka converter not working")
3324
@pytest.mark.timeout(30)
3425
def test_obs3_gz():
3526

@@ -87,7 +78,6 @@ def test_obs3_gz():
8778
assert times[-1] == datetime(2018, 7, 19, 1, 10)
8879

8980

90-
@pytest.mark.skipif(exe is None, reason="Hatanaka converter not working")
9181
@pytest.mark.timeout(30)
9282
def test_obs3():
9383
fn = R / "P43300USA_R_20190012056_17M_15S_MO.crx"

0 commit comments

Comments
 (0)