Beispiel #1
0
#
from __future__ import division, print_function
import os
import copy
import glob
import time
import re
import math
import sys
import wx
import wx.lib.mixins.listctrl as listmix
import wx.grid as wg
import numpy as np
import GSASIIpath
GSASIIpath.SetBinaryPath(True)
GSASIIpath.SetVersionNumber("$Revision: 4491 $")
import GSASIIIO as G2IO
import GSASIIctrlGUI as G2G
import GSASIIobj as G2obj
import GSASIIpy3 as G2py3
import GSASIIimgGUI as G2imG
import GSASIIfiles as G2fil
import GSASIIscriptable as G2sc
import multiprocessing as mp

try:  # fails during doc build
    wxMainFrameStyle = wx.DEFAULT_FRAME_STYLE ^ wx.CLOSE_BOX
except:
    wxMainFrameStyle = None

Beispiel #2
0
================================

Ellipse fitting & image integration

'''

import math
import time
import numpy as np
import numpy.linalg as nl
import numpy.ma as ma
import polymask as pm
from scipy.optimize import leastsq
import copy
import GSASIIpath
GSASIIpath.SetVersionNumber("$Revision$")
import GSASIIplot as G2plt
import GSASIIlattice as G2lat
import GSASIIpwd as G2pwd
import GSASIIspc as G2spc
import fellipse as fel

# trig functions in degrees
sind = lambda x: math.sin(x * math.pi / 180.)
asind = lambda x: 180. * math.asin(x) / math.pi
tand = lambda x: math.tan(x * math.pi / 180.)
atand = lambda x: 180. * math.atan(x) / math.pi
atan2d = lambda y, x: 180. * math.atan2(y, x) / math.pi
cosd = lambda x: math.cos(x * math.pi / 180.)
acosd = lambda x: 180. * math.acos(x) / math.pi
rdsq2d = lambda x, p: round(1.0 / math.sqrt(x), p)
Beispiel #3
0
#!/usr/bin/env python
"""main Absorb routines
   Copyright: 2009, Robert B. Von Dreele (Argonne National Laboratory)
"""
from __future__ import division, print_function
import platform
import math
import wx
import numpy as np
import sys
import matplotlib as mpl
import GSASIIpath
GSASIIpath.SetVersionNumber("$Revision: 4339 $")
import GSASIIElem as G2elem
import GSASIIElemGUI as G2elemGUI

try:
    wx.NewIdRef
    wx.NewId = wx.NewIdRef
except AttributeError:
    pass

if '2' in platform.python_version_tuple()[0]:
    Gktheta = unichr(0x3b8)
    Gklambda = unichr(0x3bb)
    GkDelta = unichr(0x0394)
    Pwr10 = unichr(0x0b9) + unichr(0x2070)
    Pwr20 = unichr(0x0b2) + unichr(0x2070)
    Pwrm1 = unichr(0x207b) + unichr(0x0b9)
    Pwrm2 = unichr(0x207b) + unichr(0x0b2)
    Pwrm6 = unichr(0x207b) + unichr(0x2076)
Beispiel #4
0
# $Id: G2img_CheMin.py 3136 2017-10-23 16:39:16Z vondreele $
########### SVN repository information ###################
'''
*Module G2img_png: png image file*
---------------------------------------

Routine to read an image in .png (Portable Network Graphics) format.
For now, the only known use of this is with converted Mars Rover (CheMin)
tif files, so default parameters are for that.

'''

from __future__ import division, print_function
import GSASIIobj as G2obj
import GSASIIpath
GSASIIpath.SetVersionNumber("$Revision: 3136 $")


class png_ReaderClass(G2obj.ImportImage):
    '''Reads standard PNG images; parameters are set to those of the
    Mars Rover (CheMin) diffractometer.
    '''
    def __init__(self):
        super(self.__class__, self).__init__(  # fancy way to self-reference
            extensionlist=('.png', ),
            strictExtension=True,
            formatName='PNG image',
            longFormatName='PNG image from CheMin')

    def ContentsValidator(self, filename):
        '''no test at this time
Beispiel #5
0
of slightly incorrect pseudo-TIF formats used at instruments around the world.
Note that the name ``G2img_1TIF`` is used so that this file will
sort to the top of the image formats and thus show up first in the menu.
(It is the most common, alas).

'''

from __future__ import division, print_function
import struct as st
import GSASIIobj as G2obj
import GSASIIpath
import GSASIIfiles as G2fil
import numpy as np
import time
DEBUG = False
GSASIIpath.SetVersionNumber("$Revision: 4112 $")


class TIF_ReaderClass(G2obj.ImportImage):
    '''Reads TIF files using a routine (:func:`GetTifData`) that looks
    for files that can be identified from known instruments and will
    correct for slightly incorrect TIF usage. If that routine fails,
    it will be read with a standard TIF reader, which can handle compression
    and other things less commonly used at beamlines. 
    '''
    def __init__(self):
        super(self.__class__, self).__init__(  # fancy way to self-reference
            extensionlist=('.tif', '.tiff'),
            strictExtension=False,
            formatName='TIF image',
            longFormatName='Various .tif and pseudo-TIF formats')
current project.

'''
from __future__ import division, print_function
import platform
import sys
if '2' in platform.python_version_tuple()[0]:
    import cPickle
else:
    import pickle as cPickle
import random as ran
import GSASIIobj as G2obj
import GSASIIIO as G2IO
import GSASIIstrIO as G2stIO
import GSASIIpath
GSASIIpath.SetVersionNumber("$Revision: 3828 $")


class PhaseReaderClass(G2obj.ImportPhase):
    'Opens a .GPX file and pulls out a selected phase'

    def __init__(self):
        super(self.__class__,
              self).__init__(  # fancy way to say ImportPhase.__init__
                  extensionlist=('.gpx', ),
                  strictExtension=True,
                  formatName='GSAS-II gpx',
                  longFormatName='GSAS-II project (.gpx file) import')

    def ContentsValidator(self, filename):
        "Test if the 1st section can be read as a cPickle block, if not it can't be .GPX!"
# $Id: G2pwd_fxye.py 3742 2018-11-26 21:01:03Z toby $
########### SVN repository information ###################
'''
*Module G2pwd_fxye: GSAS data files*
------------------------------------
Routine to read in powder data in a variety of formats
that are defined for GSAS.

'''
from __future__ import division, print_function
import os.path as ospath
import platform
import numpy as np
import GSASIIobj as G2obj
import GSASIIpath
GSASIIpath.SetVersionNumber("$Revision: 3742 $")


class GSAS_ReaderClass(G2obj.ImportPowderData):
    'Routines to import powder data from a GSAS files'

    def __init__(self):
        super(self.__class__, self).__init__(  # fancy way to self-reference
            extensionlist=('.fxye', '.raw', '.gsas', '.gda', '.gsa', '.gss',
                           '.RAW', '.GSAS', '.GDA', '.GSA'),
            strictExtension=False,
            formatName='GSAS powder data',
            longFormatName='GSAS powder data files (.fxye, .raw, .gsas...)')
        self.clockWd = {}
        self.TimeMap = {}
        self.dnames = []
Beispiel #8
0
# $Date: 2019-12-15 11:52:48 -0800 (Sun, 15 Dec 2019) $
# $Author: toby $
# $Revision: 4203 $
# $URL: https://subversion.xray.aps.anl.gov/pyGSAS/trunk/GSASIIElemGUI.py $
# $Id: GSASIIElemGUI.py 4203 2019-12-15 19:52:48Z toby $
########### SVN repository information ###################
'''
*GSASIIElemGUI: GUI to select and delete element lists*
-------------------------------------------------------

Module to select elements from a periodic table and
to delete an element from a list of selected elements.
'''
from __future__ import division, print_function
import GSASIIpath
GSASIIpath.SetVersionNumber("$Revision: 4203 $")
import wx
import os
import wx.lib.colourselect as wscs


class PickElement(wx.Dialog):
    '''Makes periodic table widget for picking element. Modes:
        oneOnly if True element symbols are provided, otherwise select valence
        ifNone if True show None button
        ifMag if True present magnetic scatters only
        multiple if True multiple elements can be selected
    '''
    Elem = None

    def _init_ctrls(self, prnt, ifMag=False):
Beispiel #9
0
'''
*Module G2img_HDF5: summed HDF5 image file*
-------------------------------------------

Reads all images found in a HDF5 file.

'''

from __future__ import division, print_function
try:
    import h5py
except ImportError:
    h5py = None
import GSASIIobj as G2obj
import GSASIIpath
GSASIIpath.SetVersionNumber("$Revision: 3361 $")


class HDF5_Reader(G2obj.ImportImage):
    '''Routine to read a HD5 image, typically from APS Sector 6.
    B. Frosik/SDM.
    '''
    dsetlist = []
    buffer = {}
    init = False

    def __init__(self):
        if h5py is None:
            self.UseReader = False
            print('HDF5 Reader skipped because h5py library is not installed')
            import os, sys
Beispiel #10
0
# $Id: G2pwd_xye.py 1620 2014-12-27 17:14:59Z vondreele $
########### SVN repository information ###################
'''
*Module G2pwd_FP: FullProf .dat data*
-------------------------------------

Routine to read in powder data from a FullProf .dat file

'''

from __future__ import division, print_function
import os.path as ospath
import numpy as np
import GSASIIobj as G2obj
import GSASIIpath
GSASIIpath.SetVersionNumber("$Revision: 1620 $")


