def __init__(self, parent):
        super().__init__(parent)
        self.proxy = parent
        self._fit_results = ""
        self._interface = InterfaceFactory()

        self.initialize()
        self.mapSignals()
示例#2
0
 def __init__(self,
              name: str,
              profileClass,
              datastore: xr.Dataset,
              phases=None,
              parameters=None,
              pattern=None):
     interface = InterfaceFactory()
     super(JobBase_1D, self).__init__(name,
                                      profileClass,
                                      datastore,
                                      phases,
                                      parameters,
                                      pattern,
                                      interface=interface)
     self._x_axis_name = ''
     self._y_axis_prefix = 'Intensity_'
示例#3
0
    def __init__(self,
                 phases: Union[Phase, Phases] = None,
                 parameters=None,
                 pattern=None,
                 calculator=None,
                 interface=None,
                 name: str = 'easySample'):
        if isinstance(phases, Phase):
            phases = Phases('Phases', phases)
        elif phases is None:
            phases = Phases('Phases')

        if not isinstance(phases, Phases):
            raise AttributeError('`phases` must be a Crystal or Crystals')

        if parameters is None:
            parameters = Instrument1DCWParameters.default()

        if pattern is None:
            pattern = Pattern1D.default()

        super(Sample, self).__init__(name,
                                     _phases=phases,
                                     _parameters=parameters,
                                     _pattern=pattern)

        self.filename = os.path.join(tempfile.gettempdir(),
                                     'easydiffraction_temp.cif')
        print(f"Temp CIF: {self.filename}")
        self.output_index = None
        if calculator is not None:
            self.interface = calculator
        elif interface is not None:
            self.interface = interface
        else:
            self.interface = InterfaceFactory()
__author__ = 'github.com/wardsimon'
__version__ = '0.0.1'

from easyCore import np
from easyDiffractionLib.sample import Sample
from easyDiffractionLib import Phases
from easyDiffractionLib.interface import InterfaceFactory
from easyDiffractionLib.Elements.Experiments.Experiment import Pars1D
from easyDiffractionLib.Elements.Experiments.Pattern import Pattern1D
from easyDiffractionLib.Elements.Backgrounds.Point import PointBackground, BackgroundPoint

from easyCore.Fitting.Fitting import Fitter
from easyCore.Datasets.xarray import xr

interface = InterfaceFactory()
c = Phases.from_cif_file('PbSO4.cif')
S = Sample(phases=c,
           parameters=Pars1D.default(),
           pattern=Pattern1D.default(),
           interface=interface)

file_path = 'PbSO4_neutrons_short.xye'
data_x, data_y, data_e = np.loadtxt(file_path, unpack=True)

data_set = xr.Dataset()
data_set.easyCore.add_coordinate('tth', data_x)
data_set.easyCore.add_variable('I', ['tth'], data_y)
data_set.easyCore.sigma_attach('I', data_e)

S.parameters.wavelength = 1.912
S.parameters.u_resolution = 1.4
示例#5
0
__author__ = 'github.com/wardsimon'
__version__ = '0.0.1'

from easyCore import np

from easyDiffractionLib.sample import Sample
from easyDiffractionLib import Phase, Phases
from easyDiffractionLib.interface import InterfaceFactory
from easyDiffractionLib.Profiles.P1D import Instrument1DCWParameters

import matplotlib.pyplot as plt


i = InterfaceFactory()

c = Phases.from_cif_file('tests/SrTiO3.cif')

S = Sample(phases=c, parameters=Instrument1DCWParameters.default(), interface=i)

x_data = np.linspace(5, 150, 10000)
y_data = i.fit_func(x_data)

i.switch('CrysPy')
S._updateInterface()

y_data2 = np.array(i.fit_func(x_data))

fig = plt.figure()
axprops = dict()
ax1 = fig.add_axes([0.1, 0.5, 0.8, 0.4], **axprops)
ax1.plot(x_data, y_data, label="CrysFML")
示例#6
0
__author__ = 'github.com/wardsimon'
__version__ = '0.0.1'

from easyCore import np

from easyDiffractionLib.sample import Sample
from easyDiffractionLib import Phase
from easyDiffractionLib.interface import InterfaceFactory as Calculator
from easyDiffractionLib.Profiles.P1D import Instrument1DCWParameters

import matplotlib.pyplot as plt

calculator = Calculator()

phase = Phase.from_cif_file('tests/SrTiO3.cif')

sample = Sample(phases=phase,
                parameters=Instrument1DCWParameters.default(),
                calculator=calculator)

# sample.phase.cell.length_a = 5
sample.parameters.wavelength = 1.25
# print(S)
x_data = np.linspace(5, 150, 100)
y_data = calculator.fit_func(x_data)

plt.plot(x_data, y_data, label="CrysPy")
plt.show()

sample.parameters.wavelength = 2.5
y_data = calculator.fit_func(x_data)
示例#7
0
from easyCore import np

from easyDiffractionLib.sample import Sample
from easyDiffractionLib import Site, Phases, Phase
from easyDiffractionLib.interface import InterfaceFactory as Calculator
from easyDiffractionLib.Profiles.P1D import Instrument1DCWParameters as CWParams
from easyDiffractionLib.Profiles.P1D import Instrument1DTOFParameters as TOFParams
from easyDiffractionLib.Profiles.P1D import Powder1DParameters

import matplotlib.pyplot as plt

calculator = Calculator()
calculator.switch('CrysPy')

atom = Site.from_pars(label="Cl1",
                      specie='Cl',
                      fract_x=0.1250,
                      fract_y=0.1670,
                      fract_z=0.1070)
atom.add_adp('Uiso', Uiso=0.0)

phase = Phase(name="p1")
phase.spacegroup.space_group_HM_name = "P 42/n c m"
phase.add_atom(atom)

phases = Phases()
phases.append(phase)

parameters = CWParams.default()
parameters.length_a = 8.56
parameters.length_c = 6.12
示例#8
0
def main():
    interface = InterfaceFactory()
    print(f"Available interfaces: {interface.available_interfaces}")