• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python util.setup_logging函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyrocko.util.setup_logging函数的典型用法代码示例。如果您正苦于以下问题:Python setup_logging函数的具体用法?Python setup_logging怎么用?Python setup_logging使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了setup_logging函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: make_targets

import sys
import matplotlib
matplotlib.use('Qt4Agg')
import logging
import os.path as op
import numpy as num
import progressbar

from pyrocko import model, trace, util, orthodrome, cake, gui_util
from pyrocko.gf.seismosizer import Target, SeismosizerTrace
from pyrocko.snuffling import Snuffling, Choice, Param, Switch
from similarity import SimilarityMatrix, Similarity
import matplotlib.pyplot as plt
util.setup_logging('cc.py')
logger = logging.getLogger('cc-snuffling')

def make_targets(pile, stations):
    targets = []
    for nslc_id in pile.nslc_ids.keys():
        for s in stations:
            if util.match_nslc('%s.*'%(s.nsl_string()), nslc_id):
                targets.append(Target(lat=s.lat,
                                     lon=s.lon,
                                     depth=s.depth,
                                     elevation=s.elevation,
                                     codes=nslc_id))
            else:
                continue
    return targets

开发者ID:jconvers,项目名称:contrib-snufflings,代码行数:29,代码来源:snuffling.py


示例2: testUSGS

    def testUSGS(self):

        def is_the_haiti_event(ev):
            assert near(ev.magnitude, 7.0, 0.1)
            assert near(ev.lat, 18.443, 0.01)
            assert near(ev.lon, -72.571, 0.01)
            assert near(ev.depth, 13000., 1.)

        cat = catalog.USGS()

        tmin = util.str_to_time('2010-01-12 21:50:00')
        tmax = util.str_to_time('2010-01-13 03:17:00')

        names = cat.get_event_names(time_range=(tmin, tmax), magmin=5.)
        assert len(names) == 13
        for name in names:
            ev = cat.get_event(name)
            if ev.magnitude >= 7.:
                is_the_haiti_event(ev)
                ident = ev.name

        assert ident is not None
        cat.flush()
        ev = cat.get_event(ident)
        is_the_haiti_event(ev)


if __name__ == "__main__":
    util.setup_logging('test_catalog', 'debug')
    unittest.main()
开发者ID:emolch,项目名称:pyrocko,代码行数:30,代码来源:test_catalog.py


示例3: CPT

    for level in dry.levels:
        if level.vmax > 0.0:
            if level.vmin < 0.0:
                level.vmin = 0.0

            levels.append(level)

    combi = CPT(color_below=wet.color_below, color_above=dry.color_above, color_nan=dry.color_nan, levels=levels)

    return combi


if __name__ == "__main__":
    from pyrocko import util

    util.setup_logging("pyrocko.automap", "info")

    m = Map(
        lat=rand(40, 70.0),
        lon=rand(0.0, 20.0),
        radius=math.exp(rand(math.log(10 * km), math.log(2000 * km))),
        width=rand(10, 20),
        height=rand(10, 20),
        show_grid=True,
        show_topo=True,
        illuminate=True,
    )

    m.draw_cities()
    print m
    m.save("map.pdf")
开发者ID:gladkovvalery,项目名称:pyrocko,代码行数:31,代码来源:automap.py


示例4: template

            dest='markers_filename',
            metavar='FILENAME',
            help='Read markers from FILENAME')

         parser.add_option(
            '--output',
            dest='out_filename',
            default=default_output_filename,
            metavar='FILENAME',
            help='set output filename template (default="%s")' % default_output_filename)


def __snufflings__():
    return [ExtractEvents()]


if __name__ == '__main__':
    import logging
    logger = logging.getLogger()
    util.setup_logging('extract_events.py', 'info')
    s = ExtractEvents()
    options, args, parser = s.setup_cli()
    s.markers_filename = options.markers_filename
    s.out_filename = options.out_filename
    if not options.markers_filename:
        logger.critical('no markers file given; use the --markers=FILENAME option')
        sys.exit(1)

    s.call()

开发者ID:HerrMuellerluedenscheid,项目名称:contrib-snufflings,代码行数:29,代码来源:extract_events.py


