In [1]:
import logging
import numpy as np
import pandas as pd
root = logging.getLogger()
root.addHandler(logging.StreamHandler())
import datetime
%matplotlib inline
from shapely.prepared import prep
from shapely import speedups
speedups.enable()
from iSDM.environment import RealmsLayer

In [2]:
freshwater_ecoregions = RealmsLayer(file_path="../data/freshwater_ecoregions/")
freshwater_ecoregions.load_data()
freshwater_ecoregions_data = freshwater_ecoregions.get_data()


Loading data from ../data/freshwater_ecoregions/ 
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-2-040d1dd5432f> in <module>()
      1 freshwater_ecoregions = RealmsLayer(file_path="../data/freshwater_ecoregions/")
----> 2 freshwater_ecoregions.load_data()
      3 freshwater_ecoregions_data = freshwater_ecoregions.get_data()

/home/daniela/anaconda/envs/biodiversity_py3/lib/python3.4/site-packages/iSDM-0.0.1-py3.4.egg/iSDM/environment.py in load_data(self, file_path)
    764 
    765         logger.info("Loading data from %s " % self.file_path)
--> 766         self.data_full = GeoDataFrame.from_file(self.file_path)
    767         self.data_full.columns = [x.lower() for x in self.data_full.columns]
    768         logger.info("The shapefile contains data on %d environmental regions." % self.data_full.shape[0])

/home/daniela/anaconda/envs/biodiversity_py3/lib/python3.4/site-packages/geopandas/geodataframe.py in from_file(cls, filename, **kwargs)
    159 
    160         """
--> 161         return geopandas.io.file.read_file(filename, **kwargs)
    162 
    163     @classmethod

/home/daniela/anaconda/envs/biodiversity_py3/lib/python3.4/site-packages/geopandas/io/file.py in read_file(filename, **kwargs)
     18         else:
     19             f_filt = f
---> 20         gdf = GeoDataFrame.from_features(f, crs=crs)
     21 
     22     return gdf

/home/daniela/anaconda/envs/biodiversity_py3/lib/python3.4/site-packages/geopandas/geodataframe.py in from_features(cls, features, crs)
    171         """
    172         rows = []
--> 173         for f in features:
    174             if hasattr(f, "__geo_interface__"):
    175                 f = f.__geo_interface__

fiona/ogrext.pyx in fiona.ogrext.Iterator.__next__ (fiona/ogrext.c:17244)()

fiona/ogrext.pyx in fiona.ogrext.FeatureBuilder.build (fiona/ogrext.c:3254)()

IndexError: list index out of range

In [3]:
import fiona
from shapely.geometry import mapping, shape
from fiona import collection
with fiona.open("../data/freshwater_ecoregions/feow_hydrosheds.shp", 'r') as src:
    for feature in src:
        print(feature)


---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-3-1a07d7720e51> in <module>()
      3 from fiona import collection
      4 with fiona.open("../data/freshwater_ecoregions/feow_hydrosheds.shp", 'r') as src:
----> 5     for feature in src:
      6         print(feature)

fiona/ogrext.pyx in fiona.ogrext.Iterator.__next__ (fiona/ogrext.c:17244)()

fiona/ogrext.pyx in fiona.ogrext.FeatureBuilder.build (fiona/ogrext.c:3254)()

IndexError: list index out of range

This is most likely due to fiona not yet supporting GDAL 2 (there is an open pull request). Try downgrading to GDAL 1.11 and let us know if that fixes the problem.

The issue does exist because fiona is not 100% OK with gdal 2.0.0. Try directly OGR/GDAL

awesome, works


In [28]:
import ogr, gdal, osr
source_ds = ogr.Open("../data/freshwater_ecoregions/feow_hydrosheds.shp")
source_layer = source_ds.GetLayer()

In [29]:
source_layer


Out[29]:
<osgeo.ogr.Layer; proxy of <Swig Object of type 'OGRLayerShadow *' at 0x7fe9ae61bae0> >

In [30]:
pixelWidth = pixelHeight = 0.0083333333  # around 2GB for a global file at this resolution using UInt16 (2 bytes)
x_min, y_min, x_max, y_max = -180, -90, 180, 90
cols = int((x_max - x_min) / pixelHeight)
rows = int((y_max - y_min) / pixelWidth)
# GDT_Byte buffer will map all values greater than 255 to 255
target_ds = gdal.GetDriverByName('GTiff').Create('../data/freshwater_ecoregions/freshwater_ecoregions.tif', cols, rows, 1, gdal.GDT_UInt16) 
target_ds.SetGeoTransform((x_min, pixelWidth, 0, y_max, 0, -pixelHeight))
band = target_ds.GetRasterBand(1)
NoData_value = 0
band.SetNoDataValue(NoData_value)
band.FlushCache()
# band = None
# target_ds = None

In [31]:
gdal.RasterizeLayer(target_ds, [1], source_layer, burn_values=[255], options = ["ATTRIBUTE=FEOW_ID", "ALL_TOUCHED=TRUE"])


CPLE_AppDefined in b'Failed to fetch spatial reference on layer feow_hydrosheds to build transformer, assuming matching coordinate systems.\n'
Out[31]:
0

In [32]:
target_dsSRS = osr.SpatialReference()
target_dsSRS.ImportFromEPSG(4326)
target_ds.SetProjection(target_dsSRS.ExportToWkt())


Out[32]:
0

In [33]:
band = None
target_ds = None

In [34]:
from iSDM.environment import RasterEnvironmentalLayer
freshwater_ecoregions = RasterEnvironmentalLayer(file_path="../data/freshwater_ecoregions/freshwater_ecoregions.tif")
freshwater_ecoregions_reader = freshwater_ecoregions.load_data()


Loaded raster data from ../data/freshwater_ecoregions/freshwater_ecoregions.tif 
Driver name: GTiff 
Metadata: {'affine': Affine(0.0083333333, 0.0, -180.0,
       0.0, -0.0083333333, 90.0),
 'count': 1,
 'crs': {'init': 'epsg:4326'},
 'driver': 'GTiff',
 'dtype': 'uint16',
 'height': 21600,
 'nodata': 0.0,
 'transform': (-180.0, 0.0083333333, 0.0, 90.0, 0.0, -0.0083333333),
 'width': 43200} 
Resolution: x_res=43200 y_res=21600.
Bounds: BoundingBox(left=-180.0, bottom=-89.99999928000003, right=179.99999856000005, top=90.0) 
Coordinate reference system: {'init': 'epsg:4326'} 
Affine transformation: (-180.0, 0.0083333333, 0.0, 90.0, 0.0, -0.0083333333) 
Number of layers: 1 
Dataset loaded. Use .read() or .read_masks() to access the layers.

In [35]:
freshwater_ecoregions_data = freshwater_ecoregions_reader.read(1)

In [36]:
np.unique(freshwater_ecoregions_data) # hmm, don't like this, there are more layers.


Out[36]:
array([  0, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
       113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125,
       126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138,
       139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151,
       152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164,
       165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 201,
       202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214,
       215, 216, 217, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310,
       311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323,
       324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336,
       337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349,
       350, 351, 352, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410,
       411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423,
       424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436,
       437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449,
       450, 451, 452, 453, 501, 502, 503, 504, 505, 506, 507, 508, 509,
       510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522,
       523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535,
       536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548,
       549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561,
       562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574,
       575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 586, 587,
       601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613,
       614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626,
       627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639,
       640, 641, 642, 643, 701, 702, 703, 704, 705, 706, 707, 708, 709,
       710, 711, 712, 713, 714, 715, 716, 717, 718, 719, 720, 721, 722,
       723, 724, 725, 726, 727, 728, 729, 730, 731, 732, 733, 734, 735,
       736, 737, 738, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748,
       749, 750, 751, 752, 753, 755, 756, 757, 758, 759, 760, 761, 762,
       763, 764, 765, 766, 767, 768, 769, 801, 802, 803, 804, 805, 806,
       807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819,
       820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 901, 902,
       903, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915,
       916, 917, 918, 919, 920, 921, 998, 999], dtype=uint16)

