<commit_before>#!/usr/bin/env python
# XWavelength.py
#   Copyright (C) 2006 CCLRC, <NAME>
#
#   This code is distributed under the BSD license, a copy of which is 
#   included in the root directory of this package.
#
# A versioning object representing the wavelength level in the .xinfo
# hierarchy. This will include all of the methods for performing operations
# on a wavelength as well as stuff for integration with the rest of the
# .xinfo hierarchy.
# 
# The following are properties defined for an XWavelength object:
# 
# wavelength
# f_pr
# f_prpr
#
# However, these objects are not versioned, since they do not (in the current
# implementation) impact on the data reduction process. These are mostly
# passed through.
#
# FIXME 05/SEP/06 this also needs to be able to handle the information
#                 pertaining to the lattice, because it is critcial that
#                 all of the sweeps for a wavelength share the same
#                 lattice.
# 
# FIXME 05/SEP/06 also don't forget about ordering the sweeps in collection
#                 order for the data reduction, to make sure that we 
#                 reduce the least damaged data first.

from XSweep import XSweep

from Object import Object

from Handlers.Flags import Flags

class XWavelength(Object):
    '''An object representation of a wavelength, which will after data
    reduction correspond to an MTZ hierarchy dataset.'''

    def __init__(self, name, crystal, wavelength,
                 f_pr = 0.0, f_prpr = 0.0, dmin = 0.0, dmax = 0.0):
        '''Create a new wavelength named name, belonging to XCrystal object
        crystal, with wavelength and optionally f_pr, f_prpr assigned.'''

        Object.__init__(self)

        # check that the crystal is an XCrystal

        if not crystal.__class__.__name__ == 'XCrystal':
            pass

        # set up this object

        self._name = name
        self._crystal = crystal
        self._wavelength = wavelength
        self._f_pr = f_pr
        self._f_prpr = f_prpr
        self._resolution_high = dmin
        self._resolution_low = dmax
        
        # then create space to store things which are contained
        # in here - the sweeps

        self._sweeps = []

        return

    def __repr__(self):
        result = 'Wavelength name: %s\n' % self._name
        result += 'Wavelength %7.5f\n' % self._wavelength
        if self._f_pr != 0.0 and self._f_prpr != 0.0:
            result += 'F\', F\'\' = (%5.2f, %5.2f)\n' % (self._f_pr,
                                                         self._f_prpr)

        result += 'Sweeps:\n'
        for s in self._sweeps:
            if Flags.get_failover():
                try:
                    result += '%s\n' % str(s)
                except:
                    self._sweeps.remove(s)
            else:
                result += '%s\n' % str(s)

        return result[:-1]

    def summarise(self):

        summary = ['Wavelength: %s (%7.5f)' % (self._name, self._wavelength)]

        for s in self._sweeps:
            for record in s.summarise():
                summary.append(record)<commit_msg>Tried to make error more helpful<commit_after>#!/usr/bin/env python
# XWavelength.py
#   Copyright (C) 2006 CCLRC, <NAME>
#
#   This code is distributed under the BSD license, a copy of which is 
#   included in the root directory of this package.
#
# A versioning object representing the wavelength level in the .xinfo
# hierarchy. This will include all of the methods for performing operations
# on a wavelength as well as stuff for integration with the rest of the
# .xinfo hierarchy.
# 
# The following are properties defined for an XWavelength object:
# 
# wavelength
# f_pr
# f_prpr
#
# However, these objects are not versioned, since they do not (in the current
# implementation) impact on the data reduction process. These are mostly
# passed through.
#
# FIXME 05/SEP/06 this also needs to be able to handle the information
#                 pertaining to the lattice, because it is critcial that
#                 all of the sweeps for a wavelength share the same
#                 lattice.
# 
# FIXME 05/SEP/06 also don't forget about ordering the sweeps in collection
#                 order for the data reduction, to make sure that we 
#                 reduce the least damaged data first.

from XSweep import XSweep
from Object import Object
from Handlers.Flags import Flags
from Handlers.Streams import Chatter

class XWavelength(Object):
    '''An object representation of a wavelength, which will after data
    reduction correspond to an MTZ hierarchy dataset.'''

    def __init__(self, name, crystal, wavelength,
                 f_pr = 0.0, f_prpr = 0.0, dmin = 0.0, dmax = 0.0):
        '''Create a new wavelength named name, belonging to XCrystal object
        crystal, with wavelength and optionally f_pr, f_prpr assigned.'''

        Object.__init__(self)

        # check that the crystal is an XCrystal

        if not crystal.__class__.__name__ == 'XCrystal':
            pass

        # set up this object

        self._name = name
        self._crystal = crystal
        self._wavelength = wavelength
        self._f_pr = f_pr
        self._f_prpr = f_prpr
        self._resolution_high = dmin
        self._resolution_low = dmax
        
        # then create space to store things which are contained
        # in here - the sweeps

        self._sweeps = []

        return

    def __repr__(self):
        result = 'Wavelength name: %s\n' % self._name
        result += 'Wavelength %7.5f\n' % self._wavelength
        if self._f_pr != 0.0 and self._f_prpr != 0.0:
            result += 'F\', F\'\' = (%5.2f, %5.2f)\n' % (self._f_pr,
                                                         self._f_prpr)

        result += 'Sweeps:\n'
        for s in self._sweeps:

            # would be nice to put this somewhere else in the hierarchy - not
            # sure how to do that though (should be handled in Innterfaces?)

            if Flags.get_failover():
                try:
                    result += '%s\n' % str(s)
                except Exception, e:
                    Chatter.write('Processing sweep %s failed: %s' % \
                                  (s.get_name(), str(e)))
                    self._sweeps.remove(s)
            else:
                result += '%s\n' % str(s)

        return result[:-1]

    def summarise(self):

        summary = ['Wavelength: %s (%7.5f)' % (self._name, self._wavelength)]

        for s in self._sweeps:
            for record in s.summarise():
                summary.append(record)
{'fraction_non_alphanumeric': 0.08359836437982734, 'fraction_numerical': 0.009995456610631531, 'mean_word_length': 1.9963702359346642, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '879877', 'n_tokens_mistral': 1930, 'n_tokens_neox': 1812, 'n_words': 702}