コード例 #1
0
    def initparser(cls, parser, env):
        def observable(path):
            #
            # Future spectra location
            #
            try:
                return env.future['spectra'][path]
            except KeyError:
                pass

            # To be deprecated spectra location
            nspath, name = path.split('/')
            try:
                return env.ns(nspath).observables[name]
            except KeyError:
                raise PartNotFoundError("observable", path)

        parser.add_argument('plot', default=[],
                            metavar=('DATA',),
                            action=append_typed(observable))
        parser.add_argument('-J', '--no-joints', action='store_false', dest='joints', help='disable joints')
        parser.add_argument('--subgraph', action='store_true', help='enable subgraphs')
        parser.add_argument('-s', '--splines', help='splines option [dot]')
        parser.add_argument('-o', '--output', nargs='+', default=[], dest='outputs', help='output dot/pdf/png file')
        parser.add_argument('-O', '--stdout', action='store_true', help='output to stdout')
        parser.add_argument('-E', '--stderr', action='store_true', help='output to stderr')
        parser.add_argument('-n', '--namespace', '--ns', default=cls.undefined, nargs='?', help='use <namespace> to read parameters', metavar='namespace')
        parser.add_argument('--option', nargs=2, action='append', dest='options', default=[], help='AGraph kwargs key value pair')

        parser.add_argument_group(title='filters', description='Options to filter nodes')
        parser.add_argument('-i', '--include-only', '--include', nargs='+', help='Pattersn to be included (exclusive)')
コード例 #2
0
ファイル: derivative.py プロジェクト: gnafit/gna
 def initparser(cls, parser, env):
     parser.add_argument('--reldelta',
                         type=float,
                         default=1.0 / (65536 * 16))
     parser.add_argument(
         '-a',
         '--add',
         nargs=3,
         default=[],
         metavar=('NAME', 'PREDICTION', 'PAR'),
         action=append_typed(str, env.parts.prediction, str),
         help='add prediction NAME for derivative of PREDICTION wrt PAR')
コード例 #3
0
ファイル: histogram.py プロジェクト: gnafit/gna
    def initparser(cls, parser, env):
        def observable(path):
            nspath, name = path.split('/')
            try:
                return env.ns(nspath).observables[name]
            except KeyError:
                raise PartNotFoundError("observable", path)

        parser.add_argument('-p',
                            '--plot',
                            default=[],
                            metavar=('DATA', ),
                            action=append_typed(observable))
コード例 #4
0
ファイル: covmat.py プロジェクト: gnafit/gna
 def initparser(cls, parser, env):
     parser.add_argument('name')
     parser.add_argument(
         '-a',
         '--add',
         nargs=2,
         default=[],
         metavar=('NAME', 'DIAGONAL'),
         action=append_typed(
             str, qualified(env.parts.prediction, env.parts.data)),
         help='add statistical covariance matrix NAME from DIAGONAL')
     parser.add_argument('-f',
                         '--fix',
                         default=[],
                         action=append_typed(env.parts.covmat, lazy=True),
                         help='fix covariance matrix NAME')
     parser.add_argument('-p',
                         '--print',
                         default=[],
                         metavar='NAME',
                         action=append_typed(env.parts.covmat, lazy=True),
                         help='print covariance matrix NAME')
コード例 #5
0
 def initparser(cls, parser, env):
     parser.add_argument(
         '-a',
         '--add',
         nargs=2,
         default=[],
         metavar=('NAME', 'PREDICTION'),
         action=append_typed(str, env.parts.prediction),
         help='set data NAME to Asimov from prediction PREDICTION')
     parser.add_argument('-p',
                         '--print',
                         action='append',
                         default=[],
                         metavar='NAME',
                         type=env.parts.data,
                         help='print data NAME')
コード例 #6
0
ファイル: plot_heatmap_v1.py プロジェクト: gnafit/gna
    def initparser(cls, parser, env):
        def observable(path):
            #
            # Future spectra location
            #
            try:
                return env.future[path]
            except KeyError:
                import IPython
                IPython.embed()
                pass

            # To be deprecated spectra location
            try:
                return env.ns('').getobservable(path)
            except KeyError:
                raise PartNotFoundError("observable", path)

        def yamlload(s):
            ret = yaml.load(s, Loader=yaml.Loader)
            return ret

        parser.add_argument('plot',
                            nargs='+',
                            metavar='DATA',
                            default=[],
                            action=append_typed(observable))
        parser.add_argument(
            '--plot-kwargs',
            type=yamlload,
            help=
            'All additional plotting options go here. They are applied for all plots'
        )
        parser.add_argument('-l',
                            '--log',
                            action='store_true',
                            help='use log scale')

        parse_filters = parser.add_mutually_exclusive_group()
        parse_filters.add_argument('--filter',
                                   '-f',
                                   choices=filters.keys(),
                                   help='filter the matrix')
