Beispiel #1
0
def check_result(detail):
    expected_list = []
    expected_list.append(
        volume.Volume(CREATE_VOL_BASIC_1.VOL_NAME, CREATE_VOL_BASIC_1.VOL_SIZE,
                      CREATE_VOL_BASIC_1.VOL_IOPS, CREATE_VOL_BASIC_1.VOL_BW))
    expected_list.append(
        volume.Volume(CREATE_VOL_BASIC_2.VOL_NAME, CREATE_VOL_BASIC_2.VOL_SIZE,
                      CREATE_VOL_BASIC_2.VOL_IOPS, CREATE_VOL_BASIC_2.VOL_BW))
    expected_list.append(
        volume.Volume(CREATE_VOL_BASIC_3.VOL_NAME, CREATE_VOL_BASIC_3.VOL_SIZE,
                      CREATE_VOL_BASIC_3.VOL_IOPS, CREATE_VOL_BASIC_3.VOL_BW))

    data = json.loads(detail)
    actual_list = []
    for item in data['Response']['result']['data']['volumes']:
        vol = volume.Volume(item['name'], item['total'], item['maxiops'],
                            item['maxbw'])
        actual_list.append(vol)

    if len(actual_list) != len(expected_list):
        return "fail"

    for actual in actual_list:
        checked = False
        for expected in expected_list:
            if actual.name == expected.name and actual.total == expected.total and actual.maxiops == expected.maxiops and actual.maxbw == expected.maxbw:
                checked = True
                break
        if checked == False:
            return "fail"
    return "pass"
Beispiel #2
0
def check_result(detail):
    expected_list = []
    for i in range(0, pos_constant.MAX_VOL_CNT):
        expected_list.append(
            volume.Volume(VOL_NAME_PREFIX + str(i + 1), VOL_SIZE, VOL_IOPS,
                          VOL_BW))

    data = json.loads(detail)
    actual_list = []
    for item in data['Response']['result']['data']['volumes']:
        vol = volume.Volume(item['name'], item['total'], item['maxiops'],
                            item['maxbw'])
        actual_list.append(vol)

    if len(actual_list) != len(expected_list):
        return "fail"

    for actual in actual_list:
        checked = False
        for expected in expected_list:
            if actual.name == expected.name and actual.total == expected.total and actual.maxiops == expected.maxiops and actual.maxbw == expected.maxbw:
                checked = True
                break
        if checked == False:
            return "fail"
    return "pass"
Beispiel #3
0
    def event(self, event):
        if self.confirmation:
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_LEFT:
                    self.confirmed = (self.confirmed - 1) % 2
                elif event.key == pygame.K_RIGHT:
                    self.confirmed = (self.confirmed + 1) % 2
                if event.key == pygame.K_SPACE or event.key == pygame.K_RETURN:
                    if self.confirmed:
                        globes.Globals.HIGHSCORES.clear_file()
                        self.confirmation = False
                    else:
                        self.confirmation = False
        else:
            if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
                globes.Globals.STATE = menu.Menu(True)
            if event.type == pygame.KEYDOWN and event.key == pygame.K_UP:
                self.option = (self.option - 1) % 4
            if event.type == pygame.KEYDOWN and event.key == pygame.K_DOWN:
                self.option = (self.option + 1) % 4

            if event.type == pygame.KEYDOWN and \
                    (event.key == pygame.K_SPACE or
                     event.key == pygame.K_RETURN):
                if self.option == 0:
                    self.confirmation = True
                elif self.option == 1:
                    globes.Globals.STATE = joystick.Joystick()
                elif self.option == 2:
                    globes.Globals.STATE = volume.Volume(True)
                if self.option == 3:
                    globes.Globals.STATE = menu.Menu(True)
