コード例 #1
0
ファイル: test_obs3.py プロジェクト: scienceopen/pyrinex
def test_bad_system():
    """ Z and Y are not currently used by RINEX """
    with pytest.raises(KeyError):
        gr.load(R/'demo3.10o', use='Z')

    with pytest.raises(KeyError):
        gr.load(R/'demo3.10o', use=['Z', 'Y'])
コード例 #2
0
def parse_rinex(kind, name=None):
    """ Parse observation files. If 'name' is given, only
        that specific file is parse, otherwise parse all files
        in 'kind' folder.
    """
    path = kind + '/'
    if not name:
        X = {"E": [], "G": []}
        for f in os.listdir(path):
            try:
                print('Parsing ' + f)
                gps = gr.load(path + f, use='G').to_dataframe()
                gal = gr.load(path + f, use='E').to_dataframe()
                if not gps.empty:
                    X["G"].append(gps)
                if not gal.empty:
                    X["E"].append(gal)
            except:
                print("Something went wrong!!!")
        return X
    else:
        X = {}
        try:
            print('Parsing ' + name)
            gps = gr.load(path + name, use='G').to_dataframe()
            gal = gr.load(path + name, use='E').to_dataframe()
            if not gps.empty:
                X["G"] = gps
            if not gal.empty:
                X["E"] = gal
        except:
            print("Something went wrong!!!")
        return X
コード例 #3
0
def test_bad_system():
    """ Z and Y are not currently used by RINEX """
    with pytest.raises(KeyError):
        gr.load(R / 'demo3.10o', use='Z')

    with pytest.raises(KeyError):
        gr.load(R / 'demo3.10o', use=['Z', 'Y'])
コード例 #4
0
ファイル: rnx2nc.py プロジェクト: aldebaran1/georinex
def _convert(file, odir, i):
    print('Converting file: ', file)
    try:
        gr.load(file, out=odir, useindicators=i)
    except Exception as e:
        print(e)
    sleep(0.1)
コード例 #5
0
def test_bad_system():
    """ Z and Y are not currently used by RINEX """
    with pytest.raises(KeyError):
        gr.load(R / "demo3.10o", use="Z")

    with pytest.raises(KeyError):
        gr.load(R / "demo3.10o", use=["Z", "Y"])
コード例 #6
0
def test_meas_one():
    """
    test specifying specific measurements (usually only a few of the thirty or so are needed)
    """
    fn = R / 'demo.10o'
    obs = gr.load(fn)
    for v in ['L1', 'L2', 'P1', 'P2', 'C1', 'S1', 'S2']:
        assert v in obs
    assert len(obs.data_vars) == 7

    sv = obs.sv.values
    assert len(sv) == 14
    for s in [
            'G13', 'R19', 'G32', 'G07', 'R23', 'G31', 'G20', 'R11', 'G12',
            'G26', 'G09', 'G21', 'G15', 'S24'
    ]:
        assert s in sv

    assert obs['C1'].sel(sv='G07').values == approx([22227666.76, 25342359.37])
    # %% one measurement
    obs = gr.load(fn, meas='C1')
    assert 'L1' not in obs

    C1 = obs['C1']
    assert C1.shape == (
        2, 14)  # two times, 14 SVs overall for all systems in this file
    assert C1.sel(sv='G07').values == approx([22227666.76, 25342359.37])

    assert obs.fast_processing
コード例 #7
0
ファイル: test_nav3.py プロジェクト: nmayorov/georinex
def test_mixed():
    fn = R / 'ELKO00USA_R_20182100000_01D_MN.rnx.gz'
    nav = gr.load(fn,
                  tlim=(datetime(2018, 7, 28, 21), datetime(2018, 7, 28, 23)))

    assert isinstance(nav, xarray.Dataset)
    assert sorted(nav.svtype) == ['C', 'E', 'G', 'R']

    times = nav.time.values.astype('datetime64[us]').astype(datetime)

    assert times.size == 15
    # %% full flle test
    nav = gr.load(fn)
    assert (nav.sv.values == [
        'C06', 'C07', 'C08', 'C11', 'C12', 'C14', 'C16', 'C20', 'C21', 'C22',
        'C27', 'C29', 'C30', 'E01', 'E02', 'E03', 'E04', 'E05', 'E07', 'E08',
        'E09', 'E11', 'E12', 'E14', 'E18', 'E19', 'E21', 'E24', 'E25', 'E26',
        'E27', 'E30', 'E31', 'G01', 'G02', 'G03', 'G04', 'G05', 'G06', 'G07',
        'G08', 'G09', 'G10', 'G11', 'G12', 'G13', 'G14', 'G15', 'G16', 'G17',
        'G18', 'G19', 'G20', 'G21', 'G22', 'G23', 'G24', 'G25', 'G26', 'G27',
        'G28', 'G29', 'G30', 'G31', 'G32', 'R01', 'R02', 'R03', 'R04', 'R05',
        'R06', 'R07', 'R08', 'R09', 'R10', 'R11', 'R12', 'R13', 'R14', 'R15',
        'R16', 'R17', 'R18', 'R19', 'R20', 'R21', 'R22', 'R23', 'R24'
    ]).all()

    C05 = nav.sel(sv='C06').dropna(how='all', dim='time')
    E05 = nav.sel(sv='E05').dropna(how='all', dim='time')

    assert C05.time.size == 3  # from inspection of file
    assert E05.time.size == 22  # duplications in file at same time--> take first time
