Changeset 2068 for trunk/GSASIIIO.py


Ignore:
Timestamp:
Nov 24, 2015 12:39:12 PM (6 years ago)
Author:
toby
Message:

cleanup image reader documetation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIIO.py

    r2065 r2068  
    496496                    print 'Transposing Image!'
    497497                    rd.Image = rd.Image.T
     498                rd.Data['ImageTag'] = rd.repeatcount
    498499                LoadImage2Tree(imagefile,G2frame,rd.Comments,rd.Data,rd.Npix,rd.Image)
    499500                repeat = rd.repeat
     
    722723        return head,data,Npix,image
    723724       
    724 # should get moved to importer when ready to test
    725 def GetPNGData(filename,imageOnly=False):
    726     '''Read an image in a png format, assumes image is converted from CheMin tif file
    727     so default parameters are that machine.
    728     '''
    729     import scipy.misc
    730     Image = scipy.misc.imread(filename,flatten=True)
    731     Npix = Image.size
    732     Comments = ['no metadata']
    733     pixy = list(Image.shape)
    734     sizexy = [40,40]
    735     Data = {'wavelength': 1.78892, 'pixelSize': sizexy, 'distance': 18.0,'size':pixy}
    736     Data['center'] = [pixy[0]*sizexy[0]/1000,pixy[1]*sizexy[1]/2000]
    737     if imageOnly:
    738         return Image.T
    739     else:
    740         return Comments,Data,Npix,Image.T
    741    
    742725def ProjFileOpen(G2frame):
    743726    'Read a GSAS-II project file and load into the G2 data tree'
     
    16511634    '''Defines a base class for the reading of images
    16521635
    1653     Images are intially read with a call to :meth:`GSASII.GSASII.OnImportImage`
    1654     which in turn calls :meth:`GSASII.GSASII.OnImportGeneric`, which calls
    1655     methods :meth:`ExtensionValidator`, :meth:`ContentsValidator` and
    1656     :meth:`Reader`. Images are also reread with :func:`GSASIIIO.GetImageData`
    1657 
    1658     See :ref:`Writing a Import Routine<Import_Routines>`
    1659     for an explanation on how to use import classes in general. The specifics
    1660     for reading an image requires that the ``Reader()`` routine in the import
    1661     class should set:
     1636    Images are read in only these places:
    16621637   
    1663       * :attr:`Comments` (a list of strings),
    1664       * :attr:`Data` (a dict defining image parameters),
    1665       * :attr:`Npix` (the number of pixels in the image)
    1666       * :attr:`Image` (the actual image)
    1667       * optionally: :attr:`repeat` (set to True if there are additional images to
    1668         read in the file)
    1669      
     1638      * Initial reading is typically done from a menu item
     1639        with a call to :meth:`GSASII.GSASII.OnImportImage`
     1640        which in turn calls :meth:`GSASII.GSASII.OnImportGeneric`. That calls
     1641        methods :meth:`ExtensionValidator`, :meth:`ContentsValidator` and
     1642        :meth:`Reader`. This returns a list of reader objects for each read image.
     1643
     1644      * Images are read alternatively in :func:`GSASIIIO.ReadImages`, which puts image info
     1645        directly into the data tree.
     1646
     1647      * Images are reloaded with :func:`GSASIIIO.GetImageData`.
     1648
     1649    .. _Image_import_routines:
     1650
     1651    When reading an image, the ``Reader()`` routine in the ImportImage class
     1652    should set:
     1653   
     1654      * :attr:`Comments`: a list of strings (str),
     1655      * :attr:`Npix`: the number of pixels in the image (int),
     1656      * :attr:`Image`: the actual image as a numpy array (np.array)
     1657      * :attr:`Data`: a dict defining image parameters (dict). Within this dict the following
     1658        data items are needed:
     1659       
     1660         * 'pixelSize': size of each pixel in microns (such as ``[200,200]``.
     1661         * 'wavelength': wavelength in Angstoms.
     1662         * 'distance': distance of detector from sample in cm.
     1663         * 'center': uncalibrated center of beam on detector (such as ``[204.8,204.8]``.
     1664         * 'size': size of image (such as ``[2048,2048]``).
     1665         * 'ImageTag': image number or other keyword used to retrieve image from
     1666           a multi-image data file (defaults to ``1`` if not specified).
     1667
     1668    optional data items:
     1669   
     1670      * :attr:`repeat`: set to True if there are additional images to
     1671        read in the file, False otherwise
     1672      * :attr:`repeatcount`: set to the number of the image.
    16701673     
    16711674    Note that the above is initialized with :meth:`InitParameters`.
     1675    (Also see :ref:`Writing a Import Routine<Import_Routines>`
     1676    for an explanation on how to use import classes in general.)
    16721677    '''
    16731678    def __init__(self,formatName,longFormatName=None,extensionlist=[],
     
    16891694        self.Image = None
    16901695        self.repeat = False
     1696        self.repeatcount = 1
    16911697
    16921698    def LoadImage(self,ParentFrame,imagefile,imagetag=None):
Note: See TracChangeset for help on using the changeset viewer.