Beispiel #4
0
def test_volume():
    path1 = "../../data/volume_test/Takacs_Akos_20180131_038318067_STD19194862AMR806_SER1401_ACQ14.con"
    path2 = "../../data/SA_all/17352962AMR801/901/contour.con"
    path4 = "../../data/SA_all/17577538AMR801/901/contour.con"
    path5 = "../../data/SA_all/17651351AMR806/1301/contour.con"
    path6 = "../../data/SA_all/17827245AMR809/1301/contour.con"

    v = vol.Volume(path6)
    v.calculate_volumes('pixel')
    print('---------------------------')
    print('LEFT VEN.')
    print('LVED: %.3f'%v.lved)
    print('LVED-idx: %.3f'%v.lved_i)
    print('LVES: %.3f'%v.lves)
    print('LVES-idx: %.3f'%v.lves_i)
    print('LVSV: %.3f'%v.lvsv)
    print('LVSV-idx: %.3f'%v.lvsv_i)
    
    print('---------------------------')
    print('RIGHT VEN.')
    print('RVED: %.3f'%v.rved)
    print('RVED-idx: %.3f'%v.rved_i)
    print('RVES: %.3f'%v.rves)
    print('RVES-idx: %.3f'%v.rves_i)
    print('RVSV: %.3f'%v.rvsv)
    print('RVSV-idx: %.3f'%v.rvsv_i)
Beispiel #5
0
def main():
    cargs = parse_args(sys.argv[1:])

    data_type = np.dtype(cargs.dtype)
    fd = np.memmap(cargs.raw, dtype=data_type, mode='r')

    tf_x = np.loadtxt(cargs.tf, dtype=np.float64, usecols=0, skiprows=1)
    tf_y = np.loadtxt(cargs.tf, dtype=np.float64, usecols=1, skiprows=1)
    vdims = np.array([cargs.vx, cargs.vy, cargs.vz], dtype=np.uint64)
    bcount = np.array([cargs.bx, cargs.by, cargs.bz], dtype=np.uint64)
    bdims = np.divide(vdims, bcount)
    blocks = np.zeros(cargs.bx * cargs.by * cargs.bz)
    block_size = vdims / bcount
    block_extent = block_size * bcount

    print('Running volume analysis')
    vol_min, vol_max, vol_tot = run_volume(fd, np.prod(vdims))

    print('Running relevance analysis')
    relevancies = run_block(fd, tf_x, tf_y, vol_min, vol_max, vdims, bdims,
                            bcount)
    rov_min = np.min(relevancies)
    rov_max = np.max(relevancies)

    print("Creating index file")

    vol_path, vol_name = os.path.split(cargs.raw)
    tr_path, tr_name = os.path.split(cargs.tf)

    max_dim = np.max(vdims)
    world_dims = [vdims[0] / max_dim, vdims[1] / max_dim, vdims[2] / max_dim]
    world_origin = [0.0, 0.0, 0.0]

    vol_stats = volume.VolStats(min=vol_min, max=vol_max, avg=0.0, tot=vol_tot)
    vol = volume.Volume(world_dims, world_origin, vdims.tolist(), rov_min,
                        rov_max)

    blocks = indexfile.create_file_blocks(bcount, fd.dtype, vol, relevancies)

    ifile = indexfile.IndexFile(
        **{
            'world_dims': world_dims,
            'world_origin': world_origin,
            'vol_stats': vol_stats,
            'vol_name': vol_name,
            'vol_path': vol_path,
            'volume': vol,
            'tr_func': tr_name,
            'dtype': fd.dtype.name,
            'num_blocks': bcount,
            'blocks_extent': block_extent,
            'blocks': blocks,
        })
    ifile.write(cargs.out)
Beispiel #6
0
 def __init__(self, samps = None,
              bounds = None,
              volume = None,
              measure = None,
              is_eq = True,
              bandlims = None):
     
     #TODO: remove this member
     self.is_eq = is_eq
     
     if samps is None:
     
         self.samps = gd.Grid()
         self.bounds = gd.Grid()
     
     else:
     
         self.samps = samps
         self.bounds = bounds
     
     self.ns = self.samps.get_curr_cards()
     
     if volume is None:
         
         self.volume = vol.Volume()
     
     else:
         
         self.volume = volume
     
     if measure is None:
         
         self.measure = ms.Measure()
     
     else:
     
         self.measure = measure
          
     
     if bandlims is None:
         
         bounds = deep(self.bounds)
         
         self.bandlims = deep(bounds.get_lims() )
         
     else:
         
         self.bandlims = deep(bandlims)
         
     return