コード例 #8
0
ファイル: test_obs2.py プロジェクト: scienceopen/pyrinex
def test_meas_one():
    """
    test specifying specific measurements (usually only a few of the thirty or so are needed)
    """
    fn = R/'demo.10o'
    obs = gr.load(fn)
    for v in ['L1', 'L2', 'P1', 'P2', 'C1', 'S1', 'S2']:
        assert v in obs
    assert len(obs.data_vars) == 7

    sv = obs.sv.values
    assert len(sv) == 14
    for s in ['G13', 'R19', 'G32', 'G07', 'R23', 'G31', 'G20', 'R11',
              'G12', 'G26', 'G09', 'G21', 'G15', 'S24']:
        assert s in sv

    assert obs['C1'].sel(sv='G07').values == approx([22227666.76, 25342359.37])
# %% one measurement
    obs = gr.load(fn, meas='C1')
    assert 'L1' not in obs

    C1 = obs['C1']
    assert C1.shape == (2, 14)  # two times, 14 SVs overall for all systems in this file
    assert C1.sel(sv='G07').values == approx([22227666.76, 25342359.37])

    assert obs.fast_processing
コード例 #9
0
ファイル: test_nav3.py プロジェクト: nmayorov/georinex
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)
コード例 #10
0
ファイル: rnx2nc.py プロジェクト: mfkiwl/pyGnss
def _convert(file, odir, i, tlim=None, fast=True, 
             use = 'G', override=False):
    try:
        gr.load(file, out = odir, useindicators = i,
                fast = fast, tlim=tlim, use = use, overwrite = override)
    except Exception as e:
        print (e)
    sleep(0.1)
コード例 #11
0
ファイル: test_obs2.py プロジェクト: scienceopen/pyrinex
def test_fast_slow():
    fn = R/'minimal2.10o'
    fobs = gr.load(fn, fast=True)
    sobs = gr.load(fn, fast=False)

    assert fobs.equals(sobs)

    assert fobs.fast_processing
    assert not sobs.fast_processing
コード例 #12
0
def test_fast_slow():
    fn = R / 'minimal2.10o'
    fobs = gr.load(fn, fast=True)
    sobs = gr.load(fn, fast=False)

    assert fobs.equals(sobs)

    assert fobs.fast_processing
    assert not sobs.fast_processing
コード例 #13
0
ファイル: test_nav2.py プロジェクト: oldbridge/georinex
def test_blank():
    fn = R / 'blank.10n'
    nav = gr.load(fn)
    assert nav is None

    with tempfile.TemporaryDirectory() as outdir:
        gr.load(fn, outdir)

    times = gr.gettime(fn)
    assert times is None
コード例 #14
0
ファイル: test_nav3.py プロジェクト: nmayorov/georinex
def test_blank(tmp_path):
    fn = R / 'blank3.10n'
    nav = gr.load(fn)
    assert nav is None

    outdir = tmp_path
    gr.load(fn, outdir)

    times = gr.gettime(fn)
    assert times is None
