示例#1
0
def parse_args(description=__doc__):
    """Parse command-line arguments"""
    parser = ArgumentParser(description=description)

    parser.add_argument('--outdir', required=True)

    group = parser.add_argument_group(title='Scan parameters')
    for dim in HYPO_PARAMS_T._fields:
        group.add_argument(
            '--{}'.format(dim.replace('_', '-')),
            nargs='+',
            required=True,
            help='''Hypothses will take this(these) value(s) for dimension
            {dim_hr}. Specify a single value to not scan over this dimension;
            specify a human-readable string of values, e.g. '0, 0.5, 1-10:0.2'
            scans 0, 0.5, and from 1 to 10 (inclusive of both endpoints) with
            stepsize of 0.2.'''.format(dim_hr=dim.replace('_', ' ')))

    split_kwargs = init_obj.parse_args(dom_tables=True,
                                       hypo=True,
                                       events=True,
                                       parser=parser)
    split_kwargs['scan_kw'] = split_kwargs.pop('other_kw')

    if split_kwargs['events_kw']['hits'] is None:
        raise ValueError('Must specify a path to a pulse series or photon'
                         ' series using --hits.')

    return split_kwargs
示例#2
0
文件: i3reco.py 项目: icecube/retro
def main():
    """Script to run Retro recos in icetray"""
    parser = ArgumentParser()

    parser.add_argument(
        "--input-i3-file",
        type=str,
        required=True,
        nargs="+",
        help="""Input I3 file""",
    )

    parser.add_argument(
        "--output-i3-file",
        type=str,
        required=True,
        help="""Output I3 file""",
    )

    split_kwargs = init_obj.parse_args(dom_tables=True,
                                       tdi_tables=True,
                                       parser=parser)

    other_kw = split_kwargs.pop("other_kw")

    # instantiate Retro reco object
    my_reco = Reco(**split_kwargs)

    tray = I3Tray()

    tray.AddModule(
        _type="I3Reader",
        _name="reader",
        FilenameList=other_kw["input_i3_file"],
    )

    tray.Add(
        _type=my_reco,
        _name="retro",
        methods="crs_prefit",
        reco_pulse_series_name="SRTTWOfflinePulsesDC",
        hit_charge_quant=0.05,
        min_hit_charge=0.25,
        seeding_recos=["L5_SPEFit11", "LineFit_DC"],
        triggers=["I3TriggerHierarchy"],
        additional_keys=["L5_oscNext_bool"],
        filter='event["header"]["L5_oscNext_bool"] and len(event["hits"]) >= 8',
        point_estimator="median",
    )

    tray.AddModule(
        _type="I3Writer",
        _name="writer",
        DropOrphanStreams=[icetray.I3Frame.DAQ],
        filename=other_kw["output_i3_file"],
    )

    tray.AddModule(_type="TrashCan", _name="GoHomeYouReDrunk")
    tray.Execute()
    tray.Finish()
示例#3
0
def main(description=__doc__):
    """Script main function"""
    parser = ArgumentParser(description=description)
    parser.add_argument('--outdir', required=True)

    split_kwargs = init_obj.parse_args(dom_tables=True, parser=parser)
    generate_stacked_tables(dom_tables_kw=split_kwargs['dom_tables_kw'],
                            **split_kwargs['other_kw'])
示例#4
0
def parse_args(description=__doc__):
    """Parse command-line arguments"""
    parser = ArgumentParser(description=description)

    parser.add_argument(
        '--outdir', required=True,
    )
    parser.add_argument(
        '--sim-to-test', required=True, choices=sorted(SIMULATIONS.keys())
    )

    return init_obj.parse_args(parser=parser, dom_tables=True, hypo=True)
示例#5
0
def parse_args(description=__doc__):
    """Parse command-line arguments"""
    parser = ArgumentParser(description=description)

    parser.add_argument(
        '--outdir',
        required=True,
    )
    parser.add_argument(
        '--sim-to-test',
        required=True,
    )

    dom_tables_kw, hypo_kw, _, pdf_kw = (init_obj.parse_args(parser=parser,
                                                             hits=False))

    return dom_tables_kw, hypo_kw, pdf_kw
示例#6
0
文件: reco.py 项目: mhieronymus/retro
def parse_args(description=__doc__):
    """Parse command-line arguments.

    Returns
    -------
    split_kwargs : dict of dicts
        Contains keys "dom_tables_kw", "hypo_kw", "events_kw", and "reco_kw",
        where values are kwargs dicts usable to instantiate or call each of the
        corresponding objects or functions.

    """
    parser = ArgumentParser(description=description)

    parser.add_argument('--outdir', required=True)

    group = parser.add_argument_group(title='Hypothesis parameter priors', )

    group.add_argument(
        '--spatial-prior',
        choices='dc dc_subdust ic SPEFit2'.split(),
        required=True,
        help='''Choose a prior for choosing spatial samples. "dc", "dc_subdust"
        and "ic" are uniform priors with hard cut-offs at the extents of the
        respective volumes, while "SPEFit2" samples from Cauchy distributions
        around the SPEFit2 (x, y, z) best-fit values.''')
    group.add_argument(
        '--temporal-prior',
        choices='uniform SPEFit2'.split(),
        required=True,
        help='''Choose a prior for choosing temporal samples. "uniform" chooses
        uniformly from 4000 ns prior to the first hit up to the last hit, while
        "SPEFit2" samples from a Cauchy distribution near (not *at* due to
        bias) the SPEFit2 time best-fit value.''')
    group.add_argument(
        '--energy-prior',
        choices=[PRI_UNIFORM, PRI_LOG_UNIFORM, PRI_LOG_NORMAL],
        required=True,
        help='''Prior to put on _total_ event energy. Must specify
        --energy-lims.''')
    group.add_argument(
        '--energy-lims',
        nargs='+',
        required=True,
        help='''Lower and upper energy limits, in GeV. E.g.: --energy-lims=1,100
        Required if --energy-prior is {}, {}, or {}'''.format(
            PRI_UNIFORM, PRI_LOG_UNIFORM, PRI_LOG_NORMAL))

    group = parser.add_argument_group(title='MultiNest parameters', )

    group.add_argument(
        '--importance-sampling',
        action='store_true',
        help='''Importance nested sampling (INS) mode. Could be more efficient,
        but also can be unstable. Does not work with multimodal.''')
    group.add_argument(
        '--max-modes',
        type=int,
        required=True,
        help=
        '''Set to 1 to disable multi-modal search. Must be 1 if --importance-sampling is
        specified.''')
    group.add_argument('--const-eff',
                       action='store_true',
                       help='''Constant efficiency mode.''')
    group.add_argument('--n-live', type=int, required=True)
    group.add_argument('--evidence-tol', type=float, required=True)
    group.add_argument('--sampling-eff', type=float, required=True)
    group.add_argument(
        '--max-iter',
        type=int,
        required=True,
        help='''Note that iterations of the MultiNest algorithm are _not_ the
        number of likelihood evaluations. An iteration comes when one live
        point is discarded by finding a sample with higher likelihood than at
        least one other live point. Such a point can take many likelihood
        evaluatsions to find.''')
    group.add_argument(
        '--seed',
        type=int,
        required=True,
        help='''Integer seed for MultiNest's random number generator.''')

    split_kwargs = init_obj.parse_args(dom_tables=True,
                                       hypo=True,
                                       events=True,
                                       parser=parser)

    split_kwargs['reco_kw'] = reco_kw = split_kwargs.pop('other_kw')

    if reco_kw['energy_prior'] in [
            PRI_UNIFORM, PRI_LOG_UNIFORM, PRI_LOG_NORMAL
    ]:
        assert reco_kw['energy_lims'] is not None
        elims = ''.join(reco_kw['energy_lims'])
        elims = [float(l) for l in elims.split(',')]
        reco_kw['energy_lims'] = elims
    elif reco_kw['energy_lims'] is not None:
        raise ValueError(
            '--energy-limits not used with energy prior {}'.format(
                reco_kw['energy_prior']))

    return split_kwargs