Beispiel #1
0
ens_dir = os.path.join(output_dir, 'measures_ensemble02')
ens_map_dir = os.path.join(ens_dir, 'maps')
ens_FM_dir = os.path.join(ens_dir, 'hydro')
ens_overview_dir = os.path.join(ens_dir, 'overview')

scratch_dir = os.path.join(root_dir, 'scratch')
clone_file = os.path.join(ref_map_dir, 'clone.map')
pcr.setclone(clone_file)
pcr.setglobaloption('unittrue')
os.chdir(scratch_dir)
ppp
#%% Initialize BIOSAFE
ndff_species = pd.read_pickle(os.path.join(bio_dir, 'ndff_sub_BS_13.pkl'))
flpl_sections = pcr.readmap(os.path.join(bio_dir, 'flpl_sections.map'))
ecotopes = measures.read_map_with_legend(os.path.join(bio_dir, 'ecotopes.map'))
legalWeights, linksLaw, linksEco = bsIO.from_csv(bio_dir)
speciesPresence = pd.DataFrame(np.random.randint(2, size=len(linksLaw)),\
                    columns=['speciesPresence'], \
                    index=linksLaw.index)
ecotopeArea = pd.DataFrame(np.ones(82) * 1e5,\
                           columns = ['area_m2'],\
                           index = linksEco.columns.values[0:-1])

bs = biosafe.biosafe(legalWeights, linksLaw, linksEco, speciesPresence,
                     ecotopeArea)
excel_file = os.path.join(bio_dir, 'BIOSAFE_20150629.xlsx')
lut1 = pd.read_excel(excel_file, sheetname='lut_RWES').fillna(method='ffill')
# this lookup table has:
#       ecotope codes of BIOSAFE in the first column: oldEcotope
#       aggregated/translated ectotopes in the second column: newEcotope
linksEco1 = biosafe.aggregateEcotopes(linksEco, lut1)
Beispiel #2
0
        FTEI = 100 * self.TEI() * ecoAreas['fraction']
        return FTEI.fillna(0)
        
if __name__ == '__main__':
    #%% initiate biosafe 
    
    # Directory settings
    root_dir = os.path.dirname(os.getcwd())
    scratch_dir = os.path.join(root_dir, 'scratch')
    input_dir  = os.path.join(root_dir, 'inputData')
    os.chdir(scratch_dir)
    
    # Input data
    excelFile = os.path.join(input_dir, 'BIOSAFE_20150629.xlsx')
    #bsIO.xlsxToCsv(excelFile, scratch_dir)
    legalWeights, linksLaw, linksEco = bsIO.from_csv(input_dir)
    speciesPresence = pd.DataFrame(np.random.randint(2, size=len(linksLaw)),\
                        columns=['speciesPresence'], \
                        index=linksLaw.index)
    ecotopeArea = pd.DataFrame(np.ones(82) * 1e5,\
                               columns = ['area_m2'],\
                               index = linksEco.columns.values[0:-1])
    
    ndff_species = pd.read_pickle(os.path.join(input_dir, 'ndff_sub_BS_13.pkl'))
    flpl_sections_f = os.path.join(input_dir, 'flpl_sections.map')
    pcr.setclone(flpl_sections_f)
    flpl_sections = pcr.readmap(flpl_sections_f)
    ecotopes = read_map_with_legend(os.path.join(input_dir, 'ecotopes.map'))
    
    #%% test a single instance of biosafe
    legalWeights, linksLaw, linksEco = bsIO.from_csv(input_dir)