コード例 #15
0
 def get_ephemeris_dataframe(self, fileinfo, constellations=None):
     filepath = fileinfo['filepath']
     url = fileinfo['url']
     directory = os.path.split(filepath)[0]
     filename = os.path.split(filepath)[1]
     if url == 'igs.bkg.bund.de':
         dest_filepath = os.path.join(self.data_directory, 'igs', filename)
     else:
         dest_filepath = os.path.join(self.data_directory, 'nasa', filename)
     decompressed_filename = os.path.splitext(dest_filepath)[0]
     if not os.path.isfile(decompressed_filename):
         if url == 'gdc.cddis.eosdis.nasa.gov':
             secure = True
         else:
             secure = False
         try:
             self.retrieve_file(url, directory, filename, dest_filepath,
                                secure)
             self.decompress_file(dest_filepath)
         except ftplib.error_perm as err:
             print('ftp error')
             return pd.DataFrame()
     if not self.leapseconds:
         self.leapseconds = EphemerisManager.load_leapseconds(
             decompressed_filename)
     if constellations:
         data = georinex.load(decompressed_filename,
                              use=constellations).to_dataframe()
     else:
         data = georinex.load(decompressed_filename).to_dataframe()
     data.dropna(how='all', inplace=True)
     data.reset_index(inplace=True)
     data['source'] = decompressed_filename
     WEEKSEC = 604800
     data['t_oc'] = pd.to_numeric(data['time'] -
                                  datetime(1980, 1, 6, 0, 0, 0))
     data['t_oc'] = 1e-9 * data['t_oc'] - WEEKSEC * np.floor(
         1e-9 * data['t_oc'] / WEEKSEC)
     data['time'] = data['time'].dt.tz_localize('UTC')
     data.rename(columns={
         'M0': 'M_0',
         'Eccentricity': 'e',
         'Toe': 't_oe',
         'DeltaN': 'deltaN',
         'Cuc': 'C_uc',
         'Cus': 'C_us',
         'Cic': 'C_ic',
         'Crc': 'C_rc',
         'Cis': 'C_is',
         'Crs': 'C_rs',
         'Io': 'i_0',
         'Omega0': 'Omega_0'
     },
                 inplace=True)
     return data
コード例 #16
0
def test_blank(tmp_path):
    fn = R / 'blank.10o'
    obs = gr.load(fn)
    assert obs is None

    outdir = tmp_path
    gr.load(fn, outdir)
    assert not (outdir / (fn.name + '.nc')).is_file()

    times = gr.gettime(fn)
    assert times is None
コード例 #17
0
ファイル: test_conv.py プロジェクト: scienceopen/pyrinex
def test_netcdf_write(tmp_path):
    """
    NetCDF4 wants suffix .nc -- arbitrary tempfile.NamedTemporaryFile names do NOT work!
    """
    pytest.importorskip('netCDF4')

    fn = tmp_path / 'rw.nc'
    obs = gr.load(R/'demo.10o', out=fn)

    wobs = gr.load(fn)

    assert obs.equals(wobs)
コード例 #18
0
ファイル: test_obs2.py プロジェクト: oldbridge/georinex
def test_blank():
    fn = R / 'blank.10o'
    obs = gr.load(fn)
    assert obs is None

    with tempfile.TemporaryDirectory() as outdir:
        outdir = Path(outdir)
        gr.load(fn, outdir)
        assert not (outdir / (fn.name + '.nc')).is_file()

    times = gr.gettime(fn)
    assert times is None
コード例 #19
0
def test_netcdf_write(tmp_path):
    """
    NetCDF4 wants suffix .nc -- arbitrary tempfile.NamedTemporaryFile names do NOT work!
    """
    pytest.importorskip("netCDF4")

    fn = tmp_path / "rw.nc"
    obs = gr.load(R / "demo.10o", out=fn)

    wobs = gr.load(fn)

    assert obs.equals(wobs)
コード例 #20
0
ファイル: test_nav3.py プロジェクト: nmayorov/georinex
def test_ionospheric_correction():
    nav = gr.load(R / "demo.17n")

    assert nav.attrs['ionospheric_corr_GPS'] == approx([
        1.1176e-08, -1.4901e-08, -5.9605e-08, 1.1921e-07, 9.8304e04,
        -1.1469e05, -1.9661e05, 7.2090e05
    ])

    nav = gr.load(R / "galileo3.15n")

    assert nav.attrs['ionospheric_corr_GAL'] == approx(
        [0.1248e+03, 0.5039, 0.2377e-01, 0])
コード例 #21
0
ファイル: test_nav3.py プロジェクト: nmayorov/georinex
def test_minimal(tmp_path):
    fn = R / 'minimal3.10n'

    nav = gr.load(fn)
    assert isinstance(nav, xarray.Dataset)

    outdir = tmp_path
    gr.load(fn, outdir)
    outfn = (outdir / (fn.name + '.nc'))
    assert outfn.is_file()

    assert nav.equals(gr.load(outfn)), f'{outfn}  {fn}'