Beispiel #7
0
    def testBoundsZeroAlign(self):

        OneToTwo = meshwithrbffallback.MeshWithRBFFallback(
            IdentityTransformPoints)
        OneToThree = meshwithrbffallback.MeshWithRBFFallback(
            MirrorTransformPoints)

        vol = volume.Volume()

        vol.AddSection(2, OneToTwo)
        vol.AddSection(3, OneToThree)

        volBounds = vol.VolumeBounds

        self.assertEqual(volBounds.ToTuple(), (-10, -10, 10, 10),
                         "Volume bounds are not correct")
        vol.TranslateToZeroOrigin()

        zeroedVolBounds = vol.VolumeBounds
        self.assertEqual(zeroedVolBounds.ToTuple(), (0, 0, 20, 20),
                         "Volume bounds are not correct")
        pass
Beispiel #8
0
                   foreground=dk_grey,
                   background=grey),
    widget.TaskList(borderwidth=1,
                    background=grey,
                    border=cyan,
                    urgent_border=red),
    widget.TextBox(text="\u25e4 ", fontsize=42, padding=-8, foreground=grey),
    #widget.TextBox(text=u'\U0001f321'),
    widget.Systray(),
    widget.TextBox(text="\u2328", foreground=cyan),
    widget.KeyboardLayout(configured_keyboards=["us dvorak", "us"],
                          foreground=cyan,
                          update_interval=5),
    tempsensor.TempSensor(font="fontawesome"),
    networkmonitor.NetworkMonitor(font="fontawesome"),
    volume.Volume(font="fontawesome"),
    widget.Clock(format='%m-%d-%Y %a %H:%M:%S'),
]

widgets2 = [
    widget.TextBox(text="\u25e4 ", fontsize=42, padding=-8, foreground=grey),
    widget.GroupBox(borderwidth=4,
                    highlight_method='line',
                    margin=0,
                    disable_drag=True,
                    this_current_screen_border=cyan,
                    this_screen_border=lt_grey,
                    other_screen_border=med_grey,
                    urgent_border=red),
    widget.TextBox(text="\u25e4",
                   fontsize=42,
Beispiel #9
0
import volume
from subprocess import call

volume = volume.Volume('vdrive')
volume.format()
call('head -n 1 vdrive', shell=True)
Beispiel #10
0
    def play(self):

        self.emit("preplay")

        self.player = gst.Pipeline("player")

        self.queue_video = gst.element_factory_make("queue", "queue_video")
        self.player.add(self.queue_video)

        self.input_type = 0

        # Source selection

        self.source_pads = {}
        self.audio_pads = {}
        self.pip_pads = {}

        self.output_bins = {}
        type = 0
        source_number = 0
        pip_number = 0

        self.pip = PictureInPicture()

        self.player.add(self.pip)

        for row in self.sources.get_store():
            (name, source) = row
            element = source.create()
            self.player.add(element)

            if element.does_audio():
                if not self.input_type & MEDIA_AUDIO:

                    # The pipeline has audio sources, and this is the first
                    # audio source we add

                    if self.audio_source is None:
                        self.emit("error", "You need to select an audio source")
                        self.emit("stopped")
                        return
                    self.input_type |= MEDIA_AUDIO
                    self.input_selector = gst.element_factory_make(
                            "input-selector", "audio-selector"
                    )
                    self.player.add(self.input_selector)

                audiobin = audioinputbin.AudioInputBin(source)
                self.player.add(audiobin)

                element.audio_pad.link(audiobin.get_static_pad("sink"))
                self.audio_pads[name] = \
                        self.input_selector.get_request_pad("sink%d")
                audiobin.src_pad.link(self.audio_pads[name])

            if element.does_video():
                self.input_type |= MEDIA_VIDEO

                self.source_pads[name] = source_number
                source_number = source_number + 1

                # Thumbnail preview

                tee = gst.element_factory_make("tee", None)
                self.player.add(tee)
                element.video_pad.link(tee.sink_pads().next())

                thumbnail_queue = gst.element_factory_make("queue", None)
                self.player.add(thumbnail_queue)
                self.thumbnails[name] = Preview(self)
                self.player.add(self.thumbnails[name])

                thumbnail_err = gst.element_link_many(
                    tee, thumbnail_queue, self.thumbnails[name]
                )
                if thumbnail_err == False:
                    self.emit("error", "Error conecting thumbnail preview.")

                # Picture in Picture

                self.pip_pads[name] = pip_number
                pip_number = pip_number + 1

                main_queue = gst.element_factory_make("queue", None)
                self.player.add(main_queue)
                pip_queue = gst.element_factory_make("queue", None)
                self.player.add(pip_queue)

                tee.link(main_queue)
                tee.link(pip_queue)
                main_queue.src_pads().next().link(self.pip.get_request_pad_A())
                pip_queue.src_pads().next().link(self.pip.get_request_pad_B())

            if name == self.video_source:
                type |= element.get_type()
            if name == self.audio_source:
                type |= element.get_type()

        self.watermark = gst.element_factory_make(
                "cairoimageoverlay", "cairoimageoverlay"
        )
        self.player.add(self.watermark)

        self.colorspace = gst.element_factory_make(
                "ffmpegcolorspace", "colorspace-imageoverlay-videobalance"
        )
        self.player.add(self.colorspace)

        self.videobalance = gst.element_factory_make(
                "videobalance", "videobalance"
        )
        self.player.add(self.videobalance)
        if self.videobalance_contrast:
            self.videobalance.set_property(
                    "contrast", self.videobalance_contrast
            )
        if self.videobalance_brightness:
            self.videobalance.set_property(
                    "brightness", self.videobalance_brightness
            )
        if self.videobalance_hue:
            self.videobalance.set_property(
                    "hue", self.videobalance_hue
            )
        if self.videobalance_saturation:
            self.videobalance.set_property(
                    "saturation", self.videobalance_saturation
            )

        gst.element_link_many(
                self.pip, self.watermark, self.colorspace, self.videobalance,
                self.queue_video
        )

        self._switch_source()
        self._switch_pip()

        if self.pip_position:
            self.pip.set_property("position", self.pip_position)

        self.effect[MEDIA_VIDEO] = effect.video_effect.VideoEffect(
                self.effect_name[MEDIA_VIDEO]
        )
        self.player.add(self.effect[MEDIA_VIDEO])

        self.overlay = gst.element_factory_make("textoverlay", "overlay")
        self.overlay.set_property("font-desc", self.overlay_font)
        self.overlay.set_property("halign", self.halign)
        self.overlay.set_property("valign", self.valign)
        self.player.add(self.overlay)

        gst.element_link_many(
                self.queue_video, self.effect[MEDIA_VIDEO], self.overlay
        )

        self.preview_tee = multeequeue.MulTeeQueue()
        self.player.add(self.preview_tee)

        self.overlay.link(self.preview_tee)

        if self.input_type & MEDIA_AUDIO:
            self.convert = gst.element_factory_make("audioconvert", "convert")
            self.player.add(self.convert)

            self.effect[MEDIA_AUDIO] = effect.audio_effect.AudioEffect(
                    self.effect_name[MEDIA_AUDIO]
            )
            self.player.add(self.effect[MEDIA_AUDIO])

            self.audio_tee = gst.element_factory_make("tee", "audio_tee")
            self.player.add(self.audio_tee)

            self.volume = volume.Volume()
            self.player.add(self.volume)

            gst.element_link_many(
                    self.input_selector, self.volume,
                    self.effect[MEDIA_AUDIO], self.convert, self.audio_tee
            )
            self.input_selector.set_property(
                    "active-pad", self.audio_pads[self.audio_source]
            )
        added_encoders = {}

        pip_width = 0
        pip_height = 0

        for row in self.outputs.get_store():
            (name, output) = row

            output_bin = outputbin.OutputBin(output)
            self.output_bins[name] = output_bin
            self.player.add(output_bin)

            encoder_name = output.get_config()["parent"]

            encoder_item = self.encoders.get_item(encoder_name)
            if encoder_item is None:
                self.emit("error", "Please, add an encoder.")
                break

            if added_encoders.has_key(encoder_name):
                tee = added_encoders[encoder_name]

                tee.link(output_bin)
            else:
                tee = gst.element_factory_make("tee", None)
                self.player.add(tee)

                converter_item = encoder_item.parent
                converter = converter_item.create()
                if converter_item.config["width"] > pip_width:
                    pip_width = converter_item.config["width"]
                if converter_item.config["height"] > pip_height:
                    pip_height = converter_item.config["height"]
                self.player.add(converter)

                encoder = encoder_item.factory.create(type)
                if encoder.vorbisenc:
                    self.metadata = metadata.Metadata(encoder.vorbisenc)
                    self.metadata.set_tags(self.taglist)
                encoder.config(encoder_item.config)
                self.player.add(encoder)

                added_encoders[encoder_name] = tee
                self.preview_tee.get_src_pad().link(
                        converter.sink_pads().next()
                )
                gst.element_link_many(
                        converter, encoder, tee, output_bin
                )

                if self.input_type & MEDIA_AUDIO:
                    audio_queue = gst.element_factory_make("queue", None)
                    self.player.add(audio_queue)

                    gst.element_link_many(self.audio_tee, audio_queue, encoder)

        self.preview = Preview(self)
        self.player.add(self.preview)
        self.preview_tee.get_src_pad().link(self.preview.sink_pads().next())

        if pip_width == 0:
            pip_width = 320
            pip_height = 240
        self.pip.set_property("width", int(pip_width))
        self.pip.set_property("height", int(pip_height))

        self.video_width = int(pip_width)
        self.video_height = int(pip_height)
        self._set_watermark(self.video_width, self.video_height)

        self.overlay.set_property("text", self.overlay_text)
        if self.volume_value is not None:
            self.volume.set_property("volume", self.volume_value)

        self.emit("pipeline-ready")

        bus = self.player.get_bus()
        bus.add_signal_watch()
        bus.enable_sync_message_emission()
        bus.connect("message", self.on_message)
        bus.connect("sync-message::element", self.on_sync_message)
        cr = self.player.set_state(gst.STATE_PLAYING)
        if cr == gst.STATE_CHANGE_SUCCESS:
            self.emit("playing")
        elif cr == gst.STATE_CHANGE_ASYNC:
            self.pending_state = gst.STATE_PLAYING
Beispiel #11
0
# Add Aircraft section
aircraftFrame = aircraft.Aircraft(root, mainFrame)
aircraftFrame.grid(column=0, row=2, sticky='w')

# Add horizontal line
ttk.Separator(mainFrame, orient=HORIZONTAL).grid(column=0, row=3, sticky='ew')

# Add Origin Section
originFrame = origin.Origin(root, mainFrame)
originFrame.grid(column=0, row=4, sticky='w')

# Add horizontal line
ttk.Separator(mainFrame, orient=HORIZONTAL).grid(column=0, row=5, sticky='ew')

# Create Volumne section
volumeFrame = volume.Volume(root, mainFrame, originFrame)
volumeFrame.grid(column=0, row=6, sticky='w')
originFrame.volFrame = volumeFrame

# Add horizontal line
ttk.Separator(mainFrame, orient=HORIZONTAL).grid(column=0, row=7, sticky='ew')

# Create Generate section
generateFrame = tools.Generate(root, mainFrame, displayFrame, aircraftFrame,
                               originFrame, volumeFrame)
generateFrame.grid(column=0, row=8)

# Close on Escape
root.bind('<Key-Escape>', generateFrame.close)

# Change close function
Beispiel #12
0
def factory(bandlims, ns, shf = [0.0], gdtype = 'cartes'):
    
    res = None
    
    if 'cartes' == gdtype: 

        ct = ns[0]

        lim_t = ct * 4 - 1
        
        lbpar_t = cd.LbFixParams( [ct], [lim_t] )

        shf_t = shf[0]
        
        T = bandlims[0][1]
        
        dt = T / ct
        
        diff = [dt]
        shf = [shf_t]
        band = [T]
        
        ptpar = cd.PtFixParams(diff, shf, band)
        
        lb_t = cd.LbGen(lbpar_t)
        
        pt_t = cd.PtGen(ptpar)
        
        dim_lb = (0, 0)
        
        obj_lb = [lb_t]
        dims_lb = [dim_lb]
        
        mst_lb = mst.MdimStruct(obj_lb, dims_lb) 
        
        dims_pt = [ (0, 0) ]
        obj_pt = [pt_t]
        
        mst_pt = mst.MdimStruct(obj_pt, dims_pt)
        
        gen = gn.Generator(mst_lb, mst_pt)
        
        samps = gd.Grid(gen)
        
        shf = [0.0]
        
        ptpar = cd.PtFixParams(diff, shf, band)

        pt_t = cd.PtGen(ptpar)
        
        dims_pt = [ (0, 0) ]
        obj_pt = [pt_t]
        
        mst_pt = mst.MdimStruct(obj_pt, dims_pt)
        
        gen = gn.Generator(mst_lb, mst_pt)
        
        bounds = gd.Grid(gen)
                    
        bandstr = mst.MdimStruct( [ [0, T] ], [ (0,0) ] )
        
        res = Domain(samps, bounds, None, None, True, bandstr)
        
    elif 'polar' == gdtype:
        
        R = bandlims[0][1]
        A = bandlims[1][1]
        
        cr = int( ns[0] )
        ca = int( ns[1] )
        
        lim_r = cr * 4 - 1
        lim_a = ca * 2 - 1
        
        lbpar_r = pl.LbFixParams( [cr], [lim_r] )
        lbpar_a = pl.LbFixParams( [ca], [lim_a] )
        
        shf_r = shf[0]
        shf_a = shf[1]
        
        dr = R / cr
        da = A / ca
        
        diff = [dr, da]
        shf = [shf_r, shf_a]
        band = [R, A]
        
        ptpar = pl.PtFixParams(diff, shf, band)
        
        pol_lb_r = pl.PolarLbGen(lbpar_r)
        pol_lb_a = pl.PolarLbGen(lbpar_a)
        
        pol_pt = pl.PolarPtGen(ptpar)
        
        dim_lb_r = (0, 0)
        dim_lb_a = (1, 1)
        
        obj_lb = [pol_lb_r, pol_lb_a]
        dims_lb = [dim_lb_r, dim_lb_a]
        
        mst_lb = mst.MdimStruct(obj_lb, dims_lb) 
        
        dims_pt = [ (0, 1) ]
        obj_pt = [pol_pt]
        
        mst_pt = mst.MdimStruct(obj_pt, dims_pt)
        
        gen = gn.Generator(mst_lb, mst_pt)
        
        samps = gd.Grid(gen)
        
        shf_r = 0.0
        shf_a = 0.0
        
        ptpar = pl.PtFixParams(diff, shf, band)
        
        pol_pt = pl.PolarPtGen(ptpar)
        
        dims_pt = [ (0, 1) ]
        obj_pt = [pol_pt]
        
        mst_pt = mst.MdimStruct(obj_pt, dims_pt)
        
        gen = gn.Generator(mst_lb, mst_pt)
        
        bounds = gd.Grid(gen)

        volume = vol.Volume( mst.MdimStruct( [vol.sector], [ (0,1) ] ) )
        
        meas = ms.Measure( mst.MdimStruct( [ms.sector], [ (0,1) ] ) )
        
        bandstr = mst.MdimStruct( [ [0, R], [0, A] ], [ (0,0), (1,1) ] )
        
        res = Domain(samps, bounds, volume, meas, True, bandstr)
        
    else:
       
        pass 
    
    return res
Beispiel #13
0
 def reconnect(self,filename):
     self.volume = volume.Volume(filename)
     self.volume.reconnect()
Beispiel #14
0
 def format(self,filename):
     self.volume = volume.Volume(filename)
     self.volume.format()