In [26]:
source_layer.GetFeatureCount() # this many unique regions.


Out[26]:
449

In [27]:
np.unique(freshwater_ecoregions_data).shape # cool, 0 layer for no data


Out[27]:
(450,)

In [17]:
freshwater_ecoregions_data_selected = freshwater_ecoregions_data.copy()
freshwater_ecoregions_data_selected[freshwater_ecoregions_data_selected!=405] = 0

In [18]:
import matplotlib.pyplot as plt
%matplotlib inline
plt.figure(figsize=(25,20))
plt.imshow(freshwater_ecoregions_data_selected, cmap="hot", interpolation="none")


Out[18]:
<matplotlib.image.AxesImage at 0x7fe97b28fcf8>

In [37]:
freshwater_ecoregions_data.shape


Out[37]:
(21600, 43200)

In [217]:
unique_freshwater_ecoregions = np.unique(freshwater_ecoregions_data)[1:] # discard the "0" == nodata

In [424]:
import pickle
bias_grid = pickle.load(open("../data/bias_grid/bias_grid.pkl", "rb"))
bias_grid_log = pickle.load(open("../data/bias_grid/bias_grid_log.pkl", "rb"))
bias_grid_standardized = pickle.load(open("../data/bias_grid/bias_grid_standardized.pkl", "rb"))
bias_grid_minmax_scale = pickle.load(open("../data/bias_grid/bias_grid_minmax_scale.pkl", "rb"))

In [ ]:


In [240]:
bias_grid.shape


Out[240]:
(2160, 4320)

In [254]:
bias_grid[np.where(freshwater_ecoregions_data==101)] # number of cells in ecoregion


Out[254]:
88

In [268]:
len(np.where(bias_grid[np.where(freshwater_ecoregions_data==101)]>0)[0]) # number of positive cells in biasGrid


Out[268]:
32

In [271]:
num_cells_ecoregion_array = []
num_positive_cells_bias_grid_array = []
ratio_array = []
for ecoregion in unique_freshwater_ecoregions:
    number_cells_ecoregion = len(np.where(freshwater_ecoregions_data==ecoregion)[0])
    number_positive_cells_bias_grid = len(np.where(bias_grid[np.where(freshwater_ecoregions_data==ecoregion)]>0)[0])
    ratio = number_positive_cells_bias_grid/number_cells_ecoregion
    num_cells_ecoregion_array.append(number_cells_ecoregion)
    num_positive_cells_bias_grid_array.append(number_positive_cells_bias_grid)
    ratio_array.append(ratio)
#     print("Processed %s, num_cells_ecoregion=%s, number_positive_bias=%s, ratio=%s " % (ecoregion, number_cells_ecoregion, number_positive_cells_bias_grid, ratio))


