<commit_before>#
# mosflm_like.py
#
#  Copyright (C) 2013 Diamond Light Source
#
#  Author: Luiso & James
#
#  This code is distributed under the BSD license, a copy of which is
#  included in the root directory of this package.

from __future__ import division

class MosflmProfileFitting:
  '''A class to perform 2D mosflm-like profile fitting'''

  def __init__(self, experiment, nblocks):
    self.experiment = experiment
    self.nblocks = nblocks


  #def __call__(self, sweep, crystal, ref_table, reference = None):
  #def __call__(self, sweep, ref_table, reference = None):
  def __call__(self, ref_table, reference = None):

    from dials.array_family import flex
    from dials.algorithms.integration import flex_2d_layering_n_integrating
    from dials.algorithms.integration.call_mosflm_2d  import mosflm_caller

    flex_2d_layering_n_integrating(ref_table)

    print "Performing profile fitting  ...."
    xyz = ref_table['xyzcal.px']
    index = sorted(range(len(ref_table)), key=lambda i: xyz[i][2])
    ref_table.reorder(flex.size_t(index))


    nz_blocks = 5
    dp_lng =len(ref_table)
    zblock_size = dp_lng / nz_blocks
    for block_z_num in range(nz_blocks):
      z_blocks_start = int(block_z_num * zblock_size)
      z_blocks_end = int((block_z_num + 1) * zblock_size)
      local_ref_table = ref_table[z_blocks_start:z_blocks_end]


      xmax, ymax = self.experiment.detector[0].get_image_size()
      local_ref_table = mosflm_caller(local_ref_table, xmax, ymax, self.nblocks)

      ref_table[z_blocks_start:z_blocks_end] = local_ref_table

    print "profile fitting            ....       Done"
    old_way = '''
    flex_2d_layering_n_integrating(ref_table)
    xmax, ymax = self.experiment.detector[0].get_image_size()
    ref_table = mosflm_caller(ref_table, xmax, ymax, self.nblocks)
    #'''<commit_msg>if this version is integrated with the command  dials.integrate refined_experiments.json indexed.pickle intensity.algorithm=mosflm shoebox.n_blocks=36 it should work<commit_after>#
# mosflm_like.py
#
#  Copyright (C) 2013 Diamond Light Source
#
#  Author: Luiso & James
#
#  This code is distributed under the BSD license, a copy of which is
#  included in the root directory of this package.

from __future__ import division

class MosflmProfileFitting:
  '''A class to perform 2D mosflm-like profile fitting'''

  def __init__(self, experiment, nblocks):
    self.experiment = experiment
    self.nblocks = nblocks


  #def __call__(self, sweep, crystal, ref_table, reference = None):
  #def __call__(self, sweep, ref_table, reference = None):
  def __call__(self, ref_table, reference = None):

    from dials.array_family import flex
    from dials.algorithms.integration import flex_2d_layering_n_integrating
    from dials.algorithms.integration.call_mosflm_2d  import mosflm_caller

    flex_2d_layering_n_integrating(ref_table)

    print "Performing profile fitting  ...."
    xyz = ref_table['xyzcal.px']
    index = sorted(range(len(ref_table)), key=lambda i: xyz[i][2])
    ref_table.reorder(flex.size_t(index))

    new_block_way = '''
    nz_blocks = 5
    dp_lng =len(ref_table)
    zblock_size = dp_lng / nz_blocks
    for block_z_num in range(nz_blocks):
      z_blocks_start = int(block_z_num * zblock_size)
      z_blocks_end = int((block_z_num + 1) * zblock_size)
      local_ref_table = ref_table[z_blocks_start:z_blocks_end]

      xmax, ymax = self.experiment.detector[0].get_image_size()
      local_ref_table = mosflm_caller(local_ref_table, xmax, ymax, self.nblocks)

      ref_table[z_blocks_start:z_blocks_end] = local_ref_table
    #'''

    #old_way = '''
    xmax, ymax = self.experiment.detector[0].get_image_size()
    ref_table = mosflm_caller(ref_table, xmax, ymax, self.nblocks)
    #'''

    print "profile fitting            ....       Done"
{'fraction_non_alphanumeric': 0.09531290913851793, 'fraction_numerical': 0.007593610892903902, 'mean_word_length': 3.9869451697127936, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7470497', 'n_tokens_mistral': 1365, 'n_tokens_neox': 1303, 'n_words': 297}