From 361111432e60b1f0e16a43967c0c3f2a92950c99 Mon Sep 17 00:00:00 2001 From: "Michael Hirsch, Ph.D" Date: Tue, 28 Aug 2018 11:04:31 -0400 Subject: [PATCH] Squashed commit of the following: commit 37015dff673de071c3f669672a7f270d45ac4aad Author: Michael Hirsch, Ph.D Date: Tue Aug 28 10:57:09 2018 -0400 windows path commit 0cf1d83ce703c0414d9d158dedca99621ddc3fed Author: Michael Hirsch, Ph.D Date: Tue Aug 28 10:52:51 2018 -0400 windows cwd shell bug workaround commit 270e31dc73c6600f13e7a2fd2e08a0294c315baf Author: Michael Hirsch, Ph.D Date: Tue Aug 28 10:47:19 2018 -0400 correct windows hatanaka exe name commit 3a86acbbcb3157c95d02c3e244547e59ab644fac Author: Michael Hirsch, Ph.D Date: Tue Aug 28 10:26:51 2018 -0400 skip commit d83262a65372e653e742f674fa08353a5f68bc96 Author: Michael Hirsch, Ph.D Date: Tue Aug 28 10:24:06 2018 -0400 better crx2rnx detect commit 023cdc44b9ed09086d65d30f6e37e59bb0345f0e Author: Michael Hirsch, Ph.D Date: Tue Aug 28 01:18:03 2018 -0400 revert commit 8a1673db2a8ec6622a6bf5425d4f3fcedb55991c Author: Michael Hirsch, Ph.D Date: Tue Aug 28 01:13:08 2018 -0400 diag msgs commit 23fe258b9a21e662c24b0468e8303e6fa84e65e3 Author: Michael Hirsch, Ph.D Date: Tue Aug 28 01:12:35 2018 -0400 cleanup commit d977f9d72b7c297bf5a8ae5d736ddcc5a6907d39 Author: Michael Hirsch, Ph.D Date: Tue Aug 28 01:05:12 2018 -0400 diag msgs commit f306f4faae845a75f5cc63d6e4872a585dea81f2 Author: Michael Hirsch, Ph.D Date: Tue Aug 28 01:02:18 2018 -0400 diag msgs commit 97f62e31302863d29012732798ea3ac371d8cedd Author: Michael Hirsch, Ph.D Date: Tue Aug 28 00:58:29 2018 -0400 diag msgs commit acfdfc506a2a93c491115862863cd6c9d4e27861 Author: Michael Hirsch, Ph.D Date: Tue Aug 28 00:56:20 2018 -0400 diag msgs commit 06c4ec5566843a9e69c6e41491f07bbb5251e39f Author: Michael Hirsch, Ph.D Date: Tue Aug 28 00:49:41 2018 -0400 more tolerant crx2rnx detection commit 0a60041ea2e3a31634e80561b8b9c084e2d7cc5c Author: Michael Hirsch, Ph.D Date: Tue Aug 28 00:42:55 2018 -0400 cleanup commit 8a703eaadc09029c403641f8b70551cf681f28a4 Author: Michael Hirsch, Ph.D Date: Tue Aug 28 00:40:47 2018 -0400 tell windows what CC is commit 9e255f507d7402c161f91da2193a9b589eca32fb Author: Michael Hirsch, Ph.D Date: Tue Aug 28 00:36:29 2018 -0400 PATH CI cleanup windows commit aa46d89937db4f4d7656480b3328326730a499ca Author: Michael Hirsch, Ph.D Date: Tue Aug 28 00:32:47 2018 -0400 CI windows chdir first commit 0d5e459974d2377fb0ea3a7196d313f8500c84a3 Author: Michael Hirsch, Ph.D Date: Tue Aug 28 00:31:54 2018 -0400 CI dir make commit 4d940e73491719d405ccc75f33f141918c182e18 Author: Michael Hirsch, Ph.D Date: Tue Aug 28 00:28:10 2018 -0400 appveyor try compile windows vers --- .appveyor.yml | 9 ++++++++- README.md | 16 ++++++++++++++++ georinex/io.py | 5 ++++- setup.cfg | 2 +- tests/test_hatanaka.py | 21 +++++++++++++++------ tests/test_nav2.py | 10 ++++++++++ tests/test_nav3.py | 2 ++ 7 files changed, 56 insertions(+), 9 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 8b4cb86..c96fd63 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -5,6 +5,7 @@ image: stack: python 3 environment: + MINGW_DIR: C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin PY_DIR: C:\Python37-x64 clone_depth: 3 @@ -12,9 +13,15 @@ clone_depth: 3 build: off init: +- cmd: set PATH=%MINGW_DIR%;%PATH% - cmd: set PATH=%PY_DIR%;%PY_DIR%\Scripts;%PATH% +- cmd: set CC=gcc -install: pip install -e .[tests,io] +install: +- cmd: mingw32-make -C rnxcmp +- sh: make -C rnxcmp + +- pip install -e .[tests,io] test_script: pytest -xrsv diff --git a/README.md b/README.md index 6827e50..8e5d27c 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,22 @@ If you need to use `.crx` Hatanaka compressed RINEX, compile the `crx2rnx` code make install -C rnxcmp ``` +#### Windows +Windows as usual is more difficult to compile code on. +For optional Hatanaka converter, here are some tips. + +> cc -O2 source/rnx2crx.c -o rnx2crx +process_begin: CreateProcess(NULL, cc -O2 source/rnx2crx.c -o rnx2crx, ...) failed. +make (e=2): The system cannot find the file specified. + +Assuming you have +[installed MinGW compiler on Windows](https://www.scivision.co/windows-gcc-gfortran-cmake-make-install/): +```posh +set CC=gcc +mingw32-make -C rnxcmp +``` + + ## Usage The simplest command-line use is through the top-level `ReadRinex` script. diff --git a/georinex/io.py b/georinex/io.py index decd667..2d59a85 100644 --- a/georinex/io.py +++ b/georinex/io.py @@ -58,12 +58,15 @@ def _opencrx(f: TextIO) -> str: Nbytes is used to read first line. """ exe = './crx2rnx' + shell = False if os.name == 'nt': exe = exe[2:] + shell = True + try: In = f.read() ret = subprocess.check_output([exe, '-'], input=In, - universal_newlines=True, cwd=R/'rnxcmp') + universal_newlines=True, cwd=R/'rnxcmp', shell=shell) except FileNotFoundError as e: raise FileNotFoundError(f'trouble converting Hatanka file, did you compile the crx2rnx program? {e}') diff --git a/setup.cfg b/setup.cfg index 5ef89ec..8071c3c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = georinex -version = 1.6.2 +version = 1.6.3 author = Michael Hirsch, Ph.D. description = Python RINEX 2/3 NAV/OBS reader with speed and simplicity. url = https://github.com/scivision/georinex diff --git a/tests/test_hatanaka.py b/tests/test_hatanaka.py index 28df63a..8617a9d 100644 --- a/tests/test_hatanaka.py +++ b/tests/test_hatanaka.py @@ -4,17 +4,26 @@ from pathlib import Path import georinex as gr from datetime import datetime -R = Path(__file__).parent +import os -try: - # capture_output is py >= 3.7 - ret = subprocess.run(['crx2rnx', '-h'], stderr=subprocess.PIPE, universal_newlines=True) # -h returncode == 1 +R = Path(__file__).parent +Rexe = Path(__file__).resolve().parents[1] / 'rnxcmp' +exe = './crx2rnx' +shell = False +if os.name == 'nt': + exe = exe[2:] + shell = True + +try: # capture_output is py >= 3.7 + ret = subprocess.run([exe, '-h'], stderr=subprocess.PIPE, + universal_newlines=True, cwd=Rexe, shell=shell) # -h returncode == 1 nocrx = False if ret.stderr.startswith('Usage') else True -except (FileNotFoundError, PermissionError): +except (FileNotFoundError, PermissionError) as e: + print(e) nocrx = True -@pytest.mark.skipif(nocrx, reason='crx2rnx not found') +@pytest.mark.skipif(nocrx, reason=f'crx2rnx not found in {Rexe}') @pytest.mark.timeout(30) def test_obs3(): fn = R / 'CEBR00ESP_R_20182000000_01D_30S_MO.crx.gz' diff --git a/tests/test_nav2.py b/tests/test_nav2.py index 6200f19..8b44473 100644 --- a/tests/test_nav2.py +++ b/tests/test_nav2.py @@ -10,6 +10,8 @@ def test_time(): + pytest.importorskip('unlzw') + times = gr.gettime(R/'ab422100.18n.Z').values.astype('datetime64[us]').astype(datetime) assert times[0] == datetime(2018, 7, 29, 1, 59, 44) @@ -17,6 +19,8 @@ def test_time(): def test_data(): + pytest.importorskip('unlzw') + nav = gr.load(R/'ab422100.18n.Z') nav0 = nav.sel(time='2018-07-29T03:59:44').dropna(dim='sv', how='all') @@ -43,6 +47,8 @@ def test_mangled(): def test_tlim(): + pytest.importorskip('unlzw') + nav = gr.load(R/'ceda2100.18e.Z', tlim=('2018-07-29T11', '2018-07-29T12')) times = nav.time.values.astype('datetime64[us]').astype(datetime) @@ -57,6 +63,8 @@ def test_tlim(): def test_galileo(): + pytest.importorskip('unlzw') + nav = gr.load(R/'ceda2100.18e.Z') E18 = nav.sel(sv='E18').dropna(dim='time', how='all') @@ -72,6 +80,8 @@ def test_galileo(): def test_gps(): + pytest.importorskip('unlzw') + nav = gr.load(R/'brdc2800.15n.Z') times = nav.time.values.astype('datetime64[us]').astype(datetime).tolist() diff --git a/tests/test_nav3.py b/tests/test_nav3.py index be2f979..7c8fad9 100644 --- a/tests/test_nav3.py +++ b/tests/test_nav3.py @@ -33,6 +33,8 @@ def test_tlim(): def test_qzss(): """./ReadRinex.py -q tests/qzss3.14n -o r3qzss.nc """ + pytest.importorskip('netCDF4') + truth = gr.load(R/'r3qzss.nc') nav = gr.load(R/'qzss3.14n') assert nav.equals(truth)