コード例 #22
0
ファイル: test_nav3.py プロジェクト: zhufengGNSS/georinex
def test_ref(rfn, ncfn):
    """
    python ReadRinex.py tests/data/galileo3.15n -o r3galileo.nc
    python ReadRinex.py tests/data/demo.17n -o r3gps.nc
    python ReadRinex.py tests/data/qzss3.14n -o r3qzss.nc
    python ReadRinex.py tests/data/demo3.10n -o r3sbas.nc
    """
    pytest.importorskip('netCDF4')

    truth = gr.load(R / ncfn)
    nav = gr.load(R / rfn)

    assert nav.equals(truth)
コード例 #23
0
ファイル: test_nav2.py プロジェクト: oldbridge/georinex
def test_minimal():
    fn = R / 'minimal.10n'

    nav = gr.load(fn)
    assert isinstance(nav, xarray.Dataset)

    with tempfile.TemporaryDirectory() as outdir:
        outdir = Path(outdir)
        gr.load(fn, outdir)
        outfn = (outdir / (fn.name + '.nc'))
        assert outfn.is_file()

        assert nav.equals(gr.load(outfn)), f'{outfn}  {fn}'
コード例 #24
0
ファイル: test_stringio.py プロジェクト: scienceopen/pyrinex
def test_obs(rinex_version):
    fn = R / f'minimal{rinex_version}.10o'
    txt = fn.read_text()

    with io.StringIO(txt) as f:
        info = gr.rinexinfo(f)
        assert info['rinextype'] == 'obs'

        times = gr.gettime(f)
        obs = gr.load(f)

    assert times == datetime(2010, 3, 5, 0, 0, 30)

    assert obs.equals(gr.load(fn)), 'StringIO not matching direct file read'
コード例 #25
0
ファイル: test_stringio.py プロジェクト: scienceopen/pyrinex
def test_nav3(rinex_version, t):
    fn = R / f'minimal{rinex_version}.10n'
    txt = fn.read_text()

    with io.StringIO(txt) as f:
        info = gr.rinexinfo(f)
        assert info['rinextype'] == 'nav'

        times = gr.gettime(f)
        nav = gr.load(f)

    assert times == t

    assert nav.equals(gr.load(fn)), 'StringIO not matching direct file read'
コード例 #26
0
ファイル: test_obs3.py プロジェクト: nmayorov/georinex
def test_minimal(tmp_path):
    fn = R/'minimal3.10o'
    obs = gr.load(fn)
    assert isinstance(obs, xarray.Dataset), f'{type(obs)} should be xarray.Dataset'

    outdir = tmp_path
    gr.load(fn, outdir)

    outfn = (outdir / (fn.name + '.nc'))
    assert outfn.is_file()
    assert obs.equals(gr.load(outfn)), f'{outfn}  {fn}'

    times = gr.gettime(fn)
    assert np.isnan(times.interval)
コード例 #27
0
ファイル: test_conv.py プロジェクト: nmayorov/georinex
def test_netcdf_write(tmp_path):
    """
    NetCDF4 wants suffix .nc -- arbitrary tempfile.NamedTemporaryFile names do NOT work!
    """
    pytest.importorskip('netCDF4')

    outdir = tmp_path
    fn = outdir / 'rw.nc'
    obs = gr.load(R / 'demo.10o', out=fn)

    wobs = gr.load(fn)

    # MUST be under context manager for lazy loading
    assert obs.equals(wobs)
コード例 #28
0
ファイル: test_stringio.py プロジェクト: donok1/georinex
def test_obs(rinex_version):
    fn = R / f"minimal{rinex_version}.10o"
    txt = fn.read_text()

    with io.StringIO(txt) as f:
        info = gr.rinexinfo(f)
        assert info["rinextype"] == "obs"

        times = gr.gettime(f)
        obs = gr.load(f)

    assert times == datetime(2010, 3, 5, 0, 0, 30)

    assert obs.equals(gr.load(fn)), "StringIO not matching direct file read"
