Exemplo n.º 1
0
  # Parse the command line. quick_parse is required for MPI compatibility
  params, options = parser.parse_args(show_diff_phil=True,quick_parse=True)

  #Program defaults
  if params.refdir is None:
    from LS49 import ls49_big_data
    params.refdir = os.path.join(ls49_big_data,"adse13_196","report1")
  assert os.path.isdir(params.testdir)
  assert os.path.isdir(params.refdir)
  return params,options

if __name__=="__main__":
  params,options = parse_input()
  simulation_template = os.path.join(params.testdir, params.template)
  reference_template = os.path.join(params.refdir, params.template)
  actual_compare = 0
  for i in range(params.ntest):
    newfile = simulation_template%i
    oldfile = reference_template%i

    #print(oldfile,newfile)
    import os
    if not os.path.isfile(oldfile):continue
    if not os.path.isfile(newfile):continue
    print("COMPARISON",i)
    compare_two_images(reference=oldfile, test=newfile, tolerance_delta=params.maxdelta,
      tolerance_count=params.maxcount, verbose_pixels=params.verbose, verbose=False)
    actual_compare += 1
  assert actual_compare >= params.mincompare, "Did not compare %d images, only %d"%(params.mincompare,actual_compare)
  print("OK")
Exemplo n.º 2
0

#explanation:  for mono and poly, use the step5_pad simulation with separate structure factors for each energy channel
# for laue, we want a single kernel call, so use step5_laue that sets only a single value for structure factors,
# and an appropriate reference image calculated that way on CPU.

if __name__ == "__main__":
    import sys
    mode = sys.argv[1]
    assert mode in ["mono", "poly", "laue"]
    if mode == "laue":
        run_laue(create=False)
        ls49_big_data = os.environ[
            "LS49_BIG_DATA"]  # get absolute path from environment
        compare_two_images(reference=os.path.join(
            ls49_big_data, "reference", "step5laue_remote_ref_000000.img.gz"),
                           test="./cuda_step5laue_000000.img.gz",
                           tolerance_count=200)
    elif mode == "poly":
        run_polychromatic(create=False)
        ls49_big_data = os.environ[
            "LS49_BIG_DATA"]  # get absolute path from environment
        compare_two_images(reference=os.path.join(
            ls49_big_data, "reference", "step5_MPIbatch_000000.img.gz"),
                           test="./cuda_step5poly_000000.img.gz")
    else:
        run_monochromatic()
        ls49_big_data = os.environ[
            "LS49_BIG_DATA"]  # get absolute path from environment
        compare_two_images(reference=os.path.join(ls49_big_data, "reference",
                                                  "step5_000000.img.gz"),
                           test="./cuda_step5_000000.img.gz")
    # make sure the user doesn't overwrite existing images
    import LS49.utils.safe_to_write as s2w
    s2w.cwd_safe_to_write([
        "*cuda_step5*_000000_intimage*.img", "*cuda_step5*_000000.img.gz",
        "*cuda_step5*_000000_dblprec*.pickle"
    ])

    mode = sys.argv[1]
    assert mode in ["mono", "poly"]
    ls49_big_data = os.environ[
        "LS49_BIG_DATA"]  # get absolute path from environment
    if mode == "poly":
        run_polychromatic()
        # compare to reference integer image, smv-formatted
        compare_two_images(reference=os.path.join(
            ls49_big_data, "reference",
            "ref_cpu_step5poly_000000_intimage_001.img"),
                           test="cuda_step5poly_000000_intimage_001.img")
        # compare to reference double precision image, numpy array pickle
        compare_two_raw_images(
            reference=os.path.join(
                ls49_big_data, "reference",
                "ref_cpu_step5poly_000000_dblprec_001.pickle"),
            test="./cuda_step5poly_000000_dblprec_001.pickle")
    else:
        run_monochromatic()
        # compare to reference integer image, smv-formatted
        compare_two_images(reference=os.path.join(
            ls49_big_data, "reference",
            "ref_cpu_step5_000000_intimage_001.img"),
                           test="cuda_step5_000000_intimage_001.img")
        # compare to reference double precision image, numpy array pickle
Exemplo n.º 4
0
def run_polychromatic(create):
    from LS49.sim.step5_pad import tst_all
    tst_all(quick=False,
            prefix="cuda_step5")  #actually perform the 100-channel simulation


