How to use the georinex.io function in georinex

To help you get started, we’ve selected a few georinex examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github scivision / georinex / georinex / io.py View on Github external
def rinexinfo(f: Union[Path, TextIO]) -> Dict[str, Any]:
    """verify RINEX version"""
    if isinstance(f, (str, Path)):
        fn = Path(f).expanduser()

        if fn.suffixes == ['.crx', '.gz']:
            with gzip.open(fn, 'rt') as z:
                return rinexinfo(io.StringIO(z.read(80)))
        elif fn.suffix == '.crx':
            with fn.open('r') as f:
                return rinexinfo(io.StringIO(f.read(80)))
        else:
            with opener(fn) as f:
                return rinexinfo(f)

    try:
        line = f.readline(80)  # don't choke on binary files
        if not isinstance(line, str) or line[60:80] not in ('RINEX VERSION / TYPE', 'CRINEX VERS   / TYPE'):
            raise ValueError

        info = {'version': float(line[:9]),  # yes :9
                'filetype': line[20],
                'systems': line[40],
                'hatanaka': line[20:40] == 'COMPACT RINEX FORMAT'}

        if info['systems'] == ' ':
            if info['filetype'] == 'N' and int(info['version']) == 2:  # type: ignore
github scivision / georinex / georinex / io.py View on Github external
if fn.suffixes == ['.crx', '.gz']:
        if header:
            with gzip.open(fn, 'rt') as f:
                yield f
        else:
            with gzip.open(fn, 'rt') as g:
                f = io.StringIO(_opencrx(g))
                yield f
    elif fn.suffix == '.crx':
        if header:
            with fn.open('r') as f:
                yield f
        else:
            with fn.open('r') as g:
                f = io.StringIO(_opencrx(g))
                yield f
    elif fn.suffix == '.gz':
        with gzip.open(fn, 'rt') as f:
            yield f
    elif fn.suffix == '.zip':
        with zipfile.ZipFile(fn, 'r') as z:
            flist = z.namelist()
            for rinexfn in flist:
                with z.open(rinexfn, 'r') as bf:
                    f = io.TextIOWrapper(bf, newline=None)
                    yield f
    elif fn.suffix == '.Z':
        if unlzw is None:
            raise ImportError('pip install unlzw')
        with fn.open('rb') as zu:
            with io.StringIO(unlzw.unlzw(zu.read()).decode('ascii')) as f:
github scivision / georinex / georinex / io.py View on Github external
def opener(fn: Path, header: bool = False, verbose: bool = False) -> TextIO:
    """provides file handle for regular ASCII or gzip files transparently"""
    if fn.is_dir():
        raise FileNotFoundError(f'{fn} is a directory; I need a file')

    if verbose:
        if fn.stat().st_size > 100e6:
            print(f'opening {fn.stat().st_size/1e6} MByte {fn.name}')

    if fn.suffixes == ['.crx', '.gz']:
        if header:
            with gzip.open(fn, 'rt') as f:
                yield f
        else:
            with gzip.open(fn, 'rt') as g:
                f = io.StringIO(_opencrx(g))
                yield f
    elif fn.suffix == '.crx':
        if header:
            with fn.open('r') as f:
                yield f
        else:
            with fn.open('r') as g:
                f = io.StringIO(_opencrx(g))
                yield f
    elif fn.suffix == '.gz':
        with gzip.open(fn, 'rt') as f:
            yield f
    elif fn.suffix == '.zip':
        with zipfile.ZipFile(fn, 'r') as z:
            flist = z.namelist()
            for rinexfn in flist: