Changeset 4304


Ignore:
Timestamp:
Feb 14, 2020 6:14:35 PM (4 years ago)
Author:
toby
Message:

add sample broadening to scriptable

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIscriptable.py

    r4303 r4304  
    47284728                continue
    47294729            self.data['Histograms'][h].update(copy.deepcopy(copydict))
     4730           
     4731    def setSampleProfile(self, histname, parmType, mode, val1, val2=None, axis=None, LGmix=None):
     4732        """Sets sample broadening parameters for a histogram associated with the
     4733        current phase. This currently supports isotropic and uniaxial broadening
     4734        modes only.
     4735
     4736        :param histogram: is a histogram object (:class:`G2PwdrData`) or
     4737            a histogram name or the index number of the histogram.
     4738            The index number is relative to all histograms in the tree, not to
     4739            those in the phase.
     4740        :param str parmType: should be 'size' or 'microstrain' (can be abbreviated to 's' or 'm')
     4741        :mode str mode: should be 'isotropic' or 'uniaxial' (can be abbreviated to 'i' or 'u')
     4742        :param float val1: value for isotropic size (in microns) or 
     4743           microstrain (delta Q/Q x 10**6, unitless) or the equatorial value in the uniaxial case
     4744        :param float val2: value for axial size (in microns) or 
     4745           microstrain (delta Q/Q x 10**6, unitless) in uniaxial case; not used for isotropic
     4746        :param list axis: tuple or list with three values indicating the preferred direction
     4747          for uniaxial broadening; not used for isotropic
     4748        :param float LGmix: value for broadening type (1=Lorentzian, 0=Gaussian or a value
     4749          between 0 and 1. Default value (None) is ignored.
     4750
     4751        Examples::
     4752
     4753            phase0.setSampleProfile(0,'size','iso',1.2)
     4754            phase0.setSampleProfile(0,'micro','isotropic',1234)
     4755            phase0.setSampleProfile(0,'m','u',1234,4567,[1,1,1],.5)
     4756            phase0.setSampleProfile(0,'s','u',1.2,2.3,[0,0,1])
     4757        """
     4758        if parmType.lower().startswith('s'):
     4759            key = 'Size'
     4760        elif parmType.lower().startswith('m'):
     4761            key = 'Mustrain'
     4762        else:
     4763            G2fil.G2Print('setSampleProfile Error: value for parmType of {} is not size or microstrain'.
     4764                              format(parmType))
     4765            raise Exception('Invalid parameter in setSampleProfile')
     4766        if mode.lower().startswith('i'):
     4767            iso = True
     4768        elif mode.lower().startswith('u'):
     4769            iso = False
     4770            if val2 is None:
     4771                G2fil.G2Print('setSampleProfile Error: value for val2 is required with mode of uniaxial')
     4772                raise Exception('Invalid val2 parameter in setSampleProfile')
     4773            if axis is None:
     4774                G2fil.G2Print('setSampleProfile Error: value for axis is required with mode of uniaxial')
     4775                raise Exception('Invalid axis parameter in setSampleProfile')
     4776        else:
     4777            G2fil.G2Print('setSampleProfile Error: value for mode of {} is not isotropic or uniaxial'.
     4778                              format(mode))
     4779            raise Exception('Invalid parameter in setSampleProfile')
     4780       
     4781        d = self.data['Histograms'][self._decodeHist(histname)][key]
     4782        if iso:
     4783            d[0] = 'isotropic'
     4784            d[1][0] = float(val1)
     4785            if LGmix is not None: d[1][2] = float(LGmix)
     4786        else:
     4787            d[3] = [int(axis[0]),int(axis[1]),int(axis[2])]           
     4788            d[0] = 'uniaxial'
     4789            d[1][0] = float(val1)
     4790            d[1][1] = float(val2)
     4791            if LGmix is not None: d[1][2] = float(LGmix)           
    47304792
    47314793    def setHAPvalues(self, HAPdict, targethistlist='all', skip=[], use=None):
Note: See TracChangeset for help on using the changeset viewer.