if __name__ == "__main__":
    import sys
    mode = sys.argv[1]
    assert mode in ["mono", "poly"]
    if mode == "poly":
        run_polychromatic(create=False)
        ls49_big_data = os.environ[
            "LS49_BIG_DATA"]  # get absolute path from environment
        compare_two_images(reference=os.path.join(
            ls49_big_data, "reference", "step5_MPIbatch_000000.img.gz"),
                           test="./cuda_step5poly_000000.img.gz")
    else:
        run_monochromatic()
        ls49_big_data = os.environ[
            "LS49_BIG_DATA"]  # get absolute path from environment
        compare_two_images(reference=os.path.join(ls49_big_data, "reference",
                                                  "step5_000000.img.gz"),
                           test="./cuda_step5_000000.img.gz")
        # test the raw photons due to Bragg scatter:
        compare_two_images(reference=os.path.join(
            ls49_big_data, "reference", "step5_000000_intimage_001.img"),
                           test="./cuda_step5_000000_intimage_001.img")
        # add in the effects of water scatter:
        compare_two_images(reference=os.path.join(
            ls49_big_data, "reference", "step5_000000_intimage_002.img"),
Exemplo n.º 5
0
      self.data[channel_no]=data
      print ("Storing channel information for energy %d"%channel_no)
debug_utils.channel_extractor = channel_extractor
filename="energy_dependent_diffraction.pickle"

from LS49.tests import tst_monochromatic_image
from LS49 import ls49_big_data

def run_polychromatic(create):
  from LS49.sim.step5_pad import tst_all
  tst_all(quick=False) #actually perform the 100-channel simulation
  from LS49.sim.step5_pad import CHDBG_singleton
  if create:
    cPickle.dump(CHDBG_singleton.data,
      open(os.path.join(ls49_big_data,"reference",filename),"wb"),cPickle.HIGHEST_PROTOCOL)
  else:
    with open(os.path.join(ls49_big_data,"reference",filename),"rb") as ref_F:
      if six.PY3:
        CH_ref = cPickle.load(ref_F, encoding="bytes")
      else:
        CH_ref = cPickle.load(ref_F)
    assert len(CHDBG_singleton.data)==10,"Should have recorded 10 energy channels"
    for key in CHDBG_singleton.data:
        assert CHDBG_singleton.data[key] == CH_ref[key],"Energy-channel results should agree with reference"

if __name__=="__main__":
  run_polychromatic(create=False)
  tst_monochromatic_image.compare_two_images(
    reference=os.path.join(ls49_big_data,"reference","step5_MPIbatch_000000.img.gz"), test="./step5poly_000000.img.gz")
  print("OK")
Exemplo n.º 6
0
from __future__ import division, print_function
import os

from LS49.tests import tst_monochromatic_image
from LS49 import ls49_big_data


def run_polychromatic(create):
    #from LS49.sim import step5_laue
    #step5_laue.add_spots_algorithm = "JH"
    from LS49.sim.step5_laue import tst_all
    tst_all(quick=False)  #actually perform the 100-channel simulation


if __name__ == "__main__":
    run_polychromatic(create=False)
    tst_monochromatic_image.compare_two_images(
        reference=os.path.join(ls49_big_data, "reference",
                               "step5laue_remote_ref_000000.img.gz"),
        test="./step5laue_000000.img.gz",
        tolerance_count=200)
    print("OK")
Exemplo n.º 7
0
from __future__ import division, print_function
import os
from LS49.tests.tst_monochromatic_image import compare_two_images


if __name__=="__main__":
  from LS49.sim import step5_pad_chan_sim
  import sys

  algo = sys.argv[1]
  assert( algo in ["cuda","NKS","JH"])
  step5_pad_chan_sim.ADD_SPOTS_ALGORITHM = algo

  print ("\n\n<><><><>\nUSING ALGO: %s\n><><><><>" % algo)

  step5_pad_chan_sim.tst_all(prefix="cuda_step5_pad_chan_sim_")
  ls49_big_data = os.environ["LS49_BIG_DATA"]

  compare_two_images(
    reference=os.path.join(
            ls49_big_data,
            "reference",
            "cuda_step5_pad_chan_sim_poly_000000.img.gz"),
    test="./cuda_step5_pad_chan_sim_poly_000000.img.gz")

  print("OK")