def readobject(directory=None):
    # load this here to prevent circular
    from paramgrid import gridconfig

    if directory is None:
        directory = sys.argv[1]
    fname = os.path.abspath(directory) + os.sep + 'batch.pyobj'
    if not os.path.exists(fname):
        if gridconfig.pathIsGrid(directory):
            return gridconfig.makeGrid(directory,
                                       readOnly=True,
                                       interactive=False)
        return None
    try:
        config_dir = os.path.abspath(directory) + os.sep + 'config'
        if os.path.exists(config_dir):
            # set path in case using functions defined and hene imported from in settings file
            sys.path.insert(0, config_dir)
        with open(fname, 'rb') as inp:
            return pickle.load(inp)
    except Exception as e:
        print('Error lading cached batch object: %s', e)
        resetGrid(directory)
        if gridconfig.pathIsGrid(directory):
            return gridconfig.makeGrid(directory,
                                       readOnly=True,
                                       interactive=False)
        raise
Ejemplo n.º 2
0
def readobject(directory=None):
    # load this here to prevent circular
    from paramgrid import gridconfig

    if directory is None:
        directory = sys.argv[1]
    fname = os.path.abspath(directory) + os.sep + 'batch.pyobj'
    if not os.path.exists(fname):
        if gridconfig.pathIsGrid(directory):
            return gridconfig.makeGrid(directory, readOnly=True, interactive=False)
        return None
    try:
        with open(fname, 'rb') as inp:
            return pickle.load(inp)
    except:
        resetGrid(directory)
        if gridconfig.pathIsGrid(directory):
            return gridconfig.makeGrid(directory, readOnly=True, interactive=False)
        raise
Ejemplo n.º 3
0
def load_supported_grid(chain_dir):
    if is_grid_object(chain_dir):
        return chain_dir
    try:
        # If cosmomc is installed, e.g. to allow use of old Planck grids
        # The 2018 final Planck grid should be OK with getdist default chain grid below
        from paramgrid import gridconfig, batchjob
        if gridconfig.pathIsGrid(chain_dir):
            return batchjob.readobject(chain_dir)
    except ImportError:
        pass
    return None
Ejemplo n.º 4
0
def readobject(directory=None):
    # load this here to prevent circular
    from paramgrid import gridconfig

    if directory is None:
        directory = sys.argv[1]
    fname = os.path.abspath(directory) + os.sep + 'batch.pyobj'
    if not os.path.exists(fname):
        if gridconfig.pathIsGrid(directory):
            return gridconfig.makeGrid(directory, readOnly=True, interactive=False)
        return None
    try:
        config_dir = os.path.abspath(directory) + os.sep + 'config'
        if os.path.exists(config_dir):
            # set path in case using functions defined and hene imported from in settings file
            sys.path.insert(0, config_dir)
        with open(fname, 'rb') as inp:
            return pickle.load(inp)
    except Exception as e:
        print('Error lading cached batch object: %s', e)
        resetGrid(directory)
        if gridconfig.pathIsGrid(directory):
            return gridconfig.makeGrid(directory, readOnly=True, interactive=False)
        raise