Exemplo n.º 1
0
 def init(self, parent_widget=None):
     decl = rt_params.declarations(self.FILE_PREFIX)
     self.defaults = rt_params.defaults(self.FILE_PREFIX, decl)
     self.params = rt_params.init_params(self.defaults)
     self._view = genesis_pane.View(self, parent_widget)
     self.w = {}
     return self._view
Exemplo n.º 2
0
 def init(self, parent_widget=None):
     decl = rt_params.declarations(self.FILE_PREFIX)
     self.defaults = rt_params.defaults(
         self.FILE_PREFIX + '_' + self.SRW_MODE,
         decl['simulation_complexity'][self.SRW_MODE + '_particle'])
     self.params = rt_params.init_params(self.defaults)
     self._view = srw_pane.View(self, parent_widget)
     return self._view
Exemplo n.º 3
0
def _params(base_name):
    decl = rt_params.declarations('srw')
    defaults = rt_params.defaults_from_dict(
        pkunit.data_yaml('sample'),
        'srw_multi',
        decl['simulation_complexity']['multi_particle'],
    )
    res = rt_params.init_params(defaults)
    res.wavefront = res.simulation_kind.e.wavefront
    res.simulation_kind = srw_enums.SimulationKind.E
    return res
Exemplo n.º 4
0
def test_init_params():
    """Verify a couple of values exist"""
    decl = rt_params.declarations('srw')['simulation_complexity']['multi_particle']
    p = rt_params.init_params(
        rt_params.defaults('srw_multi', decl),
    )
    assert 0.5 == p['beam']['avg_current'], \
        'Value must be converted to type correctly'
    assert 1000 == p['simulation_kind']['e']['wavefront']['num_points_energy'], \
        'Selectors must be parsed correctly'
    assert p
Exemplo n.º 5
0
def test_defaults():
    """Verify a couple of values exist"""
    decl = rt_params.declarations('srw')['simulation_complexity']['multi_particle']
    d = rt_params.defaults('srw_multi', decl)
    assert isinstance(
        d['undulator']['orientation'].value,
        srw_enums.UndulatorOrientation), \
        'Value must be parsed correctly'
    assert 101 == \
        d['simulation_kind']['x_and_y']['wavefront']['num_points_x'].value, \
        'Value must be parsed correctly'
    _assert_unicode(d)
Exemplo n.º 6
0
def test_declarations():
    """Verify a couple of values exist"""
    d = rt_params.declarations('srw')
    pkdp(d['precision']['spectral_flux'].children)
    assert d['undulator']['period_len'].units == 'm', \
        'Undulator period length units should be centimeters'
    assert d['precision']['spectral_flux']['flux_calculation'].py_type \
        == srw_enums.FluxCalculation, \
        'Flux Calculation type should be srw_enums.Flux'
    pkdp(d['precision']['spectral_flux'].values()[3])
    l = list(iter(d['precision']['spectral_flux'].values()))
    assert 'Azimuthal Integration Precision' == l[3].label, \
        'Result should be ordered'
    _assert_unicode(d)
Exemplo n.º 7
0
def test_iter_defaults():
    """Verify a couple of values exist"""
    decl = rt_params.declarations('srw')['simulation_complexity']['multi_particle']
    defaults = rt_params.defaults('srw_multi', decl)
    it = defaults['precision'].iter_leaves()
    assert 'Initial Harmonic' == it.next().decl.label, \
        'Ensure values are in order of leaves'
    assert 'Final Harmonic' == it.next().decl.label, \
        'Ensure see we can traverse to second leaf'
    it = defaults['precision'].iter_nodes()
    assert 'Precision' == it.next().decl.label, \
        'Ensure parent is first value'
    assert 'Spectral Flux Calculation' == it.next().decl.label, \
        'Ensure see first parent node'
    assert 'Initial Harmonic' == it.next().decl.label, \
        'Ensure see first leaf'
    assert 'Final Harmonic' == it.next().decl.label, \
        'Ensure see we can traverse to second leaf'