Example #1
0
    def from_file(file, projection, image_set, feature_filter=None):
        '''Format is: epoch, x, y, intensity, snr, scale'''
        new = MultiScaleImageSet()
        array = np.loadtxt(file, dtype=str, delimiter=' ')
        epochs = dict()
        img_metas = dict()
        cs = projection.get_coordinate_system()
        for line in array:
            date = nputils.epoch_to_datetime(line[0])
            x, y = projection.s2p(map(float, line[1:3]))
            intensity = float(line[3])
            snr = float(line[4])
            if date not in img_metas:
                img_metas[date] = imgutils.ImageMeta(date, cs,
                                                     image_set.get_beam(date))
            feature = ImageFeature([y, x], img_metas[date], intensity, snr)
            if feature_filter is not None and not feature_filter(feature):
                continue
            scale = np.round(float(line[5]) / projection.mean_pixel_scale())
            if not date in epochs:
                epochs[date] = dict()
            ms_features = epochs[date]
            if not scale in ms_features:
                ms_features[scale] = DatedFeaturesGroupScale(scale, epoch=date)
            ms_features[scale].add_feature(feature)

        for epoch, scales in epochs.items():
            ms_features = BaseMultiScaleImage(epoch)
            ms_features.extend(scales.values())
            new.append(ms_features)

        print "Loaded MultiScaleImageSet from %s" % file
        return new
Example #2
0
    def from_file(file, projection, image_set, feature_filter=None):
        '''Format is: epoch, x, y, intensity, snr, scale'''
        new = MultiScaleImageSet()
        array = np.loadtxt(file, dtype=str, delimiter=' ')
        epochs = dict()
        img_metas = dict()
        cs = projection.get_coordinate_system()
        for line in array:
            date = nputils.epoch_to_datetime(line[0])
            x, y = projection.s2p(map(float, line[1:3]))
            intensity = float(line[3])
            snr = float(line[4])
            if date not in img_metas:
                img_metas[date] = imgutils.ImageMeta(date, cs,
                                                     image_set.get_beam(date))
            feature = ImageFeature([y, x], img_metas[date], intensity, snr)
            if feature_filter is not None and not feature_filter(feature):
                continue
            scale = np.round(float(line[5]) / projection.mean_pixel_scale())
            if not date in epochs:
                epochs[date] = dict()
            ms_features = epochs[date]
            if not scale in ms_features:
                ms_features[scale] = DatedFeaturesGroupScale(scale, epoch=date)
            ms_features[scale].add_feature(feature)

        for epoch, scales in epochs.items():
            ms_features = BaseMultiScaleImage(epoch)
            ms_features.extend(scales.values())
            new.append(ms_features)

        print "Loaded MultiScaleImageSet from %s" % file
        return new