Coverage for /usr/local/lib/python3.11/dist-packages/pyrocko/__init__.py: 48%

40 statements  

« prev     ^ index     » next       coverage.py v6.5.0, created at 2023-11-09 13:44 +0000

1# https://pyrocko.org - GPLv3 

2# 

3# The Pyrocko Developers, 21st Century 

4# ---|P------/S----------~Lg---------- 

5 

6''' 

7A toolbox and library for seismology. 

8''' 

9 

10import sys 

11 

12try: 

13 from .info import * # noqa 

14 __version__ = version # noqa 

15except ImportError: 

16 pass # not available in dev mode 

17 

18grumpy = 0 # noqa 

19 

20 

21def get_logger(): 

22 from .util import logging 

23 return logging.getLogger('pyrocko') 

24 

25 

26class ExternalProgramMissing(Exception): 

27 pass 

28 

29 

30def app_init(log_level='info', progress_viewer='terminal', program_name=None): 

31 ''' 

32 Setup logging and progress indicators for Pyrocko scripts. 

33 

34 This is a shortcut for calling :py:func:`pyrocko.util.setup_logging` and 

35 :py:func:`pyrocko.progress.set_default_viewer`. 

36 

37 :param program_name: 

38 ``programname`` argument for :py:func:`pyrocko.util.setup_logging` 

39 :type program_name: 

40 str 

41 

42 :param log_level: 

43 ``levelname`` argument for :py:func:`pyrocko.util.setup_logging` 

44 :type log_level: 

45 str 

46 

47 :param progress_viewer: 

48 ``viewer`` argument for 

49 :py:func:`pyrocko.progress.set_default_viewer` 

50 ''' 

51 from pyrocko import util, progress 

52 if program_name is None: 

53 program_name = sys.argv[0] 

54 

55 util.setup_logging(sys.argv[0], log_level) 

56 progress.set_default_viewer(progress_viewer) 

57 

58 

59def make_squirrel(*args, **kwargs): 

60 from pyrocko.squirrel import Squirrel 

61 return Squirrel(*args, **kwargs) 

62 

63 

64def snuffle(*args, **kwargs): 

65 ''' 

66 Start Snuffler. 

67 

68 Calls :py:func:`pyrocko.gui.snuffler.snuffler.snuffle` 

69 ''' 

70 

71 from pyrocko import deps 

72 

73 deps.require('PyQt5.Qt') 

74 deps.require('PyQt5.QtWebEngine') 

75 

76 from pyrocko.gui.snuffler import snuffler 

77 return snuffler.snuffle(*args, **kwargs) 

78 

79 

80def sparrow(*args, **kwargs): 

81 ''' 

82 Start Sparrow. 

83 

84 Calls :py:func:`pyrocko.gui.sparrow.main`. 

85 ''' 

86 

87 from pyrocko import deps 

88 

89 deps.require('vtk') 

90 deps.require('PyQt5.Qt') 

91 # deps.import_optional('kite', 'InSAR visualization') 

92 

93 from pyrocko.gui.sparrow.main import main 

94 return main(*args, **kwargs) 

95 

96 

97def drum(*args, **kwargs): 

98 ''' 

99 Start Drum Plot. 

100 

101 Calls :py:func:`pyrocko.gui.drum.main`. 

102 ''' 

103 

104 from pyrocko import deps 

105 

106 deps.require('PyQt5.Qt') 

107 deps.require('serial') 

108 

109 from pyrocko.gui.drum.main import main 

110 return main(*args, **kwargs)