Ejemplo n.º 1
0
 def write_ns_script_data(self, dir=None):
     path1 = os.path.join(dir, self.ns_name + '_ns.py')
     path2 = os.path.join(dir, self.ns_name + '_ns.dat')
     fid = open(path1, 'w')
     fid.write(self.ns_string)
     fid.close()
     import petram.helper.pickle_wrapper as pickle
     fid = open(path2, 'wb')
     pickle.dump(self.dataset, fid)
     fid.close()
Ejemplo n.º 2
0
    def OnCopyItemFromModelMult(self, evt):
        tree = self.tree
        items = tree.GetSelections()
        indices = [tree.GetIndexOfItem(ii) for ii in items]
        mm = [self.model.GetItem(ii) for ii in indices]
        base = [m.split_digits()[0] for m in mm]

        _copied_item = (base, mm)

        fid = open(petram_model_scratch, 'wb')
        pickle.dump(_copied_item, fid)
        fid.close()
Ejemplo n.º 3
0
    def save_to_file(self, path, meshfile_relativepath=False):
        import petram.helper.pickle_wrapper as pickle

        if meshfile_relativepath:
            for od in self.walk():
                if hasattr(od, 'use_relative_path'):
                    od.use_relative_path()
        pickle.dump(self, open(path, 'wb'))
        if meshfile_relativepath:
            for od in self.walk():
                if hasattr(od, 'use_relative_path'):
                    od.restore_fullpath()
Ejemplo n.º 4
0
    def save_scanner_data(self, solver):
        solver_name = solver.fullpath()
        data = self.list_data()
        dprint1("saving parameter", os.getcwd())
        try:
            from mpi4py import MPI
        except ImportError:
            from petram.helper.dummy_mpi import MPI
        myid = MPI.COMM_WORLD.rank

        if myid == 0:
            fid = open("parametric_data_" + solver_name, "wb")
            dd = {"name": solver_name, "data": data}
            pickle.dump(dd, fid)
            fid.close()

        MPI.COMM_WORLD.Barrier()
Ejemplo n.º 5
0
def save_test(model):
    from ifigure.widgets.dialog import writedir
    path = writedir(message='Enter Save dirctory')
    if path == '': return
    path = expanduser(path)

    for od in model.walk():
        if hasattr(od, 'use_relative_path'):
            mpath = od.get_real_path()
            od.use_relative_path()
            shutil.copyfile(mpath, os.path.join(path, os.path.basename(mpath)))

    try:
        pickle.dump(model, open(os.path.join(path, 'model.pmfm'), 'wb'))
        model.generate_script(dir=path, parallel=False, filename='model.py')

        model.generate_script(dir=path, parallel=True, filename='modelp.py')
    except:
        import traceback
        traceback.print_exc()

    for od in model.walk():
        if hasattr(od, 'use_relative_path'):
            od.restore_fullpath()