asi_core.asi_analysis ===================== .. py:module:: asi_core.asi_analysis .. autoapi-nested-parse:: This module provides functions to analyse all-sky images. Functions --------- .. autoapisummary:: asi_core.asi_analysis._to_radians asi_core.asi_analysis.polar_to_cart asi_core.asi_analysis.get_sun_pos_in_asi asi_core.asi_analysis.compute_sun_dist_map asi_core.asi_analysis.compute_cloud_coverage_and_distance_to_sun asi_core.asi_analysis.sph2cart asi_core.asi_analysis.cart2sph asi_core.asi_analysis.create_perspective_undistortion_LUT asi_core.asi_analysis.create_panoramic_undistortion_LUT asi_core.asi_analysis.get_sun_dist asi_core.asi_analysis.is_circle_contour asi_core.asi_analysis.get_saturated_mask Module Contents --------------- .. py:function:: _to_radians(ele, az) Converts elevation and azimuth angles from degrees to radians. .. py:function:: polar_to_cart(r, ele, az) Converts polar coordinates to Cartesian coordinates. .. py:function:: get_sun_pos_in_asi(sun_ele, sun_az, ele_mat, az_mat) Determines the pixel position of the sun in an all-sky image. :param sun_ele: Sun elevation angle in degrees. :param sun_az: Sun azimuth angle in degrees. :param ele_mat: Elevation matrix of the all-sky image. :param az_mat: Azimuth matrix of the all-sky image. :return: (row, col) coordinates of the sun in the image. .. py:function:: compute_sun_dist_map(sun_ele, sun_az, ele_mat, az_mat, apply_filter=False, size=5) Computes the distance map from each pixel to the sun in an all-sky image. :param sun_ele: Sun elevation angle in degrees. :param sun_az: Sun azimuth angle in degrees. :param ele_mat: Elevation matrix of the all-sky image. :param az_mat: Azimuth matrix of the all-sky image. :param apply_filter: Whether to apply median filtering (default: False). :param size: Kernel size for median filtering (default: 5). :return: Distance map (in degrees) to the sun. .. py:function:: compute_cloud_coverage_and_distance_to_sun(seg_mask, cam_mask, sun_dist_map, cloud_value=1) Computes cloud coverage and the minimum distance between clouds and the sun. :param seg_mask: Segmentation mask of the sky (clouds vs. background). :param cam_mask: Camera mask indicating valid pixels. :param sun_dist_map: Distance map from each pixel to the sun. :param cloud_value: Value representing clouds in the segmentation mask (default: 1). :return: Tuple (cloud_coverage, min_dist_cloud, coord_cloud): - cloud_coverage: Fraction of the sky covered by clouds. - min_dist_cloud: Minimum distance between a cloud pixel and the sun. - coord_cloud: Coordinates of the closest cloud pixel to the sun. .. py:function:: sph2cart(az, el, r) Transform spherical to cartesian coordinates :param az: [radian] array of the azimuth angle, over positive x-axis, rotating around z-axis :param el: [radian] array of the elevation angle :param r: array of the radius :return: arrays of the cartesian coordinates x, y, z (same unit as radius) .. py:function:: cart2sph(x, y, z) Transform cartesian to spherical coordinates. See reverse function sph2cart, for further convention. :param x: cartesian coordinate x :param y: cartesian coordinate y, same unit as x :param z: cartesian coordinate z, same unit as x :return: arrays of the azimuth angle, elevation angle, radius (same unit as x) .. py:function:: create_perspective_undistortion_LUT(o, sf) Create a look-up table for perspective undistortion. :param o: OcamModel instance :param sf: Scaling factor. :return: Two look-up tables (mapx and mapy) for perspective undistortion. .. py:function:: create_panoramic_undistortion_LUT(r_min, r_max, o) Create a look-up table for panoramic undistortion. :param r_min: Minimum radial distance. :param r_max: Maximum radial distance. :param o: Dictionary containing camera parameters (height, width, xc, yc). :return: Two look-up tables (map_x and map_y) for panoramic undistortion. .. py:function:: get_sun_dist(az, ele, timestamp, location) Calculate the sun distance angle based on azimuth and elevation angles. :param az: Azimuth angles (in degrees) of the sun. :param ele: Elevation angles (in degrees) of the sun. :param timestamp: Specific timestamp for which the solar position is calculated. :param location: Dictionary containing the latitude, longitude, and altitude of the location. :return: Three values: sun distance angle, sun azimuth angle, and sun elevation angle. .. py:function:: is_circle_contour(contour, aspect_ratio_tolerance=0.1, circularity_threshold=0.8) Determines if a contour is circular based on its aspect ratio and circularity. :param contour: (numpy.ndarray) The contour to analyze. :param aspect_ratio_tolerance: (float, optional) The maximum difference between the aspect ratio of the contour's bounding rectangle and 1. Default is 0.1. :param circularity_threshold: (float, optional) The minimum circularity of the contour. Default is 0.7. :returns: bool, True if the contour is circular, False otherwise. .. py:function:: get_saturated_mask(img, saturation_limit=240, gray_scale=True, channel_dim=-1)