Exemplo n.º 1
0
    def __init__(self, parent):
        """
        initialization
        """
        RietveldClass.__init__(self, parent)

        return
Exemplo n.º 2
0
    def __init__(self, parent):
        """
        initialization
        """
        RietveldClass.__init__(self, parent)

        return
Exemplo n.º 3
0
    def __init__(self, parent):
        """
        initialization

        parent: None of real parent class
        """
        RietveldClass.__init__(self, parent)

        return
Exemplo n.º 4
0
    def __init__(self, parent, nbas):
        """
        initialization
        """
        RietveldClass.__init__(self, parent)

        for i in xrange(0, nbas):
            param_name = "Ireps"+str(i)
            self.ParamDict[param_name] = IntInfo(param_name, "real/pure imaginary BSF coefficient flags"+str(i), 0)
            self.__dict__[param_name] = self.ParamDict[param_name].get("Default")

        return
Exemplo n.º 5
0
    def __init__(self, Parent, order=None, value=None):
        """
        initialization
        order:  polynomial order
        value:  Bkgd
        """
        RietveldClass.__init__(self, Parent)
        if order is not None:
            self.set("order", order)
        if value is not None:
            self.set("Bkgd", value)

        return
Exemplo n.º 6
0
    def __init__(self, parent):
        """
        initialization:
        """
        RietveldClass.__init__(self, parent)

        # initialize subclass-object
        operatorset = OperatorSet(self)
        self.set("OperatorSet", operatorset)

        # initialize attributes
        self._contributionlist = []

        return
Exemplo n.º 7
0
    def __init__(self, parent):
        """
        initialization:
        """
        RietveldClass.__init__(self, parent)

        # initialize subclass-object
        operatorset = OperatorSet(self)
        self.set("OperatorSet", operatorset)

        # initialize attributes
        self._contributionlist = []

        return
Exemplo n.º 8
0
    def __init__(self, parent, nbas):
        """
        initialization
        """
        RietveldClass.__init__(self, parent)

        for i in xrange(0, nbas):
            param_name = "Ireps" + str(i)
            self.ParamDict[param_name] = IntInfo(
                param_name,
                "real/pure imaginary BSF coefficient flags" + str(i), 0)
            self.__dict__[param_name] = self.ParamDict[param_name].get(
                "Default")

        return
Exemplo n.º 9
0
    def set(self, param_name, value, index=None):
        """
        Phase extending RietveldClass.set() method

        Arguments:
        param_name  --  string, parameter name
        value       --  instance, value to set
        """
        rvalue = RietveldClass.set(self, param_name, value, index=index)


        if param_name == "Jvi":
            self.set("More", True)
        elif param_name == "Jdi":
            self.set("More", True)
        elif param_name == "Hel":
            self.set("More", True)
        elif param_name == "Sol":
            self.set("More", True)
        elif param_name == "Mom":
            self.set("More", True)
        elif param_name == "Ter":
            self.set("More", True)

        return rvalue
Exemplo n.º 10
0
    def __init__(self, Parent):
        RietveldClass.__init__(self, Parent)

        """
        init subclass
        """
        background = Background(None)
        self.set("Background", background)

        lpfactor = LPFactor(None)
        self.set("LPFactor", lpfactor)

        # init attributes

        self._contributionlist = []
        self._reflections = {} 
        return
Exemplo n.º 11
0
    def __str__(self):
        """
        customerized output
        """
        rstring = ""

        rstring += RietveldClass.__str__(self)

        return rstring
Exemplo n.º 12
0
    def __str__(self):
        """
        customerized output
        """
        rstring  = ""

        rstring += RietveldClass.__str__(self)

        return rstring