コード例 #7
0
ファイル: plot_spectrum.py プロジェクト: gnafit/gna
    def initparser(cls, parser, env):
        def observable(path):
            #
            # Future spectra location
            #
            try:
                return env.future['spectra'][path]
            except KeyError:
                pass

            # To be deprecated spectra location
            try:
                return env.ns('').getobservable(path)
            except KeyError:
                raise PartNotFoundError("observable", path)

        def yamlload(s):
            ret = yaml.load(s, Loader=yaml.Loader)
            return ret

        what = parser.add_mutually_exclusive_group()
        what.add_argument(
            '-dp',
            '--difference-plot',
            '--diff',
            default=[],
            nargs=2,
            action=append_typed(observable, observable),
            help='Subtract two obs, they MUST have the same binning')
        what.add_argument('--ratio',
                          default=[],
                          nargs=2,
                          action=append_typed(observable, observable),
                          help="Plot ratio of 2 observables")
        what.add_argument('--offset-ratio',
                          '--oratio',
                          default=[],
                          nargs=2,
                          action=append_typed(observable, observable),
                          help="Plot ratio of 2 observables -1")
        what.add_argument('-p',
                          '--plot',
                          default=[],
                          metavar=('DATA', ),
                          action=append_typed(observable))

        parser.add_argument('--vs',
                            metavar='X points',
                            type=observable,
                            help='Points over X axis to plot vs')
        parser.add_argument('--plot-type',
                            choices=[
                                'histo', 'bin_center', 'bar', 'hist',
                                'errorbar', 'plot', 'ravelplot'
                            ],
                            metavar='PLOT_TYPE',
                            help='Select plot type')
        parser.add_argument('--scale',
                            action='store_true',
                            help='scale histogram by bin width')
        parser.add_argument(
            '-l',
            '--legend',
            action='append',
            default=[],
            metavar=('Legend', ),
            help=
            'Add legend to the plot, note that number of legends must match the number of plots'
        )
        parser.add_argument(
            '--plot-kwargs',
            type=yamlload,
            help=
            'All additional plotting options go here. They are applied for all plots'
        )
コード例 #8
0
ファイル: scanXd.py プロジェクト: gnafit/gna
    def initparser(cls, parser, env):
        #
        # Make variable parser
        #
        import argparse
        varparser = AppendSubparser(prefix_chars='+', prog='--var')
        varparser.add_argument('parname', help='variable name')
        varparser.add_argument('+L',
                               '++log',
                               action='store_true',
                               help='use logarithmic scale')
        # varparser.add_argument( '++split', default=1, type=int, help='split the range into <N> subranges. To be used with --split key', metavar='N' )
        # varparser.add_argument( '+v', '++value', help='saved value to use for center' )

        group = varparser.add_mutually_exclusive_group(required=True)
        group.add_argument('+l',
                           '++limits',
                           nargs=2,
                           type=float,
                           help='variable limits')
        group.add_argument('+e',
                           '++err',
                           type=float,
                           help='error to set limits (+/-e)')

        group = varparser.add_mutually_exclusive_group(required=True)
        group.add_argument('+s', '++step', type=float, help='variable step')
        group.add_argument('+n',
                           '++npoints',
                           type=int,
                           help='number of points')

        #
        # Make main parser
        #
        parser.add_argument('minimizer',
                            default=[],
                            metavar=('MINIMIZER'),
                            action=append_typed(env.parts.minimizer))
        parser.add_argument('--pars',
                            nargs='+',
                            required=True,
                            help='All parameters track')
        # parser.add_argument( '--file', default='main', help='select target file' )
        # parser.add_argument( '--hdf', help='save hdf output' )

        parser.add_argument(
            '-v',
            '--var',
            nargs='+',
            action=varparser,
            help='variables specification, use +h/++help for syntax',
            dest='variables')
        parser.add_argument('-f',
                            '--folder',
                            default='scanXd',
                            help='folder to store the data')
        parser.add_argument('-V',
                            '--verbose',
                            action='count',
                            default=0,
                            help='verbose')
        parser.add_argument('-s',
                            '--scan',
                            action='store_true',
                            help='do scan')

        group = parser.add_mutually_exclusive_group()
        group.add_argument('-m',
                           '--minimize',
                           action='store_true',
                           help='minimize on each step')
        group.add_argument('--dummy',
                           action='store_true',
                           help='run script without actual calculation')
        group.add_argument(
            '--dummyfalse',
            action='store_true',
            help='run script without actual calculation, with failure status')

        parser.add_argument('--start-from',
                            choices=['default', 'bestfit'],
                            default='default',
                            help='the very starting point')