Exemple #1
0
def fp_distro(plt):
  OX = GS_ROI(full_path("data_sherrell/pf-rd-ox_fftkk.out"))
  RD = GS_ROI(full_path("data_sherrell/pf-rd-red_fftkk.out"))
  MM = GS_ROI(full_path("data_sherrell/Fe_fake.dat"))
  delta_fp = flex.double()

  for i in range(1,100):
    #delta_fp.append ( MM.fp[i]-MM.fp[i-1] );
    delta_fp.append ( OX.fp[i]-OX.fp[i-1] ); delta_fp.append ( RD.fp[i]-RD.fp[i-1] )
  STATS = flex.mean_and_variance(delta_fp)
  mean = STATS.mean()
  sigma = STATS.unweighted_sample_standard_deviation()
  displaynorm = 3.0
  plotx = flex.double([0.005*x for x in range(-100,100)])
  ploty = flex.double([displaynorm *
       (1./math.sqrt(2.*math.pi*sigma*sigma))*math.exp(-0.5*(math.pow(x-mean,2))/(sigma*sigma))
       for x in plotx])
  print("mean",mean,"sigma",sigma)
  compute_functional_and_gradients_fp(FE1_fp=OX.fp,FE2_fp=RD.fp,mean=mean,sigma=sigma)
  n,bins,patches = plt.hist(delta_fp, 50, normed=0, facecolor="orange", alpha=0.75)
  plt.plot(plotx, ploty, "r-")
  plt.xlabel("Delta fp")
  plt.title("Histogram of Delta fp")
  plt.axis([-1,1,0,40])
  plt.show()
Exemple #2
0
def restrain_II(plt):
  OX = GS_ROI(full_path("data_sherrell/pf-rd-ox_fftkk.out"))
  RD = GS_ROI(full_path("data_sherrell/pf-rd-red_fftkk.out"))
  MT = GS_ROI(full_path("data_sherrell/Fe_fake.dat")) # with interpolated points
  r_mean = flex.double(200)
  r_sigma = flex.double(200)
  for ichannel in range(100):
    fp_pop = flex.mean_and_variance(flex.double([OX.fp[ichannel],RD.fp[ichannel],MT.fp[ichannel]]))
    fdp_pop = flex.mean_and_variance(flex.double([OX.fdp[ichannel],RD.fdp[ichannel],MT.fdp[ichannel]]))
    r_mean[ichannel] = fp_pop.mean(); r_mean[100+ichannel] = fdp_pop.mean()
    r_sigma[ichannel] = fp_pop.unweighted_sample_standard_deviation()
    r_sigma[100+ichannel] = fdp_pop.unweighted_sample_standard_deviation()

  plt.stackplot(OX.energy,r_mean[0:100]-r_sigma[0:100],color=('lightgreen'))
  plt.stackplot(OX.energy,r_mean[0:100]+r_sigma[0:100],color=('white'))
  plt.stackplot(OX.energy,r_mean[100:200]+r_sigma[100:200],color=('lightgreen'))
  plt.stackplot(OX.energy,r_mean[100:200]-r_sigma[100:200],color=('white'))
  plt.plot(OX.energy,r_mean[0:100]+r_sigma[0:100],'g-')
  plt.plot(OX.energy,r_mean[100:200]+r_sigma[100:200],'g-')
  plt.plot(OX.energy,r_mean[0:100]-r_sigma[0:100],'g-')
  plt.plot(OX.energy,r_mean[100:200]-r_sigma[100:200],'g-')
  plt.plot(OX.energy,r_mean[0:100],'g-')
  plt.plot(OX.energy,r_mean[100:200],'g-')
  OX.plot_them(plt,f1="b.",f2="b.")
  OX.plot_them(plt,f1="b-",f2="b-")
  RD = GS_ROI(full_path("data_sherrell/pf-rd-red_fftkk.out"))
  RD.plot_them(plt,f1="r.",f2="r.")
  RD.plot_them(plt,f1="r-",f2="r-")
  MT = GS_ROI(full_path("data_sherrell/Fe_fake.dat")) # with interpolated points
  MT.plot_them(plt,f1="m-",f2="m-")
  plt.axes().set_ylim((-8.3,4.2))
  plt.show()
Exemple #3
0
def XXX(plt):
  GS = GS_ROI(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 = GS_ROI(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 = GS_ROI(full_path("data_sherrell/Fe_fake.dat")) # with interpolated points
  GS.plot_them(plt,f1="m-",f2="m-")
  #plt.axes().set_xlim((7088,7152))
  plt.axes().set_ylim((-8.3,4.2))
  plt.show()
Exemple #4
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
Exemple #5
0
def restrain_II_values():
  OX = GS_ROI(full_path("data_sherrell/pf-rd-ox_fftkk.out"))
  RD = GS_ROI(full_path("data_sherrell/pf-rd-red_fftkk.out"))
  MT = GS_ROI(full_path("data_sherrell/Fe_fake.dat")) # with interpolated points
  r_mean = flex.double(200)
  r_sigma = flex.double(200)
  for ichannel in range(100):
    fp_pop = flex.mean_and_variance(flex.double([OX.fp[ichannel],RD.fp[ichannel],MT.fp[ichannel]]))
    fdp_pop = flex.mean_and_variance(flex.double([OX.fdp[ichannel],RD.fdp[ichannel],MT.fdp[ichannel]]))
    r_mean[ichannel] = fp_pop.mean(); r_mean[100+ichannel] = fdp_pop.mean()
    r_sigma[ichannel] = (1./SEVERITY_FACTOR)*fp_pop.unweighted_sample_standard_deviation()
    r_sigma[100+ichannel] = (1./SEVERITY_FACTOR)*fdp_pop.unweighted_sample_standard_deviation()
  return r_mean, r_sigma
Exemple #6
0
def tst_analytical_fp():
  from libtbx.test_utils import approx_equal
  OX = GS_ROI(full_path("data_sherrell/pf-rd-ox_fftkk.out"))
  RD = GS_ROI(full_path("data_sherrell/pf-rd-red_fftkk.out"))
  fbase,g1base,g2base = compute_functional_and_gradients_fp(
         FE1_fp=OX.fp,FE2_fp=RD.fp,mean=0.0,sigma=0.1)
  EPS = 0.0001
  for ichannel in range(100):
    OX.fp[ichannel]+=EPS
    fnew,g1new,g2new = compute_functional_and_gradients_fp(
         FE1_fp=OX.fp,FE2_fp=RD.fp,mean=0.0,sigma=0.1)
    assert approx_equal((fnew-fbase)/EPS , g1base[ichannel],eps = 1e-1)
    OX.fp[ichannel]-=EPS
    RD.fp[ichannel]+=EPS
    fnew,g1new,g2new = compute_functional_and_gradients_fp(
         FE1_fp=OX.fp,FE2_fp=RD.fp,mean=0.0,sigma=0.1)
    assert approx_equal((fnew-fbase)/EPS , g2base[ichannel],eps = 1e-1)
    RD.fp[ichannel]-=EPS
Exemple #7
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))
Exemple #8
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" %
Exemple #9
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)