示例#1
0
def unit_dict(keys, unit_symbols):
    """
    Forms a dict mapping keys to pmd_unit objects
    """
    d = {}
    for k, s in zip(keys, unit_symbols):
        d[k] = unit(s)
    return d
    def __init__(self, input_particle_group=None, data=None):
        if (input_particle_group):
            data={}
            for key in input_particle_group._settable_keys:
                data[key] = copy.copy(input_particle_group[key])  # is deepcopy needed?
        
        super().__init__(data=data)
        
        if ('sqrt_norm_emit_4d' not in PARTICLEGROUP_UNITS.keys()):
            PARTICLEGROUP_UNITS['sqrt_norm_emit_4d'] = unit('m')

        if ('slice_emit_x' not in PARTICLEGROUP_UNITS.keys()):
            PARTICLEGROUP_UNITS['slice_emit_x'] = unit('m')

        if ('slice_emit_y' not in PARTICLEGROUP_UNITS.keys()):
            PARTICLEGROUP_UNITS['slice_emit_y'] = unit('m')

        if ('slice_emit_4d' not in PARTICLEGROUP_UNITS.keys()):
            PARTICLEGROUP_UNITS['slice_emit_4d'] = unit('m')
示例#3
0
    def __init__(self, input_particle_group=None, data=None):
        self.n_slices = 50
        self.slice_key = 't'

        if (input_particle_group):
            data = {}
            for key in input_particle_group._settable_keys:
                data[key] = copy.copy(
                    input_particle_group[key])  # is deepcopy needed?

            if ('id' not in input_particle_group._settable_keys
                    and hasattr(input_particle_group, 'id')):
                data['id'] = copy.copy(input_particle_group['id'])

        super().__init__(data=data)

        new_units = {}
        new_units['sqrt_norm_emit_4d'] = 'm'
        new_units['root_norm_emit_6d'] = 'm'
        new_units['slice_emit_x'] = 'm'
        new_units['slice_emit_y'] = 'm'
        new_units['core_emit_x'] = 'm'
        new_units['core_emit_y'] = 'm'
        new_units['core_emit_4d'] = 'm'
        new_units['slice_emit_4d'] = 'm'
        new_units['action_x'] = 'm'
        new_units['action_y'] = 'm'
        new_units['rp'] = 'rad'
        new_units['action_4d'] = 'm'
        new_units['crazy_action_x'] = 'm'
        new_units['crazy_action_y'] = 'm'
        new_units['signed_pr'] = 'eV/c'
        new_units['ptrans'] = 'eV/c'

        for k in new_units:
            if (k not in PARTICLEGROUP_UNITS.keys()):
                PARTICLEGROUP_UNITS[k] = unit(new_units[k])
示例#4
0
OutputColumnNames['Cemit'] = CemitColumnNames
OutputColumnNames['Xemit'] = XemitColumnNames
OutputColumnNames['Yemit'] = YemitColumnNames
OutputColumnNames['Zemit'] = ZemitColumnNames
OutputColumnNames['LandF'] = LandFColumnNames

OutputColumnFactors['Cemit'] = CemitColumnFactors
OutputColumnFactors['Xemit'] = XemitColumnFactors
OutputColumnFactors['Yemit'] = YemitColumnFactors
OutputColumnFactors['Zemit'] = ZemitColumnFactors
OutputColumnFactors['LandF'] = LandFColumnFactors

ERROR = {'error': True}

# Special additions
OutputUnits['cov_x__xp'] = unit('m')
OutputUnits['cov_y__yp'] = unit('m')
OutputUnits['cov_z__energy'] = unit('m*eV')


def astra_run_extension(run_number):
    """
    Astra adds an extension according to the run number: 1 -> '001'
    """
    return str(run_number).zfill(3)


def find_astra_output_files(
        input_filePath,
        run_number,
        types=['Cemit', 'Xemit', 'Yemit', 'Zemit', 'LandF']):