Ejemplo n.º 1
0
        pass
        
    ## Custom methods.  Anything beyond what is handled by the automatic API
    ## Diagnostic methods

    def check(self, metric):
        codes = { 'wind': '0WU',
          'PTH': '0TU',
          'rain': '0RU',
          'self': '0SU'
        }

        self.cmd_output(codes[metric]+'\n\r')
     
    def reset(self, code):
        codes = { 'rain': '0XZRU',
                  'intensity': '0XZRI'
              }
        output = self.cmd_output(codes[code]+'\n\r')
        

if __name__ == "__main__":
    logging.basicConfig(level=getattr(logging, os.environ.get('LOGGING_LEVEL','WARN')))

    import lewas.cli as cli
    args = cli.parse(name='weather_station')
    config = args.config 
    weather_station = Instrument(args.reader, parser=args.parser, name=args.instrument_name, site=config['site'])
    kwargs = {}
    weather_station.run(args.datastore, **kwargs)
Ejemplo n.º 2
0

def init(args, **kwargs):
    logger.log(logging.INFO, 'sonde init')
    if hasattr(args.reader, 'write'):
        setattr(args, 'header', header_from_stream(args.reader))
    else:
        setattr(args, 'header', header_from_file('data/sonde_headers.txt'))
    return args

def parser(args, **kwargs):
    token_sep = re.compile('(?:([{}])\s*|\s+)'.format(''.join(decorations.keys())))
    parsers = [ split_parser(token_sep, compact=False) ]
    fields = list(starmap(parser_from_header, enumerate(args.header))) # starmap(fn, iterable) ~ [ fn(*args) for args in iterable ]
    parsers.append(field_parser(fields))
    parsers.append(lambda m: filter(lambda n: n.unit, m)) # get rid of mesaurements without unit set, in this case, the time field
    parsers.reverse()

    return compose(*parsers)

if __name__ == '__main__':
    logging.basicConfig(level=getattr(logging, os.environ.get('LOGGING_LEVEL','WARN')))

    import lewas.cli as cli
    args = cli.parse(name='sonde')
    config = args.config 
    import inspect
    #logger.log(logging.DEBUG, 'using parser with source: {}'.format(inspect.getsource(args.parser([]))))
    sonde = Instrument(args.reader, parser=args.parser, name=args.instrument_name, site=config['site'])
    sonde.run(args.datastore, **config)
Ejemplo n.º 3
0
    def start(self):
        pass

    ## Custom methods.  Anything beyond what is handled by the automatic API
    ## Diagnostic methods

    def check(self, metric):
        codes = {'wind': '0WU', 'PTH': '0TU', 'rain': '0RU', 'self': '0SU'}

        self.cmd_output(codes[metric] + '\n\r')

    def reset(self, code):
        codes = {'rain': '0XZRU', 'intensity': '0XZRI'}
        output = self.cmd_output(codes[code] + '\n\r')


if __name__ == "__main__":
    logging.basicConfig(
        level=getattr(logging, os.environ.get('LOGGING_LEVEL', 'WARN')))

    import lewas.cli as cli
    args = cli.parse(name='weather_station')
    config = args.config
    weather_station = Instrument(args.reader,
                                 parser=args.parser,
                                 name=args.instrument_name,
                                 site=config['site'])
    kwargs = {}
    weather_station.run(args.datastore, **kwargs)
Ejemplo n.º 4
0
cell_parsers.reverse()


def parser(args, **kwargs):
    return {start_re: compose(*start_parsers), cell_re: compose(*cell_parsers)}


if __name__ == '__main__':
    logging.basicConfig(
        level=getattr(logging, os.environ.get('LOGGING_LEVEL', 'WARN')))

    import lewas.cli as cli
    args = cli.parse(name='argonaut')
    config = args.config
    argonaut = Instrument(args.reader,
                          parser=args.parser,
                          name=args.instrument_name,
                          site=config['site'])

    #start_line = '10.0     5.5   0.362   3.9   3.9  10.0 179 177 169   0    0.0   0.0   0.0  0.0  0.0  0.0   4.34      0.000 0.000  11.6   0.1    0.3  29  30  30'
    #m = args.parser[start_re](start_line)
    #print(m)
    #for i in range(1,5):
    #    cell_line = '{}     4.7    -2.2   4.4   4.3 179 175'.format(i)
    #    m = args.parser[cell_re](cell_line)
    #    print(m)

    #sys.exit(0)
    kwargs = {}
    argonaut.run(args.datastore, **kwargs)
Ejemplo n.º 5
0
# we appended parsing steps in the reverse order that compose will compose them
start_parsers.reverse()
cell_parsers.reverse()


def parser(args, **kwargs):
    return {start_re: compose(*start_parsers), cell_re: compose(*cell_parsers)}


if __name__ == "__main__":
    logging.basicConfig(level=getattr(logging, os.environ.get("LOGGING_LEVEL", "WARN")))

    import lewas.cli as cli

    args = cli.parse(name="argonaut")
    config = args.config
    argonaut = Instrument(args.reader, parser=args.parser, name=args.instrument_name, site=config["site"])

    # start_line = '10.0     5.5   0.362   3.9   3.9  10.0 179 177 169   0    0.0   0.0   0.0  0.0  0.0  0.0   4.34      0.000 0.000  11.6   0.1    0.3  29  30  30'
    # m = args.parser[start_re](start_line)
    # print(m)
    # for i in range(1,5):
    #    cell_line = '{}     4.7    -2.2   4.4   4.3 179 175'.format(i)
    #    m = args.parser[cell_re](cell_line)
    #    print(m)

    # sys.exit(0)
    kwargs = {}
    argonaut.run(args.datastore, **kwargs)