def toPropertyMap(self) -> PropertyMap: return PropertyMap({ "DefaultXYStage": Property(self.defaultXYStage), "DefaultZStage": Property(self.defaultZStage), "DevicePositions": PropertyMapArray([i.toPropertyMap() for i in self.stagePositions]), "GridCol": Property(0), "GridRow": Property(0), "Label": Property(self.label), "Properties": PropertyMap({}) })
def toPropertyMap(self) -> PropertyMap: """Returns the position list as a PropertyMap that is formatted just like a `PropertyMap` from Micro-Manager.""" pmap = PropertyMap({ "StagePositions": PropertyMapArray([i.toPropertyMap() for i in self.positions]) }) return pmap
def toPropertyMap(self) -> PropertyMap: return PropertyMap({ "Device": Property(self.stageName), "Position_um": PropertyArray([Property(self.x), Property(self.y)]), })
def load(cls, fileName: str) -> PositionList: return cls.fromPropertyMap(PropertyMap.loadFromFile(fileName))
annot.set_visible(True) fig.canvas.draw_idle() else: if vis: annot.set_visible(False) fig.canvas.draw_idle() fig.canvas.mpl_connect("motion_notify_event", hover) if __name__ == "__main__": path1 = r"PositionList.pos" path2 = r"PositionListOut.pos" ## Test that loading, mirroring, and then saving results in no changes to the position list. p = PropertyMap.loadFromFile(path1) pp = PositionList.fromPropertyMap(p) pp.mirrorX().mirrorY().mirrorX().mirrorY() ppp = pp.toPropertyMap() ppp.saveToFile(path2) with open(path1) as f1, open(path2) as f2: assert f1.read() == f2.read() def generateList(data: np.ndarray): """Example function to create a brand new position list in python.""" assert isinstance(data, np.ndarray) assert len(data.shape) == 2 assert data.shape[1] == 2 positions = [] for n, i in enumerate(data): positions.append(Position2d(*i, "TIXYDrive", f"Cell{n + 1}"))