def setup(): global PATH, CLASS os.environ["DATA_FILE"] = PATH if OUT is not None: os.environ["PROC_SAVE_PATH"] = OUT stringdat, dim = StringIO.load_strings() CLASS = classify(stringdat, dim) CLASS.calculate()
def setup(): global DIM, SU2, PERIODIC, SEED, UNI, SAVE_DIR random.seed(SEED) TIME = datetime.now().strftime("%H:%M:%S %d-%m-%Y") GAUGE = 'SU2' if SU2 else 'U1' # TODO os.environ["LOG_FILE"] = "data/testlog.log" os.environ["DATA_FILE"] = "{}/{}_{}_{}{}.dat".format( SAVE_DIR, DIM, "periodic" if PERIODIC else "normal", GAUGE, NCOUNT) dim = [DIM for i in range(3)] StringIO.format_new_string_save(TIME, SEED, DIM, PERIODIC, GAUGE) UNI = VUniverse(dim, su2=SU2) UNI.assign_vertices(periodic=PERIODIC) UNI.calculate_strings() UNI.save_state()
def add_source(self, src): data = StringIO.load_processed_data(src) for key, v in data.items(): if key in self._data: x, ys = self._data[key] y = [None for _ in x] for x2, y2 in zip(*v): try: ind = x.index(x2) except ValueError as e: x.append(x2) y.append(None) for others in ys: others.append(None) ind = -1 y[ind] = y2 ys.append(y) self._data[key] = (x, ys) else: self._data[key] = (v[0], [v[1]]) # [x1, x2 ..] [[1y1, 1y2, ..], [2y1, 2y2, ..]]
if len(sys.argv) == 3: if sys.argv[1] == 'dim': DIM = int(sys.argv[2]) TIME = datetime.now().strftime("%H:%M:%S %d-%m-%Y") GAUGE = 'SU2' if SU2 else 'U1' # TODO os.environ["LOG_FILE"] = "data/testlog.log" os.environ["DATA_FILE"] = "data/raw_5/{}_{}_{}_test.dat".format( DIM, "periodic" if PERIODIC else "normal", GAUGE) random.seed(SEED) dim = [DIM for i in range(3)] StringIO.format_new_string_save(TIME, SEED, DIM, PERIODIC, GAUGE) uni = VUniverse(dim, su2=SU2) uni.assign_vertices(periodic=PERIODIC) def d3plot(): fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ax.set_xlabel('X axis') ax.set_ylabel('Y axis') ax.set_zlabel('Z axis') ax.set_xlim3d(0, max(dim)) ax.set_ylim3d(0, max(dim)) ax.set_zlim3d(0, max(dim))
from cosmicstrings.io import StringIO from cosmicstrings.classifiers import classify import sys import os import matplotlib.pyplot as plt os.environ["DATA_FILE"] = 'data/raw_1/100_normal_test.dat' os.environ["PROC_SAVE_PATH"] = "data/proc/" stringdat, dim = StringIO.load_strings() c = classify(stringdat, dim) c.calculate() c.plotl2(startn=2, endn=20) c.plotperimeter() c.plotvol2surf() c.plotperim2dens(maxp=30) c.plotlength2dens(maxp=40) c.save_data_to_file() #l = classify() #l.load_file_to_data("data/proc/10testproc.dat") plt.show()
def load_file_to_data(self, file): self._fdata.append(StringIO.load_processed_data(file)) print(self._fdata)
def save_data_to_file(self): time = datetime.datetime.now().strftime("%H:%M:%S %d-%m-%Y") StringIO.format_new_proc_save(time) StringIO.save_processed_data(self._data)
def save_state(self): StringIO.save_strings(self.strings)