Exemple #1
0
def assess_bio_effects(bio_mod, eco_ref, sections, ndff_species, maps_dir):
    """
    Determine all effects for all measures.
    """
    bs_ref = biosafe.spatialBiosafe(bio_mod,
                                    eco_ref,
                                    sections,
                                    ndff_species,
                                    params=['FI', 'TFI'],
                                    toFiles=None)
    FI_ref, TFI_ref = bs_ref.spatial()
    TFI_ref.drop(['xcoor', 'ycoor'], axis=1, inplace=True)
    TFI_ref['msr'] = 'reference'
    FI_ref.drop(['xcoor', 'ycoor'], axis=1, inplace=True)
    FI_ref['msr'] = 'reference'
    FI_list, TFI_list = [FI_ref], [TFI_ref]
    measure_names = [
        f for f in os.listdir(maps_dir)
        if os.path.isdir(os.path.join(maps_dir, f))
    ]
    for msr_name in measure_names[:]:
        print msr_name
        measure_pathname = os.path.join(maps_dir, msr_name)
        assert os.path.isdir(measure_pathname) == True
        msr = measures.read_measure(measure_pathname)
        eco_map = pcr.cover(msr.ecotopes.pcr_map, ecotopes.pcr_map)
        msr_eco = measures.LegendMap(eco_map, ecotopes.legend_df)
        bs_msr = biosafe.spatialBiosafe(bio_mod,
                                        msr_eco,
                                        sections,
                                        ndff_species,
                                        params=['FI', 'TFI'],
                                        toFiles=None)
        FI_msr, TFI_msr = bs_msr.spatial()
        TFI_msr.drop(['xcoor', 'ycoor'], axis=1, inplace=True)
        TFI_msr['msr'] = msr_name
        FI_msr.drop(['xcoor', 'ycoor'], axis=1, inplace=True)
        FI_msr['msr'] = msr_name
        FI_list.append(FI_msr)
        TFI_list.append(TFI_msr)

    FI_all = pd.concat(FI_list)
    TFI_all = pd.concat(TFI_list)
    return FI_all, TFI_all
Exemple #2
0
def assess_effects(cost_types, maps_dir, cost_correction):
    """
    Determine all effects for all measures.
    """
    measure_names = [
        f for f in os.listdir(maps_dir)
        if os.path.isdir(os.path.join(maps_dir, f))
    ]

    cost_list = []
    std_list = []
    for msr_name in measure_names[:]:
        print(msr_name)
        measure_pathname = os.path.join(maps_dir, msr_name)
        measure = read_measure(measure_pathname)
        cost_all_types, std_all_types = assess_costs(cost_types, measure)
        cost_list.append(cost_all_types)
        std_list.append(std_all_types)

    cost_all_msrs = pd.concat(cost_list)
    std_all_msrs = pd.concat(std_list)
    cost_all_msrs.index.name = 'id'
    std_all_msrs.index.name = 'id'
    return cost_all_msrs, std_all_msrs
Exemple #3
0
    # Set earthwork values
    cost_input_ew = pd.read_csv(os.path.join(cost_dir, 'cost_ew.csv'),
                                index_col=0)
    cost_correction = pd.read_csv(os.path.join(cost_dir,
                                               'cost_correction.csv'),
                                  index_col=0,
                                  comment='#')

    #%% Test the cost calculation
    msr_name = 'sidechannel_everywhere'
    label = 'everywhere'
    msr_name = 'lowering_everywhere'
    label = 'everywhere'
    #msr_name = 'minemblowering_dummy-ID'
    #msr_name = 'groynelowering_dummy-ID'
    msr = read_measure(os.path.join(msr_map_dir, msr_name))
    printing = True
    dh = dem - msr.dem
    vtot = pcr.maptotal(dh * 25**2)
    pcr.aguila(dh)
    ### Smoothing
    c_sm = CostSmoothing('dummy', smoothing_distr)
    sm_cost, sm_std = c_sm.overview(msr)
    if printing == True:
        print(sm_cost)
        print(sm_std)

    ### Earth work
    c_ew = CostEarthwork(label, minemb_ext_use_distr, minemb_int_use_distr,
                         minemb_polluted_distr, dem, minemb, groyne,
                         pollution_zones, cost_input_ew)