Exemple #1
0
 def __init__(self):
   from dials.algorithms.background.simple import NormalOutlierRejector
   min_data = 10
   self.reject = NormalOutlierRejector(min_data)
   self.size = (9,9,9)
   self.ninvalid = 5
   self.nforeground = 20
   self.mean = 20
def test_normal():
    min_data = 10
    reject = NormalOutlierRejector(min_data)
    size = (9, 9, 9)
    ninvalid = 5
    nforeground = 20
    mean = 20

    def assert_is_correct(data, mask):
        assert_basic_mask_is_correct(mask, ninvalid, nforeground)

    for i in range(10):
        data, mask = generate_shoebox(size, mean, nforeground, ninvalid)
        reject(data, mask)
        assert_is_correct(data, mask)
Exemple #3
0
    def run(self):
        from dials.algorithms.background.simple import Creator
        from dials.algorithms.background.simple import Constant2dModeller
        from dials.algorithms.background.simple import TruncatedOutlierRejector
        from dials.algorithms.background.simple import NSigmaOutlierRejector
        from dials.algorithms.background.simple import NormalOutlierRejector

        modeller = Constant2dModeller()

        outlier_rejector = [
            None,
            TruncatedOutlierRejector(0.01, 0.01),
            NSigmaOutlierRejector(3.0, 3.0),
            NormalOutlierRejector(10),
        ]

        for rejector in outlier_rejector:
            self.tst(Creator(modeller, rejector))
Exemple #4
0
 def select_rejector():
     if outlier == 'null':
         return None
     elif outlier == 'truncated':
         return TruncatedOutlierRejector(kwargs.get("lower", 0.01),
                                         kwargs.get("upper", 0.01))
     elif outlier == 'nsigma':
         return NSigmaOutlierRejector(kwargs.get("lower", 3),
                                      kwargs.get("upper", 3))
     elif outlier == 'normal':
         return NormalOutlierRejector(kwargs.get("min_pixels", 10))
     elif outlier == 'plane':
         return MosflmOutlierRejector(kwargs.get("fraction", 1.0),
                                      kwargs.get("n_sigma", 4.0))
     elif outlier == 'tukey':
         return TukeyOutlierRejector(kwargs.get("lower", 1.5),
                                     kwargs.get("upper", 1.5))
     raise RuntimeError("Unexpected outlier rejector: %s" % outlier)
Exemple #5
0
 def select_rejector():
     if outlier == "null":
         return None
     elif outlier == "truncated":
         return TruncatedOutlierRejector(kwargs.get("lower", 0.01),
                                         kwargs.get("upper", 0.01))
     elif outlier == "nsigma":
         return NSigmaOutlierRejector(kwargs.get("lower", 3),
                                      kwargs.get("upper", 3))
     elif outlier == "normal":
         return NormalOutlierRejector(kwargs.get("min_pixels", 10))
     elif outlier == "plane":
         return MosflmOutlierRejector(kwargs.get("fraction", 1.0),
                                      kwargs.get("n_sigma", 4.0))
     elif outlier == "tukey":
         return TukeyOutlierRejector(kwargs.get("lower", 1.5),
                                     kwargs.get("upper", 1.5))
     raise RuntimeError(f"Unexpected outlier rejector: {outlier}")
Exemple #6
0
def test_normal():
  from dials.algorithms.background.simple import NormalOutlierRejector
  min_data = 10
  reject = NormalOutlierRejector(min_data)
  size = (9,9,9)
  ninvalid = 5
  nforeground = 20
  mean = 20

  def assert_is_correct(data, mask):
    invalid, foreground, background, background_used, background_valid = \
      assert_basic_mask_is_correct(mask, ninvalid, nforeground)

  for i in range(10):
    data, mask = generate_shoebox(
      size,
      mean,
      nforeground,
      ninvalid)
    reject(data, mask)
    assert_is_correct(data, mask)