Exemple #1
0
    def set_dataset(self, ds):
#        if __ds__.axes != None :
#            if len(__ds__.axes) > 1 :
#                y_axis = __ds__.axes[len(__ds__.axes) - 2]
#                y_label = y_axis.name
#                if not y_axis.units is None :
#                    y_label += ' (' + y_axis.units + ')'
#            if len(__ds__.axes) > 0 :
#                x_axis = __ds__.axes[len(__ds__.axes) - 1]
#                x_label = x_axis.name
#                if not x_axis.units is None :
#                    x_label += ' (' + x_axis.units + ')'
        nxDs = None
        if not ds is None :
            nxDs = ds.__iNXDataset__
        pds = NXFactory.createHist2DDataset(nxDs)
#        if not x_label is None :
#            pds.setXTitle(x_label)
#        if not y_label is None :
#            pds.setYTitle(y_label)
        self.pv.setDataset(pds)
        if not ds is None :
            self.update()
        self.__ds__ = ds
        return pds
Exemple #2
0
 def set_dataset(self, ds):
     #        if __ds__.axes != None :
     #            if len(__ds__.axes) > 1 :
     #                y_axis = __ds__.axes[len(__ds__.axes) - 2]
     #                y_label = y_axis.name
     #                if not y_axis.units is None :
     #                    y_label += ' (' + y_axis.units + ')'
     #            if len(__ds__.axes) > 0 :
     #                x_axis = __ds__.axes[len(__ds__.axes) - 1]
     #                x_label = x_axis.name
     #                if not x_axis.units is None :
     #                    x_label += ' (' + x_axis.units + ')'
     nxDs = None
     if not ds is None:
         nxDs = ds.__iNXDataset__
     pds = NXFactory.createHist2DDataset(nxDs)
     #        if not x_label is None :
     #            pds.setXTitle(x_label)
     #        if not y_label is None :
     #            pds.setYTitle(y_label)
     self.pv.setDataset(pds)
     if not ds is None:
         self.update()
     self.__ds__ = ds
     return pds
Exemple #3
0
    def set_dataset(self, ds):
#        if __ds__.axes != None :
#            if len(__ds__.axes) > 1 :
#                y_axis = __ds__.axes[len(__ds__.axes) - 2]
#                y_label = y_axis.name
#                if not y_axis.units is None :
#                    y_label += ' (' + y_axis.units + ')'
#            if len(__ds__.axes) > 0 :
#                x_axis = __ds__.axes[len(__ds__.axes) - 1]
#                x_label = x_axis.name
#                if not x_axis.units is None :
#                    x_label += ' (' + x_axis.units + ')'
        nxDs = None
        pds = None
        x_label = None
        y_label = None
        if not ds is None :
            nxDs = ds.__iNXDataset__
        if ds.ndim == 2 :
            pds = NXFactory.createHist2DDataset(nxDs)
            self.__ds__ = ds
            self.ndim = 2
        elif ds.ndim == 1 :
            if ds.axes != None :
                if len(ds.axes) > 0 :
                    x_axis = ds.axes[len(ds.axes) - 1]
                    x_label = x_axis.name
                    if not x_axis.units is None :
                        x_label += ' (' + x_axis.units + ')'
            y_label = ds.title
            if not ds.units is None and len(ds.units) > 0 :
                y_label += ' (' + ds.units + ')'
            title = ds.title
            pds = NXFactory.createSingleXYDataset(title, nxDs)
            if not x_label is None :
                pds.setXTitle(x_label)
            if not y_label is None :
                pds.setYTitle(y_label)
            self.__ds__ = [ds]
            self.ndim = 1
        if not pds is None :
            self.cache.setDataset(pds)
            if not ds is None :
                self.update()
        return pds
def export_images():
    path = selectSaveFolder()
    if path == None:
        return
    dss = __DATASOURCE__.getSelectedDatasets()
    if len(dss) == 0:
        print 'Error: please select at least one data file.'
    fi = File(path)
    if not fi.exists():
        if not fi.mkdir():
            print 'Error: failed to make directory: ' + path
            return
    dss_idx = 0
    prog_bar.max = len(dss) + 1
    try:
        for dinfo in dss:
            dss_idx += 1
            prog_bar.selection = dss_idx
            ds = df[str(dinfo.location)]
            if ds.ndim < 3:
                log('dimension of ' + str(ds.id) + ' is not supported')
            dname = ds.name
            if ds.ndim == 4:
                ds = ds.get_reduced(1)
            if par_eff.value and eff_map.value != None \
                and len(eff_map.value.strip()) > 0:
                log('running efficiency correction')
                map = lib.make_eff_map(df, str(eff_map.value))
                ds = lib.eff_corr(ds, map)
            if par_geo.value :
                log('running geometry correction')
                ds = lib.geo_corr(ds, par_geo.value)
            log('process ' + dname)
            idx = dname.find('.')
            if idx > 0:
                fn = dname[0:idx]
            fn = path + '/' + fn
            wt = int(math.log10(len(ds))) + 1
            for i in xrange(len(ds)):
                log('\t frame ' + str(i))
                if ds.ndim == 4:
                    sl = ds[i, 0]
                elif ds.ndim == 3:
                    sl = ds[i]
                elif ds.ndim == 2:
                    sl = ds
                else:
                    log('dimensions are not allowed for ' + dname)
                    break
                if str(par_type.value) == 'ASCII' :
                    ext = ('%0' + str(wt) + 'd.xyz') % i
                    f = open(fn + '_' + ext, 'w')
                    try:
                        header = '#'
                        header += get_line(sl.axes[1], 3)
                        f.write(header)
                        for line in sl:
                            f.write(get_line(line, 3))
                    finally:
                        f.close()
                else:
                    pds = NXFactory.createHist2DDataset(sl.__iNXDataset__)
                    HPLOT.setDataset(pds)
                    HPLOT.getChart().setTitle(str(dname) + '_' + str(i))
                    ext = (('%0' + str(wt) + 'd.' + str(par_type.value)) % i)
                    try:
                        HPLOT.getXYPlot().getRenderer().getPaintScale().setColorScale(color_scale.Rainbow)
                    except:
                        pass
                    HPLOT.saveImage(fn + '_' + ext, str(par_type.value))
    finally:
        prog_bar.selection = 0
        prog_bar.max = 0
    log('Done')