Exemplo n.º 1
0
# Example that use bag.BAGFile to:
# - open a BAG file
# - read the whole elevation and uncertainty layers
# - read a selected range of rows for the elevation and uncertainty layers

file_bag_0 = os.path.join(Helper.samples_folder(), "bdb_00.bag")
if os.path.exists(file_bag_0):
    logger.debug("- file_bag_0: %s" % file_bag_0)

# - open a file
bag_0 = BAGFile(file_bag_0)
logger.debug("\n%s\n" % bag_0)

# - get elevation shape
logger.info("elevation shape: %s" % (bag_0.elevation_shape(), ))
# - read the full elevation
full_elevation = bag_0.elevation(mask_nan=True)
logger.info("elevation array:\n  type: %s\n  shape: %s\n  dtype: %s"
            % (type(full_elevation), full_elevation.shape, full_elevation.dtype))
ax = plt.contourf(full_elevation)
plt.colorbar(ax)
plt.show()
# - read the first 10 rows of the elevation layers
selection_slice = slice(0, 10)
sliced_elevation = bag_0.elevation(mask_nan=True, row_range=selection_slice)
logger.info("sliced elevation array:\n  type: %s\n  shape: %s\n  dtype: %s"
            % (type(sliced_elevation), sliced_elevation.shape, sliced_elevation.dtype))
ax = plt.contourf(sliced_elevation)
plt.colorbar(ax)
plt.show()