def scan_map(map_path, resource_dir = None): """ 扫描处理指定.map文件 """ print "scan map: " + map_path collect_images, map_width, map_height, lp, rp = read_map(map_path) print collect_images if resource_dir != None: for image_info in collect_images: image_name = image_info["image"] dir_name = image_name.split("_")[0] image_path = os.path.join(resource_dir, dir_name, image_name) image_info["image"] = image_path print collect_images collect_image, lt, rb = splice_images(collect_images, map_width, map_height) out_path = os.path.join(os.path.dirname(map_path), "data") if os.path.exists(out_path): os.remove(out_path) out_file = FileWriter(out_path) # 地图整体长宽 out_file.WriteInt(map_width) out_file.WriteInt(map_height) # 可破坏区域的长宽,在拼好的图片的图片区域内给出 rect = Rect((0, 0, collect_image.size[0], collect_image.size[1])) if lt.x < 0: rect.x0 = -lt.x if lt.y < 0: rect.y0 = -lt.y if rb.x > map_width: rect.x1 = collect_image.size[0] - (rb.x - map_width) if rb.y > map_height: rect.y1 = collect_image.size[1] - (rb.y - map_height) print "destory rect: " + str(rect) print "LT: " + str(lt) + " RB: " + str(rb) + " collect WH: " + str(collect_image.size[0]) + " " + str(collect_image.size[1]) # 写入破坏区域大小 out_file.WriteInt(rect.width) out_file.WriteInt(rect.height) # 可破坏区域的坐标信息 # 给出可破坏区/扫瞄区的左下点相对于整个地图的左下点的定位信息 if lt.x < 0: left = 0; else: left = lt.x if rb.y > map_height: right = 0 else: right = map_height - rb.y out_file.WriteInt(left) out_file.WriteInt(right) crop_image = collect_image.crop(rect.get_rect()) # crop_image.save("out.png") print crop_image write_collect_bits(out_file, crop_image, 1) # 玩家定位数据 # if len(lp) != 0 or len(rp) != 0: # out_file.WriteInt(1) # # out_file.WriteInt(len(lp)) # for p in lp: # out_file.WriteInt(p.x) # out_file.WriteInt(p.y) # # out_file.WriteInt(len(rp)) # for p in rp: # out_file.WriteInt(p.x) # out_file.WriteInt(p.y) # else: # out_file.WriteInt(0) out_file.close()
message.append(b_val) message.append(b_err) message[-1] = message[-1]+"\n" allattempts.append(message) fw.writeList(message) print "Run #"+str(i+1) print "dGf: "+dGf_val+" +/- "+dGf_err print " m: "+m_val+" +/- "+m_err print "C12: "+chalf_val+"+/-"+chalf_err print " b: "+b_val+"+/-"+b_err print "" numSuccess += 1 fw.close() if runFigs: for i in range(data.size): numberToView = i+2 if numberToView == -1: raise SystemExit print "Drawing Fig"+str(numberToView)+".png" plottedYData = [float(x) for x in allattempts[numberToView - 2][4:4+numberDenaturants]] A = float(allattempts[numberToView-2][4+numberDenaturants]) B = float(allattempts[numberToView-2][5+numberDenaturants]) m_val = float(allattempts[numberToView-2][8+numberDenaturants]) plottedXData = np.linspace(xdata[0], xdata[-1], num = 100) params = (float(allattempts[numberToView-2][6+numberDenaturants]), m_val) chalf_val = float(allattempts[numberToView-2][10+numberDenaturants]) ylim =[min(plottedYData)*0.8, max(plottedYData)*1.2]