def download_landscape_name(name_model: str):
    """Download an specific trained model"""
    try:
        if name_model not in landscape_models:
            logger.warning(
                "\n Model with name '%s' not available for download. "
                "\n Available models are %s" %
                (name_model, str(landscape_models)))
            return False

        loc_dir = _test_data.get(
            "landscape_generation") + "checkpoints" + os.sep + name_model
        if not os.path.isdir(loc_dir):
            os.mkdir(loc_dir)

        pos = [
            i for i in range(len(landscape_models))
            if name_model == landscape_models[i]
        ][0]
        pooch_landscape = create_pooch(landscape_urls[pos], landscape_data,
                                       loc_dir)

        for file in landscape_data:
            pooch_landscape.fetch(file, downloader=download)
        logger.info("Model %s downloaded for landscape generation" %
                    name_model)

    except Exception as e:
        logger.error(e, exc_info=True)
def download_example_gempy_model():
    """Dowload data for construction of example models with gempy"""
    try:
        pooch_gempy_example = create_pooch(
            gempy_example_models_url, gempy_example_models,
            _test_data.get("gempy_example_data"))
        pooch_gempy_example2 = create_pooch(
            gempy_example_models_url2, gempy_example_models2,
            _test_data.get("gempy_example_data"))
        for file in gempy_example_models:
            pooch_gempy_example.fetch(file, downloader=download)
        for file in gempy_example_models2:
            pooch_gempy_example2.fetch(file, downloader=download)
        logger.info("Data for gempy example models downloaded")
    except Exception as e:
        logger.error(e, exc_info=True)
def download_benisson_model():
    """Dowload data for construction of Benisson model with gempy"""
    try:
        pooch_gempy = create_pooch(gempy_benisson_url, gempy_benisson,
                                   _test_data.get("gempy_data"))
        for file in gempy_benisson:
            pooch_gempy.fetch(file, downloader=download)
        logger.info("Data for benisson model downloaded")
    except Exception as e:
        logger.error(e, exc_info=True)
def download_landslides_data():
    """Download all available to display the landslide simulations """
    try:
        pooch_landslides_dem = create_pooch(landslides_dems_url,
                                            landslides_dems,
                                            _test_data.get("landslide_topo"))
        pooch_landslides_area = create_pooch(
            landslides_areas_url, landslides_areas,
            _test_data.get("landslide_release"))
        pooch_landslides_sim = create_pooch(
            landslides_results_url, landslides_results,
            _test_data.get("landslide_simulation"))

        for file in landslides_dems:
            pooch_landslides_dem.fetch(file, downloader=download)
        for file in landslides_areas:
            pooch_landslides_area.fetch(file, downloader=download)
        for file in landslides_results:
            pooch_landslides_sim.fetch(file, downloader=download)
        logger.info("Data for landslides downloaded")
    except Exception as e:
        logger.error(e, exc_info=True)
def download_test_data():
    """
    Download all data for testing
    Returns:

    """
    try:
        pooch_data = create_pooch(tests_url, tests, _test_data.get("test"))
        for file in tests:
            pooch_data.fetch(file, downloader=download)
        logger.info("Data for testing downloaded")
    except Exception as e:
        logger.error(e, exc_info=True)
def download_topography_data():
    """
    Download all available DEMs to SaveTopoModule
    Returns:

    """
    try:
        pooch_topo = create_pooch(topomodule_url, topomodule_files,
                                  _test_data.get("topo"))
        for file in topomodule_files:
            pooch_topo.fetch(file, downloader=download)
        logger.info("Data for topography downloaded")
    except Exception as e:
        logger.error(e, exc_info=True)
import os
import gempy as gp
from sandbox import _test_data

os.environ["THEANO_FLAGS"] = "mode=FAST_RUN"
all_models = [
    'Horizontal_layers', 'Recumbent_fold', 'Anticline', 'Pinchout', 'Fault',
    'Unconformity'
]
# Not used since some devices are made to be used offline
# data_path = 'https://raw.githubusercontent.com/cgre-aachen/gempy_data/master/'
# path_to_data = data_path + "/data/input_data/jan_models/"

path_to_data = _test_data.get('gempy_example_data')


def create_model_dict(model_name: list = all_models, **kwargs):
    """
    Create all the example models for the gempy module and stores them in a dictionary
    Returns:
        Dictionary with all the gempy models
    """
    model_dict = {}
    for model in model_name:
        model_dict.update({model: create_example_model(model, **kwargs)})
    return model_dict


def create_example_model(name,
                         extent=[0, 1000, 0, 1000, 0, 1800],
                         do_sections=False,