class fp_ReaderClass(G2obj.ImportPowderData):
    'Routines to import powder data from a FullProf 1-10 column .dat file'

    def __init__(self):
        super(self.__class__, self).__init__(  # fancy way to self-reference
            extensionlist=('.dat', ),
            strictExtension=False,
            formatName='FullProf .dat',
            longFormatName='FullProf 1-10 column .dat powder data file')
        self.scriptable = True

    # Validate the contents -- make sure we only have valid lines
    def ContentsValidator(self, filename):
# $Id: G2img_CBF.py 3207 2017-12-27 02:18:10Z toby $
########### SVN repository information ###################
'''
*Module G2img_CBF: .cbf cif image file*
---------------------------------------

'''

from __future__ import division, print_function
import time
import GSASIIobj as G2obj
import GSASIIpath
import struct as st
import numpy as np
import unpack_cbf as cbf
GSASIIpath.SetVersionNumber("$Revision: 3207 $")


class CBF_ReaderClass(G2obj.ImportImage):
    '''Routine to read a Read cif image data .cbf file.
    This is used by Pilatus. 
    '''
    def __init__(self):
        super(self.__class__, self).__init__(  # fancy way to self-reference
            extensionlist=('.cbf', ),
            strictExtension=True,
            formatName='CBF image',
            longFormatName='CIF Binary Data Format image file (NB: Slow!)')

    def ContentsValidator(self, filename):
        '''no test used at this time
from __future__ import division, print_function
import sys
import os.path
import math
import random as ran
import numpy as np
try:
    import wx
except ImportError:
    wx = None
import GSASIIobj as G2obj
import GSASIIspc as G2spc
import GSASIIlattice as G2lat
import GSASIIpath
GSASIIpath.SetVersionNumber("$Revision: 4076 $")
R2pisq = 1. / (2. * np.pi**2)


class PDB_ReaderClass(G2obj.ImportPhase):
    'Routine to import Phase information from a PDB file'

    def __init__(self):
        super(
            self.__class__,
            self).__init__(  # fancy way to say ImportPhase.__init__
                extensionlist=('.pdb', '.ent', '.PDB', '.ENT'),
                strictExtension=True,
                formatName='PDB',
                longFormatName='Original Protein Data Bank (.pdb file) import')
########### SVN repository information ###################
'''
*Module G2pdf_gr: read PDF G(R) data*
------------------------------------------------

Routines to read in G(R) data from an .gr type file, with
Angstrom steps. 

'''

from __future__ import division, print_function
import os.path as ospath
import numpy as np
import GSASIIobj as G2obj
import GSASIIpath
GSASIIpath.SetVersionNumber("$Revision: 2738 $")


class txt_PDFReaderClass(G2obj.ImportPDFData):
    'Routines to import PDF G(R) data from a .gr file'

    def __init__(self):
        super(self.__class__, self).__init__(  # fancy way to self-reference
            extensionlist=('.gr', ),
            strictExtension=False,
            formatName='r (A) step G(r) data',
            longFormatName='r (A) stepped G(r) PDF data from pdfGet or GSAS-II'
        )

    # Validate the contents -- make sure we only have valid lines
    def ContentsValidator(self, filename):
Beispiel #14
0
# $Revision: 3670 $
# $URL: https://subversion.xray.aps.anl.gov/pyGSAS/trunk/exports/G2export_FIT2D.py $
# $Id: G2export_FIT2D.py 3670 2018-10-11 16:52:33Z toby $
########### SVN repository information ###################
'''
*Module G2export_FIT2D: Fit2D "Chi" export*
-------------------------------------------

Code to create .chi (Fit2D like) files for GSAS-II powder data export 

'''
from __future__ import division, print_function
import os.path
import numpy as np
import GSASIIpath
GSASIIpath.SetVersionNumber("$Revision: 3670 $")
import GSASIIIO as G2IO
import GSASIIobj as G2obj


class ExportPowderCHI(G2IO.ExportBaseclass):
    '''Used to create a CHI file for a powder data set

    :param wx.Frame G2frame: reference to main GSAS-II frame
    '''
    def __init__(self, G2frame):
        super(self.__class__,
              self).__init__(  # fancy way to say <parentclass>.__init__
                  G2frame=G2frame,
                  formatName='Fit2D chi file',
                  extension='.chi',
Beispiel #15
0
wx is not installed.

Future refactoring: This module and GSASIIIO.py needs some work to
move non-wx routines here. It may will likely make sense to rename the module(s)
at that point.
'''
from __future__ import division, print_function
import platform
import os
import sys
import glob
import inspect
import numpy as np

import GSASIIpath
GSASIIpath.SetVersionNumber("$Revision: 4687 $")

# N.B. This is duplicated in G2IO
def sfloat(S):
    'Convert a string to float. An empty field or a unconvertable value is treated as zero'
    if S.strip():
        try:
            return float(S)
        except ValueError:
            pass
    return 0.0

G2printLevel = 'all'
'''This defines the level of output from calls to :func:`G2Print`, 
which should  be used in place of print() within this module. 
Settings for this are 'all', 'warn', 'error' or 'none'. Also see: