def configure(self, options):
        # call the base class method
        # this is not 'pure virtual' in the parlance of our times
        OptionSuite.configure(self, options)

        if self.options['other'] is None:
            self.options['other'] = []
 def configure(self, options):
     # call the base class method
     # this is not 'pure virtual' in the parlance of our times
     OptionSuite.configure(self, options)
     if options['geometry'] == 'flat':
         # this conforms to the behavior of the old simprod code
         options['length'] = None
         options['radius'] = None
         options['detcfg'] = None
     else:
         options['detcfg'] = options['length'] / (2. * options['radius'])
Exemple #3
0
    def __init__(self, options, groups):
        OptionSuite.__init__(self, options)

        options.append(
            Option(name='atmod',
                   long_name='--atmod',
                   help='Atmosphere model (October=13)',
                   default=13,
                   type='int'))

        options.append(
            Option(
                name='ratmo',
                long_name='--ratmo',
                help=
                'Use a "real" atmosphere. If this is set, atmod is ignored.',
                type='int'))
    def __init__(self, options, groups):
        OptionSuite.__init__(self, options)

        groups.append(
            OptionGroup(name='deprecated',
                        title="Deprecated options",
                        help="Stop using these!"))

        options.append(
            Option(long_name='--runnum',
                   help='Run number. Use runnr instead.',
                   group='deprecated'))
        options.append(
            Option(long_name='--crtype',
                   help='Primary particle code. Use primpar instead.',
                   group='deprecated'))
        options.append(
            Option(long_name='--model',
                   help='Use he_model instead.',
                   group='deprecated'))
        options.append(
            Option(long_name='--lemodel',
                   help='Use le_model instead.',
                   group='deprecated'))
        options.append(
            Option(long_name='--nevents',
                   help='Use nshow instead.',
                   group='deprecated'))
        options.append(
            Option(long_name='--flat-detector',
                   help='Use geometry instead.',
                   group='deprecated'))
        options.append(
            Option(long_name='--usepipe',
                   help='Use pipe instead.',
                   group='deprecated'))
        options.append(
            Option(long_name='--topdir',
                   help='Use outdir instead.',
                   group='deprecated'))
        options.append(
            Option(long_name='--URL',
                   help='Use url instead.',
                   group='deprecated'))
Exemple #5
0
    def __init__(self, options, groups):
        OptionSuite.__init__(self, options)

        # this correspond one-to-one with corsika keywords
        options.append(Option(long_name = '--thin-fraction',
                              default = 1e-6,
                              help = 'Relative thinning factor (E_thin/E_0)'))
        options.append(Option(long_name = '--thin-wmax',
                              default = None,
                              help = 'Maximum weight'))
        options.append(Option(long_name = '--thin-rmax',
                              default = 0.,
                              help = 'Maximum weight. Default is 0 so the core is not thinned.'))
        options.append(Option(long_name = '--thin-thinrat',
                              default = 1.,
                              help = 'Ratio between thinning factor of EM and hadron components set using THINH. Default is 1.'))
        options.append(Option(long_name = '--thin-weitrat',
                              default = None,
                              help = 'Ratio between maximum weights of EM and hadron components set using THINH. The default depends on the method.'))

        # these are options that were in ThinCorsika
        # one problem with this is that the parameters do not correspond to CORSIKA keywords,
        # another is that the defaults are absurd.
        # Normally one does not need to give both (EM, hadron) thinning factors.
        options.append(Option(long_name = '--thinem_e',
                              help = 'Relative thinning energy for EM particles (deprecated)'))
        options.append(Option(long_name = '--thinem_wmax',
                              help = 'Maximum weight for EM particles (deprecated)'))
        options.append(Option(long_name = '--thinh_e',
                              help = 'Relative thinning energy for hadronic component (default is same as for EM) (deprecated)'))
        options.append(Option(long_name = '--thinh_wmax',
                              help='Maximum weight for particles in the hadronic component (default is 1) (deprecated)'))

        # these were options in AutoThinCorsika
        options.append(Option(long_name = '--thin_method',
                              help = 'Method for calculating thinning parameters. One of: none, 2009, 2010',
                              choices = [ 'none', '2009', '2010', 'auger-optimum', 'icecube-optimum'],
                              default = 'auger-optimum'))
    def configure(self, options):
        # call the base class method
        # this is not 'pure virtual' in the parlance of our times
        OptionSuite.configure(self, options)

        deprecated = []
        if not self.options['runnum'] is None:
            deprecated.append('runnum')
            self.options['runnr'] = self.options['runnum']
        if not self.options['crtype'] is None:
            deprecated.append('crtype')
            self.options['prmpar'] = self.options['crtype']
        if not self.options['model'] is None:
            deprecated.append('model')
            self.options['he_model'] = self.options['model']
        if not self.options['lemodel'] is None:
            deprecated.append('lemodel')
            self.options['le_model'] = self.options['lemodel']
        if not self.options['nevents'] is None:
            deprecated.append('nevents')
            self.options['nshow'] = self.options['nevents']
        if not self.options['flat_detector'] is None:
            deprecated.append('flat_detector')
            self.options['geometry'] = 'flat'
        if not self.options['usepipe'] is None:
            deprecated.append('usepipe')
            self.options['pipe'] = self.options['usepipe']
        if not self.options['topdir'] is None:
            deprecated.append('topdir')
            self.options['outdir'] = self.options['topdir']
        if not self.options['URL'] is None:
            deprecated.append('URL')
            self.options['url'] = self.options['URL']
        if deprecated:
            import logging
            logging.getLogger('Corsika').warning(
                'Update your configuration. The following deprecated options are being used:\n  %s'
                % ('\n  '.join(deprecated)))
