Example #1
0
def str2mask(value):
    items = value.split(';')
    masks = []
    for item in items:
        name = item[0:item.index('[')];
        rstr = item[item.index('[') + 1 : item.index(']')]
        range = rstr.split(',')
        mask = RectangleMask(True, float(range[0]), float(range[2]), \
                             float(range[1]) - float(range[0]), \
                             float(range[3]) - float(range[2]))
        mask.name = name
        masks.append(mask)
    return masks
Example #2
0
def str2mask(value):
    items = value.split(';')
    masks = []
    for item in items:
        name = item[0:item.index('[')]
        rstr = item[item.index('[') + 1:item.index(']')]
        range = rstr.split(',')
        mask = RectangleMask(True, float(range[0]), float(range[2]), \
                             float(range[1]) - float(range[0]), \
                             float(range[3]) - float(range[2]))
        mask.name = name
        masks.append(mask)
    return masks
Example #3
0
def str2mask(value):
    items = value.split(";")
    masks = []
    for item in items:
        name = item[0 : item.index("[")]
        rstr = item[item.index("[") + 1 : item.index("]")]
        range = rstr.split(",")
        mask = RectangleMask(
            True, float(range[0]), float(range[2]), float(range[1]) - float(range[0]), float(range[3]) - float(range[2])
        )
        mask.name = name
        masks.append(mask)
    return masks
Example #4
0
 def add_mask(self, x_min, x_max, y_min, y_max, name = None, is_inclusive = True, shape = 'r'):
     x = min(x_min, x_max)
     y = min(y_min, y_max)
     width = abs(x_max - x_min)
     height = abs(y_max - y_min)
     if shape is None or not shape[0].lower() == 'e' :
         mask = RectangleMask(is_inclusive, x, y, width, height)
     else :
         mask = EllipseMask(is_inclusive, x, y, width, height)
     if not name is None :
         mask.setName(name)
     self.pv.getPlot().addMask(mask)
     self.pv.getPlot().repaint()
     return mask
Example #5
0
File: wplot.py Project: nxi/gumtree
 def add_mask_2d(self, x_min, x_max, y_min, y_max, name = None, is_inclusive = True, shape = 'r'):
     x = min(x_min, x_max)
     y = min(y_min, y_max)
     width = abs(x_max - x_min)
     height = abs(y_max - y_min)
     if shape is None or not shape[0].lower() == 'e' :
         mask = RectangleMask(is_inclusive, x, y, width, height)
     else :
         mask = EllipseMask(is_inclusive, x, y, width, height)
     if not name is None :
         mask.setName(name)
     if not hasattr(self.cache, "masks") :
         self.masks = []
     self.masks.append(mask)
     return mask
Example #6
0
def make_mask_group(ds, num):
    masks = []
    y_axis = ds.axes[1]
    y_step = (y_axis[-1] - y_axis[0]) / num
    for i in xrange(num):
        mask = RectangleMask(True, -180, y_axis[0] + y_step * i, \
                             360, y_step)
        masks.append(mask)
    return masks
Example #7
0
 def add_mask(self,
              x_min,
              x_max,
              y_min,
              y_max,
              name=None,
              is_inclusive=True,
              shape='r'):
     x = min(x_min, x_max)
     y = min(y_min, y_max)
     width = abs(x_max - x_min)
     height = abs(y_max - y_min)
     if shape is None or not shape[0].lower() == 'e':
         mask = RectangleMask(is_inclusive, x, y, width, height)
     else:
         mask = EllipseMask(is_inclusive, x, y, width, height)
     if not name is None:
         mask.setName(name)
     self.pv.getPlot().addMask(mask)
     self.pv.getPlot().repaint()
     return mask
Example #8
0
def integration_export():
    global INT_EXP_OPTIONS
    path = selectSaveFolder()
    if path == None:
        return
    dss = __get_selected_files__()
    if len(dss) == 0:
        print 'Error: please select at least one data file.'
    prog_bar.max = len(dss) + 1
    prog_bar.selection = 0
    if len(dss) == 0:
        return
    fi = File(path)
    if not fi.exists():
        if not fi.mkdir():
            print 'Error: failed to make directory: ' + path
            return
    if eff_corr_enabled.value and eff_map.value != None \
            and len(eff_map.value.strip()) > 0:
        map = lib.make_eff_map(
            df,
            get_calibration_path() + '/' + str(eff_map.value))
    else:
        map = None
    dss_idx = 0
    rfs = []
    for dinfo in dss:
        dss_idx += 1
        prog_bar.selection = dss_idx
        df.datasets.clear()
        log('exporting ' + dinfo)
        ds = df[str(dinfo)]
        rds = silent_reduce(ds, map)
        masks = []
        if exp_mask.value == INT_EXP_OPTIONS[0]:
            if reg_enabled.value:
                try:
                    masks = Plot1.get_masks()
                except:
                    pass
            if len(masks) == 0:
                #                if reg_list.value != None and reg_list.value.strip() != '':
                #                    masks = str2mask(reg_list.value)
                masks = str2mask(get_mask_str())
            c_masks = []
            for m in masks:
                c_m = RectangleMask(True, -180, m.minY, 360, m.maxY - m.minY)
                c_masks.append(c_m)
            vi = lib.v_intg(rds, c_masks)
            vi.location = ds.location
            rf = lib.v_export(vi, path)
            rfs.append(rf)
        elif exp_mask.value == INT_EXP_OPTIONS[1]:
            vi = lib.v_intg(rds, masks)
            vi.location = ds.location
            rf = lib.v_export(vi, path)
            rfs.append(rf)
        else:
            idx = INT_EXP_OPTIONS.index(exp_mask.value)
            mask_group = make_mask_group(rds, idx)
            for mask in mask_group:
                vi = lib.v_intg(rds, [mask])
                vi.location = ds.location
                rf = lib.v_export(vi, path)
                rfs.append(rf)
    prog_bar.selection = dss_idx + 1
    prog_bar.selection = 0

    #    set_pref_value(SAVED_MASK_PRFN , str(reg_list.value))
    set_pref_value(SAVED_MASK_PRFN, get_mask_str())
    set_pref_value(SAVED_EFFICIENCY_FILENAME_PRFN, str(eff_map.value))
    save_pref()

    #    sname = 'Kowari_reduced_' + str(int(time.time() * 1000))[2:] + '.zip'
    #    print 'compressing result in ' + sname
    #    f_out = zipfile.ZipFile(path + '/' + sname, mode='w')
    #    for rfn in rfs:
    #        try:
    #            f_out.write(rfn, arcname = rfn[rfn.rindex('/') + 1 :])
    #        except:
    #            print 'failed to zip'
    #            f_out.close()
    #    f_out.close()
    #    report_file(sname)
    zip_files(rfs, '/Kowari_rd_' + str(int(time.time()))[2:] + '.zip')

    print 'Done'