How to use the georinex.io.StringIO 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
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:
                yield f

    else:
        with fn.open('r') as f:
            yield f
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'}