コード例 #29
0
ファイル: test_conv.py プロジェクト: oldbridge/georinex
def test_netcdf_write():
    """
    NetCDF4 wants suffix .nc -- arbitrary tempfile.NamedTemporaryFile names do NOT work!
    """
    pytest.importorskip('netCDF4')

    with tempfile.TemporaryDirectory() as D:
        fn = Path(D) / 'rw.nc'
        obs = gr.load(R / 'demo.10o', out=fn)

        wobs = gr.load(fn)

        # MUST be under context manager for lazy loading
        assert obs.equals(wobs)
コード例 #30
0
ファイル: test_stringio.py プロジェクト: donok1/georinex
def test_nav3(rinex_version, t):
    fn = R / f"minimal{rinex_version}.10n"
    txt = fn.read_text()

    with io.StringIO(txt) as f:
        info = gr.rinexinfo(f)
        assert info["rinextype"] == "nav"

        times = gr.gettime(f)
        nav = gr.load(f)

    assert times == t

    assert nav.equals(gr.load(fn)), "StringIO not matching direct file read"
コード例 #31
0
ファイル: test_nav3.py プロジェクト: geospace-code/georinex
def test_ref(rfn, ncfn):
    """
    python -m georinex.read src/georinex/tests/data/galileo3.15n -o galileo3.15n.nc
    python -m georinex.read src/georinex/tests/data/demo_nav3.17n -o demo_nav3.17n.nc
    python -m georinex.read src/georinex/tests/data/qzss_nav3.14n -o qzss_nav3.14n.nc
    python -m georinex.read src/georinex/tests/data/demo_nav3.10n -o demo_nav3.10n.nc
    """
    pytest.importorskip("netCDF4")

    truth = gr.load(R / ncfn)
    nav = gr.load(R / rfn)

    for v in nav.data_vars:
        assert truth[v].equals(nav[v])
    assert nav.equals(truth)
コード例 #32
0
ファイル: test_obs3.py プロジェクト: oldbridge/georinex
def test_minimal():
    fn = R/'minimal3.10o'
    obs = gr.load(fn)
    assert isinstance(obs, xarray.Dataset), f'{type(obs)} should be xarray.Dataset'

    with tempfile.TemporaryDirectory() as outdir:
        outdir = Path(outdir)
        gr.load(fn, outdir)

        outfn = (outdir / (fn.name + '.nc'))
        assert outfn.is_file()
        assert obs.equals(gr.load(outfn)), f'{outfn}  {fn}'

    times = gr.gettime(fn)
    assert np.isnan(times.interval)
コード例 #33
0
ファイル: ReadRinex.py プロジェクト: scienceopen/pyrinex
def main():
    p = ArgumentParser(description='example of reading RINEX 2/3 Navigation/Observation file')
    p.add_argument('rinexfn', help='path to RINEX 2 or RINEX 3 file')
    p.add_argument('-o', '--out', help='write data to path or file as NetCDF4')
    p.add_argument('-v', '--verbose', action='store_true')
    p.add_argument('-p', '--plot', help='display plots', action='store_true')
    p.add_argument('-u', '--use', help='select which GNSS system(s) to use', nargs='+')
    p.add_argument('-m', '--meas', help='select which GNSS measurement(s) to use', nargs='+')
    p.add_argument('-t', '--tlim', help='specify time limits (process part of file)', nargs=2)
    p.add_argument('-useindicators', help='use SSI, LLI indicators (signal, loss of lock)',
                   action='store_true')
    p.add_argument('-strict', help='do not use speculative preallocation (slow) let us know if this is needed',
                   action='store_false')
    p.add_argument('-interval', help='read the rinex file only every N seconds', type=float)
    P = p.parse_args()

    data = gr.load(P.rinexfn, P.out, use=P.use, tlim=P.tlim,
                   useindicators=P.useindicators, meas=P.meas,
                   verbose=P.verbose, fast=P.strict, interval=P.interval)
# %% plots
    if P.plot:
        import georinex.plots as grp
        from matplotlib.pyplot import show

        grp.timeseries(data)
        show()
    else:
        print(data)
コード例 #34
0
ファイル: test_obs2.py プロジェクト: scienceopen/pyrinex
def test_meas_onesys_indicators():
    obs = gr.load(R/'demo.10o', use='G', meas='C1', useindicators=True)

    C1 = obs['C1']

    assert C1.sel(sv='G07').values == approx([22227666.76, 25342359.37])
    assert obs.fast_processing
