|
18 | 18 |
|
19 | 19 | climada init |
20 | 20 | """ |
| 21 | +from shutil import copyfile |
| 22 | +from pathlib import Path |
21 | 23 |
|
22 | | -from .util.config import CONFIG, setup_conf_user, setup_logging |
23 | | -setup_conf_user() |
24 | | -setup_logging(CONFIG['global']['log_level']) |
| 24 | +from .util.config import CONFIG, setup_logging |
| 25 | +from .util.constants import * |
| 26 | + |
| 27 | + |
| 28 | +__all__ = ['init'] |
| 29 | + |
| 30 | + |
| 31 | +NGI_UNEP_DIR = SYSTEM_DIR.joinpath('ls_pr_NGI_UNEP') |
| 32 | +GSDP_DIR = SYSTEM_DIR.joinpath('GSDP') |
| 33 | + |
| 34 | +REPO_DATA = { |
| 35 | + 'data/system': [ |
| 36 | + ISIMIP_GPWV3_NATID_150AS, |
| 37 | + GLB_CENTROIDS_MAT, |
| 38 | + ENT_TEMPLATE_XLS, |
| 39 | + HAZ_TEMPLATE_XLS, |
| 40 | + RIVER_FLOOD_REGIONS_CSV, |
| 41 | + NATEARTH_CENTROIDS[150], |
| 42 | + NATEARTH_CENTROIDS[360], |
| 43 | + SYSTEM_DIR.joinpath('GDP2Asset_converter_2.5arcmin.nc'), |
| 44 | + SYSTEM_DIR.joinpath('WEALTH2GDP_factors_CRI_2016.csv'), |
| 45 | + SYSTEM_DIR.joinpath('GDP_TWN_IMF_WEO_data.csv'), |
| 46 | + SYSTEM_DIR.joinpath('FAOSTAT_data_country_codes.csv'), |
| 47 | + SYSTEM_DIR.joinpath('rcp_db.xls'), |
| 48 | + SYSTEM_DIR.joinpath('tc_if_cal_v01_TDR1.0.csv'), |
| 49 | + SYSTEM_DIR.joinpath('tc_if_cal_v01_EDR.csv'), |
| 50 | + SYSTEM_DIR.joinpath('tc_if_cal_v01_RMSF.csv'), |
| 51 | + ], |
| 52 | + 'data/system/ls_pr_NGI_UNEP': [ |
| 53 | + NGI_UNEP_DIR.joinpath('ls_pr_md.xml'), |
| 54 | + NGI_UNEP_DIR.joinpath('ls_pr.tfw'), |
| 55 | + NGI_UNEP_DIR.joinpath('ls_pr.tif'), |
| 56 | + NGI_UNEP_DIR.joinpath('ls_pr.xml'), |
| 57 | + ], |
| 58 | + 'data/system/GSDP': [ |
| 59 | + GSDP_DIR.joinpath(f'{cc}_GSDP.xls') |
| 60 | + for cc in ['AUS', 'BRA', 'CAN', 'CHE', 'CHN', 'DEU', 'FRA', 'IDN', 'IND', 'JPN', 'MEX', |
| 61 | + 'TUR', 'USA', 'ZAF'] |
| 62 | + ], |
| 63 | + 'data/demo': [ |
| 64 | + ENT_DEMO_TODAY, |
| 65 | + ENT_DEMO_FUTURE, |
| 66 | + EXP_DEMO_H5, |
| 67 | + HAZ_DEMO_FL, |
| 68 | + HAZ_DEMO_FLDDPH, |
| 69 | + HAZ_DEMO_FLDFRC, |
| 70 | + HAZ_DEMO_MAT, |
| 71 | + HAZ_DEMO_H5, |
| 72 | + TC_ANDREW_FL, |
| 73 | + DEMO_GDP2ASSET, |
| 74 | + DEMO_DIR.joinpath('demo_emdat_impact_data_2020.csv'), |
| 75 | + DEMO_DIR.joinpath('histsoc_landuse-15crops_annual_FR_DE_DEMO_2001_2005.nc'), |
| 76 | + DEMO_DIR.joinpath('hist_mean_mai-firr_1976-2005_DE_FR.hdf5'), |
| 77 | + DEMO_DIR.joinpath('FAOSTAT_data_producer_prices.csv'), |
| 78 | + DEMO_DIR.joinpath('FAOSTAT_data_production_quantity.csv'), |
| 79 | + DEMO_DIR.joinpath('lpjml_ipsl-cm5a-lr_ewembi_historical_2005soc_co2_yield-whe-noirr_annual_FR_DE_DEMO_1861_2005.nc'), |
| 80 | + DEMO_DIR.joinpath('h08_gfdl-esm2m_ewembi_historical_histsoc_co2_dis_global_daily_DEMO_FR_2001_2003.nc'), |
| 81 | + DEMO_DIR.joinpath('h08_gfdl-esm2m_ewembi_historical_histsoc_co2_dis_global_daily_DEMO_FR_2004_2005.nc'), |
| 82 | + DEMO_DIR.joinpath('gepic_gfdl-esm2m_ewembi_historical_2005soc_co2_yield-whe-noirr_global_DEMO_TJANJIN_annual_1861_2005.nc'), |
| 83 | + DEMO_DIR.joinpath('pepic_miroc5_ewembi_historical_2005soc_co2_yield-whe-firr_global_annual_DEMO_TJANJIN_1861_2005.nc'), |
| 84 | + DEMO_DIR.joinpath('pepic_miroc5_ewembi_historical_2005soc_co2_yield-whe-noirr_global_annual_DEMO_TJANJIN_1861_2005.nc'), |
| 85 | + DEMO_DIR.joinpath('WS_ERA40_sample.mat'), |
| 86 | + DEMO_DIR.joinpath('WS_Europe.xls'), |
| 87 | + ] + WS_DEMO_NC |
| 88 | +} |
| 89 | + |
| 90 | + |
| 91 | +def setup_climada_data(): |
| 92 | + |
| 93 | + for dirpath in [DEMO_DIR, SYSTEM_DIR, NGI_UNEP_DIR, GSDP_DIR]: |
| 94 | + dirpath.mkdir(parents=True, exist_ok=True) |
| 95 | + |
| 96 | + for src_dir, path_list in REPO_DATA.items(): |
| 97 | + for path in path_list: |
| 98 | + if not path.exists(): |
| 99 | + src = Path(__file__).parent.parent.joinpath(src_dir, path.name) |
| 100 | + copyfile(src, path) |
| 101 | + |
| 102 | + |
| 103 | +def init(): |
| 104 | + setup_climada_data() |
| 105 | + setup_logging(CONFIG.log_level.str()) |
| 106 | + |
| 107 | + |
| 108 | +init() |
0 commit comments