def test_azAngs_from_hexaPositionOffset_against_specimen_values( self, all_magnets_after_allocation, config, specimen_values_hexaPositionOffset): all_magnets_updated = offsets.hexaPositionOffset( all_magnets_after_allocation, config['offsetFile']) for specimen, test in zip(specimen_values_hexaPositionOffset, all_magnets_updated): assert np.allclose(specimen.azAngs, test.azAngs)
def allocate_hexabundles_for_single_tile(self, tile_number, plot=False): ### FIXME- add documentation here # fileNameGuides = ('GAMA_'+batch+'/Configuration/HECTORConfig_Guides_GAMA_'+batch+'_tile_%03d.txt' % (tileNum)) fileNameGuides = f"{self.configuration_location}/HECTORConfig_Guides_{self.config['output_filename_stem']}_tile_{tile_number:03d}.txt" # proxy file to arrange guides in required format to merge with hexa probes proxyGuideFile = f'{self.allocation_files_location_base}/newfile.txt' # Adding ID column and getting rid of the header line of Guides cluster to add to the hexa cluster file_arranging.arrange_guidesFile(fileNameGuides, proxyGuideFile) # fileNameHexa = ('GAMA_'+batch+'/Configuration/HECTORConfig_Hexa_GAMA_'+batch+'_tile_%03d.txt' % (tileNum)) fileNameHexa = f"{self.configuration_location}/HECTORConfig_Hexa_{self.config['output_filename_stem']}_tile_{tile_number:03d}.txt" plate_file = f"{self.allocation_files_location_base}/Hexa_and_Guides_{self.config['output_filename_stem']}_tile_{tile_number:03d}.txt" # plate_file = get_file('GAMA_'+batch+'/Output/Hexa_and_Guides_GAMA_'+batch+'_tile_%03d.txt' % (tileNum)) #### Offset function: thermal coefficient based movement of magnet pair as a whole plate_file,magnetPair_offset = offsets.magnetPair_radialPositionOffset(plate_file) # Adding guides cluster txt file to hexa cluster txt file file_arranging.merge_hexaAndGuides(fileNameHexa, proxyGuideFile, plate_file) # extracting all the magnets and making a list of them from the plate_file all_magnets = extract_data.create_list_of_all_magnets_from_file(extract_data.get_file(plate_file), magnetPair_offset) #### Offset functions- still a work in progress- need to determine input source and add column to output file all_magnets = offsets.hexaPositionOffset(all_magnets) # create magnet pickup areas for all the magnets plots.create_magnet_pickup_areas(all_magnets) if plot: #************** # creating plots and drawing pickup areas plt.clf() plt.close() HECTOR_plate().draw_circle('r') plots.draw_magnet_pickup_areas(all_magnets, '--c') #************** # test for collision and detect magnets which have all pickup directions blocked conflicted_magnets = conflicts.functions.find_all_blocked_magnets(all_magnets) # create a list of the fully blocked magnets fully_blocked_magnets = conflicts.functions.create_list_of_fully_blocked_magnets(conflicted_magnets) fully_blocked_magnets_dictionary = conflicts.functions.blocking_magnets_for_fully_blocked_magnets(conflicted_magnets) # print the fully blocked magnets out in terminal and record in conflicts file conflictsRecord = f'{self.allocation_files_location_base}/Conflicts_Index.txt' conflicts.blocked_magnet.print_fully_blocked_magnets(fully_blocked_magnets,conflictsRecord, fileNameHexa) conflictFile = f'{self.allocation_files_location_base}/unresolvable_conflicts.txt' flagsFile = f'{self.allocation_files_location_base}/Flags.txt' #*** Choose former method OR median method OR larger bundle prioritized method for hexabundle allocation *** positioning_array,self.galaxyIDrecord = position_ordering.create_position_ordering_array(all_magnets, fully_blocked_magnets, conflicted_magnets, self.galaxyIDrecord, self.config['output_filename_stem'], tile_number, conflictFile, flagsFile) if plot: # draw all the magnets in the plots created earlier figureFile = f"{self.plot_location}/savedPlot_{self.config['output_filename_stem']}_tile_{tile_number:03d}.pdf" plots.draw_all_magnets(all_magnets, self.config['output_filename_stem'], tile_number,figureFile) #*********** # checking positioning_array prints out all desired parameters print(positioning_array) # insert column heading and print only rectangular magnet rows in the csv file newrow = ['Magnet', 'Label', 'Center_x', 'Center_y', 'rot_holdingPosition', 'rot_platePlacing', 'order', 'Pickup_option', 'ID','Index', 'Hexabundle'] newrow_circular = ['Magnet', 'Label', 'Center_x', 'Center_y', 'holding_position_ang', 'plate_placement_ang', 'order', 'Pickup_option', 'ID', 'Index', 'Hexabundle'] # final two output files outputFile = f"{self.allocation_files_location_tiles}/Hexa_and_Guides_with_PositioningArray_{self.config['output_filename_stem']}_tile_{tile_number:03d}.txt" robotFile = f"{self.allocation_files_location_tiles}/Robot_{self.config['output_filename_stem']}_tile_{tile_number:03d}.txt" # creating robotFile array and storing it in robot file positioning_array, robotFilearray = file_arranging.create_robotFileArray(positioning_array,robotFile,newrow,fully_blocked_magnets_dictionary) # adjusting the positioning array to merge only selected parameters to the output file positioning_array, positioning_array_circular = file_arranging.positioningArray_adjust_and_mergetoFile(positioning_array, plate_file, outputFile, newrow,newrow_circular) # produce final files with consistent layout and no extra commas file_arranging.finalFiles(outputFile, robotFile)