proc_utils/proj.py
def haversineForGrid(grid):
    """
    This function is used to obtain vertical and horizontal distances inside a grid
    :param grid:
    :return:
    """
    grid_rad = list(map(np.radians, grid))
    lat_rad = grid_rad[1]
    lon_rad = grid_rad[0]

    dlat = lat_rad[1:,:] - lat_rad[:-1,:]
    dlon = lon_rad[:,1:] - lon_rad[:,:-1]

    # We are creating horizontal and vertical distances
    out_dims = (2, grid[0].shape[0]-1,grid[0].shape[1]-1)
    output = np.zeros(out_dims)

    # Filling by cols
    for c_col in range(out_dims[2]):
        output[0,:,c_col] = np.sin(dlat[:,c_col]/2.0)**2
        output[1,:,c_col] = (np.cos(lat_rad[:,c_col+1]) * np.cos(lat_rad[:,c_col]) * np.sin(dlon[:,c_col]/2.0)**2)[:-1]

    c = 2 * np.arcsin(np.sqrt(output))
    dist = (6371000 * c)  # [m]
    return dist

    This function is used to obtain vertical and horizontal distances inside a grid
    :param grid:
    :return:
    
This function is used to obtain vertical and horizontal distances inside a grid
This function is used to obtain vertical and horizontal distances inside a grid
def haversineForGrid(grid):
    grid_rad = list(map(np.radians, grid))
    lat_rad = grid_rad[1]
    lon_rad = grid_rad[0]
    dlat = lat_rad[1:,:] - lat_rad[:-1,:]
    dlon = lon_rad[:,1:] - lon_rad[:,:-1]
    out_dims = (2, grid[0].shape[0]-1,grid[0].shape[1]-1)
    output = np.zeros(out_dims)
    for c_col in range(out_dims[2]):
        output[0,:,c_col] = np.sin(dlat[:,c_col]/2.0)**2
        output[1,:,c_col] = (np.cos(lat_rad[:,c_col+1]) * np.cos(lat_rad[:,c_col]) * np.sin(dlon[:,c_col]/2.0)**2)[:-1]
    c = 2 * np.arcsin(np.sqrt(output))
    dist = (6371000 * c)  
    return dist
def haversineForGrid ( grid ) : grid_rad = list ( map ( np . radians , grid ) ) lat_rad = grid_rad [ 1 ] lon_rad = grid_rad [ 0 ] dlat = lat_rad [ 1 : , : ] - lat_rad [ : - 1 , : ] dlon = lon_rad [ : , 1 : ] - lon_rad [ : , : - 1 ] out_dims = ( 2 , grid [ 0 ] . shape [ 0 ] - 1 , grid [ 0 ] . shape [ 1 ] - 1 ) output = np . zeros ( out_dims ) for c_col in range ( out_dims [ 2 ] ) : output [ 0 , : , c_col ] = np . sin ( dlat [ : , c_col ] / 2.0 ) ** 2 output [ 1 , : , c_col ] = ( np . cos ( lat_rad [ : , c_col + 1 ] ) * np . cos ( lat_rad [ : , c_col ] ) * np . sin ( dlon [ : , c_col ] / 2.0 ) ** 2 ) [ : - 1 ] c = 2 * np . arcsin ( np . sqrt ( output ) ) dist = ( 6371000 * c ) return dist
This function is used to obtain vertical and horizontal distances inside a grid
This function is used to obtain vertical and horizontal distances inside a grid
"""
    This function is used to obtain vertical and horizontal distances inside a grid
    :param grid:
    :return:
    """ # We are creating horizontal and vertical distances # Filling by cols # [m]
None
grid
None