Changeset 3828

Feb 22, 2019 9:35:29 AM (4 years ago)

fix cif export w/unused histogram; switch 3.x imports to pickle w/warn if _pickle not available; doc fixes; scriptable enhancements

9 edited


  • trunk/

    r3825 r3828  
    3838    import cPickle
    40     import _pickle as cPickle
     40    import pickle as cPickle
    4141import sys
    4242import re
  • trunk/

    r3826 r3828  
    3030    import cPickle
    32     import _pickle as cPickle
     32    try:
     33        import _pickle as cPickle
     34    except:
     35        print('Warning: failed to import the optimized Py3 pickle (_pickle)')
     36        import pickle as cPickle
    3337import numpy as np
    3438import as ma
  • trunk/

    r3822 r3828  
    563563    strtypes = (str,unicode)
    565     import _pickle as cPickle
     565    import pickle as cPickle
    566566    strtypes = (str,bytes)
    567567import imp
    32103210                   'SampleAbs', 'center', 'ellipses', 'linescan',
    32113211                    'pixelSize', 'range', 'ring', 'rings', 'size', ],
    3212         'dict': ['varylist'],
     3212        'dict': ['varyList'],
    32133213        }
    32143214    '''Defines the items known to exist in the Image Controls tree section
    32713271        if arg in['Image Controls']:
    32723272            return['Image Controls'][arg]
     3273        print(self.findControl(''))
    32733274        raise Exception('arg {} not defined in G2Image.getControl'.format(arg))
    33733374        print('file {} read into {}'.format(filename,
     3376    def getVary(self,*args):
     3377        '''Return the refinement flag(s) for Image Controls parameter(s)
     3378        in the current image.
     3379        If the parameter is not found, an exception is raised.
     3381        :param str arg: the name of a refinement parameter in the
     3382          varyList for the image. The name should be one of
     3383          'dep', 'det-X', 'det-Y', 'dist', 'phi', 'tilt', or 'wave'
     3384        :param str arg1: the name of a parameter (dict entry) as before,
     3385          optional
     3388        :returns: a list of bool value(s)
     3389        '''
     3390        res = []
     3391        for arg in args:
     3392            if arg in['Image Controls']['varyList']:
     3393                res.append(['Image Controls']['varyList'][arg])
     3394            else:
     3395                raise Exception('arg {} not defined in G2Image.getVary'.format(arg))
     3396        return res
     3398    def setVary(self,arg,value):
     3399        '''Set a refinement flag for Image Controls parameter in the
     3400        current image.
     3401        If the parameter is not found an exception is raised.
     3403        :param str arg: the name of a refinement parameter in the
     3404          varyList for the image. The name should be one of
     3405          'dep', 'det-X', 'det-Y', 'dist', 'phi', 'tilt', or 'wave'
     3406        :param str arg: the name of a parameter (dict entry) in the
     3407          image. The parameter must be found in :data:`ControlList`
     3408          or an exception is raised.
     3409        :param value: the value to set the parameter. The value is
     3410          cast as the appropriate type from :data:`ControlList`.
     3411        '''
     3412        if arg in['Image Controls']['varyList']:
     3413  ['Image Controls']['varyList'][arg] = bool(value)
     3414        else:
     3415            raise Exception('arg {} not defined in G2Image.setVary'.format(arg))
    33753417    def Recalibrate(self):
    33763418        '''Invokes a recalibration fit (same as Image Controls/Calibration/Recalibrate
    33793421        This may produce a better result if run more than once.
    33803422        '''
     3423        LoadG2fil()
    33813424        ImageZ = GetCorrImage(Readers['Image'],self.proj,self)
    33823425        G2img.ImageRecalibrate(None,ImageZ,['Image Controls'],['Masks'])
  • trunk/docs/source/imports.rst

    r3823 r3828  
    44Imports are implemented by deriving a class from
    55:class:`GSASIIobj.ImportPhase`, :class:`GSASIIobj.ImportStructFactor`,
    6 :class:`GSASIIobj.ImportPowderData`
    7 or :class:`GSASIIIO.ImportPowderData` (which are in turn
     6:class:`GSASIIobj.ImportPowderData` ,
     10or :class:`GSASIIobj.ImportImage` (which are in turn
    811derived from :class:`GSASIIobj.ImportBaseclass`)
    912to implement import of
    1114Module file names (`G2phase_`, `G2pwd_` and `G2sfact_`, etc.) are used to
    1215determine which menu an import routine should be placed into. (N.B. this
    13 was an unnecessary choice; this could be done from the class used.)
    15 This list may not include all currently defined formats, since modules
    16 may be loaded from anywhere in the path.
     16naming was an unnecessary choice; importer types could be determined
     17from the base class.)
     19Most importers are listed below by type (provided this documentation is
     20up to date), but note that since modules
     21may be loaded from anywhere in the path, your installation could have
     22locally-defined importers as well.
    1824.. _import_routines:
    2329When writing a import routine, one should create a new class derived
    24 from :class:`GSASIIIO.ImportPhase`, :class:`GSASIIIO.ImportStructFactor`
    25 or :class:`GSASIIIO.ImportPowderData`. As described below,
     31:class:`GSASIIobj.ImportPhase`, :class:`GSASIIobj.ImportStructFactor`,
     32:class:`GSASIIobj.ImportPowderData` ,
     36or :class:`GSASIIobj.ImportImage`. As described below,
    2637all these classes will implement
    2738an ``__init__()`` and a ``Reader()`` method, and most will supply a
    2839``ContentsValidator()`` method, too.
    29 See the :class:`~GSASIIIO.ImportPhase`,
    30 :class:`~GSASIIIO.ImportStructFactor`,
    31 :class:`~GSASIIIO.ImportPowderData`
    32 or :class:`~GSASIIIO.ImportImage` class documentation
     40See the appropriate class documentation
    3341for details on what values each type of ``Reader()`` should set.
    113121If the file cannot be read,  the ``Reader`` routine should
    114 return False or raise an :class:`GSASIIIO.ImportBaseclass.ImportException`
     122return False or raise an :class:`GSASIIobj.ImportBaseclass.ImportException`
    115123exception. (Why either? Sometimes an exception is the easiest way to
    116124bail out of a called routine.) Place text in `self.errors` and/or use::
    173181  called.
    175 Note that :meth:`GSASIIIO.ImportBaseclass.CIFValidator` is a ContentsValidator
     183Note that :meth:`GSASIIobj.ImportBaseclass.CIFValidator` is a ContentsValidator
    176184for validating CIF files.
    301309Image import routines are classes derived from
    302 :class:`GSASIIIO.ImportImage`.
    303311See :ref:`Writing a Import Routine<import_routines>` for general
    304312information on importers and the :class:`GSASIIobj.ImportImage` for
    340348    :members:
     350.. automodule:: G2img_SFRM
     351    :members:
    342353PDF Import Routines
  • trunk/exports/

    r3800 r3828  
    635635            for histogram in sorted(phasedict['Histograms']):
    636636                if histogram.startswith("HKLF"): continue # powder only
     637                if not self.Phases[phasenam]['Histograms'][histogram]['Use']: continue
    637638                Histogram = self.Histograms.get(histogram)
    638639                if not Histogram: continue
  • trunk/imports/

    r3473 r3828  
    127127        import cPickle
    128128    else:
    129         import _pickle as cPickle
     129        import pickle as cPickle
    130130    import time
    131131    more = False
  • trunk/imports/

    r3310 r3828  
    2121    import cPickle
    23     import _pickle as cPickle
     23    import pickle as cPickle
    2424import random as ran
    2525import GSASIIobj as G2obj
  • trunk/imports/

    r3136 r3828  
    1818    import cPickle
    20     import _pickle as cPickle
     20    import pickle as cPickle
    2121import numpy as np
    2222import GSASIIobj as G2obj
  • trunk/

    r3826 r3828  
    2828    import StringIO
    30     import _pickle as cPickle
     30    import pickle as cPickle
    3131    import io as StringIO
    3232import cProfile,pstats
Note: See TracChangeset for help on using the changeset viewer.