Ejemplo n.º 1
0
def FourierMatch(obj1, obj2, format='PyList'):
    """abstraction function of the underlying matching algorithm and format objects"""
    " obj1, obj2, are two items formatted according to format"
    " format = all supported formats from formats.getFormatStrings()"
    " output = FourierMatch object"
    ##todo implement a function to auto determine format of obj1 and obj2

    #get list of supported formats and add auto to them.
    SFormats = formats.getFormatStrings()
    SFormats.append('auto')

    #make sure we got a good format string
    try:
        formatIndex = SFormats.index(format)
    except ValueError:
        raise formats.FormatError(formats.UnsupportedFormat,
                                  "format %s is undefined" % format)

    # make format object out of the input
    if (format != 'auto'):
        fClassList = formats.getFormats()
        FObj1 = fClassList[formatIndex](obj1)
        FObj2 = fClassList[formatIndex](obj2)
    else:
        raise ValueError("not implemented")

    FourierMatched = pysmac.match.FourierCompare(FObj1, FObj2)
    return FourierMatched
Ejemplo n.º 2
0
Archivo: match.py Proyecto: askeys/smac
    def __init__(self, f, f2, compare):
        """
        Construct/Validate matcher object
        f - A file name containing point data
        f2 - Another file name containing point data
        compare - @class{BaseCompare} which implements compares the two files
        """
        # The format objects associated with the matcher
        self.format = None
        self.format2 = None

        # Extract the format information
        formatList = getFormats()
        for fM in formatList:
            if fM.isFormat(f):
                self.format = fM(f)
            if fM.isFormat(f2):
                self.format2 = fM(f2)
        if self.format is None:
            raise FormatError(self, "Matcher.__init__ unknown format in file %s" % (str(f)))
        if self.format2 is None:
            raise FormatError(self, "Matcher.__init__ unknown format in file %s" % (str(f2)))

        # Check the compare
        if not callable(compare):
            raise CompareError(self, "Matcher.__init__ object type is not callable" % (str(compare)))
        if not issubclass(compare, BaseCompare):
            raise CompareError(self, "Matcher.__init__ unknown compare type %s" % (str(compare)))

        # Create the compare object
        self.compare = compare(self.format, self.format2)

        # Get the match
        self.match = self.compare.getMeanMatch()
Ejemplo n.º 3
0
def FourierMatch(obj1,obj2,format='PyList'):
    """abstraction function of the underlying matching algorithm and format objects"""
    " obj1, obj2, are two items formatted according to format"
    " format = all supported formats from formats.getFormatStrings()"
    " output = FourierMatch object"
    ##todo implement a function to auto determine format of obj1 and obj2

    #get list of supported formats and add auto to them.
    SFormats = formats.getFormatStrings()
    SFormats.append('auto')

    #make sure we got a good format string
    try:
        formatIndex = SFormats.index(format)
    except ValueError:
        raise formats.FormatError(formats.UnsupportedFormat, "format %s is undefined" % format)

    # make format object out of the input
    if (format != 'auto'):
        fClassList = formats.getFormats()
        FObj1 = fClassList[formatIndex](obj1)
        FObj2 = fClassList[formatIndex](obj2)
    else :
        raise ValueError("not implemented")

    FourierMatched = pysmac.match.FourierCompare(FObj1,FObj2);
    return FourierMatched
Ejemplo n.º 4
0
Archivo: match.py Proyecto: ikrist/smac
    def __init__(self, f, f2, compare):
        """
        Construct/Validate matcher object
        f - A file name containing point data
        f2 - Another file name containing point data
        compare - @class{BaseCompare} which implements compares the two files
        """
        # The format objects associated with the matcher
        self.format = None
        self.format2 = None

        # Extract the format information
        formatList = getFormats()
        for fM in formatList:
            if fM.isFormat(f):
                self.format = fM(f)
            if fM.isFormat(f2):
                self.format2 = fM(f2)
        if self.format is None:
            raise FormatError(
                self, "Matcher.__init__ unknown format in file %s" % (str(f)))
        if self.format2 is None:
            raise FormatError(
                self, "Matcher.__init__ unknown format in file %s" % (str(f2)))

        # Check the compare
        if not callable(compare):
            raise CompareError(
                self, "Matcher.__init__ object type is not callable" %
                (str(compare)))
        if not issubclass(compare, BaseCompare):
            raise CompareError(
                self,
                "Matcher.__init__ unknown compare type %s" % (str(compare)))

        # Create the compare object
        self.compare = compare(self.format, self.format2)

        # Get the match
        self.match = self.compare.getMeanMatch()