Processed 101, num_cells_ecoregion=28772, number_positive_bias=32, ratio=0.0011121924092868066 
Processed 102, num_cells_ecoregion=15228, number_positive_bias=7, ratio=0.00045967953769372207 
Processed 103, num_cells_ecoregion=21111, number_positive_bias=347, ratio=0.016436928615413765 
Processed 104, num_cells_ecoregion=13196, number_positive_bias=16, ratio=0.0012124886329190664 
Processed 105, num_cells_ecoregion=28304, number_positive_bias=5, ratio=0.00017665347654041832 
Processed 106, num_cells_ecoregion=18108, number_positive_bias=0, ratio=0.0 
Processed 107, num_cells_ecoregion=4022, number_positive_bias=2, ratio=0.0004972650422675286 
Processed 108, num_cells_ecoregion=6138, number_positive_bias=0, ratio=0.0 
Processed 109, num_cells_ecoregion=11636, number_positive_bias=113, ratio=0.009711240976280509 
Processed 110, num_cells_ecoregion=19331, number_positive_bias=1, ratio=5.173038125290983e-05 
Processed 111, num_cells_ecoregion=25556, number_positive_bias=0, ratio=0.0 
Processed 112, num_cells_ecoregion=65763, number_positive_bias=0, ratio=0.0 
Processed 113, num_cells_ecoregion=23703, number_positive_bias=0, ratio=0.0 
Processed 114, num_cells_ecoregion=5195, number_positive_bias=0, ratio=0.0 
Processed 115, num_cells_ecoregion=2852, number_positive_bias=6, ratio=0.0021037868162692847 
Processed 116, num_cells_ecoregion=12509, number_positive_bias=1074, ratio=0.0858581821088816 
Processed 117, num_cells_ecoregion=6871, number_positive_bias=237, ratio=0.03449279580847038 
Processed 118, num_cells_ecoregion=6374, number_positive_bias=1401, ratio=0.21979918418575461 
Processed 119, num_cells_ecoregion=1202, number_positive_bias=40, ratio=0.033277870216306155 
Processed 120, num_cells_ecoregion=4611, number_positive_bias=337, ratio=0.07308609846020386 
Processed 121, num_cells_ecoregion=5158, number_positive_bias=415, ratio=0.0804575416828228 
Processed 122, num_cells_ecoregion=1424, number_positive_bias=100, ratio=0.0702247191011236 
Processed 123, num_cells_ecoregion=1773, number_positive_bias=146, ratio=0.0823463056965595 
Processed 124, num_cells_ecoregion=847, number_positive_bias=9, ratio=0.010625737898465172 
Processed 125, num_cells_ecoregion=2736, number_positive_bias=173, ratio=0.06323099415204679 
Processed 126, num_cells_ecoregion=3155, number_positive_bias=43, ratio=0.013629160063391443 
Processed 127, num_cells_ecoregion=2339, number_positive_bias=109, ratio=0.04660111158614793 
Processed 128, num_cells_ecoregion=1178, number_positive_bias=27, ratio=0.022920203735144314 
Processed 129, num_cells_ecoregion=580, number_positive_bias=28, ratio=0.04827586206896552 
Processed 130, num_cells_ecoregion=7271, number_positive_bias=303, ratio=0.04167239719433365 
Processed 131, num_cells_ecoregion=2134, number_positive_bias=125, ratio=0.05857544517338332 
Processed 132, num_cells_ecoregion=2243, number_positive_bias=43, ratio=0.019170753455193937 
Processed 133, num_cells_ecoregion=1535, number_positive_bias=32, ratio=0.020846905537459284 
Processed 134, num_cells_ecoregion=830, number_positive_bias=0, ratio=0.0 
Processed 135, num_cells_ecoregion=1878, number_positive_bias=24, ratio=0.012779552715654952 
Processed 136, num_cells_ecoregion=6, number_positive_bias=0, ratio=0.0 
Processed 137, num_cells_ecoregion=812, number_positive_bias=6, ratio=0.007389162561576354 
Processed 138, num_cells_ecoregion=535, number_positive_bias=3, ratio=0.005607476635514018 
Processed 139, num_cells_ecoregion=998, number_positive_bias=89, ratio=0.08917835671342686 
Processed 140, num_cells_ecoregion=3747, number_positive_bias=219, ratio=0.05844675740592474 
Processed 141, num_cells_ecoregion=1871, number_positive_bias=135, ratio=0.07215392838054516 
Processed 142, num_cells_ecoregion=11495, number_positive_bias=1128, ratio=0.09812962157459765 
Processed 143, num_cells_ecoregion=9276, number_positive_bias=796, ratio=0.0858128503665373 
Processed 144, num_cells_ecoregion=6162, number_positive_bias=223, ratio=0.0361895488477767 
Processed 145, num_cells_ecoregion=1619, number_positive_bias=76, ratio=0.04694255713403336 
Processed 146, num_cells_ecoregion=2361, number_positive_bias=105, ratio=0.044472681067344345 
Processed 147, num_cells_ecoregion=1257, number_positive_bias=61, ratio=0.04852824184566428 
Processed 148, num_cells_ecoregion=7841, number_positive_bias=1401, ratio=0.17867618926157378 
Processed 149, num_cells_ecoregion=3652, number_positive_bias=172, ratio=0.047097480832420595 
Processed 150, num_cells_ecoregion=5615, number_positive_bias=745, ratio=0.13268032056990206 
Processed 151, num_cells_ecoregion=654, number_positive_bias=47, ratio=0.07186544342507645 
Processed 152, num_cells_ecoregion=1552, number_positive_bias=323, ratio=0.20811855670103094 
Processed 153, num_cells_ecoregion=1652, number_positive_bias=167, ratio=0.10108958837772397 
Processed 154, num_cells_ecoregion=506, number_positive_bias=40, ratio=0.07905138339920949 
Processed 155, num_cells_ecoregion=754, number_positive_bias=106, ratio=0.14058355437665782 
Processed 156, num_cells_ecoregion=2316, number_positive_bias=280, ratio=0.12089810017271158 
Processed 157, num_cells_ecoregion=4725, number_positive_bias=1117, ratio=0.2364021164021164 
Processed 158, num_cells_ecoregion=2467, number_positive_bias=1022, ratio=0.4142683421159303 
Processed 159, num_cells_ecoregion=2866, number_positive_bias=105, ratio=0.0366364270760642 
Processed 160, num_cells_ecoregion=2575, number_positive_bias=5, ratio=0.001941747572815534 
Processed 161, num_cells_ecoregion=1944, number_positive_bias=4, ratio=0.00205761316872428 
Processed 162, num_cells_ecoregion=1703, number_positive_bias=0, ratio=0.0 
Processed 163, num_cells_ecoregion=2428, number_positive_bias=0, ratio=0.0 
Processed 164, num_cells_ecoregion=1395, number_positive_bias=0, ratio=0.0 
Processed 165, num_cells_ecoregion=776, number_positive_bias=3, ratio=0.003865979381443299 
Processed 166, num_cells_ecoregion=820, number_positive_bias=0, ratio=0.0 
Processed 167, num_cells_ecoregion=1935, number_positive_bias=2, ratio=0.0010335917312661498 
Processed 168, num_cells_ecoregion=645, number_positive_bias=2, ratio=0.0031007751937984496 
Processed 169, num_cells_ecoregion=1490, number_positive_bias=1, ratio=0.0006711409395973154 
Processed 170, num_cells_ecoregion=851, number_positive_bias=1, ratio=0.0011750881316098707 
Processed 171, num_cells_ecoregion=753, number_positive_bias=0, ratio=0.0 
Processed 172, num_cells_ecoregion=252, number_positive_bias=0, ratio=0.0 
Processed 173, num_cells_ecoregion=1322, number_positive_bias=3, ratio=0.0022692889561270802 
Processed 174, num_cells_ecoregion=807, number_positive_bias=8, ratio=0.009913258983890954 
Processed 175, num_cells_ecoregion=890, number_positive_bias=12, ratio=0.01348314606741573 
Processed 176, num_cells_ecoregion=9, number_positive_bias=0, ratio=0.0 
Processed 201, num_cells_ecoregion=1208, number_positive_bias=0, ratio=0.0 
Processed 202, num_cells_ecoregion=1401, number_positive_bias=5, ratio=0.0035688793718772305 
Processed 203, num_cells_ecoregion=1562, number_positive_bias=0, ratio=0.0 
Processed 204, num_cells_ecoregion=368, number_positive_bias=1, ratio=0.002717391304347826 
Processed 205, num_cells_ecoregion=1381, number_positive_bias=0, ratio=0.0 
Processed 206, num_cells_ecoregion=330, number_positive_bias=0, ratio=0.0 
Processed 207, num_cells_ecoregion=187, number_positive_bias=0, ratio=0.0 
Processed 208, num_cells_ecoregion=249, number_positive_bias=0, ratio=0.0 
Processed 209, num_cells_ecoregion=191, number_positive_bias=1, ratio=0.005235602094240838 
Processed 210, num_cells_ecoregion=366, number_positive_bias=0, ratio=0.0 
Processed 211, num_cells_ecoregion=1959, number_positive_bias=3, ratio=0.0015313935681470138 
Processed 212, num_cells_ecoregion=675, number_positive_bias=2, ratio=0.002962962962962963 
Processed 213, num_cells_ecoregion=177, number_positive_bias=1, ratio=0.005649717514124294 
Processed 214, num_cells_ecoregion=1127, number_positive_bias=1, ratio=0.0008873114463176575 
Processed 215, num_cells_ecoregion=203, number_positive_bias=42, ratio=0.20689655172413793 
Processed 216, num_cells_ecoregion=240, number_positive_bias=1, ratio=0.004166666666666667 
Processed 217, num_cells_ecoregion=3, number_positive_bias=0, ratio=0.0 
Processed 301, num_cells_ecoregion=3103, number_positive_bias=0, ratio=0.0 
Processed 302, num_cells_ecoregion=3548, number_positive_bias=11, ratio=0.0031003382187147687 
Processed 303, num_cells_ecoregion=843, number_positive_bias=0, ratio=0.0 
Processed 304, num_cells_ecoregion=1838, number_positive_bias=1, ratio=0.000544069640914037 
Processed 305, num_cells_ecoregion=598, number_positive_bias=0, ratio=0.0 
Processed 306, num_cells_ecoregion=898, number_positive_bias=0, ratio=0.0 
Processed 307, num_cells_ecoregion=5728, number_positive_bias=0, ratio=0.0 
Processed 308, num_cells_ecoregion=3491, number_positive_bias=0, ratio=0.0 
Processed 309, num_cells_ecoregion=1374, number_positive_bias=0, ratio=0.0 
Processed 310, num_cells_ecoregion=1831, number_positive_bias=0, ratio=0.0 
Processed 311, num_cells_ecoregion=3542, number_positive_bias=0, ratio=0.0 
Processed 312, num_cells_ecoregion=5801, number_positive_bias=1, ratio=0.00017238407171177384 
Processed 313, num_cells_ecoregion=2861, number_positive_bias=0, ratio=0.0 
Processed 314, num_cells_ecoregion=5399, number_positive_bias=0, ratio=0.0 
Processed 315, num_cells_ecoregion=6709, number_positive_bias=0, ratio=0.0 
Processed 316, num_cells_ecoregion=22422, number_positive_bias=0, ratio=0.0 
Processed 317, num_cells_ecoregion=1682, number_positive_bias=0, ratio=0.0 
Processed 318, num_cells_ecoregion=5000, number_positive_bias=0, ratio=0.0 
Processed 319, num_cells_ecoregion=4210, number_positive_bias=0, ratio=0.0 
Processed 320, num_cells_ecoregion=5131, number_positive_bias=0, ratio=0.0 
Processed 321, num_cells_ecoregion=4622, number_positive_bias=0, ratio=0.0 
Processed 322, num_cells_ecoregion=5703, number_positive_bias=0, ratio=0.0 
Processed 323, num_cells_ecoregion=6714, number_positive_bias=0, ratio=0.0 
Processed 324, num_cells_ecoregion=8992, number_positive_bias=1, ratio=0.00011120996441281138 
Processed 325, num_cells_ecoregion=4275, number_positive_bias=0, ratio=0.0 
Processed 326, num_cells_ecoregion=3442, number_positive_bias=0, ratio=0.0 
Processed 327, num_cells_ecoregion=7647, number_positive_bias=0, ratio=0.0 
Processed 328, num_cells_ecoregion=6234, number_positive_bias=0, ratio=0.0 
Processed 329, num_cells_ecoregion=766, number_positive_bias=0, ratio=0.0 
Processed 330, num_cells_ecoregion=463, number_positive_bias=0, ratio=0.0 
Processed 331, num_cells_ecoregion=522, number_positive_bias=0, ratio=0.0 
Processed 332, num_cells_ecoregion=3464, number_positive_bias=0, ratio=0.0 
Processed 333, num_cells_ecoregion=1011, number_positive_bias=0, ratio=0.0 
Processed 334, num_cells_ecoregion=2660, number_positive_bias=0, ratio=0.0 
Processed 335, num_cells_ecoregion=152, number_positive_bias=0, ratio=0.0 
Processed 336, num_cells_ecoregion=3201, number_positive_bias=0, ratio=0.0 
Processed 337, num_cells_ecoregion=2547, number_positive_bias=0, ratio=0.0 
Processed 338, num_cells_ecoregion=2472, number_positive_bias=0, ratio=0.0 
Processed 339, num_cells_ecoregion=7522, number_positive_bias=0, ratio=0.0 
Processed 340, num_cells_ecoregion=4123, number_positive_bias=0, ratio=0.0 
Processed 341, num_cells_ecoregion=2970, number_positive_bias=0, ratio=0.0 
Processed 342, num_cells_ecoregion=7397, number_positive_bias=0, ratio=0.0 
Processed 343, num_cells_ecoregion=6858, number_positive_bias=0, ratio=0.0 
Processed 344, num_cells_ecoregion=10679, number_positive_bias=1, ratio=9.364172675344133e-05 
Processed 345, num_cells_ecoregion=8944, number_positive_bias=0, ratio=0.0 
Processed 346, num_cells_ecoregion=993, number_positive_bias=0, ratio=0.0 
Processed 347, num_cells_ecoregion=4049, number_positive_bias=0, ratio=0.0 
Processed 348, num_cells_ecoregion=20836, number_positive_bias=2, ratio=9.59877135726627e-05 
Processed 349, num_cells_ecoregion=1110, number_positive_bias=0, ratio=0.0 
Processed 350, num_cells_ecoregion=196, number_positive_bias=1, ratio=0.00510204081632653 
Processed 351, num_cells_ecoregion=14, number_positive_bias=0, ratio=0.0 
Processed 352, num_cells_ecoregion=205, number_positive_bias=2, ratio=0.00975609756097561 
Processed 401, num_cells_ecoregion=3251, number_positive_bias=3, ratio=0.0009227929867733005 
Processed 402, num_cells_ecoregion=4768, number_positive_bias=1969, ratio=0.41296140939597314 
Processed 403, num_cells_ecoregion=3516, number_positive_bias=376, ratio=0.10693970420932879 
Processed 404, num_cells_ecoregion=27089, number_positive_bias=5877, ratio=0.2169515301413858 
Processed 405, num_cells_ecoregion=5231, number_positive_bias=3505, ratio=0.670043968648442 
Processed 406, num_cells_ecoregion=24044, number_positive_bias=6533, ratio=0.27171019797038765 
Processed 407, num_cells_ecoregion=48006, number_positive_bias=1365, ratio=0.0284339457567804 
Processed 408, num_cells_ecoregion=7301, number_positive_bias=39, ratio=0.005341734009039857 
Processed 409, num_cells_ecoregion=3059, number_positive_bias=2, ratio=0.0006538084341288003 
Processed 410, num_cells_ecoregion=40267, number_positive_bias=1, ratio=2.4834231504706088e-05 
Processed 411, num_cells_ecoregion=3063, number_positive_bias=0, ratio=0.0 
Processed 412, num_cells_ecoregion=3525, number_positive_bias=1330, ratio=0.3773049645390071 
Processed 413, num_cells_ecoregion=2666, number_positive_bias=968, ratio=0.3630907726931733 
Processed 414, num_cells_ecoregion=2558, number_positive_bias=1168, ratio=0.45660672400312746 
Processed 415, num_cells_ecoregion=2226, number_positive_bias=966, ratio=0.4339622641509434 
Processed 416, num_cells_ecoregion=3406, number_positive_bias=554, ratio=0.1626541397533764 
Processed 417, num_cells_ecoregion=4476, number_positive_bias=132, ratio=0.029490616621983913 
Processed 418, num_cells_ecoregion=10975, number_positive_bias=18, ratio=0.0016400911161731208 
Processed 419, num_cells_ecoregion=916, number_positive_bias=12, ratio=0.013100436681222707 
Processed 420, num_cells_ecoregion=714, number_positive_bias=6, ratio=0.008403361344537815 
Processed 421, num_cells_ecoregion=665, number_positive_bias=8, ratio=0.012030075187969926 
Processed 422, num_cells_ecoregion=790, number_positive_bias=0, ratio=0.0 
Processed 423, num_cells_ecoregion=2283, number_positive_bias=10, ratio=0.004380201489268506 
Processed 424, num_cells_ecoregion=805, number_positive_bias=13, ratio=0.016149068322981366 
Processed 425, num_cells_ecoregion=11268, number_positive_bias=1, ratio=8.874689385871494e-05 
Processed 426, num_cells_ecoregion=528, number_positive_bias=2, ratio=0.003787878787878788 
Processed 427, num_cells_ecoregion=9754, number_positive_bias=1, ratio=0.0001025220422390814 
Processed 428, num_cells_ecoregion=932, number_positive_bias=2, ratio=0.002145922746781116 
Processed 429, num_cells_ecoregion=1439, number_positive_bias=10, ratio=0.006949270326615705 
Processed 430, num_cells_ecoregion=3140, number_positive_bias=6, ratio=0.001910828025477707 
Processed 431, num_cells_ecoregion=1082, number_positive_bias=0, ratio=0.0 
Processed 432, num_cells_ecoregion=1667, number_positive_bias=12, ratio=0.007198560287942412 
Processed 433, num_cells_ecoregion=1434, number_positive_bias=5, ratio=0.003486750348675035 
Processed 434, num_cells_ecoregion=3418, number_positive_bias=0, ratio=0.0 
Processed 435, num_cells_ecoregion=780, number_positive_bias=5, ratio=0.00641025641025641 
Processed 436, num_cells_ecoregion=378, number_positive_bias=9, ratio=0.023809523809523808 
Processed 437, num_cells_ecoregion=347, number_positive_bias=0, ratio=0.0 
Processed 438, num_cells_ecoregion=575, number_positive_bias=17, ratio=0.029565217391304348 
Processed 439, num_cells_ecoregion=6839, number_positive_bias=1, ratio=0.00014622020763269483 
Processed 440, num_cells_ecoregion=30086, number_positive_bias=0, ratio=0.0 
Processed 441, num_cells_ecoregion=4771, number_positive_bias=0, ratio=0.0 
Processed 442, num_cells_ecoregion=7457, number_positive_bias=4, ratio=0.0005364087434625185 
Processed 443, num_cells_ecoregion=3123, number_positive_bias=7, ratio=0.002241434518091579 
Processed 444, num_cells_ecoregion=315, number_positive_bias=2, ratio=0.006349206349206349 
Processed 445, num_cells_ecoregion=793, number_positive_bias=1, ratio=0.0012610340479192938 
Processed 446, num_cells_ecoregion=1011, number_positive_bias=0, ratio=0.0 
Processed 447, num_cells_ecoregion=1345, number_positive_bias=0, ratio=0.0 
Processed 448, num_cells_ecoregion=6904, number_positive_bias=0, ratio=0.0 
Processed 449, num_cells_ecoregion=667, number_positive_bias=0, ratio=0.0 
Processed 450, num_cells_ecoregion=4283, number_positive_bias=0, ratio=0.0 
Processed 451, num_cells_ecoregion=1294, number_positive_bias=0, ratio=0.0 
Processed 452, num_cells_ecoregion=5023, number_positive_bias=0, ratio=0.0 
Processed 453, num_cells_ecoregion=1918, number_positive_bias=0, ratio=0.0 
Processed 501, num_cells_ecoregion=5911, number_positive_bias=0, ratio=0.0 
Processed 502, num_cells_ecoregion=6802, number_positive_bias=0, ratio=0.0 
Processed 503, num_cells_ecoregion=47754, number_positive_bias=0, ratio=0.0 
Processed 504, num_cells_ecoregion=54690, number_positive_bias=1, ratio=1.8284878405558604e-05 
Processed 505, num_cells_ecoregion=12821, number_positive_bias=1, ratio=7.799703611262772e-05 
Processed 506, num_cells_ecoregion=561, number_positive_bias=0, ratio=0.0 
Processed 507, num_cells_ecoregion=2880, number_positive_bias=0, ratio=0.0 
Processed 508, num_cells_ecoregion=1634, number_positive_bias=0, ratio=0.0 
Processed 509, num_cells_ecoregion=7808, number_positive_bias=7, ratio=0.000896516393442623 
Processed 510, num_cells_ecoregion=465, number_positive_bias=0, ratio=0.0 
Processed 511, num_cells_ecoregion=2141, number_positive_bias=3, ratio=0.0014012143858010276 
Processed 512, num_cells_ecoregion=1512, number_positive_bias=0, ratio=0.0 
Processed 513, num_cells_ecoregion=144, number_positive_bias=0, ratio=0.0 
Processed 514, num_cells_ecoregion=3272, number_positive_bias=1, ratio=0.0003056234718826406 
Processed 515, num_cells_ecoregion=878, number_positive_bias=0, ratio=0.0 
Processed 516, num_cells_ecoregion=5068, number_positive_bias=0, ratio=0.0 
Processed 517, num_cells_ecoregion=2281, number_positive_bias=1, ratio=0.00043840420868040335 
Processed 518, num_cells_ecoregion=978, number_positive_bias=2, ratio=0.002044989775051125 
Processed 519, num_cells_ecoregion=177, number_positive_bias=1, ratio=0.005649717514124294 
Processed 520, num_cells_ecoregion=13588, number_positive_bias=0, ratio=0.0 
Processed 521, num_cells_ecoregion=4266, number_positive_bias=13, ratio=0.0030473511486169714 
Processed 522, num_cells_ecoregion=14463, number_positive_bias=2, ratio=0.00013828389684021296 
Processed 523, num_cells_ecoregion=14085, number_positive_bias=0, ratio=0.0 
Processed 524, num_cells_ecoregion=864, number_positive_bias=0, ratio=0.0 
Processed 525, num_cells_ecoregion=4806, number_positive_bias=0, ratio=0.0 
Processed 526, num_cells_ecoregion=239, number_positive_bias=0, ratio=0.0 
Processed 527, num_cells_ecoregion=4122, number_positive_bias=9, ratio=0.002183406113537118 
Processed 528, num_cells_ecoregion=2240, number_positive_bias=0, ratio=0.0 
Processed 529, num_cells_ecoregion=3072, number_positive_bias=0, ratio=0.0 
Processed 530, num_cells_ecoregion=2835, number_positive_bias=0, ratio=0.0 
Processed 531, num_cells_ecoregion=11355, number_positive_bias=0, ratio=0.0 
Processed 532, num_cells_ecoregion=3186, number_positive_bias=8, ratio=0.0025109855618330196 
Processed 533, num_cells_ecoregion=2499, number_positive_bias=6, ratio=0.0024009603841536613 
Processed 534, num_cells_ecoregion=3335, number_positive_bias=1, ratio=0.0002998500749625187 
Processed 535, num_cells_ecoregion=6421, number_positive_bias=2, ratio=0.0003114779629341224 
Processed 536, num_cells_ecoregion=2178, number_positive_bias=0, ratio=0.0 
Processed 537, num_cells_ecoregion=6443, number_positive_bias=0, ratio=0.0 
Processed 538, num_cells_ecoregion=143, number_positive_bias=0, ratio=0.0 
Processed 539, num_cells_ecoregion=100, number_positive_bias=0, ratio=0.0 
Processed 540, num_cells_ecoregion=4761, number_positive_bias=1, ratio=0.00021003990758244065 
Processed 541, num_cells_ecoregion=1113, number_positive_bias=0, ratio=0.0 
Processed 542, num_cells_ecoregion=1463, number_positive_bias=8, ratio=0.005468215994531784 
Processed 543, num_cells_ecoregion=1394, number_positive_bias=0, ratio=0.0 
Processed 544, num_cells_ecoregion=2491, number_positive_bias=9, ratio=0.0036130068245684463 
Processed 545, num_cells_ecoregion=2015, number_positive_bias=2, ratio=0.0009925558312655087 
Processed 546, num_cells_ecoregion=10148, number_positive_bias=1, ratio=9.854158454867954e-05 
Processed 547, num_cells_ecoregion=282, number_positive_bias=0, ratio=0.0 
Processed 548, num_cells_ecoregion=49, number_positive_bias=0, ratio=0.0 
Processed 549, num_cells_ecoregion=203, number_positive_bias=1, ratio=0.0049261083743842365 
Processed 550, num_cells_ecoregion=700, number_positive_bias=0, ratio=0.0 
Processed 551, num_cells_ecoregion=4010, number_positive_bias=4, ratio=0.000997506234413965 
Processed 552, num_cells_ecoregion=3919, number_positive_bias=3, ratio=0.0007655014034192396 
Processed 553, num_cells_ecoregion=1638, number_positive_bias=0, ratio=0.0 
Processed 554, num_cells_ecoregion=460, number_positive_bias=0, ratio=0.0 
Processed 555, num_cells_ecoregion=6923, number_positive_bias=7, ratio=0.0010111223458038423 
Processed 556, num_cells_ecoregion=2872, number_positive_bias=5, ratio=0.0017409470752089136 
Processed 557, num_cells_ecoregion=1278, number_positive_bias=0, ratio=0.0 
Processed 558, num_cells_ecoregion=3463, number_positive_bias=4, ratio=0.001155067860236789 
Processed 559, num_cells_ecoregion=1278, number_positive_bias=8, ratio=0.006259780907668232 
Processed 560, num_cells_ecoregion=2549, number_positive_bias=0, ratio=0.0 
Processed 561, num_cells_ecoregion=1468, number_positive_bias=2, ratio=0.0013623978201634877 
Processed 562, num_cells_ecoregion=123, number_positive_bias=1, ratio=0.008130081300813009 
Processed 563, num_cells_ecoregion=676, number_positive_bias=0, ratio=0.0 
Processed 564, num_cells_ecoregion=9227, number_positive_bias=12, ratio=0.001300531050178823 
Processed 565, num_cells_ecoregion=1047, number_positive_bias=0, ratio=0.0 
Processed 566, num_cells_ecoregion=1973, number_positive_bias=0, ratio=0.0 
Processed 567, num_cells_ecoregion=2074, number_positive_bias=1, ratio=0.00048216007714561236 
Processed 568, num_cells_ecoregion=749, number_positive_bias=2, ratio=0.0026702269692923898 
Processed 569, num_cells_ecoregion=2199, number_positive_bias=24, ratio=0.010914051841746248 
Processed 570, num_cells_ecoregion=5574, number_positive_bias=0, ratio=0.0 
Processed 571, num_cells_ecoregion=5873, number_positive_bias=1, ratio=0.00017027073046143367 
Processed 572, num_cells_ecoregion=901, number_positive_bias=3, ratio=0.003329633740288568 
Processed 573, num_cells_ecoregion=2478, number_positive_bias=2, ratio=0.0008071025020177562 
Processed 574, num_cells_ecoregion=576, number_positive_bias=1, ratio=0.001736111111111111 
Processed 575, num_cells_ecoregion=7374, number_positive_bias=27, ratio=0.003661513425549227 
Processed 576, num_cells_ecoregion=7221, number_positive_bias=30, ratio=0.004154549231408392 
Processed 577, num_cells_ecoregion=200, number_positive_bias=3, ratio=0.015 
Processed 578, num_cells_ecoregion=2286, number_positive_bias=14, ratio=0.006124234470691163 
Processed 579, num_cells_ecoregion=2859, number_positive_bias=0, ratio=0.0 
Processed 580, num_cells_ecoregion=1927, number_positive_bias=1, ratio=0.0005189413596263622 
Processed 581, num_cells_ecoregion=1630, number_positive_bias=1, ratio=0.0006134969325153375 
Processed 582, num_cells_ecoregion=669, number_positive_bias=0, ratio=0.0 
Processed 583, num_cells_ecoregion=672, number_positive_bias=3, ratio=0.004464285714285714 
Processed 584, num_cells_ecoregion=68, number_positive_bias=0, ratio=0.0 
Processed 585, num_cells_ecoregion=37, number_positive_bias=1, ratio=0.02702702702702703 
Processed 586, num_cells_ecoregion=97, number_positive_bias=0, ratio=0.0 
Processed 587, num_cells_ecoregion=30, number_positive_bias=2, ratio=0.06666666666666667 
Processed 601, num_cells_ecoregion=4205, number_positive_bias=0, ratio=0.0 
Processed 602, num_cells_ecoregion=77999, number_positive_bias=4, ratio=5.1282708752676314e-05 
Processed 603, num_cells_ecoregion=4254, number_positive_bias=0, ratio=0.0 
Processed 604, num_cells_ecoregion=511, number_positive_bias=1, ratio=0.0019569471624266144 
Processed 605, num_cells_ecoregion=49634, number_positive_bias=0, ratio=0.0 
Processed 606, num_cells_ecoregion=10211, number_positive_bias=0, ratio=0.0 
Processed 607, num_cells_ecoregion=34486, number_positive_bias=0, ratio=0.0 
Processed 608, num_cells_ecoregion=88317, number_positive_bias=0, ratio=0.0 
Processed 609, num_cells_ecoregion=36481, number_positive_bias=0, ratio=0.0 
Processed 610, num_cells_ecoregion=8751, number_positive_bias=0, ratio=0.0 
Processed 611, num_cells_ecoregion=4998, number_positive_bias=0, ratio=0.0 
Processed 612, num_cells_ecoregion=6766, number_positive_bias=0, ratio=0.0 
Processed 613, num_cells_ecoregion=4631, number_positive_bias=1, ratio=0.00021593608291945585 
Processed 614, num_cells_ecoregion=6549, number_positive_bias=0, ratio=0.0 
Processed 615, num_cells_ecoregion=2295, number_positive_bias=0, ratio=0.0 
Processed 616, num_cells_ecoregion=7857, number_positive_bias=1, ratio=0.00012727504136438844 
Processed 617, num_cells_ecoregion=9444, number_positive_bias=0, ratio=0.0 
Processed 618, num_cells_ecoregion=5850, number_positive_bias=0, ratio=0.0 
Processed 619, num_cells_ecoregion=4627, number_positive_bias=0, ratio=0.0 
Processed 620, num_cells_ecoregion=9538, number_positive_bias=0, ratio=0.0 
Processed 621, num_cells_ecoregion=16886, number_positive_bias=0, ratio=0.0 
Processed 622, num_cells_ecoregion=8497, number_positive_bias=0, ratio=0.0 
Processed 623, num_cells_ecoregion=8595, number_positive_bias=0, ratio=0.0 
Processed 624, num_cells_ecoregion=8094, number_positive_bias=0, ratio=0.0 
Processed 625, num_cells_ecoregion=16806, number_positive_bias=0, ratio=0.0 
Processed 626, num_cells_ecoregion=7639, number_positive_bias=0, ratio=0.0 
Processed 627, num_cells_ecoregion=843, number_positive_bias=0, ratio=0.0 
Processed 628, num_cells_ecoregion=3546, number_positive_bias=0, ratio=0.0 
Processed 629, num_cells_ecoregion=7273, number_positive_bias=0, ratio=0.0 
Processed 630, num_cells_ecoregion=6726, number_positive_bias=0, ratio=0.0 
Processed 631, num_cells_ecoregion=6935, number_positive_bias=0, ratio=0.0 
Processed 632, num_cells_ecoregion=4158, number_positive_bias=0, ratio=0.0 
Processed 633, num_cells_ecoregion=2447, number_positive_bias=0, ratio=0.0 
Processed 634, num_cells_ecoregion=1730, number_positive_bias=0, ratio=0.0 
Processed 635, num_cells_ecoregion=2614, number_positive_bias=0, ratio=0.0 
Processed 636, num_cells_ecoregion=11711, number_positive_bias=0, ratio=0.0 
Processed 637, num_cells_ecoregion=4674, number_positive_bias=0, ratio=0.0 
Processed 638, num_cells_ecoregion=2639, number_positive_bias=7, ratio=0.002652519893899204 
Processed 639, num_cells_ecoregion=1122, number_positive_bias=2, ratio=0.0017825311942959 
Processed 640, num_cells_ecoregion=1114, number_positive_bias=0, ratio=0.0 
Processed 641, num_cells_ecoregion=5576, number_positive_bias=0, ratio=0.0 
Processed 642, num_cells_ecoregion=5257, number_positive_bias=12, ratio=0.002282670724747955 
Processed 643, num_cells_ecoregion=69, number_positive_bias=1, ratio=0.014492753623188406 
Processed 701, num_cells_ecoregion=6149, number_positive_bias=0, ratio=0.0 
Processed 702, num_cells_ecoregion=5091, number_positive_bias=0, ratio=0.0 
Processed 703, num_cells_ecoregion=11816, number_positive_bias=1, ratio=8.463100880162491e-05 
Processed 704, num_cells_ecoregion=876, number_positive_bias=0, ratio=0.0 
Processed 705, num_cells_ecoregion=3300, number_positive_bias=0, ratio=0.0 
Processed 706, num_cells_ecoregion=2458, number_positive_bias=0, ratio=0.0 
Processed 707, num_cells_ecoregion=8674, number_positive_bias=0, ratio=0.0 
Processed 708, num_cells_ecoregion=3241, number_positive_bias=0, ratio=0.0 
Processed 709, num_cells_ecoregion=13635, number_positive_bias=6, ratio=0.00044004400440044003 
Processed 710, num_cells_ecoregion=2404, number_positive_bias=2, ratio=0.0008319467554076539 
Processed 711, num_cells_ecoregion=3892, number_positive_bias=0, ratio=0.0 
Processed 712, num_cells_ecoregion=2599, number_positive_bias=2, ratio=0.0007695267410542517 
Processed 713, num_cells_ecoregion=7091, number_positive_bias=0, ratio=0.0 
Processed 714, num_cells_ecoregion=3900, number_positive_bias=0, ratio=0.0 
Processed 715, num_cells_ecoregion=2008, number_positive_bias=7, ratio=0.0034860557768924302 
Processed 716, num_cells_ecoregion=2150, number_positive_bias=0, ratio=0.0 
Processed 717, num_cells_ecoregion=657, number_positive_bias=2, ratio=0.0030441400304414 
Processed 718, num_cells_ecoregion=240, number_positive_bias=9, ratio=0.0375 
Processed 719, num_cells_ecoregion=1584, number_positive_bias=5, ratio=0.0031565656565656565 
Processed 720, num_cells_ecoregion=5890, number_positive_bias=15, ratio=0.0025466893039049238 
Processed 721, num_cells_ecoregion=1915, number_positive_bias=0, ratio=0.0 
Processed 722, num_cells_ecoregion=2741, number_positive_bias=9, ratio=0.003283473184968989 
Processed 723, num_cells_ecoregion=18, number_positive_bias=0, ratio=0.0 
Processed 724, num_cells_ecoregion=1684, number_positive_bias=0, ratio=0.0 
Processed 725, num_cells_ecoregion=74, number_positive_bias=0, ratio=0.0 
Processed 726, num_cells_ecoregion=2267, number_positive_bias=5, ratio=0.0022055580061755625 
Processed 727, num_cells_ecoregion=2664, number_positive_bias=6, ratio=0.0022522522522522522 
Processed 728, num_cells_ecoregion=1238, number_positive_bias=15, ratio=0.012116316639741519 
Processed 729, num_cells_ecoregion=2283, number_positive_bias=9, ratio=0.003942181340341655 
Processed 730, num_cells_ecoregion=1068, number_positive_bias=61, ratio=0.05711610486891386 
Processed 731, num_cells_ecoregion=549, number_positive_bias=2, ratio=0.0036429872495446266 
Processed 732, num_cells_ecoregion=2213, number_positive_bias=15, ratio=0.006778129236330773 
Processed 733, num_cells_ecoregion=696, number_positive_bias=2, ratio=0.0028735632183908046 
Processed 734, num_cells_ecoregion=1987, number_positive_bias=12, ratio=0.006039255158530448 
Processed 735, num_cells_ecoregion=1328, number_positive_bias=6, ratio=0.004518072289156626 
Processed 736, num_cells_ecoregion=825, number_positive_bias=0, ratio=0.0 
Processed 737, num_cells_ecoregion=1655, number_positive_bias=0, ratio=0.0 
Processed 738, num_cells_ecoregion=2169, number_positive_bias=1, ratio=0.0004610419548178884 
Processed 739, num_cells_ecoregion=2273, number_positive_bias=1, ratio=0.0004399472063352398 
Processed 740, num_cells_ecoregion=989, number_positive_bias=0, ratio=0.0 
Processed 741, num_cells_ecoregion=1377, number_positive_bias=1, ratio=0.0007262164124909223 
Processed 742, num_cells_ecoregion=1413, number_positive_bias=1, ratio=0.0007077140835102619 
Processed 743, num_cells_ecoregion=1697, number_positive_bias=0, ratio=0.0 
Processed 744, num_cells_ecoregion=1102, number_positive_bias=2, ratio=0.0018148820326678765 
Processed 745, num_cells_ecoregion=1368, number_positive_bias=0, ratio=0.0 
Processed 746, num_cells_ecoregion=2453, number_positive_bias=2, ratio=0.0008153281695882593 
Processed 747, num_cells_ecoregion=1468, number_positive_bias=0, ratio=0.0 
Processed 748, num_cells_ecoregion=1664, number_positive_bias=8, ratio=0.004807692307692308 
Processed 749, num_cells_ecoregion=2835, number_positive_bias=2, ratio=0.0007054673721340388 
Processed 750, num_cells_ecoregion=53, number_positive_bias=0, ratio=0.0 
Processed 751, num_cells_ecoregion=37, number_positive_bias=0, ratio=0.0 
Processed 752, num_cells_ecoregion=1584, number_positive_bias=2, ratio=0.0012626262626262627 
Processed 753, num_cells_ecoregion=32, number_positive_bias=0, ratio=0.0 
Processed 755, num_cells_ecoregion=3080, number_positive_bias=5, ratio=0.0016233766233766235 
Processed 756, num_cells_ecoregion=603, number_positive_bias=1, ratio=0.001658374792703151 
Processed 757, num_cells_ecoregion=380, number_positive_bias=24, ratio=0.06315789473684211 
Processed 758, num_cells_ecoregion=198, number_positive_bias=9, ratio=0.045454545454545456 
Processed 759, num_cells_ecoregion=496, number_positive_bias=0, ratio=0.0 
Processed 760, num_cells_ecoregion=508, number_positive_bias=13, ratio=0.025590551181102362 
Processed 761, num_cells_ecoregion=2543, number_positive_bias=2, ratio=0.0007864726700747149 
Processed 762, num_cells_ecoregion=35, number_positive_bias=0, ratio=0.0 
Processed 763, num_cells_ecoregion=6713, number_positive_bias=12, ratio=0.0017875763444063757 
Processed 764, num_cells_ecoregion=7032, number_positive_bias=0, ratio=0.0 
Processed 765, num_cells_ecoregion=7010, number_positive_bias=0, ratio=0.0 
Processed 766, num_cells_ecoregion=15358, number_positive_bias=0, ratio=0.0 
Processed 767, num_cells_ecoregion=3078, number_positive_bias=0, ratio=0.0 
Processed 768, num_cells_ecoregion=171, number_positive_bias=1, ratio=0.005847953216374269 
Processed 769, num_cells_ecoregion=69, number_positive_bias=0, ratio=0.0 
Processed 801, num_cells_ecoregion=2056, number_positive_bias=0, ratio=0.0 
Processed 802, num_cells_ecoregion=6965, number_positive_bias=1, ratio=0.00014357501794687725 
Processed 803, num_cells_ecoregion=2548, number_positive_bias=0, ratio=0.0 
Processed 804, num_cells_ecoregion=29837, number_positive_bias=9, ratio=0.00030163890471562155 
Processed 805, num_cells_ecoregion=14219, number_positive_bias=59, ratio=0.004149377593360996 
Processed 806, num_cells_ecoregion=21634, number_positive_bias=0, ratio=0.0 
Processed 807, num_cells_ecoregion=7688, number_positive_bias=105, ratio=0.013657648283038502 
Processed 808, num_cells_ecoregion=15679, number_positive_bias=71, ratio=0.004528350022322852 
Processed 809, num_cells_ecoregion=1799, number_positive_bias=15, ratio=0.008337965536409116 
Processed 810, num_cells_ecoregion=736, number_positive_bias=5, ratio=0.006793478260869565 
Processed 811, num_cells_ecoregion=4888, number_positive_bias=107, ratio=0.02189034369885434 
Processed 812, num_cells_ecoregion=1613, number_positive_bias=1, ratio=0.0006199628022318661 
Processed 813, num_cells_ecoregion=2774, number_positive_bias=7, ratio=0.0025234318673395817 
Processed 814, num_cells_ecoregion=1488, number_positive_bias=3, ratio=0.0020161290322580645 
Processed 815, num_cells_ecoregion=3874, number_positive_bias=1, ratio=0.0002581311306143521 
Processed 816, num_cells_ecoregion=1439, number_positive_bias=6, ratio=0.004169562195969423 
Processed 817, num_cells_ecoregion=963, number_positive_bias=0, ratio=0.0 
Processed 818, num_cells_ecoregion=900, number_positive_bias=1, ratio=0.0011111111111111111 
Processed 819, num_cells_ecoregion=314, number_positive_bias=1, ratio=0.0031847133757961785 
Processed 820, num_cells_ecoregion=433, number_positive_bias=2, ratio=0.004618937644341801 
Processed 821, num_cells_ecoregion=557, number_positive_bias=4, ratio=0.00718132854578097 
Processed 822, num_cells_ecoregion=16, number_positive_bias=2, ratio=0.125 
Processed 823, num_cells_ecoregion=85, number_positive_bias=0, ratio=0.0 
Processed 824, num_cells_ecoregion=71, number_positive_bias=1, ratio=0.014084507042253521 
Processed 825, num_cells_ecoregion=20, number_positive_bias=0, ratio=0.0 
Processed 826, num_cells_ecoregion=51, number_positive_bias=0, ratio=0.0 
Processed 827, num_cells_ecoregion=8, number_positive_bias=0, ratio=0.0 
Processed 828, num_cells_ecoregion=327, number_positive_bias=23, ratio=0.07033639143730887 
Processed 829, num_cells_ecoregion=46, number_positive_bias=0, ratio=0.0 
Processed 830, num_cells_ecoregion=59, number_positive_bias=2, ratio=0.03389830508474576 
Processed 901, num_cells_ecoregion=104, number_positive_bias=3, ratio=0.028846153846153848 
Processed 902, num_cells_ecoregion=134, number_positive_bias=0, ratio=0.0 
Processed 903, num_cells_ecoregion=204, number_positive_bias=6, ratio=0.029411764705882353 
Processed 904, num_cells_ecoregion=37, number_positive_bias=0, ratio=0.0 
Processed 905, num_cells_ecoregion=85, number_positive_bias=0, ratio=0.0 
Processed 906, num_cells_ecoregion=321, number_positive_bias=7, ratio=0.021806853582554516 
Processed 907, num_cells_ecoregion=34, number_positive_bias=0, ratio=0.0 
Processed 908, num_cells_ecoregion=12, number_positive_bias=0, ratio=0.0 
Processed 909, num_cells_ecoregion=7, number_positive_bias=0, ratio=0.0 
Processed 910, num_cells_ecoregion=24, number_positive_bias=0, ratio=0.0 
Processed 911, num_cells_ecoregion=61, number_positive_bias=0, ratio=0.0 
Processed 912, num_cells_ecoregion=76, number_positive_bias=0, ratio=0.0 
Processed 913, num_cells_ecoregion=1, number_positive_bias=0, ratio=0.0 
Processed 914, num_cells_ecoregion=101, number_positive_bias=0, ratio=0.0 
Processed 915, num_cells_ecoregion=7, number_positive_bias=0, ratio=0.0 
Processed 916, num_cells_ecoregion=5, number_positive_bias=0, ratio=0.0 
Processed 917, num_cells_ecoregion=96, number_positive_bias=0, ratio=0.0 
Processed 918, num_cells_ecoregion=31, number_positive_bias=0, ratio=0.0 
Processed 919, num_cells_ecoregion=34, number_positive_bias=1, ratio=0.029411764705882353 
Processed 920, num_cells_ecoregion=12, number_positive_bias=0, ratio=0.0 
Processed 921, num_cells_ecoregion=4, number_positive_bias=0, ratio=0.0 
Processed 998, num_cells_ecoregion=100605, number_positive_bias=0, ratio=0.0 
Processed 999, num_cells_ecoregion=2212, number_positive_bias=27, ratio=0.012206148282097649 

