예제 #1
0
    def create_editables(store_dir, config, force=False, extra=None):
        try:
            util.ensuredir(store_dir)
        except:
            raise CannotCreate('cannot create directory %s' % store_dir)

        fns = []

        config_fn = os.path.join(store_dir, 'config')
        remove_if_exists(config_fn, force)
        meta.dump(config, filename=config_fn)

        fns.append(config_fn)

        for sub_dir in ['extra']:
            dpath = os.path.join(store_dir, sub_dir)
            remake_dir(dpath, force)

        if extra:
            for k, v in extra.iteritems():
                check_string_id(k)
                fn = os.path.join(store_dir, 'extra', k)
                remove_if_exists(fn, force)
                meta.dump(v, filename=fn)

                fns.append(fn)

        return fns
예제 #2
0
    def create_editables(store_dir, config, force=False, extra=None):
        try:
            util.ensuredir(store_dir)
        except:
            raise CannotCreate('cannot create directory %s' % store_dir)

        fns = []

        config_fn = os.path.join(store_dir, 'config')
        remove_if_exists(config_fn, force)
        meta.dump(config, filename=config_fn)

        fns.append(config_fn)

        for sub_dir in ['extra']:
            dpath = os.path.join(store_dir, sub_dir)
            remake_dir(dpath, force)

        if extra:
            for k, v in extra.iteritems():
                check_string_id(k)
                fn = os.path.join(store_dir, 'extra', k)
                remove_if_exists(fn, force)
                meta.dump(v, filename=fn)

                fns.append(fn)

        return fns
예제 #3
0
    def create(store_dir, meta, force=False, extra=None):
        '''Create new GF store.
        
        Creates a new GF store at path `store_dir`. The layout of the GF is
        defined with the parameters given in `meta`, which should be an
        object of a subclass of :py:class:`pyrocko.gf.meta.GFSet`. This function will
        refuse to overwrite an existing GF store, unless `force` is set  to
        ``True``. If more information, e.g. parameters used for the modelling
        code, earth models or other, should be saved along with the GF store,
        these may be provided though a dict given to `extra`. The keys of 
        this dict must be names and the values must be *guts* type objects.
        '''

        store = Store_.create(store_dir, meta.deltat, meta.nrecords, 
                force=force)

        meta_fn = os.path.join(store_dir, 'meta')
        remove_if_exists(meta_fn, force)

        meta_module.dump(meta, filename=meta_fn)

        for sub_dir in 'decimated', 'extra':
            dpath = os.path.join(store_dir, sub_dir)
            if os.path.exists(dpath):
                if force:
                    shutil.rmtree(dpath)
                else:
                    raise CannotCreate('directory %s already exists' % dpath)

            os.mkdir(dpath)

        if extra:
            for k,v in extra.iteritems():
                check_string_id(k)
                fn = os.path.join(store_dir, 'extra', k)
                remove_if_exists(fn, force)
                meta_module.dump(v, filename=fn)
예제 #4
0
 def save_config(self):
     config_fn = os.path.join(self.store_dir, 'config')
     meta.dump(self.config, filename=config_fn)
예제 #5
0
    def save_config(self, make_backup=False):
        config_fn = os.path.join(self.store_dir, 'config')
        if make_backup:
            os.rename(config_fn, config_fn + '~')

        meta.dump(self.config, filename=config_fn)