def __init__(self, kind): self.kind = kind self.data = { 'primary': {decoder.mask2hex(mask): None for mask in kind.primary_masks}, 'inverse': {decoder.mask2hex(mask): None for mask in kind.inverse_masks} }
def hadamard_image(self, hadamard, name, delay = 1, measurements = 1, averaging_delay = 0, duty_cycle = False): #take_data = True, duty_cycle = False, cal = None, averaging = True, caching = True, f = '634ghz', attr = 's_db' ''' TO DO: implement modifiable duty_cyce NOTE: might have to change order of slides for variant = 'both' --> currently: all primary then all inverse future possibly: primary inverse primary inverse primary etc... ''' data = structure.image_data(hadamard, name) #if take_data: ppt = projector.PPT(hadamard) ppt.start_pres() time.sleep(5) start_time = 0 elapsed_time = 0 #take primary data if hadamard.variant == 'primary' or hadmard.variant == 'both': for x in range (0, hadamard.size): start_time = time.time() ppt.show_slide(x + 2) time.sleep(delay) measurement_list = [] for y in range (0, measurements): measurement_list.append(self.zva.get_network(name = 'measurement_' + str(y) + '.s1p')) time.sleep(averaging_delay) data.add_primary_data(decoder.mask2hex(hadamard.primary_masks[x]), measurement_list) elapsed_time = time.time() - start_time if duty_cycle: ppt.first_slide() time.sleep(elapsed_time) #take inverse data if hadamard.variant == 'inverse' or hadamard.variant == 'both': for x in range (0, hadamard.size): start_time = time.time() ppt.show_slide(hadamard.size + x + 2) time.sleep(delay) measurement_list = [] for y in range (0, measurements): measurement_list.append(self.zva.get_network(name = 'measurement_' + str(y) + '.s1p')) time.sleep(averaging_delay) data.add_inverse_data(decoder.mask2hex(hadamard.inverse_masks[x]), measurement_list) elapsed_time = time.time() - start_time if duty_cycle: ppt.first_slide() time.sleep(elapsed_time) projector.kill_pptx() ''' TO DO: implement variant options in decoder ''' return data
def __init__(self, kind, image_name): self.kind = kind self.image_name = image_name self.data = { 'primary': {decoder.mask2hex(mask): [] for mask in kind.primary_masks}, 'inverse': {decoder.mask2hex(mask): [] for mask in kind.inverse_masks} }
def walsh_image(self, walsh, name, delay=1, measurements=1, averaging_delay=0): ''' TO DO: implement variant and duty cycle stuff ''' data = structure.image_data(walsh, name) ppt = projector.PPT(walsh) ppt.start_pres() ppt.first_slide() time.sleep(5) for x in range(0, walsh.size): ppt.show_slide(x + 2) time.sleep(delay) measurement_list = [] for y in range(0, measurements): measurement_list.append( self.zva.get_network(name='measurement_' + str(y) + '.s1p')) time.sleep(averaging_delay) data.add_primary_data(decoder.mask2hex(walsh.primary_masks[x]), measurement_list) projector.kill_pptx() return data
def gen_walsh_set(self, walsh, canvas_size=1024): scale = walsh.scale / 100. raw_masks = walsh.primary_masks canvas_size = 1024 size = 2**walsh.rank total = size**2 + 1 Application = win32com.client.Dispatch('PowerPoint.Application') Presentation = Application.Presentations.Add() height = Presentation.PageSetup.SlideHeight width = Presentation.PageSetup.SlideWidth x_inc = height / size * scale y_inc = height / size * scale #TO DO: implement variant name = walsh.directory if not os.path.exists(name): os.mkdir(name) with open(name + '\\map.csv', 'wb') as outfile: fieldnames = ['slide', 'mask in hex'] writer = csv.DictWriter(outfile, fieldnames=fieldnames) writer.writeheader() count = 0 for k in range((len(raw_masks)) - 1, -1, -1): #make a slide slide = Presentation.Slides.Add(1, 12) #black background background = slide.ColorScheme.Colors(1).RGB = 0 for x in range(0, 2**walsh.rank): for y in range(0, 2**walsh.rank): if raw_masks[k][x][y] == 1: pixel = slide.Shapes.AddShape( msoShapeRectangle, (width - height * scale) / 2 + x * x_inc, (height - height * scale) / 2 + y * y_inc, x_inc, y_inc) pixel.Fill.ForeColor.RGB = rgb(255, 255, 255) pixel.Line.ForeColor.RGB = rgb(255, 255, 255) #write to csv map file (for decode) writer.writerow({ 'slide': total - count, 'mask in hex': decoder.mask2hex(raw_masks[k]) }) #add mask image to slide count += 1 #make last (first) slide slide = Presentation.Slides.Add(1, 12) #black background background = slide.ColorScheme.Colors(1).RGB = 0 #save and exit Presentation.SaveAs(walsh.path) os.system("taskkill /im powerpnt.exe /f")
def gen_walsh_set(self, walsh, canvas_size = 1024): scale = walsh.scale/100. raw_masks = walsh.primary_masks canvas_size = 1024 size = 2**walsh.rank total = size**2 + 1 Application = win32com.client.Dispatch('PowerPoint.Application') Presentation = Application.Presentations.Add() height = Presentation.PageSetup.SlideHeight width = Presentation.PageSetup.SlideWidth x_inc = height/size*scale y_inc = height/size*scale #TO DO: implement variant name = walsh.directory if not os.path.exists(name): os.mkdir(name) with open(name + '\\map.csv', 'wb') as outfile: fieldnames = ['slide', 'mask in hex'] writer = csv.DictWriter(outfile, fieldnames = fieldnames) writer.writeheader() count = 0 for k in range ((len(raw_masks)) - 1, -1, -1): #make a slide slide = Presentation.Slides.Add(1, 12) #black background background = slide.ColorScheme.Colors(1).RGB = 0 for x in range (0, 2**walsh.rank): for y in range(0, 2**walsh.rank): if raw_masks[k][x][y] == 1: pixel = slide.Shapes.AddShape(msoShapeRectangle, (width - height*scale)/2 + x*x_inc, (height - height*scale)/2 + y*y_inc, x_inc, y_inc) pixel.Fill.ForeColor.RGB = rgb(255, 255, 255) pixel.Line.ForeColor.RGB = rgb(255, 255, 255) #write to csv map file (for decode) writer.writerow({'slide': total - count, 'mask in hex': decoder.mask2hex(raw_masks[k])}) #add mask image to slide count += 1 #make last (first) slide slide = Presentation.Slides.Add(1, 12) #black background background = slide.ColorScheme.Colors(1).RGB = 0 #save and exit Presentation.SaveAs(walsh.path) os.system("taskkill /im powerpnt.exe /f")
def take_walsh_cal_set(self, walsh, delay = 0): ''' TO DO: implement duty cycle stuff and variant stuff ''' cals = structure.cal_set(walsh) ppt = projector.PPT(walsh) ppt.start_pres() time.sleep(5) for x in range (0, walsh.size): ppt.show_slide(x + 2) time.sleep(delay) cals.data['primary'][decoder.mask2hex(walsh.primary_masks[x])] = self.take_simple_cal() projector.kill_pptx() return cals
def take_walsh_cal_set(self, walsh, delay=0): ''' TO DO: implement duty cycle stuff and variant stuff ''' cals = structure.cal_set(walsh) ppt = projector.PPT(walsh) ppt.start_pres() time.sleep(5) for x in range(0, walsh.size): ppt.show_slide(x + 2) time.sleep(delay) cals.data['primary'][decoder.mask2hex( walsh.primary_masks[x])] = self.take_simple_cal() projector.kill_pptx() return cals
def take_hadamard_cal_set(self, hadamard, delay=0, duty_cycle=False): cals = structure.cal_set(hadamard) #if take_data: ppt = projector.PPT(hadamard) ppt.start_pres() raw_input('Press Enter to Continue...') start_time = 0 elapsed_time = 0 #take primary data if hadamard.variant == 'primary' or hadmard.variant == 'both': for x in range(0, hadamard.size): start_time = time.time() ppt.show_slide(x + 2) time.sleep(delay) cals.data['primary'][decoder.mask2hex( hadamard.primary_masks[x])] = self.take_simple_cal() elapsed_time = time.time() - start_time if duty_cycle: ppt.first_slide() time.sleep(elapsed_time) #take inverse data if hadamard.variant == 'inverse' or hadamard.variant == 'both': for x in range(0, hadamard.size): start_time = time.time() ppt.show_slide(hadamard.size + x + 2) time.sleep(delay) cals.data['primary'][mask2hex( hadamard.inverse_masks[x])] = self.take_simple_cal() elapsed_time = time.time() - start_time if duty_cycle: ppt.first_slide() time.sleep(elapsed_time) projector.kill_pptx() return cals
def walsh_image(self, walsh, name, delay = 1, measurements = 1, averaging_delay = 0): ''' TO DO: implement variant and duty cycle stuff ''' data = structure.image_data(walsh, name) ppt = projector.PPT(walsh) ppt.start_pres() ppt.first_slide() time.sleep(5) for x in range (0, walsh.size): ppt.show_slide(x + 2) time.sleep(delay) measurement_list = [] for y in range (0, measurements): measurement_list.append(self.zva.get_network(name = 'measurement_' + str(y) + '.s1p')) time.sleep(averaging_delay) data.add_primary_data(decoder.mask2hex(walsh.primary_masks[x]), measurement_list) projector.kill_pptx() return data
def take_hadamard_cal_set(self, hadamard, delay = 0, duty_cycle = False): cals = structure.cal_set(hadamard) #if take_data: ppt = projector.PPT(hadamard) ppt.start_pres() raw_input('Press Enter to Continue...') start_time = 0 elapsed_time = 0 #take primary data if hadamard.variant == 'primary' or hadmard.variant == 'both': for x in range (0, hadamard.size): start_time = time.time() ppt.show_slide(x + 2) time.sleep(delay) cals.data['primary'][decoder.mask2hex(hadamard.primary_masks[x])] = self.take_simple_cal() elapsed_time = time.time() - start_time if duty_cycle: ppt.first_slide() time.sleep(elapsed_time) #take inverse data if hadamard.variant == 'inverse' or hadamard.variant == 'both': for x in range (0, hadamard.size): start_time = time.time() ppt.show_slide(hadamard.size + x + 2) time.sleep(delay) cals.data['primary'][mask2hex(hadamard.inverse_masks[x])] = self.take_simple_cal() elapsed_time = time.time() - start_time if duty_cycle: ppt.first_slide() time.sleep(elapsed_time) projector.kill_pptx() return cals
def hadamard_image(self, hadamard, name, delay=1, measurements=1, averaging_delay=0, duty_cycle=False): #take_data = True, duty_cycle = False, cal = None, averaging = True, caching = True, f = '634ghz', attr = 's_db' ''' TO DO: implement modifiable duty_cyce NOTE: might have to change order of slides for variant = 'both' --> currently: all primary then all inverse future possibly: primary inverse primary inverse primary etc... ''' data = structure.image_data(hadamard, name) #if take_data: ppt = projector.PPT(hadamard) ppt.start_pres() time.sleep(5) start_time = 0 elapsed_time = 0 #take primary data if hadamard.variant == 'primary' or hadmard.variant == 'both': for x in range(0, hadamard.size): start_time = time.time() ppt.show_slide(x + 2) time.sleep(delay) measurement_list = [] for y in range(0, measurements): measurement_list.append( self.zva.get_network(name='measurement_' + str(y) + '.s1p')) time.sleep(averaging_delay) data.add_primary_data( decoder.mask2hex(hadamard.primary_masks[x]), measurement_list) elapsed_time = time.time() - start_time if duty_cycle: ppt.first_slide() time.sleep(elapsed_time) #take inverse data if hadamard.variant == 'inverse' or hadamard.variant == 'both': for x in range(0, hadamard.size): start_time = time.time() ppt.show_slide(hadamard.size + x + 2) time.sleep(delay) measurement_list = [] for y in range(0, measurements): measurement_list.append( self.zva.get_network(name='measurement_' + str(y) + '.s1p')) time.sleep(averaging_delay) data.add_inverse_data( decoder.mask2hex(hadamard.inverse_masks[x]), measurement_list) elapsed_time = time.time() - start_time if duty_cycle: ppt.first_slide() time.sleep(elapsed_time) projector.kill_pptx() ''' TO DO: implement variant options in decoder ''' return data
def __init__(self, kind): self.kind = kind self.name = kind.name self.data = {'primary' : {decoder.mask2hex(mask) : {} for mask in kind.primary_masks}, 'inverse' : {decoder.mask2hex(mask) : {} for mask in kind.inverse_masks}}
def __init__(self, kind, image_name): self.kind = kind self.image_name = image_name self.data = {'primary' : {decoder.mask2hex(mask) : [] for mask in kind.primary_masks}, 'inverse' : {decoder.mask2hex(mask) : [] for mask in kind.inverse_masks}}