def calculate_speeds(IM, origin=None, Jacobian=False, dr=1, dt=None): """ Angular integration of the image. Returning the one-dimentional intensity profile as a function of the radial coordinate. Parameters ---------- IM: rows x cols 2D np.array The data image. origin: tuple Image center coordinate relative to *bottom-left* corner defaults to (rows//2+rows%2,cols//2+cols%2). Jacobian: boolean Include r*sinθ in the angular sum (integration). dr: float Radial coordinate grid spacing, in pixels (default 1). dt: float Theta coordinate grid spacing in degrees, defaults to rows//2. Returns ------- 1D np.array Integrated intensity array (vs radius). 1D np.array Corresponding radial coordinates """ polarIM, r_grid, theta_grid = reproject_image_into_polar(IM, origin, Jacobian=Jacobian, dr=dr, dt=dt) theta = theta_grid[0, :] # theta coordinates r = r_grid[:, 0] # radial coordinates if Jacobian: # x r sinθ sintheta = np.abs(np.sin(theta)) polarIM = polarIM * sintheta[np.newaxis, :] polarIM = polarIM * r[:, np.newaxis] speeds = np.sum(polarIM, axis=1) n = speeds.shape[0] return speeds, r[:n] # limit radial coordinates range to match speed
def calculate_speeds(IM, origin=None, Jacobian=False, dr=1, dt=None): """ Angular integration of the image. Returning the one-dimentional intensity profile as a function of the radial coordinate. Parameters ---------- IM: rows x cols 2D np.array The data image. origin: tuple Image center coordinate relative to *bottom-left* corner defaults to (rows//2+rows%2,cols//2+cols%2). Jacobian: boolean Include r*sinθ in the angular sum (integration). dr: float Radial coordinate grid spacing, in pixels (default 1). dt: float Theta coordinate grid spacing in degrees, defaults to rows//2. Returns ------- 1D np.array Integrated intensity array (vs radius). 1D np.array Corresponding radial coordinates """ polarIM, r_grid, theta_grid = reproject_image_into_polar(IM, origin, Jacobian=Jacobian, dr=dr, dt=dt) theta = theta_grid[0, :] # theta coordinates r = r_grid[:, 0] # radial coordinates if Jacobian: # x r sinθ sintheta = np.abs(np.sin(theta)) polarIM = polarIM*sintheta[np.newaxis, :] polarIM = polarIM*r[:, np.newaxis] speeds = np.sum(polarIM, axis=1) n = speeds.shape[0] return speeds, r[:n] # limit radial coordinates range to match speed
def calculate_angular_distributions(IM, radial_ranges=None): """ Intensity variation in the angular coordinate, theta. This function is the theta-coordinate complement to 'calculate_speeds(IM)' (optionally and more useful) returning intensity vs angle for defined radial ranges. Parameters ---------- IM: 2D np.array Image data radial_ranges: list of tuples [(r0, r1), (r2, r3), ...] Evaluate the intensity vs angle for the radial ranges r0_r1, r2_r3, etc. Returns -------- 2D np.array Intensity vs angle distribution for each selected radial range. 1D np.array Angle coordinates, referenced to vertical direction. """ polarIM, r_grid, theta_grid = reproject_image_into_polar(IM) theta = theta_grid[0, :] # theta coordinates r = r_grid[:, 0] # radial coordinates if radial_ranges is None: radial_ranges = [ (0, r[-1]), ] intensity_vs_theta_at_R = [] for rr in radial_ranges: subr = np.logical_and(r >= rr[0], r <= rr[1]) # sum intensity across radius of spectral feature intensity_vs_theta_at_R.append(np.sum(polarIM[subr], axis=0)) return intensity_vs_theta_at_R, theta
def calculate_angular_distributions(IM, radial_ranges=None): """ Intensity variation in the angular coordinate, theta. This function is the theta-coordinate complement to 'calculate_speeds(IM)' (optionally and more useful) returning intensity vs angle for defined radial ranges. Parameters ---------- IM: 2D np.array Image data radial_ranges: list of tuples [(r0, r1), (r2, r3), ...] Evaluate the intensity vs angle for the radial ranges r0_r1, r2_r3, etc. Returns -------- 2D np.array Intensity vs angle distribution for each selected radial range. 1D np.array Angle coordinates, referenced to vertical direction. """ polarIM, r_grid, theta_grid = reproject_image_into_polar(IM) theta = theta_grid[0, :] # theta coordinates r = r_grid[:, 0] # radial coordinates if radial_ranges is None: radial_ranges = [(0, r[-1]), ] intensity_vs_theta_at_R = [] for rr in radial_ranges: subr = np.logical_and(r >= rr[0], r <= rr[1]) # sum intensity across radius of spectral feature intensity_vs_theta_at_R.append(np.sum(polarIM[subr], axis=0)) return intensity_vs_theta_at_R, theta