How to use the generic.models.PropIntel function in generic

To help you get started, we’ve selected a few generic examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PyXRD / PyXRD / phases / models / atom_relations.py View on Github external
prop, name = self.allowed_relations[tp]
                store.append([relation, prop, name])          
        return store
    
    def apply_relation(self):
        raise NotImplementedError, "Subclasses should implement the update_value method!"
    
    pass #end of class
    
@storables.register()
class AtomRatio(AtomRelation):
    
    #MODEL INTEL:
    __parent_alias__ = "component"
    __model_intel__ = [
        PropIntel(name="sum",       label="Sum",                     data_type=float,  widget_type='float_entry', is_column=True,  storable=True,  has_widget=True, minimum=0.0),
        PropIntel(name="atom1",     label="Substituting Atom",       data_type=object, is_column=True,  storable=True,  has_widget=True),
        PropIntel(name="atom2",     label="Original Atom",           data_type=object, is_column=True,  storable=True,  has_widget=True),
    ]
    __store_id__ = "AtomRatio"
    
    #SIGNALS:
    
    #PROPERTIES:       
    _sum = 1.0
    def get_sum_value(self): return self._sum
    def set_sum_value(self, value):
        self._sum = float(value)
        self.changed.emit()
    
    def __internal_sum__(self, value):
        self._sum = float(value)
github PyXRD / PyXRD / probabilities / R3models.py View on Github external
P1100 = P1101 = P1010 = P1011 = P1110 = P1111 = P0110 = P0111 = 0
	
	indexes are NOT zero-based in external property names!
	"""

    #MODEL INTEL:
    __independent_label_map__ = [
        ("W1", r"$W_1$", [2.0/3.0, 1.0]),
        ("P1111_or_P2112", 
         r"$P_{1111} %s$ or $\newline P_{2112} %s$" % (
            mt_range(2.0/3.0, "W_1", 3.0/4.0),
            mt_range(3.0/4.0, "W_1", 1.0)
         ), [0.0, 1.0]),
    ]
    __model_intel__ = [
        PropIntel(
            name=prop, label=label, 
            minimum=rng[0], maximum=rng[1], 
            data_type=float, 
            refinable=True, storable=True, has_widget=True
        ) for prop, label, rng in __independent_label_map__
    ]
    __store_id__ = "R3G2Model"

    #PROPERTIES:
    
    _W0 = 0.0
    def get_W1_value(self): return self._W0
    def set_W1_value(self, value):
        self._W0 = min(max(value, 2.0/3.0), 1.0)
        self.update()
github PyXRD / PyXRD / phases / models / CSDS.py View on Github external
pass #end of class

@storables.register()
class LogNormalCSDSDistribution(RefinementGroup, _LogNormalMixin, _AbstractCSDSDistribution):

    #MODEL INTEL:
    __description__ = "Generic log-normal CSDS distr. (Eberl et al. 1990)"
    __model_intel__ = [
        PropIntel(name="maximum",       label="Maximum CSDS",      minimum=1,     maximum=1000,   is_column=True,  data_type=float),
        PropIntel(name="minimum",       label="Minimum CSDS",      minimum=1,     maximum=1000,   is_column=True,  data_type=float),
        PropIntel(name="average",       label="Average CSDS",      minimum=1,     maximum=200,    is_column=True,  data_type=float,   refinable=True,  storable=True,     has_widget=True),
        
        PropIntel(name="alpha_scale",   label="α scale factor",    minimum=0,   maximum=10, is_column=True,  data_type=float,   refinable=True,  storable=True,     has_widget=True),
        PropIntel(name="alpha_offset",  label="α offset factor",   minimum=-5,   maximum=5, is_column=True,  data_type=float,   refinable=True,  storable=True,     has_widget=True),
        PropIntel(name="beta_scale",    label="β² scale factor",   minimum=0,   maximum=10, is_column=True,  data_type=float,   refinable=True,  storable=True,     has_widget=True),
        PropIntel(name="beta_offset",   label="β² offset factor",  minimum=-5,   maximum=5, is_column=True,  data_type=float,   refinable=True,  storable=True,     has_widget=True),
    ]
    __store_id__ = "LogNormalCSDSDistribution"
        
    #REFINEMENT GROUP IMPLEMENTATION:
    @property
    def refine_title(self):
        return "CSDS Distribution"
    
    pass #end of class
    
@storables.register()    
class DritsCSDSDistribution(RefinementValue, _LogNormalMixin, _AbstractCSDSDistribution):

    #MODEL INTEL:
    __description__ = "Log-normal CSDS distr. (Drits et. al, 1997)"
    __model_intel__ = [
github PyXRD / PyXRD / goniometer / models.py View on Github external
from generic.calculations.data_objects import GonioData

@storables.register()
class Goniometer(ChildModel, Storable):
    # MODEL INTEL:
    __parent_alias__ = 'project'
    __model_intel__ = [ # TODO add labels
        PropIntel(name="radius", data_type=float, storable=True, has_widget=True, widget_type="float_entry"),
        PropIntel(name="divergence", data_type=float, storable=True, has_widget=True, widget_type="float_entry"),
        PropIntel(name="soller1", data_type=float, storable=True, has_widget=True, widget_type="float_entry"),
        PropIntel(name="soller2", data_type=float, storable=True, has_widget=True, widget_type="float_entry"),
        PropIntel(name="min_2theta", data_type=float, storable=True, has_widget=True, widget_type="float_entry"),
        PropIntel(name="max_2theta", data_type=float, storable=True, has_widget=True, widget_type="float_entry"),
        PropIntel(name="steps", data_type=int, storable=True, has_widget=True),
        PropIntel(name="wavelength", data_type=float, storable=True, has_widget=True, widget_type="float_entry"),
        PropIntel(name="has_ads", data_type=bool, storable=True, has_widget=True),
        PropIntel(name="ads_fact", data_type=float, storable=True, has_widget=True, widget_type="float_entry"),
        PropIntel(name="ads_phase_fact", data_type=float, storable=True, has_widget=True, widget_type="float_entry"),
        PropIntel(name="ads_phase_shift", data_type=float, storable=True, has_widget=True, widget_type="float_entry"),
        PropIntel(name="ads_const", data_type=float, storable=True, has_widget=True, widget_type="float_entry"),
    ]
    __store_id__ = "Goniometer"

    _data_object = None
    @property
    def data_object(self):
        return self._data_object

    # PROPERTIES:

    @Model.getter(
        'min_2theta', 'max_2theta', 'steps', 'wavelength', 'soller1',
github PyXRD / PyXRD / phases / models.py View on Github external
from probabilities.models import get_correct_probability_model
from phases.CSDS_models import DritsCSDSDistribution
from phases.atom_relations import AtomRelation, AtomRatio, AtomContents, ComponentPropMixin

@storables.register()
class UnitCellProperty(ChildModel, Storable, ComponentPropMixin, RefinementValue):
    
    #MODEL INTEL:
    __parent_alias__ = "component"
    __model_intel__ = [
        PropIntel(name="name",       label="Name",      data_type=unicode, is_column=True),
        PropIntel(name="value",      label="Value",     data_type=float,   widget_type='float_input', storable=True, has_widget=True, refinable=True),
        PropIntel(name="factor",     label="Factor",    data_type=float,   widget_type='float_input', storable=True, has_widget=True),
        PropIntel(name="constant",   label="Constant",  data_type=float,   widget_type='float_input', storable=True, has_widget=True),
        PropIntel(name="prop",       label="Property",  data_type=object,  widget_type='combo', storable=True, has_widget=True),
        PropIntel(name="enabled",    label="Enabled",   data_type=bool,    storable=True, has_widget=True),
        PropIntel(name="inherited",  label="Inherited", data_type=bool)
    ]
    __store_id__ = "UnitCellProperty"
    #SIGNALS:
    
    #PROPERTIES:
    name = ""
    enabled = False
    inherited = False
    ready = False
    
    _value = 1.0
    value_range = [0,2.0]
    def get_value_value(self): return self._value
    def set_value_value(self, value):
        self._value = float(value)
github PyXRD / PyXRD / phases / models.py View on Github external
def get_weight(self):
        weight = 0
        for atom in (self.layer_atoms._model_data + self.interlayer_atoms._model_data):
            weight += atom.weight
        return weight

@storables.register()
class Phase(ChildModel, Storable, ObjectListStoreParentMixin,
        ObjectListStoreChildMixin, RefinementGroup):

    #MODEL INTEL:
    __parent_alias__ = 'project'
    __model_intel__ = [
        PropIntel(name="name",                      data_type=unicode, label="Name",                is_column=True, has_widget=True, storable=True),
        PropIntel(name="display_color",             data_type=str,     label="Display color",       is_column=True, has_widget=True, widget_type='color', storable=True, inh_name="inherit_display_color"),
        PropIntel(name="based_on",                  data_type=object,  label="Based on phase",      is_column=True, has_widget=True, widget_type='combo'),
        PropIntel(name="G",                         data_type=int,     label="# of components",     is_column=True, has_widget=True, storable=True),
        PropIntel(name="R",                         data_type=int,     label="Reichweite",          is_column=True, has_widget=True),
        PropIntel(name="CSDS_distribution",         data_type=object,  label="CSDS Distribution",   is_column=True, has_widget=True, storable=True, refinable=True, inh_name="inherit_CSDS_distribution"),
        PropIntel(name="sigma_star",                data_type=float,   label="$\sigma^*$ [°]",      is_column=True, has_widget=True, storable=True, refinable=True, minimum=0.0,   maximum=90.0, inh_name="inherit_sigma_star"),
        PropIntel(name="inherit_display_color",     data_type=bool,    label="Inh. display color",  is_column=True, has_widget=True, storable=True),
        PropIntel(name="inherit_CSDS_distribution", data_type=bool,    label="Inh. mean CSDS",      is_column=True, has_widget=True, storable=True),
        PropIntel(name="inherit_sigma_star",        data_type=bool,    label="Inh. sigma star",     is_column=True, has_widget=True, storable=True),
        PropIntel(name="inherit_probabilities",     data_type=bool,    label="Inh. probabilities",  is_column=True, has_widget=True, storable=True),
        PropIntel(name="probabilities",             data_type=object,  label="Probabilities",       is_column=True, has_widget=True, storable=True, refinable=True, inh_name="inherit_probabilities",),
        PropIntel(name="components",                data_type=object,  label="Components",          is_column=True, has_widget=True, storable=True, refinable=True),
        PropIntel(name="needs_update",              data_type=object),
        PropIntel(name="dirty",                     data_type=bool),
    ]
    __store_id__ = "Phase"
    
    #SIGNALS:
github PyXRD / PyXRD / phases / models / unit_cell_prop.py View on Github external
from gtk import ListStore

from generic.io import storables, Storable
from generic.models import ChildModel, PropIntel
from generic.models.metaclasses import pyxrd_object_pool
from generic.refinement.mixins import RefinementValue

from .atom_relations import ComponentPropMixin

@storables.register()
class UnitCellProperty(ChildModel, Storable, ComponentPropMixin, RefinementValue):
    
    #MODEL INTEL:
    __parent_alias__ = "component"
    __model_intel__ = [
        PropIntel(name="name",       label="Name",      data_type=unicode, is_column=True),
        PropIntel(name="value",      label="Value",     data_type=float,   widget_type='float_entry', storable=True, has_widget=True, refinable=True),
        PropIntel(name="factor",     label="Factor",    data_type=float,   widget_type='float_entry', storable=True, has_widget=True),
        PropIntel(name="constant",   label="Constant",  data_type=float,   widget_type='float_entry', storable=True, has_widget=True),
        PropIntel(name="prop",       label="Property",  data_type=object,  widget_type='combo', storable=True, has_widget=True),
        PropIntel(name="enabled",    label="Enabled",   data_type=bool,    storable=True, has_widget=True),
        PropIntel(name="inherited",  label="Inherited", data_type=bool)
    ]
    __store_id__ = "UnitCellProperty"
    
    #PROPERTIES:
    name = ""
    enabled = False
    inherited = False
    ready = False
    
    _value = 1.0
github PyXRD / PyXRD / phases / models.py View on Github external
from atoms.models import Atom
from probabilities.models import get_correct_probability_model
from phases.CSDS_models import DritsCSDSDistribution
from phases.atom_relations import AtomRelation, AtomRatio, AtomContents, ComponentPropMixin

@storables.register()
class UnitCellProperty(ChildModel, Storable, ComponentPropMixin, RefinementValue):
    
    #MODEL INTEL:
    __parent_alias__ = "component"
    __model_intel__ = [
        PropIntel(name="name",       label="Name",      data_type=unicode, is_column=True),
        PropIntel(name="value",      label="Value",     data_type=float,   widget_type='float_input', storable=True, has_widget=True, refinable=True),
        PropIntel(name="factor",     label="Factor",    data_type=float,   widget_type='float_input', storable=True, has_widget=True),
        PropIntel(name="constant",   label="Constant",  data_type=float,   widget_type='float_input', storable=True, has_widget=True),
        PropIntel(name="prop",       label="Property",  data_type=object,  widget_type='combo', storable=True, has_widget=True),
        PropIntel(name="enabled",    label="Enabled",   data_type=bool,    storable=True, has_widget=True),
        PropIntel(name="inherited",  label="Inherited", data_type=bool)
    ]
    __store_id__ = "UnitCellProperty"
    #SIGNALS:
    
    #PROPERTIES:
    name = ""
    enabled = False
    inherited = False
    ready = False
    
    _value = 1.0
    value_range = [0,2.0]
    def get_value_value(self): return self._value
    def set_value_value(self, value):
github PyXRD / PyXRD / specimen / models / statistics.py View on Github external
from traceback import format_exc


from generic.models import PyXRDLine, ChildModel, PropIntel
from generic.calculations.statistics import Rp, derive

class Statistics(ChildModel):

    # MODEL INTEL:
    __parent_alias__ = 'specimen'
    __model_intel__ = [ # TODO add labels
        PropIntel(name="points", data_type=int, has_widget=True),
        PropIntel(name="residual_pattern", data_type=object),
        PropIntel(name="der_exp_pattern", data_type=object),
        PropIntel(name="der_calc_pattern", data_type=object),
        PropIntel(name="der_residual_pattern", data_type=object),
        PropIntel(name="Rp", data_type=float, has_widget=True),
        PropIntel(name="Rpder", data_type=float, has_widget=True),
    ]

    # PROPERTIES:
    def set_parent_value(self, value):
        ChildModel.set_parent_value(self, value)
        self.update_statistics()

    def get_points_value(self):
        try:
            e_ex, e_ey, e_cx, e_cy = self.specimen.get_exclusion_xy()
            return e_ex.size
        except: pass
        return 0
github PyXRD / PyXRD / phases / models.py View on Github external
self.value = float(self.factor * self.get_value_of_prop() + self.constant)
            self.component.dirty = True
        
    pass #end of class

@storables.register()
class Component(ChildModel, Storable, ObjectListStoreChildMixin,
        ObjectListStoreParentMixin, RefinementGroup):

    #MODEL INTEL:
    __parent_alias__ = "phase"
    __model_intel__ = [
        PropIntel(name="name",                      data_type=unicode,label="Name",                   is_column=True, has_widget=True, storable=True),
        PropIntel(name="linked_with",               data_type=object, label="Linked with",            widget_type='combo', is_column=True, has_widget=True),
        PropIntel(name="d001",                      data_type=float,  label="Cell length c [nm]",     is_column=True, has_widget=True, storable=True, refinable=True, minimum=0.0, maximum=5.0,  inh_name="inherit_d001"),
        PropIntel(name="default_c",                 data_type=float,  label="Default c length [nm]",  is_column=True, has_widget=True, storable=True, minimum=0.0, maximum=5.0,  inh_name="inherit_default_c"),
        PropIntel(name="delta_c",                   data_type=float,  label="C length dev. [nm]",     is_column=True, has_widget=True, storable=True, refinable=True, minimum=0.0, maximum=0.05, inh_name="inherit_delta_c"),
        PropIntel(name="ucp_a",                     data_type=object, label="Cell length a [nm]",     is_column=True, has_widget=True, storable=True, refinable=True, inh_name="inherit_ucp_a"),
        PropIntel(name="ucp_b",                     data_type=object, label="Cell length b [nm]",     is_column=True, has_widget=True, storable=True, refinable=True, inh_name="inherit_ucp_b"),
        PropIntel(name="inherit_d001",              data_type=bool,   label="Inh. cell length c",     is_column=True, has_widget=True, storable=True),
        PropIntel(name="inherit_ucp_b",             data_type=bool,   label="Inh. cell length b",     is_column=True, has_widget=True, storable=True),
        PropIntel(name="inherit_ucp_a",             data_type=bool,   label="Inh. cell length a",     is_column=True, has_widget=True, storable=True),
        PropIntel(name="inherit_default_c",         data_type=bool,   label="Inh. default length c",  is_column=True, has_widget=True, storable=True),
        PropIntel(name="inherit_delta_c",           data_type=bool,   label="Inh. c length dev.",     is_column=True, has_widget=True, storable=True),
        PropIntel(name="inherit_layer_atoms",       data_type=bool,   label="Inh. layer atoms",       is_column=True, has_widget=True, storable=True),
        PropIntel(name="inherit_interlayer_atoms",  data_type=bool,   label="Inh. interlayer atoms",  is_column=True, has_widget=True, storable=True),
        PropIntel(name="inherit_atom_relations",    data_type=bool,   label="Inh. atom relations",    is_column=True, has_widget=True, storable=True),
        PropIntel(name="atom_relations",            data_type=object, label="Atom relations",         is_column=True, has_widget=True, storable=True, refinable=True, inh_name="inherit_atom_relations"),
        PropIntel(name="layer_atoms",               data_type=object, label="Layer atoms",            is_column=True, has_widget=True, storable=True, inh_name="inherit_layer_atoms"),
        PropIntel(name="interlayer_atoms",          data_type=object, label="Interlayer atoms",       is_column=True, has_widget=True, storable=True, inh_name="inherit_interlayer_atoms"),
        PropIntel(name="needs_update",              data_type=object),
        PropIntel(name="dirty",                     data_type=bool),