示例5: min

            widget = layout.get_widget()
            # widget['J'] =  ('-JT%g/%g'  % (lon, lat)) + '/%(width)gp'
            widget['J'] =  ('-JE%g/%g/%g'  % (lon, lat, min(lat_delta/2.,180.))) + '/%(width)gp'
            aspect = gmtpy.aspect_for_projection( *(widget.J() + scaler.R()) )
            widget.set_aspect(aspect)
            
            if lat > 0:
                axes_layout = 'WSen'
            else:
                axes_layout = 'WseN'
        
            gmt.psbasemap( #B=('%(xinc)gg%(xinc)g:%(xlabel)s:/%(yinc)gg%(yinc)g:%(ylabel)s:' % scaler.get_params())+axes_layout,
                           B='5g5',
                        L=('x%gp/%gp/%g/%g/%gk' % (widget.width()/2., widget.height()/7.,lon,lat,scale_km) ),
                        *(widget.JXY()+scaler.R()) )
            
            gmt.psxy( in_columns=(lon_grid,lat_grid), S='x10p', W='1p/200/0/0', *(widget.JXY()+scaler.R()) )
            gmt.psxy( in_columns=(lon_grid_alt,lat_grid_alt), S='c10p', W='1p/0/0/200', *(widget.JXY()+scaler.R()) )
            
            gmt.save('orthodrome.pdf')
            subprocess.call( [ 'xpdf', '-remote', 'ortho', '-reload' ] )
            time.sleep(2)
        else:
            print 'ok', gsize, lat, lon
            
if __name__ == "__main__":
    util.setup_logging('test_orthodrome', 'warning')
    unittest.main()

            
开发者ID:gladkovvalery,项目名称:pyrocko,代码行数:28,代码来源:test_orthodrome.py


示例6: produce

def produce(deltat, duration):
    logging.debug('rate %g Hz, duration %g s' % (1./deltat, duration))
    tbegin = time.time()
    n = 0
    while True:
        t = time.time() - tbegin
        nt = int(t/deltat)
        while n < nt:
            d = random.randint(-127, 128)
            sys.stdout.write("%i\n" % d)
            n += 1

        sys.stdout.flush()

        tsleep = 0.01
        time.sleep(tsleep)

        if t > duration:
            break


util.setup_logging('producer', 'debug')

produce(0.0025, 20.)
logging.debug('sleep 2 s')
time.sleep(2.)
produce(0.0025, 20.)
produce(0.005, 20.)
produce(0.005005, 20.)
开发者ID:HerrMuellerluedenscheid,项目名称:pyrocko,代码行数:29,代码来源:datasource_deprecated.py


示例7: range

        for x in range(nx):
            strike = fuzz_angle(0., 360.)
            dip = fuzz_angle(0., 90.)
            rake = fuzz_angle(-180., 180.)

            mt = mtm.MomentTensor(
                strike=strike,
                dip=dip,
                rake=rake)

            self.compare_beachball(mt)

    def test_specific_dcs(self):
        for strike, dip, rake in [
                [270., 0.0, 0.01],
                [360., 28.373841741182012, 90.],
                [0., 0., 0.]]:

            mt = mtm.MomentTensor(
                strike=strike,
                dip=dip,
                rake=rake)

            self.compare_beachball(mt)


if __name__ == "__main__":
    util.setup_logging('test_moment_tensor', 'warning')
    unittest.main()
开发者ID:iceseismic,项目名称:pyrocko,代码行数:29,代码来源:test_beachball.py


示例8: enumerate

        emarker.set_alerted(True)

        markers = [_marker, emarker, pmarker]
        fn = tempfile.mkstemp()[1]

        marker.save_markers(markers, fn)

        in_markers = marker.load_markers(fn)
        in__marker, in_emarker, in_pmarker = in_markers
        for i, m in enumerate(in_markers):
            if not isinstance(m, marker.EventMarker):
                assert (m.tmax - m.tmin) == 9.
            else:
                assert not m.is_alerted()

        marker.associate_phases_to_events([in_pmarker, in_emarker])

        in_event = in_pmarker.get_event()

        assert all((in_event.lat == 111., in_event.lon == 111.,
                    in_event.depth == 111., in_event.time == 111.))

        assert in_pmarker.get_event_hash() == in_event.get_hash()
        assert in_pmarker.get_event_time() == 111.


if __name__ == "__main__":
    util.setup_logging('test_marker', 'warning')
    unittest.main()
开发者ID:HerrMuellerluedenscheid,项目名称:pyrocko,代码行数:29,代码来源:test_marker.py