In [280]:
ratio_array_np = np.array(ratio_array)

In [281]:
ratio_array_np.max()


Out[281]:
0.67004396864844196

In [282]:
ratio_array_np.min()


Out[282]:
0.0

In [283]:
ratio_array_np.std()


Out[283]:
0.065084924732055391

In [284]:
np.where(ratio_array_np==ratio_array_np.max())


Out[284]:
(array([149]),)

In [285]:
num_positive_cells_bias_grid_array[149]


Out[285]:
3505

In [286]:
num_cells_ecoregion_array[149]


Out[286]:
5231

In [291]:
unique_freshwater_ecoregions[149]


Out[291]:
405

In [305]:
ecoregions_vs_biasgrid = pd.DataFrame(columns=['ecoregion', 'num_cells_ecoregion', 'num_positive_bias_grid','ratio'])
ecoregions_vs_biasgrid['ecoregion'] = np.array(unique_freshwater_ecoregions)
ecoregions_vs_biasgrid['num_cells_ecoregion'] = np.array(num_cells_ecoregion_array)
ecoregions_vs_biasgrid['num_positive_bias_grid'] = np.array(num_positive_cells_bias_grid_array)
ecoregions_vs_biasgrid['ratio'] = np.array(ratio_array)

In [306]:
ecoregions_vs_biasgrid


Out[306]:
ecoregion num_cells_ecoregion num_positive_bias_grid ratio
0 101 28772 32 0.001112
1 102 15228 7 0.000460
2 103 21111 347 0.016437
3 104 13196 16 0.001212
4 105 28304 5 0.000177
5 106 18108 0 0.000000
6 107 4022 2 0.000497
7 108 6138 0 0.000000
8 109 11636 113 0.009711
9 110 19331 1 0.000052
10 111 25556 0 0.000000
11 112 65763 0 0.000000
12 113 23703 0 0.000000
13 114 5195 0 0.000000
14 115 2852 6 0.002104
15 116 12509 1074 0.085858
16 117 6871 237 0.034493
17 118 6374 1401 0.219799
18 119 1202 40 0.033278
19 120 4611 337 0.073086
20 121 5158 415 0.080458
21 122 1424 100 0.070225
22 123 1773 146 0.082346
23 124 847 9 0.010626
24 125 2736 173 0.063231
25 126 3155 43 0.013629
26 127 2339 109 0.046601
27 128 1178 27 0.022920
28 129 580 28 0.048276
29 130 7271 303 0.041672
... ... ... ... ...
419 824 71 1 0.014085
420 825 20 0 0.000000
421 826 51 0 0.000000
422 827 8 0 0.000000
423 828 327 23 0.070336
424 829 46 0 0.000000
425 830 59 2 0.033898
426 901 104 3 0.028846
427 902 134 0 0.000000
428 903 204 6 0.029412
429 904 37 0 0.000000
430 905 85 0 0.000000
431 906 321 7 0.021807
432 907 34 0 0.000000
433 908 12 0 0.000000
434 909 7 0 0.000000
435 910 24 0 0.000000
436 911 61 0 0.000000
437 912 76 0 0.000000
438 913 1 0 0.000000
439 914 101 0 0.000000
440 915 7 0 0.000000
441 916 5 0 0.000000
442 917 96 0 0.000000
443 918 31 0 0.000000
444 919 34 1 0.029412
445 920 12 0 0.000000
446 921 4 0 0.000000
447 998 100605 0 0.000000
448 999 2212 27 0.012206

449 rows × 4 columns


In [429]:
ecoregions_vs_biasgrid['ratio'].std()


Out[429]:
0.06515752366676357

In [345]:
ecoregions_vs_biasgrid['ratio'].plot(figsize=(20,25), title="Ratio biasGrid/ecoregion")


Out[345]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fd040983898>

In [327]:
ecoregions_vs_biasgrid[['num_cells_ecoregion','num_positive_bias_grid']].plot(figsize=(20,25))


Out[327]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fd0616bbba8>

Bias grid log


In [344]:
bias_grid_log.shape


Out[344]:
(2160, 4320)

In [414]:
def calculate_ratio(some_grid):
    num_cells_ecoregion_array = np.empty(len(unique_freshwater_ecoregions))
    num_positive_cells_bias_grid_array = np.empty(len(unique_freshwater_ecoregions))
    ratio_array = np.empty(len(unique_freshwater_ecoregions))
    for idx, ecoregion in enumerate(unique_freshwater_ecoregions):
        number_cells_ecoregion = len(np.where(freshwater_ecoregions_data==ecoregion)[0])
        number_positive_cells_bias_grid = len(np.where(some_grid[np.where(freshwater_ecoregions_data==ecoregion)]>0)[0])
        ratio = number_positive_cells_bias_grid/number_cells_ecoregion
        num_cells_ecoregion_array[idx] = number_cells_ecoregion
        num_positive_cells_bias_grid_array[idx] = number_positive_cells_bias_grid
        ratio_array[idx] = ratio
    return_df = pd.DataFrame(columns=['ecoregion', 'num_cells_ecoregion', 'num_positive_bias_grid','ratio'])
    return_df['ecoregion'] = np.array(unique_freshwater_ecoregions)
    return_df['num_cells_ecoregion'] = num_cells_ecoregion_array
    return_df['num_positive_bias_grid'] = num_positive_cells_bias_grid_array
    return_df['ratio'] = ratio_array
    return return_df

In [416]:
bias_grid_log_df = calculate_ratio(bias_grid_log)

In [419]:
bias_grid_log_df['ratio'].plot(figsize=(20,25), title="Ratio biasGrid_log/ecoregion")


Out[419]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fd040773be0>

In [420]:
bias_grid_standardized_df = calculate_ratio(bias_grid_standardized)

In [423]:
bias_grid_standardized_df['ratio'].plot(figsize=(20,25), title="Ratio biasGrid_standardized/ecoregion")


Out[423]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fd0406c35c0>

In [422]:
bias_grid_standardized_df.head()


Out[422]:
ecoregion num_cells_ecoregion num_positive_bias_grid ratio
0 101 28772.0 32.0 0.001112
1 102 15228.0 7.0 0.000460
2 103 21111.0 347.0 0.016437
3 104 13196.0 16.0 0.001212
4 105 28304.0 5.0 0.000177

In [425]:
bias_grid_minmax_scale


Out[425]:
1.0

In [426]:
bias_grid_minmax_scale_df = calculate_ratio(bias_grid_minmax_scale)

In [427]:
bias_grid_standardized_df['ratio'].plot(figsize=(20,25), title="Ratio biasGrid_minmax_scale/ecoregion")


Out[427]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fd040634748>

In [428]:
bias_grid_standardized_df.head()


Out[428]:
ecoregion num_cells_ecoregion num_positive_bias_grid ratio
0 101 28772.0 32.0 0.001112
1 102 15228.0 7.0 0.000460
2 103 21111.0 347.0 0.016437
3 104 13196.0 16.0 0.001212
4 105 28304.0 5.0 0.000177

In [430]:
import gc
gc.collect()


Out[430]:
3925

In [ ]: