Ignore:
Timestamp:
Aug 11, 2017 12:16:08 PM (5 years ago)
Author:
odonnell
Message:

fixed background fitting, made GSASIIpath printing optional

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branch/2frame/GSASIIscriptable.py

    r2984 r2996  
    3434
    3535import GSASIIpath
    36 GSASIIpath.SetBinaryPath() # would rather have this in __name__ == '__main__' stanza
     36GSASIIpath.SetBinaryPath(False) # would rather have this in __name__ == '__main__' stanza
    3737import GSASIIIO as G2IO
    3838import GSASIIfiles as G2fil
     
    11621162        return self['data'][0]['ranId']
    11631163
     1164    @property
     1165    def residuals(self):
     1166        data = self['data'][0]
     1167        return {key: data[key]
     1168                for key in ['R', 'Rb', 'wR', 'wRb', 'wRmin']}
     1169
    11641170    def fit_fixed_points(self):
    11651171        """Attempts to apply a background fit to the fixed points currently specified."""
     
    11991205
    12001206        # Some simple lookups
     1207        controls = self.proj['Controls']['data']
    12011208        inst, inst2 = self['Instrument Parameters']
    12021209        pwddata = self['data'][1]
     
    12151222
    12161223        # Do the fit
    1217         # TODO get controls from root
    12181224        data = np.array([xdata, ydata, W, Z, Z, Z])
    12191225        G2pwd.DoPeakFit('LSQ', [], bgrnd, limits, inst, inst2, data,
    1220                         bakVary, controls={})
     1226                        prevVaryList=bakVary, controls=controls)
    12211227
    12221228        # Post-fit
     
    12361242        return self['data'][1][3]
    12371243
    1238     def plot(self, Yobs=True, Ycalc=True, Background=True):
     1244    def plot(self, Yobs=True, Ycalc=True, Background=True, Residual=True):
    12391245        if plt:
    12401246            data = self['data'][1]
     
    12451251            if Background:
    12461252                plt.plot(data[0], data[4], label='Background')
     1253            if Residual:
     1254                plt.plot(data[0], data[5], label="Residual")
    12471255
    12481256    def set_refinements(self, refs):
     
    13101318        # are added
    13111319        if do_fit_fixed_points:
     1320            # Background won't be fit if refinement flag not set
     1321            orig = self['Background'][0][1]
     1322            self['Background'][0][1] = True
    13121323            self.fit_fixed_points()
     1324            # Restore the previous value
     1325            self['Background'][0][1] = orig
    13131326
    13141327    def clear_refinements(self, refs):
     
    13541367    def is_valid_refinement_key(key):
    13551368        valid_keys = ["Cell", "Atoms", "LeBail"]
     1369        return key in valid_keys
     1370
     1371    @staticmethod
     1372    def is_valid_HAP_refinement_key(key):
     1373        valid_keys = ["Babinet", "Extinction", "HStrain", "Mustrain",
     1374                      "Pref.Ori.", "Show", "Size", "Use", "Scale"]
    13561375        return key in valid_keys
    13571376
Note: See TracChangeset for help on using the changeset viewer.