def _calculatePatchSize(tile, patch_size):
    """
    Function to automatically calculate a patch_size

    Args:
        tile: Either an ALOS tile (biota.LoadTile()) or an ALOS change object (biota.LoadChange())
        patch_size = Number of pixels to build into a single patch. Set to 'auto' for an approx 100 x 100 output image

    Returns:
        The patch size
    """

    assert patch_size == 'auto' or type(patch_size) == float or type(patch_size) == int, "Patch size must be numeric or set to 'auto'."

    # Calculate patch_size (which aims for a 100 x 100 output image if set to auto.)
    if patch_size == 'auto': patch_size = int(round(((tile.xSize + tile.ySize) / 2.) / 100.))

    return patch_size