Beispiel #1
0
                if fix_zeros:
                    exposure_tmp.value[exposure_tmp.value<1] = 1
                # exposure_tmp.plot_raster(res=RES_ARCSEC/3600, save_tiff=\
                #                          os.path.join(RES_DIR, '%s_%ias.tiff' %(fi[0:-4], RES_ARCSEC)))
                exposure_tmp.plot_raster(res=RES_ARCSEC/3600, raster_res=res_target/3600, save_tiff=\
                                         os.path.join(RES_DIR, '%s_%ias.tiff' %(fi[0:-4]+fadd, res_target)))

"""COMBINE AND PLOT EXPOSURE AT TARGET RESOLUTION:"""
print('\n' + '\x1b[1;03;30;30m' + 'COMBINE AND PLOT EXPOSURE AT TARGET RESOLUTION' + '\x1b[0m')
for res_target in res_targets:
    exposure_data = Exposures()
    for idx, fi in enumerate(files):
        exposure_tmp = Exposures()
        if try_read_from_tiff and os.path.exists(os.path.join(RES_DIR, '%s_%ias.tiff' %(fi[0:-4]+fadd, res_target))):
            print('\n' + '\x1b[1;03;30;30m' + 'Loading: %s_%ias.tiff' %(fi[0:-4]+fadd, res_target) + '\x1b[0m')
            exposure_tmp.set_from_raster(os.path.join(RES_DIR, '%s_%ias.tiff' %(fi[0:-4]+fadd, res_target)))
            exposure_tmp = Exposures(exposure_tmp)
            exposure_tmp.set_geometry_points() # set geometry attribute (shapely Points) from GeoDataFrame from latitude and longitude
            exposure_tmp.check() # puts metadata that has not been assigned
            exposure_data = exposure_data.append(exposure_tmp)
            if fix_zeros:
                exposure_tmp.value[exposure_tmp.value<plot_minimum] = plot_minimum
        else:
            print('\n' + '\x1b[1;03;30;30m' + 'ERROR Loading: %s_%ias.tiff' %(fi[0:-4]+fadd, res_target) + '\x1b[0m')
        
    print('\n' + '\x1b[1;03;30;30m' + 'Checking combined data...' + '\x1b[0m')
    exposure_data.check()
    if write_to_tiff:
        print('\n' + '\x1b[1;03;30;30m' + 'Writing combined data to TIFF...' + '\x1b[0m')
        exposure_data.plot_raster(res=res_target/3600, raster_res=res_target/3600, save_tiff=\
            os.path.join(RES_DIR, '%s_000_%ias.tiff' %(files[0][0:-8]+fadd, res_target)))
Beispiel #2
0
    if_fl.tag.description = '1m step function'
    if_fl.append(if_1m)

    return if_fl

ifs_step = iffl()

yy_start = 106
yy_end = 116

idx_band = 1

exp = Exposures()

ssp_file = EXP_POP_PTH +'baseYr_total_2000.tif'
exp.set_from_raster(ssp_file, transform=DST_META['transform'], height=DST_META['height'], 
                width=DST_META['width'], resampling=Resampling.average)

exp.value *= 25     # sum of the grids after upscaling
if np.any(exp.value<0) == True:
    raise ValueError
exp.value_unit = 'N people per pixel'
exp.ref_year = 2000
exp[INDICATOR_CENTR+HAZ_TYPE] = np.arange(len(exp), dtype=int)
exp[INDICATOR_IF+HAZ_TYPE] = np.ones(len(exp), dtype=int)
exp.check()

for year in YEAR:    
    
    imp_model = []  # initite a list fro all models in one year
    imp_save = None