コード例 #35
0
ファイル: test_nav2.py プロジェクト: scienceopen/pyrinex
def test_small():
    pytest.importorskip('netCDF4')

    truth = xarray.open_dataset(R/'r2all.nc', group='NAV')
    nav = gr.load(R/'demo.10n')

    assert nav.equals(truth)
コード例 #36
0
ファイル: test_obs2.py プロジェクト: scienceopen/pyrinex
def test_all_systems(tmp_path, use):
    """
    ./ReadRinex.py tests/demo.10o -o r2all.nc
    ./ReadRinex.py tests/demo.10n -o r2all.nc
    """
    pytest.importorskip('netCDF4')

    truth = xarray.open_dataset(R / 'r2all.nc', group='OBS')
# %% test reading all satellites
    obs = gr.load(R/'demo.10o', use=use)
    assert obs.equals(truth)
    assert obs.fast_processing

    assert obs.position == pytest.approx([4789028.4701, 176610.0133, 4195017.031])
    try:
        assert obs.position_geodetic == approx([41.38871005, 2.11199932, 166.25085213])
    except AttributeError:  # no pymap3d
        pass
# %% test read .nc
    obs = gr.rinexobs(R / 'r2all.nc')
    assert obs.equals(truth)
# %% test write .nc
    outdir = tmp_path
    outfn = outdir / 'testout.nc'
    gr.rinexobs(R/'demo.10o', outfn=outdir / 'testout.nc')
    assert outfn.is_file() and 50000 > outfn.stat().st_size > 30000
コード例 #37
0
ファイル: test_conv.py プロジェクト: scienceopen/pyrinex
def test_netcdf_read():
    pytest.importorskip('netCDF4')

    dat = gr.load(R/'r2all.nc')

    assert isinstance(dat, dict), f'{type(dat)}'
    assert isinstance(dat['obs'], xarray.Dataset)
コード例 #38
0
ファイル: test_obs3.py プロジェクト: scienceopen/pyrinex
def test_meas_all_missing():
    """measurement not in any system"""
    fn = R/'demo3.10o'
    obs = gr.load(fn, meas='nonsense')
    assert 'nonsense' not in obs

    assert len(obs.data_vars) == 0
コード例 #39
0
ファイル: test_conv.py プロジェクト: oldbridge/georinex
def test_obsdata():
    pytest.importorskip('netCDF4')

    truth = xarray.open_dataset(R / 'r2all.nc', group='OBS', autoclose=True)

    obs = gr.load(R / 'demo.10o')
    assert obs.equals(truth)
コード例 #40
0
ファイル: test_conv.py プロジェクト: oldbridge/georinex
def test_navdata():
    pytest.importorskip('netCDF4')

    truth = xarray.open_dataset(R / 'r2all.nc', group='NAV', autoclose=True)
    nav = gr.load(R / 'demo.10n')

    assert nav.equals(truth)
コード例 #41
0
ファイル: test_conv.py プロジェクト: oldbridge/georinex
def test_netcdf_read():
    pytest.importorskip('netCDF4')

    dat = gr.load(R / 'r2all.nc')

    assert isinstance(dat, dict), f'{type(dat)}'
    assert isinstance(dat['obs'], xarray.Dataset)
コード例 #42
0
ファイル: test_conv.py プロジェクト: scienceopen/pyrinex
def test_nc_load(dtype):
    pytest.importorskip('netCDF4')

    truth = xarray.open_dataset(R/'r2all.nc', group=dtype)

    obs = gr.load(R/f'demo.10{dtype[0].lower()}')
    assert obs.equals(truth)
コード例 #43
0
ファイル: test_nav3.py プロジェクト: nmayorov/georinex
def test_tlim():
    fn = R / 'CEDA00USA_R_20182100000_01D_MN.rnx.gz'
    nav = gr.load(fn, tlim=('2018-07-29T08', '2018-07-29T09'))

    times = nav.time.values.astype('datetime64[us]').astype(datetime)

    assert (times == [
        datetime(2018, 7, 29, 8, 20),
        datetime(2018, 7, 29, 8, 50)
    ]).all()
    # %% beyond end of file
    nav = gr.load(fn, tlim=('2018-07-29T23', '2018-07-29T23:30'))

    times = nav.time.values.astype('datetime64[us]').astype(datetime)

    assert times == datetime(2018, 7, 29, 23)
コード例 #44
0
ファイル: test_nav2.py プロジェクト: scienceopen/pyrinex
def test_mangled():
    fn = R/'14601736.18n'

    nav = gr.load(fn)

    times = gr.to_datetime(nav.time)

    assert times == datetime(2018, 6, 22, 8)
コード例 #45
0
ファイル: test_obs3.py プロジェクト: scienceopen/pyrinex
def test_meas_two():
    """two NON-SEQUENTIAL measurements"""
    fn = R/'demo3.10o'
    obs = gr.load(fn, meas=['L1C', 'S1C'])
    assert 'L2P' not in obs

    L1C = obs['L1C']
    assert L1C.shape == (2, 14)
    assert (L1C.sel(sv='G07') == approx([118767195.32608, 133174968.81808])).all()

    S1C = obs['S1C']
    assert S1C.shape == (2, 14)

    assert (S1C.sel(sv='R23') == approx([39., 79.])).all()

    C1C = gr.load(fn, meas='C1C')
    assert not C1C.equals(L1C)
コード例 #46
0
ファイル: test_obs2.py プロジェクト: scienceopen/pyrinex
def test_mangled_times():
    fn = R/'badtime.10o'

    obs = gr.load(fn)

    times = gr.to_datetime(obs.time)

    assert times
コード例 #47
0
ファイル: test_time.py プロジェクト: scienceopen/pyrinex
def test_interval_obs3(interval, expected_len):

    obs = gr.load(R/'CEDA00USA_R_20182100000_23H_15S_MO.rnx.gz', interval=interval,
                  tlim=('2018-07-29T01:00', '2018-07-29T01:05'))

    times = gr.to_datetime(obs.time)

    assert len(times) == expected_len
コード例 #48
0
ファイル: test_obs3.py プロジェクト: scienceopen/pyrinex
def test_contents():
    """
    test specifying specific measurements (usually only a few of the thirty or so are needed)
    """
    fn = R/'demo3.10o'
    obs = gr.load(fn)
    for v in ['L1C', 'L2P', 'C1P', 'C2P', 'C1C', 'S1C', 'S1P', 'S2P']:
        assert v in obs
    assert len(obs.data_vars) == 8
コード例 #49
0
ファイル: test_obs3.py プロジェクト: scienceopen/pyrinex
def test_meas_one():
    fn = R/'demo3.10o'
    obs = gr.load(fn, meas='C1C')
    assert 'L1C' not in obs

    C1C = obs['C1C']
    assert C1C.shape == (2, 14)  # two times, 14 SVs overall for all systems in this file

    assert (C1C.sel(sv='G07') == approx([22227666.76, 25342359.37])).all()
コード例 #50
0
ファイル: test_rinex.py プロジェクト: scienceopen/pyrinex
def test_dont_care_file_extension():
    """ GeoRinex ignores the file extension and only considers file headers to determine what a file is."""
    fn = R / 'brdc0320.16l.txt'

    hdr = gr.rinexheader(R/fn)
    assert int(hdr['version']) == 3

    nav = gr.load(fn)
    assert nav.ionospheric_corr_GAL == approx([139, 0.132, 0.0186])
コード例 #51
0
ファイル: test_obs3.py プロジェクト: scienceopen/pyrinex
def test_all_system():
    """
    ./ReadRinex.py -q tests/demo3.10o -o r3all.nc
    """
    pytest.importorskip('netCDF4')

    obs = gr.load(R/'demo3.10o')
    truth = gr.rinexobs(R/'r3all.nc', group='OBS')

    assert obs.equals(truth)
コード例 #52
0
ファイル: test_obs3.py プロジェクト: scienceopen/pyrinex
def tests_all_indicators():
    """
    ./ReadRinex.py -q tests/demo3.10o -useindicators -o r3all_indicators.nc
    """
    pytest.importorskip('netCDF4')

    obs = gr.load(R/'demo3.10o', useindicators=True)
    truth = gr.rinexobs(R/'r3all_indicators.nc', group='OBS')

    assert obs.equals(truth)
コード例 #53
0
ファイル: test_obs2.py プロジェクト: scienceopen/pyrinex
def test_multi_system():
    """./ReadRinex.py tests/demo.10o -u G R -o r2GR.nc
    """
    pytest.importorskip('netCDF4')

    truth = xarray.open_dataset(R / 'r2GR.nc', group='OBS')

    obs = gr.load(R/'demo.10o', use=('G', 'R'))
    assert obs.equals(truth)
    assert obs.fast_processing
コード例 #54
0
ファイル: test_obs2.py プロジェクト: scienceopen/pyrinex
def test_one_sv():
    obs = gr.load(R / 'rinex2onesat.10o')

    assert len(obs.sv) == 1
    assert obs.sv.item() == 'G13'

    times = gr.to_datetime(gr.gettime(R/'rinex2onesat.10o'))

    assert (times == [datetime(2010, 3, 5, 0, 0), datetime(2010, 3, 5, 0, 0, 30)]).all()

    assert obs.fast_processing
コード例 #55
0
ファイル: test_obs2.py プロジェクト: scienceopen/pyrinex
def test_meas_indicators():
    """
    ./ReadRinex.py tests/demo.10o -useindicators -m C1 -o r2_C1_indicators.nc
    """
    pytest.importorskip('netCDF4')

    obs = gr.load(R/'demo.10o', meas='C1', useindicators=True)
    truth = gr.rinexobs(R/'r2_C1_indicators.nc', group='OBS')

    assert obs.equals(truth)
    assert obs.fast_processing
コード例 #56
0
ファイル: test_obs2.py プロジェクト: scienceopen/pyrinex
def test_meas_two():
    fn = R/'demo.10o'

    C1 = gr.load(fn, meas='C1')['C1']
# %% two NON-SEQUENTIAL measurements
    obs = gr.load(fn, meas=['L1', 'S1'])
    assert 'L2' not in obs

    L1 = obs['L1']
    assert L1.shape == (2, 14)
    assert L1.sel(sv='G07').values == approx([118767195.32608, 133174968.81808])

    S1 = obs['S1']
    assert S1.shape == (2, 14)

    assert (S1.sel(sv='R23') == approx([39., 79.])).all()

    assert not C1.equals(L1)

    assert obs.fast_processing
コード例 #57
0
ファイル: test_rinex.py プロジェクト: scienceopen/pyrinex
def test_minimal(tmp_path, filename):
    pytest.importorskip('netCDF4')

    fn = R/filename

    dat = gr.load(fn)
    assert isinstance(dat, xarray.Dataset), f'{type(dat)} should be xarray.Dataset'

    gr.load(fn, tmp_path)

    outfn = (tmp_path / (fn.name + '.nc'))
    assert dat.equals(gr.load(outfn)), f'{outfn}  {fn}'

    times = gr.gettime(fn)
    assert times.size == 1

    if dat.rinextype == 'obs':
        if int(dat.version) == 2:
            assert dat.fast_processing
        elif int(dat.version) == 3:
            assert not dat.fast_processing  # FIXME: update when OBS3 fast processing is added.
コード例 #58
0
ファイル: test_obs2.py プロジェクト: scienceopen/pyrinex
def test_mangled_data():
    fn = R/'14601736.18o'

    obs = gr.load(fn)

    times = gr.to_datetime(obs.time)

    assert (times == (datetime(2018, 6, 22, 6, 17, 30),
                      datetime(2018, 6, 22, 6, 17, 45),
                      datetime(2018, 6, 22, 6, 18))).all()

    assert not obs.fast_processing
コード例 #59
0
ファイル: test_lzw.py プロジェクト: scienceopen/pyrinex
def test_obs2():
    pytest.importorskip('unlzw')

    fn = R/'ac660270.18o.Z'

    obs = gr.load(fn)

    hdr = gr.rinexheader(fn)

    assert hdr['t0'] <= gr.to_datetime(obs.time[0])

    assert not obs.fast_processing
コード例 #60
0
ファイル: test_nav2.py プロジェクト: scienceopen/pyrinex
def test_galileo():
    nav = gr.load(R/'ceda2100.18e')

    E18 = nav.sel(sv='E18').dropna(dim='time', how='all')
    assert gr.to_datetime(E18.time) == datetime(2018, 7, 29, 12, 40)

    assert E18.to_array().values.squeeze() == approx([6.023218797054e-3, -2.854960712284e-11, 0.,
                                                      76, 79.53125, 3.006910964197e-09, -1.308337580849, 6.468966603279e-06,
                                                      1.659004657995e-01, 3.594905138016e-07, 5.289377120972e3,
                                                      45600, 5.243346095085e-06, 1.437602366755, 4.358589649200e-06,
                                                      8.809314114035e-01, 3.329375000000e2, 1.349316878658, -4.092313318419e-09,
                                                      -6.553844422498e-10, 517, 2.012000000000e3, 3.12, 455, 1.396983861923e-08,
                                                      1.536682248116e-08, 47064])