示例9: len

        if tn not in self.available_tilenames():
            return None
        else:
            fpath = self.tilepath(tn)
            if not op.exists(fpath):
                self.download_tile(tn)

            zipf = zipfile.ZipFile(fpath, 'r')
            rawdata = zipf.read(tn + '.hgt')
            zipf.close()
            data = num.fromstring(rawdata, dtype=self.dtype)
            assert data.size == self.ntx * self.nty
            data = data.reshape(self.nty, self.ntx)[::-1, ::]
            return tile.Tile(
                self.xmin + itx*self.stx,
                self.ymin + ity*self.sty,
                self.dx, self.dx, data)


if __name__ == '__main__':
    import sys

    util.setup_logging('pyrocko.topo.srtmgl3', 'info')

    if len(sys.argv) != 2:
        sys.exit('usage: python -m pyrocko.topo.srtmgl3 download')

    if sys.argv[1] == 'download':
        srtmgl3 = SRTMGL3()
        srtmgl3.download()
开发者ID:emolch,项目名称:pyrocko,代码行数:30,代码来源:srtmgl3.py


示例10: save_as

    def save_as(self):
        if self.fig:
            fn = self.output_filename()
            self.fig.savefig(fn,
                             pad_inches=0.05, 
                             bbox_inches='tight')

    def configure_cli_parser(self, parser):
        parser.add_option(
            '--events',
            dest='events_filename',
            default=None,
            metavar='FILENAME',
            help='Read events from FILENAME')
    
def __snufflings__():
    '''Returns a list of snufflings to be exported by this module.'''
    
    return [ TimeLine() ]

if __name__=='__main__':
    import matplotlib.pyplot as plt
    util.setup_logging('time_line.py', 'info')
    s = TimeLine()
    options, args, parser = s.setup_cli()

    s.cli_mode = True
    if options.events_filename:
        s.make_time_line(list(model.Event.load_catalog(options.events_filename)))

开发者ID:jconvers,项目名称:contrib-snufflings,代码行数:29,代码来源:time_line.py


示例11: test_new_zealand

                replace_topo_color_only=tile,
                illuminate=True)

            m.draw_cities()
            fname = 'automap_test_fidshi.png'
            fpath = self.fpath(fname)
            m.save(fpath)
            self.compare_with_ref(fname, 0.01, show=False)

    def test_new_zealand(self):
        m = automap.Map(
            lat=-42.57,
            lon=173.01,
            radius=1000.*km,
            width=20.,
            height=20.,
            color_dry=gmtpy.color_tup('aluminium1'),
            show_topo=False,
            show_rivers=False,
            show_plates=True)

        m.draw_cities()
        fname = 'new_zealand.pdf'
        fpath = self.fpath(fname)
        m.save(fpath)


if __name__ == "__main__":
    util.setup_logging('test_automap', 'warning')
    unittest.main()
开发者ID:HerrMuellerluedenscheid,项目名称:pyrocko,代码行数:30,代码来源:test_automap.py


示例12: range

        for n in range(nsrc):
            src = gf.RectangularSource(
                lat=0., lon=0.,
                anchor='bottom',
                north_shift=5000., east_shift=9000., depth=4.*km,
                width=2.*km, length=8.*km,
                dip=0., rake=0., strike=(180./nsrc + 1) * n,
                slip=1.)
            rect_sources.append(src)

    @staticmethod
    def plot_rectangular_source(src, store):
        from matplotlib import pyplot as plt
        from matplotlib.patches import Polygon
        ax = plt.gca()
        ne = src.outline(cs='xy')
        p = Polygon(num.fliplr(ne), fill=False, color='r', alpha=.7)
        ax.add_artist(p)

        mt = src.discretize_basesource(store)
        ax.scatter(mt.east_shifts, mt.north_shifts, alpha=1)
        ax.scatter(src.east_shift, src.north_shift, color='r')

        plt.axis('equal')
        plt.show()


if __name__ == '__main__':
    util.setup_logging('test_gf_source_types', 'warning')
    unittest.main(defaultTest='GFSourceTypesTestCase')
开发者ID:HerrMuellerluedenscheid,项目名称:pyrocko,代码行数:30,代码来源:test_gf_source_types.py


示例13: range

import random
import logging
from matplotlib import pyplot as plt
from pyrocko import moment_tensor as pmt
from pyrocko import util
from pyrocko.plot import beachball