Exemplo n.º 13
0
    def __init__(self, parent):
        """
        initialization: add a new Fit, and create the refine object belonged to this fit object
        """
        RietveldClass.__init__(self, parent)

        # init refine
        refineobj = Refine(None)
        self.set("Refine", refineobj)

        # bank information:  This is for some specific pattern data such as ".gss" with different bank
        self.banklist = []
        
        # internal data
        self.key = ''
        self._param_indices = {}
        self.updateParamIndices(self._param_indices)

        return
Exemplo n.º 14
0
    def __init__(self, parent):
        """
        initialization: add a new Fit, and create the refine object belonged to this fit object
        """
        RietveldClass.__init__(self, parent)

        # init refine
        refineobj = Refine(None)
        self.set("Refine", refineobj)

        # bank information:  This is for some specific pattern data such as ".gss" with different bank
        self.banklist = []

        # internal data
        self.key = ''
        self._param_indices = {}
        self.updateParamIndices(self._param_indices)

        return
Exemplo n.º 15
0
    def validate(self):
        """
        validate the parameters, subclass and container to meet the refinement requirement
        """ 
        rvalue = RietveldClass.validate(self)

        if self.__class__.__name__ == "FormFactor":
            print "base class FormFactor is not allowed"
            rvalue = False

        return rvalue
Exemplo n.º 16
0
    def validate(self):
        """
        validate the parameters, subclass and container to meet the refinement requirement
        """ 
        rvalue = RietveldClass.validate(self)

        name = self.__class__.__name__
        if name == "Background":
            print "base class of Background is not allowed"
            rvalue = False

        return rvalue
Exemplo n.º 17
0
    def validate(self):
        """
        validate the parameters, subclass and container to meet the refinement requirement
        """
        rvalue = RietveldClass.validate(self)

        # type check
        name = self.__class__.__name__
        if name == "AtomicDisplacementFactor":
            print "base class AtomicDisplacementFactor is not allowed"
            rvalue = False

        return rvalue
Exemplo n.º 18
0
    def validate(self):
        """
        validate the parameters, subclass and container to meet the refinement requirement
        """
        rvalue = RietveldClass.validate(self)

        # type check
        name = self.__class__.__name__
        if name == "AtomicDisplacementFactor":
            print "base class AtomicDisplacementFactor is not allowed"
            rvalue = False

        return rvalue
Exemplo n.º 19
0
    def set(self, param_name, value,  index=None):
        """
        function:    set value to parameter 'param'

        param_name:  parameter name, can be (1) parameter name (2) subclass name
        value     :  (1) corresponding python build-in type
                     (2) an object reference
        index:       for the location in ObjectListDict/ParamListDict
        """

        rvalue = RietveldClass.set(self, param_name, value, index)

        if param_name == "Nba":
           
            nba = self.get(param_name)
            background = None

            if nba == 0:
                background = BackgroundPolynomial(self)
                background.set("Order", 6)
            elif nba == 1:
                background = BackgroundPolynomial(self)
                background.set("Order", 4)
            elif nba == -1:
                background = BackgroundDebye(self)
            elif nba == -2:
                background = BackgroundFourierwindow(self)
            elif nba == -3:
                background = BackgroundPolynomial(self)
                background.set("Order", 12)
            elif nba == -4:
                background = BackgroundPolynomial(self)
                background.set("Order", 12)
            elif nba == 2:
                background = BackgroundUserDefinedLinear(self)
            elif nba == -5:
                background = BackgroundUserDefinedCubic(self)
            else:
                errmsg = "Nba = %-10s is not supported" % (nba)
                raise RietError, errmsg

            if background is not None:
                self.set("Background", background)

        else:
            pass

        return rvalue
Exemplo n.º 20
0
    def validate(self):
        """
        validate of class Phase
        """
        rvalue = RietveldClass.validate(self)

        errmsg = ""

        # FullProf parameter synchronization
        # atom
        nat = len(self.get("Atom"))
        self.set("Nat", nat)
        # dis
        dis = len(self.get("DistanceRestraint"))
        self.set("Dis", dis)
        # momma
        ang = len(self.get("AngleRestraint"))
        mom = len(self.get("MomentRestraint"))
        if ang != 0 and mom != 0:
            raise NotImplementedError, "Angular Restraint and Moment Restraint cannot be used simultaneously"
        self.set("MomMA", ang + mom)
        # nvk
        nvk = len(self.get("PropagationVector"))
        self.set("Nvk", nvk)

        # Situation validation
        # 1. Jbt and Atom Number
        jbt = self.get("Jbt")
        if abs(jbt) != 2 and nat == 0:
            # not Le-Bail (profile match)
            rvalue = False
            errmsg += "No Atom is defined while Jbt = %-5s (Not Le-Bail)" % (
                jbt)

        # error message output
        if errmsg != "":
            prtmsg = "Phase Invalid Setup: %-60s" % (errmsg)
            print prtmsg

        if rvalue is not True:
            print "Invalidity Deteced In %-10s" % (self.__class__.__name__)

        return rvalue
Exemplo n.º 21
0
    def validate(self):
        """
        validate of class Phase
        """
        rvalue = RietveldClass.validate(self)

        errmsg = ""

        # FullProf parameter synchronization
        # atom
        nat = len(self.get("Atom"))
        self.set("Nat", nat)
        # dis
        dis = len(self.get("DistanceRestraint"))
        self.set("Dis", dis)
        # momma
        ang = len(self.get("AngleRestraint"))
        mom = len(self.get("MomentRestraint"))
        if ang != 0 and mom != 0:
            raise NotImplementedError, "Angular Restraint and Moment Restraint cannot be used simultaneously"
        self.set("MomMA", ang+mom)
        # nvk
        nvk = len(self.get("PropagationVector"))
        self.set("Nvk", nvk)

        # Situation validation
        # 1. Jbt and Atom Number
        jbt = self.get("Jbt")
        if abs(jbt) != 2 and nat == 0:
            # not Le-Bail (profile match)
            rvalue = False
            errmsg += "No Atom is defined while Jbt = %-5s (Not Le-Bail)"% (jbt)

        # error message output
        if errmsg != "":
            prtmsg = "Phase Invalid Setup: %-60s"% (errmsg)
            print prtmsg

        if rvalue is not True:
            print "Invalidity Deteced In %-10s"% (self.__class__.__name__)

        return rvalue
Exemplo n.º 22
0
    def set(self, param_name, value, index=None):
        """
        Phase extending RietveldClass.set() method

        Arguments:
        param_name  --  string, parameter name
        value       --  instance, value to set
        """
        rvalue = RietveldClass.set(self, param_name, value, index=index)

        if param_name == "Jvi":
            self.set("More", True)
        elif param_name == "Jdi":
            self.set("More", True)
        elif param_name == "Hel":
            self.set("More", True)
        elif param_name == "Sol":
            self.set("More", True)
        elif param_name == "Mom":
            self.set("More", True)
        elif param_name == "Ter":
            self.set("More", True)

        return rvalue
Exemplo n.º 23
0
    def validate(self):
        """
        validate the parameters, subclass and container to meet the refinement requirement of 
        class Pattern

        Return  --  bool
        """
        from diffpy.pyfullprof.utilfunction import checkFileExistence
        rvalue = RietveldClass.validate(self)

        errmsg = ""

        # type check: virtual base class
        name = self.__class__.__name__
        if name == "Pattern":
            errmsg += "%-30s: %-40s"%("Pattern.validate()", "virtual base Pattern")
            print errmsg
            rvalue = False

        # FullProf Parameter Synchronization
        # 1. Excluded Region
        nex = len(self.get("ExcludedRegion"))
        self.set("Nex", nex)

        # 2. Scttering Factor
        nsc = len(self.get("ScatterFactor"))
        self.set("Nsc", nsc)

        # 3. background
        background = self.get("Background")

        if isinstance(background, BackgroundUserDefinedLinear):
            #NOTE: avoid using self.set('Nba', 2)
            self.Nba = 2
        elif isinstance(background, BackgroundUserDefinedCubic):
            #NOTE: avoid using self.set('Nba', -5)
            self.Nba = -5
        elif isinstance(background, BackgroundFourierwindow):
            #NOTE: avoid using self.set('Nba', -2)
            self.Nba = -2

        elif isinstance(background, BackgroundPolynomial):
            if background.get("Order") == 6:
                #NOTE: avoid using self.set('Nba', 0)
                self.Nba = 0
            elif background.get("Order") == 12:
                #NOTE: avoid using self.set('Nba', -4)
                self.Nba = -4
            else:
                errmsg = "Polynomial Order = %-4s Is Not Supported"% (background.get("Order"))
                raise NotImplementedError(errmsg)
        else:
            pass       

        if self.get("Nba") <= -5 or self.get("Nba") >= 2:
            self.set('NbaPoint', self.get("Background").size())

        if background.ParamDict.has_key("Bkpos"):
            self.set('Bkpos', self.get("Background").get("Bkpos"))

        # 4. output 
        self.set("Ipr", 3)
        if self.get("Prf") == 0:
            self.set("Prf", 3)

        # 5. peak profile Npr
        for contribution in self._contributionlist:
            npr = contribution.get("Npr")
            self.set("Npr", npr)

        # WZ: this section (item 6) is removed as all wdt from fit should be trustful
        # 6. Peak range
        # for contribution in self._contributionlist:
        #     wdt = contribution.get("Profile").get("PeakRange")
        #     if wdt > 0.0:
        #         self.set("Wdt", wdt)
        wdt = self.get("Wdt")
        if wdt <= 0.0:
            errmsg = String.Format("Pattern has Wdt (peak range) = %f <= 0") % (wdt)
            raise RietError(errmsg)

        # Check Valid
        # 1. resolution file
        if self.get("Res") != 0:
            exist = checkFileExistence(self.get("Resofile"))
            if not exist:
                rvalue = False
                errmsg += "Resolution File %-10s Cannot Be Found\n"% (self.get("Resofile"))

        # 2. data file.... ->  moved to Fit.validate()
        
        if rvalue is not True:
            print "Invalidity Detected In %-10s: %-60s"% (self.__class__.__name__, errmsg)

        return rvalue
Exemplo n.º 24
0
    def validate(self, mode="Refine"):
        """
        validate the parameters, subclass and container to meet the refinement requirement

        Arguments
        - mode  :  string, validate mode, (Refine, Calculate)

        Return  :  Boolean 
        """
        rvalue = RietveldClass.validate(self)
        errmsg = ""

        # I. Synchronization of FulProf Parameter & Check Data File Existence
        for pattern in self.get("Pattern"):

            # 2.1 data file existence
            if mode == "Refine":
                exist = checkFileExistence(pattern.get("Datafile"))
                if not exist:
                    rvalue = False
                    errmsg += "Data File %-10s Cannot Be Found\n"% (pattern.get("Datafile"))

        # 2. Nre
        nre = 0
        for variable in self.get("Refine").get("Variable"):
            if variable.get("usemin") is True:
                nre += 1
        # End -- for variable in ... 
        self.set("Nre", nre)

        # Check Validity
        # 1. parameter
        if self.get("NCY") < 1:
            rvalue = False

        # 2. .hkl file 
        #   the reason why not put the checking .hkl file in Contribution is that
        #   there is a sequence number related between pattern sequence
        #   within contribution, it is hard to get this number
        for pattern in self.get("Pattern"):
            # scan all Phases
            pindex = 1
            fnamer = pattern.get("Datafile").split(".")[0]
            usehkl = False
            for phase in self.get("Phase"):
                # get contribution
                contribution = self.getContribution(pattern, phase)
                
                if contribution is not None and contribution.get("Irf") == 2:
                    # using reflection
                    usehkl = True
                    # check single phase/contribution hkl file
                    hklfname = fnamer+str(pindex)+".hkl"
                    try:
                        hklfile = open(hklfname, "r")
                        hklfile.close()
                    except IOError, err:
                        # if no such file exits, update Irf to 0
                        contribution.set("Irf", 0)
                        # error message output
                        errmsg += "Fit.validate():  Reflection File %-10s Cannot Be Found: "% (hklfname)
                        errmsg += "Chaning Contribution.Irf to 0 ... Related to Phase[%-5s]"% (pindex)
                        print errmsg
                # End -- if contribution is not None and Irf == 2:

                pindex += 1
            # End -- for phase in self.get("Phase"):

            if usehkl is True:
                # check overall hkl file
                hklfname = fnamer+".hkl"
                try:
                    hklfile = open(hklfname, "r")
                    hklfile.close()
                except IOError, err:
                    # if no such file exists, update all Irf to 0
                    for contribution in self.get("Contribution"):
                        contribution.set("Irf", 0)
Exemplo n.º 25
0
    def __init__(self, Parent):
        RietveldClass.__init__(self, Parent)

        return
Exemplo n.º 26
0
    def __init__(self, Parent):
        RietveldClass.__init__(self, Parent)

        return
Exemplo n.º 27
0
    def validate(self, mode="Refine"):
        """
        validate the parameters, subclass and container to meet the refinement requirement

        Arguments
        - mode  :  string, validate mode, (Refine, Calculate)

        Return  :  Boolean 
        """
        rvalue = RietveldClass.validate(self)
        errmsg = ""

        # I. Synchronization of FulProf Parameter & Check Data File Existence
        for pattern in self.get("Pattern"):

            # 2.1 data file existence
            if mode == "Refine":
                exist = checkFileExistence(pattern.get("Datafile"))
                if not exist:
                    rvalue = False
                    errmsg += "Data File %-10s Cannot Be Found\n" % (
                        pattern.get("Datafile"))

        # 2. Nre
        nre = 0
        for variable in self.get("Refine").get("Variable"):
            if variable.get("usemin") is True:
                nre += 1
        # End -- for variable in ...
        self.set("Nre", nre)

        # Check Validity
        # 1. parameter
        if self.get("NCY") < 1:
            rvalue = False

        # 2. .hkl file
        #   the reason why not put the checking .hkl file in Contribution is that
        #   there is a sequence number related between pattern sequence
        #   within contribution, it is hard to get this number
        for pattern in self.get("Pattern"):
            # scan all Phases
            pindex = 1
            fnamer = pattern.get("Datafile").split(".")[0]
            usehkl = False
            for phase in self.get("Phase"):
                # get contribution
                contribution = self.getContribution(pattern, phase)

                if contribution is not None and contribution.get("Irf") == 2:
                    # using reflection
                    usehkl = True
                    # check single phase/contribution hkl file
                    hklfname = fnamer + str(pindex) + ".hkl"
                    try:
                        hklfile = open(hklfname, "r")
                        hklfile.close()
                    except IOError, err:
                        # if no such file exits, update Irf to 0
                        contribution.set("Irf", 0)
                        # error message output
                        errmsg += "Fit.validate():  Reflection File %-10s Cannot Be Found: " % (
                            hklfname)
                        errmsg += "Chaning Contribution.Irf to 0 ... Related to Phase[%-5s]" % (
                            pindex)
                        print errmsg
                # End -- if contribution is not None and Irf == 2:

                pindex += 1
            # End -- for phase in self.get("Phase"):

            if usehkl is True:
                # check overall hkl file
                hklfname = fnamer + ".hkl"
                try:
                    hklfile = open(hklfname, "r")
                    hklfile.close()
                except IOError, err:
                    # if no such file exists, update all Irf to 0
                    for contribution in self.get("Contribution"):
                        contribution.set("Irf", 0)