Exemple #7
0
    def configure(self, options):
        # call the base class method
        # this is not 'pure virtual' in the parlance of our times
        OptionSuite.configure(self, options)

        if not 'thin' in self.options['other']:
            return

        deprecated = [k for k in ['thinem_e', 'thinem_wmax', 'thinh_e', 'thinh_wmax'] if not self.options[k] is None]
        if deprecated:
            logging.getLogger('Corsika').warning('Update your configuration. The following deprecated thinning options are being used:\n  %s'%('\n  '.join(deprecated)))

        if not self.options['thinem_e'] is None:
            if self.options['thin_fraction'] is None:
                self.options['thin_fraction'] = self.options['thinem_e']
            else:
                logging.getLogger('Corsika').warning('Ignoring deprecated option thinem_e. Using thin-fraction instead.')

        if not self.options['thinh_e'] is None or not self.options['thinem_e'] is None:
            self.options['thin_thinrat'] = self.options['thinh_e']/self.options['thinem_e']
        if not self.options['thinh_wmax'] is None or not self.options['thinem_wmax'] is None:
            self.options['thin_weitrat'] = self.options['thinh_wmax']/self.options['thinem_wmax']

        if str(self.options['thin_method']) == 'none':
            self.options['efrcthn'] = self.options['thin_fraction']
            self.options['wmax'] = self.options['thin_wmax']
            self.options['rmax'] = self.options['thin_rmax']
            self.options['thinrat'] = self.options['thin_thinrat']
            self.options['weitrat'] = self.options['thin_weitrat']
        elif self.options['thin_method'] == '2009':
            self.options['efrcthn'] = 1.0E-6
            self.options['wmax'] = self.options['emin']*self.options['efrcthn'] # Calculate optimum weight from Alessio
            if self.options['wmax'] < 1.0: self.options['wmax'] = 1.0        # Ensure max weight is at least 1
            self.options['rmax'] = 0.0
            self.options['thinrat'] = 10.0/self.options['efrcthn']           # Just to be safe
            self.options['weitrat'] = 1.0/self.options['wmax']
        elif self.options['thin_method'] == '2010':
            # No in-ice muon thinning
            self.options['efrcthn'] = 1.0E-6
            # this is ~ E/(efrcthn * 10^8.4). Thinning is then 'absolute' with Eth=273 GeV if E>10**8.4 GeV
            if self.options['emin'] > pow(10, 8.4): self.options['efrcthn'] = 273.0/self.options['emin']
            self.options['wmax'] = self.options['emin']*self.options['efrcthn']
            if self.options['wmax'] < 1.0: self.options['wmax'] = 1.0  # Ensure max weight is at least 1
            self.options['rmax'] = 0.0
            self.options['thinrat'] = 10.0/self.options['efrcthn']     # Just to be safe, ethem/ethhad
            self.options['weitrat'] = 1.0/self.options['wmax']         # wmaxem/wmaxhad
        elif self.options['thin_method'] == 'auger-optimum':
            # M. Kobal (P. Auger Collaboration), Astropart. Phys. 15 (2001) 259
            # WMAX = EFRCTHN * Eo/GeV, WMAX >= 1
            self.options['efrcthn'] = self.options['thin_fraction']
            self.options['wmax'] = self.options['emin']*self.options['efrcthn']
            if self.options['wmax'] < 1.0: self.options['wmax'] = 1.0  # Ensure max weight is at least 1
            self.options['rmax'] = self.options['thin_rmax']
            self.options['thinrat'] = self.options['thin_thinrat']
            if self.options['thin_weitrat'] is None:
                self.options['weitrat'] = 1./100.
            else:
                self.options['weitrat'] = self.options['thin_weitrat']
        elif self.options['thin_method'] == 'icecube-optimum':
            # M. Kobal (P. Auger Collaboration), Astropart. Phys. 15 (2001) 259
            # WMAX = EFRCTHN * Eo/GeV, WMAX >= 1 and hadronic part is not thinned
            # WEITRAT = WMAX (with this, one can still get weights like 1.01 or so)
            # THINRAT > EFRCTHN * Eo / Ecut, where Ecut is low enough so muons/pions are never thinned. We take the ectual cut used.
            ecut = min(self.options['ecuts1'], self.options['ecuts2'])
            self.options['efrcthn'] = self.options['thin_fraction']
            self.options['wmax'] = self.options['emin']*self.options['efrcthn']
            if self.options['wmax'] < 1.0: self.options['wmax'] = 1.0
            self.options['rmax'] = self.options['thin_rmax']
            self.options['thinrat'] = (self.options['emin']*self.options['efrcthn'])/ecut
            self.options['weitrat'] = (self.options['wmax']) # should not be needed, actually
        else:
            logging.critical('Specified thinning method not supported')
Exemple #8
0
 def __init__(self, options, groups):
     OptionSuite.__init__(self, options)
    def __init__(self, options, groups, version=None):
        OptionSuite.__init__(self, options)

        if version is None: version = get_version()

        from .coconut_options import CoconutOptionCollection
        self.coconut_options = CoconutOptionCollection(version)

        options.append(
            Option(long_name='--version',
                   name='version',
                   help='Corsika version',
                   default='v6900'))

        options.append(
            Option(
                long_name='--platform',
                name='platform',
                help=
                'Compiler platform. This is usually just a tag for the tarball.',
                default='Linux'))

        options.append(
            Option(long_name='--fluka-tarball',
                   name='fluka_tarball',
                   help='Fluka tarball.',
                   default=None))

        options.append(
            Option(
                long_name='--old-names',
                name='old_names',
                action='store_true',
                help=
                'Use old naming convention for executables\nUses corsika73700Linux_SIBYLL_gheisha instead of corsika73700Linux_1_6_1_1',
                default=False))

        required = ('float', 'he_model', 'le_model', 'geometry')
        titles = {g: '' for g in self.coconut_options.option_groups}
        titles.update({
            'float': '32/64 bit compile option',
            'he_model': 'High-energy hadronic model',
            'le_model': 'Low-energy hadronic model',
            'geometry': 'Detector geometry',
            'other': 'Other compilation options'
        })
        defaults = {g: None for g in self.coconut_options.option_groups}
        defaults.update({'float': 'float_default'})
        for g in required:
            choices = [
                o.name for n, o in self.coconut_options.options.iteritems()
                if o.group == g
            ]
            options.append(
                Option(g,
                       long_name='--' + g.replace('_', '-'),
                       choices=choices,
                       default=defaults[g],
                       help=titles[g] + '. One of: %s' % (', '.join(choices))))
        for g in self.coconut_options.option_groups:
            if not g in required:
                groups.append(OptionGroup(name=g, title=titles[g]))
        for n, o in self.coconut_options.options.iteritems():
            if not o.group in required:
                options.append(
                    Option(long_name='--' + o.name.replace('_', '-'),
                           help=o.help,
                           name=o.group,
                           action='append_const',
                           const=o.name,
                           group=o.group))
    def __init__(self, options, groups):
        OptionSuite.__init__(self, options)

        groups.append(
            OptionGroup(name='other',
                        title='Other Options',
                        help='Less common options'))

        options.append(
            Option('runnr',
                   long_name='--runnr',
                   help='Run number',
                   default=1,
                   type='int'))

        options.append(
            Option(long_name='--evtnr',
                   name='evtnr',
                   help='Number of first event',
                   default=1,
                   type='int'))

        options.append(
            Option(long_name='--seed',
                   name='seed',
                   help='Random seed',
                   default=None,
                   type='int'))

        options.append(
            Option(long_name='--egs_seed_offset',
                   name='egs_seed_offset',
                   help='value to be added to EGS seed (for debugging)',
                   default=0,
                   type='int',
                   group='other'))

        options.append(
            Option(long_name='--nshow',
                   name='nshow',
                   help='Number of Showers',
                   default=1,
                   type='int'))

        options.append(
            Option(long_name='--no-nkg',
                   name='donkg',
                   help='Run NKG',
                   default=True,
                   action="store_false",
                   group='other'))

        options.append(
            Option(long_name='--no-egs',
                   name='doegs',
                   help='Run EGS',
                   default=True,
                   action="store_false",
                   group='other'))

        options.append(
            Option(long_name='--eslope',
                   name='eslope',
                   help='CR spectral index (only if ranpri=0)',
                   default=-2.7,
                   type='float'))

        options.append(
            Option(long_name='--prmpar',
                   name='prmpar',
                   help='CR primary type',
                   default=14,
                   type='int'))

        options.append(
            Option(long_name='--theta-min',
                   name='cthmin',
                   help='Min theta of injected cosmic rays',
                   default=0.0,
                   type='float'))

        options.append(
            Option(long_name='--theta-max',
                   name='cthmax',
                   help='Max theta of injected cosmic rays',
                   default=65.,
                   type='float'))

        options.append(
            Option(long_name='--phi-min',
                   name='cphmin',
                   help='Min phi of injected cosmic rays',
                   default=0.0,
                   type='float'))

        options.append(
            Option(long_name='--phi-max',
                   name='cphmax',
                   help='Max phi of injected cosmic rays',
                   default=360.0,
                   type='float'))

        options.append(
            Option(long_name='--emin',
                   name='emin',
                   help='CR min energy',
                   default=600.,
                   type='float'))

        options.append(
            Option(long_name='--emax',
                   name='emax',
                   help='CR max energy',
                   default=1.e11,
                   type='float'))

        options.append(
            Option(long_name='--ecuts1',
                   name='ecuts1',
                   help='hadron min energy (see corsika docs)',
                   default=0.1,
                   type='float',
                   group='other'))

        options.append(
            Option(long_name='--ecuts2',
                   name='ecuts2',
                   help='muon min energy (see corsika docs)',
                   default=0.1,
                   type='float',
                   group='other'))

        options.append(
            Option(long_name='--ecuts3',
                   name='ecuts3',
                   help='electron min energy (see corsika docs)',
                   default=0.00025,
                   type='float',
                   group='other'))

        options.append(
            Option(long_name='--ecuts4',
                   name='ecuts4',
                   help='photon min energy (see corsika docs)',
                   default=0.00025,
                   type='float',
                   group='other'))

        options.append(
            Option(long_name='--nuaddi',
                   name='nuaddi',
                   help='additional information for neutrinos',
                   default=False,
                   action="store_true",
                   group='other'))

        options.append(
            Option(long_name='--muaddi',
                   name='muaddi',
                   help='additional information for muons',
                   default=False,
                   action="store_true",
                   group='other'))

        options.append(
            Option(long_name='--emaddi',
                   name='emaddi',
                   help='additional information for EM particles',
                   default=False,
                   action="store_true",
                   group='other'))

        options.append(
            Option(long_name='--obslev',
                   name='obslev',
                   help='distance above sea level (in cm)',
                   type=float,
                   default=2837.e2))

        options.append(
            Option(long_name='--length',
                   name='length',
                   help='length of generation cylinder in m '
                   '(for detcfg = length/2*radius calculation)',
                   default=1400.,
                   type='float'))

        options.append(
            Option(long_name='--radius',
                   name='radius',
                   help='radius of generation cylinder in m '
                   '(for detcfg = length/2*radius calculation)',
                   default=700.,
                   type='float'))

        options.append(
            Option(long_name='--kcut',
                   name='kcut',
                   help='minimum neutrino energy required to keep the shower',
                   default=None,
                   type='float',
                   group='other'))

        options.append(
            Option(
                long_name='--save-long',
                name='save_long',
                help=
                'Save the longitudinal profile in output file (LONG blocks).',
                default=False,
                action="store_true",
                group='other'))

        options.append(
            Option(long_name='--long-step',
                   name='long_step',
                   help='Step size in longitudinal distributions',
                   default=20.,
                   type='float',
                   group='other'))

        options.append(
            Option(long_name='--arrang',
                   name='arrang',
                   help='Rotation of detector relative to magnetic '
                   'field direction (in degrees)',
                   default=0.,
                   type='float',
                   group='other'))

        options.append(
            Option(long_name='--debug',
                   name='debug',
                   help='Enable disable debug mode',
                   default=False,
                   action="store_true",
                   group='other'))

        options.append(
            Option(long_name='--hi-low',
                   name='hi_low',
                   help='Transition Energy between Models',
                   default=None,
                   type='float',
                   group='other'))

        options.append(
            Option(
                long_name='--mag-vertical',
                name='mag_vertical',
                help=
                'Magnetic field vertical component (micro-Tesla). The default is for South Pole.',
                default=16.4,
                type='float'))

        options.append(
            Option(
                long_name='--mag-horizontal',
                name='mag_horizontal',
                help=
                'Magnetic field horizontal component (micro-Tesla). The default is for South Pole.',
                default=-53.4,
                type='float'))

        options.append(
            Option(long_name='--fix-height',
                   name='fixhei',
                   help='Fix height of first interaction.',
                   default=None,
                   type='float',
                   group='other'))

        options.append(
            Option(long_name='--fixchi',
                   name='fixchi',
                   help='Starting altitude of primary particle.',
                   default=None,
                   type='float',
                   group='other'))