''' Beachball Copacabana '''

logger = logging.getLogger('pyrocko.examples.beachball_example01')

util.setup_logging()

fig = plt.figure(figsize=(10., 4.))
fig.subplots_adjust(left=0., right=1., bottom=0., top=1.)
axes = fig.add_subplot(1, 1, 1)

for i in range(200):

    # create random moment tensor
    mt = pmt.MomentTensor.random_mt()

    try:
        # create beachball from moment tensor
        beachball.plot_beachball_mpl(
            mt, axes,
            # type of beachball: deviatoric, full or double couple (dc)
            beachball_type='full',
            size=random.random()*120.,
            position=(random.random()*10., random.random()*10.),
            alpha=random.random(),
开发者ID:HerrMuellerluedenscheid,项目名称:pyrocko,代码行数:31,代码来源:beachball_example01.py


示例14: len

        s = collection.get_scenario('gnss')
        assert len(s.get_gnss_campaigns()) == 1

    @unittest.skipUnless(
        gmtpy.have_gmt(), 'GMT not available')
    @unittest.skipUnless(
        have_srtm_credentials(),
        'No Earthdata credentials in config.')
    def test_scenario_map(self):
        tempdir = mkdtemp(prefix='pyrocko-scenario')
        self.tempdirs.append(tempdir)

        generator = self.generator
        engine = gf.get_engine()

        collection = scenario.ScenarioCollection(tempdir, engine)
        collection.add_scenario('plot', generator)

        s = collection.get_scenario('plot')
        s.get_map()

    def assert_traces_almost_equal(self, trs1, trs2):
        assert len(trs1) == len(trs2)
        for (tr1, tr2) in zip(trs1, trs2):
            tr1.assert_almost_equal(tr2)


if __name__ == '__main__':
    util.setup_logging('test_scenario', 'warning')
    unittest.main()
开发者ID:emolch,项目名称:pyrocko,代码行数:30,代码来源:test_scenario.py


示例15: open

                    except IOError as e:
                        if e.errno == errno.ENOLCK:
                            time.sleep(0.01)
                            pass
                        else:
                            raise

                f.seek(0)
                assert '' == f.read()
                f.write('%s' % x)
                f.flush()
                # time.sleep(0.01)
                f.seek(0)
                f.truncate(0)
                fcntl.lockf(f, fcntl.LOCK_UN)

        fos, fn = tempfile.mkstemp()  # (dir='/try/with/nfs/mounted/dir')
        f = open(fn, 'w')
        f.close()

        for x in parimap(work, range(100), nprocs=10, eprintignore=()):
            pass

        os.close(fos)
        os.remove(fn)


if __name__ == '__main__':
    util.setup_logging('test_parimap', 'warning')
    unittest.main()
开发者ID:HerrMuellerluedenscheid,项目名称:pyrocko,代码行数:30,代码来源:test_parimap.py


示例16: GeonamesTestCase

import unittest
from pyrocko import geonames, util


class GeonamesTestCase(unittest.TestCase):

    def test_geonames(self):

        cities = geonames.get_cities(53.6, 10.0, 100e3, 200000)
        assert sorted(c.asciiname for c in cities) == \
            ['Bremen', 'Hamburg', 'Kiel', 'Luebeck']


if __name__ == "__main__":
    util.setup_logging('test_geonames', 'warning')
    unittest.main()
开发者ID:gomes310,项目名称:pyrocko,代码行数:16,代码来源:test_geonames.py


示例17: process_common_options

def process_common_options(options):
    util.setup_logging(program_name, options.loglevel)
开发者ID:emolch,项目名称:pyrocko,代码行数:2,代码来源:fomosto.py


示例18: data

        except ExternalProgramMissing as e:
            raise unittest.SkipTest(str(e))

        except ImportError as e:
            raise unittest.SkipTest(str(e))

        except topo.AuthenticationRequired as e:
            raise unittest.SkipTest('cannot download topo data (no auth credentials)')

        except Exception as e:
            raise e

    f.__name__ = 'test_example_' + test_name

    return f


for fn in sorted(example_files):
    test_name = op.splitext(op.split(fn)[-1])[0]
    setattr(
        ExamplesTestCase,
        'test_example_' + test_name,
        _make_function(test_name, fn))


if __name__ == '__main__':
    util.setup_logging('test_examples', 'warning')
    common.matplotlib_use_agg()
    unittest.main()
开发者ID:emolch,项目名称:pyrocko,代码行数:29,代码来源:test_examples.py


示例19: zip

  2.12669298e-02  5.21898977e-02 -6.61517353e-03 -8.83535221e-02 -3.66062373e-02
  1.86273292e-01  4.03764486e-01
'''  # noqa

        s2 = ims.write_string(ims.iload_string(s))
        for a, b in zip(s.strip().splitlines(), s2.strip().splitlines()):
            if a != b:
                print a
                print b
                print

        assert s.strip() == s2.strip()

    def test_ref_example11(self):

        s = '''
DATA_TYPE OUTAGE GSE2.1
Report period from 1994/12/24 00:00:00.000 to 1994/12/25 12:00:00.000
NET       Sta  Chan Aux      Start Date Time          End Date Time        Duration Comment
IDC_SEIS  APL   shz      1994/12/24 08:13:05.000 1994/12/24 08:14:10.000     65.000
IDC_SEIS  APL   shn      1994/12/25 10:00:00.000 1994/12/25 10:00:00.030      0.030
'''  # noqa

        s2 = ims.write_string(ims.iload_string(s))
        assert s.strip() == s2.strip()


if __name__ == "__main__":
    util.setup_logging('test_ims', 'warning')
    unittest.main()
开发者ID:gladkovvalery,项目名称:pyrocko,代码行数:30,代码来源:test_ims.py


示例20: snuffler_from_commandline


#.........这里部分代码省略.........
        help='use the cache even when trace attribute spoofing is active '
             '(may have silly consequences)')

    parser.add_option(
        '--store-path',
        dest='store_path',
        metavar='PATH_TEMPLATE',
        help='store data received through streams to PATH_TEMPLATE')

    parser.add_option(
        '--store-interval',
        type='float',
        dest='store_interval',
        default=600,
        metavar='N',
        help='dump stream data to file every N seconds [default: %default]')

    parser.add_option(
        '--ntracks',
        type='int',
        dest='ntracks',
        default=24,
        metavar='N',
        help='initially use N waveform tracks in viewer [default: %default]')

    parser.add_option(
        '--opengl',
        dest='opengl',
        action='store_true',
        default=False,
        help='use OpenGL for drawing')

    parser.add_option(
        '--qt5',
        dest='gui_toolkit_qt5',
        action='store_true',
        default=False,
        help='use Qt5 for the GUI')

    parser.add_option(
        '--qt4',
        dest='gui_toolkit_qt4',
        action='store_true',
        default=False,
        help='use Qt4 for the GUI')

    parser.add_option(
        '--debug',
        dest='debug',
        action='store_true',
        default=False,
        help='print debugging information to stderr')

    options, args = parser.parse_args(list(args))

    if options.debug:
        util.setup_logging('snuffler', 'debug')
    else:
        util.setup_logging('snuffler', 'warning')

    if options.gui_toolkit_qt4:
        config.override_gui_toolkit = 'qt4'

    if options.gui_toolkit_qt5:
        config.override_gui_toolkit = 'qt5'

    this_pile = pile.Pile()
    stations = []
    for stations_fn in extend_paths(options.station_fns):
        stations.extend(model.station.load_stations(stations_fn))

    for stationxml_fn in extend_paths(options.stationxml_fns):
        stations.extend(
            stationxml.load_xml(
                filename=stationxml_fn).get_pyrocko_stations())

    events = []
    for event_fn in extend_paths(options.event_fns):
        events.extend(model.load_events(event_fn))

    markers = []
    for marker_fn in extend_paths(options.marker_fns):
        markers.extend(marker.load_markers(marker_fn))

    return snuffle(
        this_pile,
        stations=stations,
        events=events,
        markers=markers,
        ntracks=options.ntracks,
        follow=options.follow,
        controls=True,
        opengl=options.opengl,
        paths=args,
        cache_dir=options.cache_dir,
        regex=options.regex,
        format=options.format,
        force_cache=options.force_cache,
        store_path=options.store_path,
        store_interval=options.store_interval)
开发者ID:emolch,项目名称:pyrocko,代码行数:101,代码来源:snuffler.py



注:本文中的pyrocko.util.setup_logging函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.str_to_time函数代码示例发布时间:2022-05-27
下一篇:
Python io.save函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap