Ejemplo n.º 1
0
def data():
  from LS49.sim.fdp_plot import george_sherrell
  return dict(
    pdb_lines = open(full_path("1m2a.pdb"),"r").read(),
    Fe_oxidized_model = george_sherrell(full_path("data_sherrell/pf-rd-ox_fftkk.out")),
    Fe_reduced_model = george_sherrell(full_path("data_sherrell/pf-rd-red_fftkk.out"))
  )
Ejemplo n.º 2
0
def plot_em(self, key, values):
    self.x = values  # XXX
    if not self.plot_plt_imported:
        from matplotlib import pyplot as plt
        self.plt = plt
        if self.params.LLG_evaluator.title is None:
            self.plt.ion()  # interactive - on
        self.plot_plt_imported = True
    if self.params.LLG_evaluator.title is None:
        self.plt.cla()  #clear last access
    fine = self.params.LLG_evaluator.plot_interpolation  # plot the non-modeled f values
    fig = self.plt.figure()

    # ground truth
    from LS49.sim.step5_pad import full_path
    GS = george_sherrell(full_path("data_sherrell/pf-rd-ox_fftkk.out"))
    GS.plot_them(self.plt, f1="b-", f2="b-")
    GS = george_sherrell(full_path("data_sherrell/pf-rd-red_fftkk.out"))
    GS.plot_them(self.plt, f1="r-", f2="r-")
    GS = george_sherrell(
        full_path("data_sherrell/Fe_fake.dat"))  # with interpolated points
    GS.plot_them(self.plt, f1="m-", f2="m-")

    # starting values
    GS = george_sherrell_star(fp=self.starting_params_FE1[0:100],
                              fdp=self.starting_params_FE1[100:200])
    GS.plot_them(fine, self.plt, f1="bx", f2="bx")
    GS = george_sherrell_star(fp=self.starting_params_FE2[0:100],
                              fdp=self.starting_params_FE2[100:200])
    GS.plot_them(fine, self.plt, f1="rx", f2="rx")

    # current values
    GS = george_sherrell_star(fp=self.x[0:100], fdp=self.x[100:200])
    GS.plot_them(fine, self.plt, f1="b.", f2="b.")
    GS = george_sherrell_star(fp=self.x[200:300], fdp=self.x[300:400])
    GS.plot_them(fine, self.plt, f1="r.", f2="r.")

    self.plt.axes().set_xlim((7102, 7137))  # XXX 7088,7152
    self.plt.axes().set_ylim((-8.6, 4.5))
    self.plt.title("Macrocycle %d Iteration %d" %
                   (self.macrocycle, self.iteration))  # XXX
    if self.params.LLG_evaluator.title is not None:
        macrocycle_tell = "" if self.macrocycle is None else "macrocycle_%02d_" % self.macrocycle
        fig.savefig(
            os.path.join(
                self.params.LLG_evaluator.plot_outdir,
                "replot_%s_%siteration_%02d.png" %
                (self.params.LLG_evaluator.title, macrocycle_tell,
                 self.iteration)))
    else:
        self.plt.draw()
        self.plt.pause(0.2)
    fig.clf()  # clear figure XXX
Ejemplo n.º 3
0
from __future__ import division, print_function
from six.moves import cPickle
import os
import six


def get_pdb_lines():
    return open(os.path.join(ls49_big_data, "1m2a.pdb"), "r").read()


from LS49 import ls49_big_data

from LS49.sim.fdp_plot import george_sherrell
Fe_oxidized_model = george_sherrell(
    os.path.join(ls49_big_data, "data_sherrell/pf-rd-ox_fftkk.out"))
Fe_reduced_model = george_sherrell(
    os.path.join(ls49_big_data, "data_sherrell/pf-rd-red_fftkk.out"))


def fix_unpickled_attributes(crystal_lattice):
    for attr in [
            "_unit_cell", "_space_group_info", "_indices", "_data", "_sigmas"
    ]:
        crystal_lattice.__dict__[attr] = crystal_lattice.__dict__[
            attr.encode()]
        del crystal_lattice.__dict__[attr.encode()]


def channel_wavelength_fmodel(create):
    from LS49.spectra.generate_spectra import spectra_simulation
    SS = spectra_simulation()
Ejemplo n.º 4
0
from __future__ import division, absolute_import, print_function

from LS49.sim.fdp_plot import george_sherrell
# %%% boilerplate context: specialize to packaged big data %%%
import os
ls49_big_data = os.environ["LS49_BIG_DATA"] # get absolute path from environment
from LS49.sim import step5_pad
step5_pad.big_data = ls49_big_data
from LS49.sim.step5_pad import full_path
# %%%%%%

if __name__=="__main__":

  from matplotlib import pyplot as plt

  GS = george_sherrell(full_path("data_sherrell/pf-rd-ox_fftkk.out"))
  GS.plot_them(plt,f1="b.",f2="b.")
  GS.plot_them(plt,f1="b-",f2="b-")
  GS = george_sherrell(full_path("data_sherrell/pf-rd-red_fftkk.out"))
  GS.plot_them(plt,f1="r.",f2="r.")
  GS.plot_them(plt,f1="r-",f2="r-")
  GS = george_sherrell(full_path("data_sherrell/Fe_fake.dat")) # with interpolated points
  #GS = george_sherrell(full_path("data_sherrell/Fe.dat"))
  GS.plot_them(plt,f1="m-",f2="m-")

  plt.axes().set_xlim((7088,7152))
  plt.axes().set_ylim((-8.3,4.2))

  print(list(GS.energy))
  print(list(GS.fdp))
Ejemplo n.º 5
0
    result_energies = flex.double()
    result_FE1_fpfdp = flex.vec2_double()
    result_FE2_fpfdp = flex.vec2_double()
    for iE, Energy in enumerate(range(7110, 7131)):
        Eidx = iE + 20  # index into the G arrays, for that particular energy
        try:
            A = lbfgs_fpfdp_fit(energy=Energy, all_data=G, Eidx=Eidx)
            result_energies.append(Energy)
            result_FE1_fpfdp.append((A.a[0], A.a[1]))
            result_FE2_fpfdp.append((A.a[2], A.a[3]))
        except Exception:
            pass

    from matplotlib import pyplot as plt
    from LS49.sim.fdp_plot import george_sherrell
    GS = george_sherrell("data_sherrell/pf-rd-ox_fftkk.out")
    GS.plot_them(plt, f1="b.", f2="b.")
    GS.plot_them(plt, f1="b-", f2="b-")
    GS = george_sherrell("data_sherrell/pf-rd-red_fftkk.out")
    GS.plot_them(plt, f1="r.", f2="r.")
    GS.plot_them(plt, f1="r-", f2="r-")
    plt.plot(result_energies, result_FE1_fpfdp.parts()[0], "c-")
    plt.plot(result_energies, result_FE1_fpfdp.parts()[1], "c-")
    plt.plot(result_energies, result_FE2_fpfdp.parts()[0], "m-")
    plt.plot(result_energies, result_FE2_fpfdp.parts()[1], "m-")
    plt.xlabel('Energy (eV)')
    plt.xlim([7088, 7152])
    plt.ylim([-8.2, 4.2])
    plt.show()
    exit("STOP")
Ejemplo n.º 6
0
from __future__ import division, absolute_import, print_function

from LS49.sim.fdp_plot import george_sherrell
# %%% boilerplate context: specialize to packaged big data %%%
from LS49 import ls49_big_data
from LS49.sim import step5_pad
step5_pad.big_data = ls49_big_data
from LS49.sim.step5_pad import full_path
# %%%%%%

if __name__ == "__main__":

    from matplotlib import pyplot as plt

    GS = george_sherrell(full_path("data_sherrell/pf-rd-ox_fftkk.out"))
    GS.plot_them(plt, f1="b.", f2="b.")
    GS.plot_them(plt, f1="b-", f2="b-")
    GS = george_sherrell(full_path("data_sherrell/pf-rd-red_fftkk.out"))
    GS.plot_them(plt, f1="r.", f2="r.")
    GS.plot_them(plt, f1="r-", f2="r-")
    GS = george_sherrell(full_path("data_sherrell/Fe.dat"))
    GS.plot_them(plt, f1="m-", f2="m-")

    from scipy.interpolate import interp1d
    fFe0fp = interp1d(GS.energy, GS.fp, kind="cubic")
    fFe0fdp = interp1d(GS.energy, GS.fdp, kind="linear")
    xnew = range(7070, 7180)
    plt.plot(xnew, fFe0fp(xnew), "g+")
    plt.plot(xnew, fFe0fdp(xnew), "g+")
    for item in xnew:
        print("%11.2f%15.7f%15.7f" %
Ejemplo n.º 7
0
from __future__ import division, print_function
from six.moves import range
from six.moves import cPickle as pickle
from scitbx.array_family import flex
from LS49.sim.step5_pad import microcrystal
from scitbx.matrix import sqr,col
from LS49.sim.step5_pad import pdb_lines
from LS49.sim.util_fmodel import gen_fmodel
from simtbx.nanoBragg import shapetype
from simtbx.nanoBragg import nanoBragg
from six.moves import StringIO
import scitbx
import math
from LS49.sim.fdp_plot import george_sherrell
Fe_oxidized_model = george_sherrell("data_sherrell/pf-rd-ox_fftkk.out")
Fe_reduced_model = george_sherrell("data_sherrell/pf-rd-red_fftkk.out")
global g_sfall
g_sfall = None
use_g_sfall=False

# use local file with (open("sfall_P1_7122_amplitudes.pickle","wb")) as F:
with (open("sfall_P1_7122_amplitudes.pickle","rb")) as F:
  sfall_7122 = pickle.load(F)

def channel_pixels(ROI,wavelength_A,flux,N,UMAT_nm,Amatrix_rot,fmodel_generator,output):
  energy_dependent_fmodel=False
  if energy_dependent_fmodel:
    fmodel_generator.reset_wavelength(wavelength_A)
    fmodel_generator.reset_specific_at_wavelength(
                   label_has="FE1",tables=Fe_oxidized_model,newvalue=wavelength_A)
    fmodel_generator.reset_specific_at_wavelength(
Ejemplo n.º 8
0
def plot_em_broken(self, key, values):
    if self.params.LLG_evaluator.plot_scope == "P1":
        scope = dict(xlimits=(7102, 7138),
                     fdp_ylimits=(0.1, 4.5),
                     fp_ylimits=(-8.6, -5.1))
    elif self.params.LLG_evaluator.plot_scope == "P2":
        scope = dict(xlimits=(7068, 7172),
                     fdp_ylimits=(-2.1, 6.5),
                     fp_ylimits=(-10.6, -3.1))
    self.x = values  # XXX
    cc = CC_to_ground_truth()
    if not self.plot_plt_imported:
        from matplotlib import pyplot as plt
        self.plt = plt
        if self.params.LLG_evaluator.title is None:
            self.plt.ion()  # interactive - on
        self.plot_plt_imported = True
    if self.params.LLG_evaluator.title is None:
        self.plt.cla()  #clear last access
    fine = self.params.LLG_evaluator.plot_interpolation  # plot the non-modeled f values
    fig, (ax1, ax2) = self.plt.subplots(2, 1, sharex=True, squeeze=True)

    # ground truth
    from LS49.sim.step5_pad import full_path
    GS = george_sherrell(full_path("data_sherrell/pf-rd-ox_fftkk.out"))
    GS.plot_them(ax1, f1="b-", f2="b-")
    GS.plot_them(ax2, f1="b-", f2="b-")
    cc.get_gt(GS, imodel=0)
    GS = george_sherrell(full_path("data_sherrell/pf-rd-red_fftkk.out"))
    GS.plot_them(ax1, f1="r-", f2="r-")
    GS.plot_them(ax2, f1="r-", f2="r-")
    cc.get_gt(GS, imodel=1)
    GS = george_sherrell(
        full_path("data_sherrell/Fe_fake.dat"))  # with interpolated points
    GS.plot_them(ax1, f1="m-", f2="m-")
    GS.plot_them(ax2, f1="m-", f2="m-")

    # starting values
    GS = george_sherrell_star(fp=self.starting_params_FE1[0:100],
                              fdp=self.starting_params_FE1[100:200])
    GS.plot_them(fine, ax1, f1="bx", f2="bx")
    GS.plot_them(fine, ax2, f1="bx", f2="bx")
    GS = george_sherrell_star(fp=self.starting_params_FE2[0:100],
                              fdp=self.starting_params_FE2[100:200])
    GS.plot_them(fine, ax1, f1="rx", f2="rx")
    GS.plot_them(fine, ax2, f1="rx", f2="rx")

    # current values
    GS = george_sherrell_star(fp=self.x[0:100], fdp=self.x[100:200])
    GS.plot_them(fine, ax1, f1="b.", f2="b.")
    GS.plot_them(fine, ax2, f1="b.", f2="b.")
    cc.get_data(GS, imodel=0)
    GS = george_sherrell_star(fp=self.x[200:300], fdp=self.x[300:400])
    GS.plot_them(fine, ax1, f1="r.", f2="r.")
    GS.plot_them(fine, ax2, f1="r.", f2="r.")
    cc.get_data(GS, imodel=1)

    #self.plt.axes().set_xlim((7102,7137)) # XXX 7088,7152
    ax1.set_xlim(scope["xlimits"])
    ax2.set_xlabel("Energy (eV)")
    ax1.set_ylabel("∆ f ′′")
    ax2.set_ylabel("∆ f ′")
    ax2.set_ylim(scope["fp_ylimits"])
    ax1.set_ylim(scope["fdp_ylimits"])
    ax1.set_title("Macrocycle %d Iteration %d" %
                  (self.macrocycle, self.iteration))  # XXX
    ax1.spines['bottom'].set_visible(False)
    ax2.spines['top'].set_visible(False)
    ax1.xaxis.tick_top()
    ax1.tick_params(labeltop='off')  # don't put tick labels at the top
    ax2.xaxis.tick_bottom()
    d = .015  # how big to make the diagonal lines in axes coordinates
    # arguments to pass to plot, just so we don't keep repeating them
    kwargs = dict(transform=ax1.transAxes,
                  color='k',
                  clip_on=False,
                  linewidth=1)
    ax1.plot((-d, +d), (-d, +d), **kwargs)  # top-left diagonal
    ax1.plot((1 - d, 1 + d), (-d, +d), **kwargs)  # top-right diagonal

    kwargs.update(transform=ax2.transAxes)  # switch to the bottom axes
    ax2.plot((-d, +d), (1 - d, 1 + d), **kwargs)  # bottom-left diagonal
    ax2.plot((1 - d, 1 + d), (1 - d, 1 + d), **kwargs)  # bottom-right diagonal

    if self.params.LLG_evaluator.title is not None:
        macrocycle_tell = "" if self.macrocycle is None else "macrocycle_%02d_" % self.macrocycle
        fig.savefig(
            os.path.join(
                self.params.LLG_evaluator.plot_outdir,
                "replot_%s_%siteration_%02d.png" %
                (self.params.LLG_evaluator.title, macrocycle_tell,
                 self.iteration)))
        if self.macrocycle in [
                1, 2, 3
        ] and self.iteration == self.params.LLG_evaluator.max_calls:
            fig.savefig(
                os.path.join(
                    self.params.LLG_evaluator.plot_outdir,
                    "replot_%s_%siteration_%02d.pdf" %
                    (self.params.LLG_evaluator.title, macrocycle_tell,
                     self.iteration)))
        print(
            "%s_%siteration_%02d CC=%6.3f%%" %
            (self.params.LLG_evaluator.title, macrocycle_tell, self.iteration,
             100 * cc.get_cc()), "CC_fp = %6.3f%% CC_fdp = %6.3f%%" %
            (100 * cc.get_cc_fp(), 100 * cc.get_cc_fdp()),
            "rmsd fp: %6.4f, rmsd fdp %6.4f" %
            (cc.get_rmsd_fp(), cc.get_rmsd_fdp()))
    else:
        self.plt.draw()
        self.plt.pause(0.2)