Ejemplo n.º 1
0
    #    failure = next(failed) - 2
    # logger.info('Total files: {}, success: {}, failed: {}'.format(
    # total, cnt['succ'], cnt['failed']))
    return

if __name__ == '__main__':
    """"""
    import argparse
    import sys
    from aux_gps import configure_logger
    from aux_gps import get_var
    from pathlib import Path
    # first check for GCORE path:
    if get_var('GCORE') is None:
        raise ValueError('Run source ~/GipsyX-1.1/rc_GipsyX.sh first !')
    logger = configure_logger(name='axis-gipsyx')
    parser = argparse.ArgumentParser(
        description=
        'a command line tool for preparing and running rinex files with gipsyX software.'
    )
    optional = parser._action_groups.pop()
    required = parser.add_argument_group('required arguments')
    #    required.add_argument(
    #        '--savepath',
    #        help="a full path to save the raw output files, e.g., /home/ziskin/Work_Files/PW_yuval/gipsyx_resolved/TELA",
    #        type=check_path)
    required.add_argument(
        '--rinexpath',
        help=
        "a full path to the rinex path of the station, /home/ziskin/Work_Files/PW_yuval/rinex/TELA",
        type=check_path)
Ejemplo n.º 2
0
#        StepSize_wRef(Bseries=B_file, output=out, MissingValueCode="-999.00",
#                      InCs=out + '_mCs.txt', p_lev=plev, Mq=Mq, Ny4a=Ny4a,
#                      Rseries=R_file)
#        print('')
#    return

if __name__ == '__main__':
    import argparse
    import sys
    from pathlib import Path
    from aux_gps import configure_logger
    from PW_paths import work_yuval
    import os
    homo_path = work_yuval / 'homogenization'
    os.environ['R_HOME'] = '/home/shlomi/anaconda3/lib/R'
    logger = configure_logger('RH_tests')
    savepath = Path(homo_path)
    parser = argparse.ArgumentParser(
        description=
        'a command line tool for running the RHtests climatology homogenization procedures.'
    )
    optional = parser._action_groups.pop()
    required = parser.add_argument_group('required arguments')
    # remove this line: optional = parser...
    required.add_argument('--station',
                          nargs='+',
                          help="GNSS 4 letter station",
                          type=check_station_name)
    required.add_argument('--field',
                          help='Either PW or ALT for now',
                          choices=['PW', 'ALT'])
Ejemplo n.º 3
0
            logger.info('saving to {} to {}'.format(filename, savepath))
            da.to_netcdf(savepath / filename, 'w', encoding=encoding)
            # print('done!')
        else:
            logger.warning('station {} is already in {}, skipping...'.format(
                st_id, savepath))
    return


if __name__ == '__main__':
    import argparse
    import sys
    from ims_procedures import ims_api_get_meta
    from pathlib import Path
    from aux_gps import configure_logger
    logger = configure_logger('ims_downloader')
    channels = [
        'BP', 'DiffR', 'Grad', 'NIP', 'Rain', 'RH', 'STDwd', 'TD', 'TDmax',
        'TDmin', 'TG', 'Time', 'WD', 'WDmax', 'WS', 'WS10mm', 'WS1mm', 'WSmax'
    ]
    savepath = Path('/home/ziskin/Work_Files/PW_yuval/IMS_T/10mins')
    parser = argparse.ArgumentParser(
        description=
        'a command line tool for downloading all 10mins stations from the IMS with specific variable'
    )
    optional = parser._action_groups.pop()
    required = parser.add_argument_group('required arguments')
    # remove this line: optional = parser...
    required.add_argument(
        '--savepath',
        help=
Ejemplo n.º 4
0
#    return header


def check_path(path):
    import os
    path = str(path)
    if not os.path.exists(path):
        raise argparse.ArgumentTypeError(path + ' does not exist...')
    return path


if __name__ == '__main__':
    import argparse
    import sys, os
    from aux_gps import configure_logger
    logger = configure_logger(name='rinex_hdr_reader')
    sys.path.insert(0, "{}/lib/python{}.{}".format(os.environ['GCOREBUILD'], \
                    sys.version_info[0], sys.version_info[1]))
    parser = argparse.ArgumentParser(
        description='a command line tool for ' +
        'reading rnx file headers for one station' + 'and produce a log file.')
    optional = parser._action_groups.pop()
    required = parser.add_argument_group('required arguments')
    # remove this line: optional = parser...
    required.add_argument('--rinexpath',
                          help="a main path to the rinex files." +
                          " files, e.g., /home/ziskin/rinex/",
                          type=check_path)
    required.add_argument('--savepath',
                          help="a path to save the log report." +
                          " files, e.g., /home/ziskin/",
Ejemplo n.º 5
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue May 28 10:52:06 2019

@author: ziskin
"""

if __name__ == '__main__':
    from PW_paths import work_yuval
    import xarray as xr
    import pandas as pd
    from aux_gps import configure_logger
    from PyEMD import EMD
    logger = configure_logger(name='emd_saver')
    samples = ['monthly', 'hourly', '3hourly', 'daily', 'weekly', None]
    logger.info('Starting to calculate IMFs for GNSS PW:')
    for sample in samples:
        if sample is None:
            GNSS_pw = xr.open_dataset(work_yuval / 'GNSS_PW.nc')
            logger.info('proccessing 5 min sample rate.')
        else:
            GNSS_pw = xr.open_dataset(work_yuval /
                                      'GNSS_{}_PW.nc'.format(sample))
            logger.info('proccessing {} sample rate.'.format(sample))
        only_pw = [x for x in GNSS_pw if 'error' not in x]
        da_list = []
        for pw in GNSS_pw[only_pw].data_vars.values():
            logger.info('calculating EMD for {} station.'.format(pw.name))
            emd = EMD()
            imfs = emd(pw.dropna('time').values)
Ejemplo n.º 6
0
 """tdppath is where the gipsyx results are (tdp files).
 e.g., /rinex/tela/30hr/results. savepath is where the raw/final post
 proccessed results will be saved."""
 import argparse
 import sys
 from PW_paths import work_yuval
 from PW_paths import work_path
 from PW_paths import geo_path
 from PW_paths import cwd
 from aux_gps import configure_logger
 garner_path = work_yuval / 'garner'
 ims_path = work_yuval / 'IMS_T'
 gis_path = work_yuval / 'gis'
 sound_path = work_yuval / 'sounding'
 rinex_on_geo = geo_path / 'Work_Files/PW_yuval/rinex'
 logger = configure_logger('gipsyx_post_proccesser')
 parser = argparse.ArgumentParser(
     description=
     'a command line tool for post proccessing PPP gipsyX results.')
 optional = parser._action_groups.pop()
 required = parser.add_argument_group('required arguments')
 required.add_argument(
     '--savepath',
     help=
     "a full path to save the raw and final output files, e.g., /home/ziskin/Work_Files/PW_yuval/gipsyx_resolved/TELA",
     type=check_path)
 required.add_argument(
     '--tdppath',
     help=
     "a full path to the tdp files path of the station, /home/ziskin/Work_Files/PW_yuval/rinex/tela/30hr/results",
     type=check_path)
Ejemplo n.º 7
0
if __name__ == '__main__':
    """--prep: prepare mode
        choices: 1) drdump 2) edit24hr 3) edit30hr
        Note: running --rinexpath arg without --prep means gd2e.py run and
        rinexpath is actually where the datarecords are. e.g., /rinex/tela/24hr
        or /rinex/tela/30hr"""
    import argparse
    import sys
    from aux_gps import configure_logger
    from aux_gps import get_var
    from pathlib import Path
    # first check for GCORE path:
    if get_var('GCORE') is None:
        raise ValueError('Run source ~/GipsyX-1.1/rc_GipsyX.sh first !')
    logger = configure_logger(name='gipsyx')
    parser = argparse.ArgumentParser(
        description=
        'a command line tool for preparing and running rinex files with gipsyX softwere.'
    )
    optional = parser._action_groups.pop()
    required = parser.add_argument_group('required arguments')
    #    required.add_argument(
    #        '--savepath',
    #        help="a full path to save the raw output files, e.g., /home/ziskin/Work_Files/PW_yuval/gipsyx_resolved/TELA",
    #        type=check_path)
    required.add_argument(
        '--rinexpath',
        help=
        "a full path to the rinex path of the station, /home/ziskin/Work_Files/PW_yuval/rinex/TELA",
        type=check_path)
Ejemplo n.º 8
0
    comp = dict(zlib=True, complevel=9)  # best compression
    encoding = {var: comp for var in result}
    result.to_netcdf(path / filename, 'w', encoding=encoding)
    logger.info('Done!')
    return

if __name__ == '__main__':
    """--mode: either download or post
    --path: where to save the downloaded files or where to save the post
    proccesed files.
   """
    import argparse
    import sys
    from aux_gps import configure_logger
    import pandas as pd
    logger = configure_logger(name='uwyo')
    parser = argparse.ArgumentParser(
        description=
        'a command line tool for downloading and proccesing upper air soundings from university of Wyoming website.'
    )
    optional = parser._action_groups.pop()
    required = parser.add_argument_group('required arguments')
    required.add_argument('--path',
                          help="a full path to the save location of the files",
                          type=check_path)
    required.add_argument('--mode',
                          help='mode of the tool',
                          choices=['download', 'post'])
    optional.add_argument('--station',
                          help='WMO station number, use with mode=download',
                          type=str)
Ejemplo n.º 9
0
#                        features=feature,
#                        inner_splits=inner_splits,
#                        outer_splits=outer_splits,
#                        refit_scorer=scorer,
#                        verbose=0,
#                        diagnostic=False,
#                        savepath=savepath)

if __name__ == '__main__':
    import argparse
    import sys
    from pathlib import Path
    from aux_gps import configure_logger
    from PW_paths import work_yuval
    hydro_path = work_yuval / 'hydro'
    logger = configure_logger('Hydro_ML')
    savepath = Path(hydro_path)
    parser = argparse.ArgumentParser(
        description=
        'a command line tool for running the ML models tuning for hydro-PWV.')
    optional = parser._action_groups.pop()
    required = parser.add_argument_group('required arguments')
    # remove this line: optional = parser...
    # required.add_argument(
    #     '--pw_station',
    #     help="GNSS 4 letter station", nargs='+',
    #     type=check_station_name)
    # required.add_argument(
    #     '--hydro_id',
    #     help="5 integer hydro station", nargs='+',
    #     type=int)  # check_hydro_id)
    year = int(year)
    this_year = datetime.today().year
    if year < 1988:
        raise argparse.ArgumentTypeError('{} should be >= 1988'.format(year))
    if year > datetime.today().year:
        raise argparse.ArgumentTypeError('{} should be <= {}'.format(
            year, this_year))
    return year


if __name__ == '__main__':
    import argparse
    import sys
    from pathlib import Path
    from aux_gps import configure_logger
    logger = configure_logger(name='rinex_garner')
    check_python_version(min_major=3, min_minor=6)
    parser = argparse.ArgumentParser(
        description='a command line tool for ' +
        'downloading a single station rinex files' +
        'from garner site and copy them to a single directory to' +
        ' be proccesed by gipsy')
    optional = parser._action_groups.pop()
    required = parser.add_argument_group('required arguments')
    # remove this line: optional = parser...
    required.add_argument(
        '--path',
        help=
        "a main path to save station rinex, the tool will create a folder in this path named as the station."
        + " files, e.g., /home/ziskin/garner/",
        type=check_path)
Ejemplo n.º 11
0
                                                    verbose=False)
    else:
        T02s = path_glob(T02_path, '*.T02')
        for T02 in T02s:
            try:
                process_single_T02_file(T02, year, savepath, verbose=True)
            except CalledProcessError:
                logger.warning('process failed on {}, skipping..'.format(T02))
    return


if __name__ == '__main__':
    import argparse
    import sys
    from aux_gps import configure_logger
    logger = configure_logger('axis_rinex_processer')
    parser = argparse.ArgumentParser(
        description=
        'a command line tool for converting T02 to RINEX and saving it to directory structure'
    )
    optional = parser._action_groups.pop()
    required = parser.add_argument_group('required arguments')
    # remove this line: optional = parser...
    required.add_argument(
        '--savepath',
        help=
        "a full path to main save directory, e.g., /home/ziskin/Work_Files/PW_yuval/axis-rinex",
        type=check_path)
    # required.add_argument('--channel', help="10 mins channel name , e.g., TD, BP or RH",
    #                       choices=channels)