def _run_multi_processing(self, star_reshape, im_shape, indices): """ Internal function to create the residuals, derotate the images, and write the output using multiprocessing. """ tmp_output = np.zeros( (len(self.m_components), im_shape[1], im_shape[2])) if self.m_res_mean_out_port is not None: self.m_res_mean_out_port.set_all(tmp_output, keep_attributes=False) if self.m_res_median_out_port is not None: self.m_res_median_out_port.set_all(tmp_output, keep_attributes=False) if self.m_res_weighted_out_port is not None: self.m_res_weighted_out_port.set_all(tmp_output, keep_attributes=False) if self.m_res_rot_mean_clip_out_port is not None: self.m_res_rot_mean_clip_out_port.set_all(tmp_output, keep_attributes=False) angles = -1. * self.m_star_in_port.get_attribute( 'PARANG') + self.m_extra_rot capsule = PcaMultiprocessingCapsule( self.m_res_mean_out_port, self.m_res_median_out_port, self.m_res_weighted_out_port, self.m_res_rot_mean_clip_out_port, self._m_config_port.get_attribute('CPU'), deepcopy(self.m_components), deepcopy(self.m_pca), deepcopy(star_reshape), deepcopy(angles), im_shape, indices) capsule.run()
def _run_multi_processing(self, star_reshape: np.ndarray, im_shape: Tuple[int, int, int], indices: np.ndarray) -> None: """ Internal function to create the residuals, derotate the images, and write the output using multiprocessing. """ cpu = self._m_config_port.get_attribute('CPU') angles = -1. * self.m_star_in_port.get_attribute( 'PARANG') + self.m_extra_rot tmp_output = np.zeros( (len(self.m_components), im_shape[1], im_shape[2])) if self.m_res_mean_out_port is not None: self.m_res_mean_out_port.set_all(tmp_output, keep_attributes=False) if self.m_res_median_out_port is not None: self.m_res_median_out_port.set_all(tmp_output, keep_attributes=False) if self.m_res_weighted_out_port is not None: self.m_res_weighted_out_port.set_all(tmp_output, keep_attributes=False) if self.m_res_rot_mean_clip_out_port is not None: self.m_res_rot_mean_clip_out_port.set_all(tmp_output, keep_attributes=False) self.m_star_in_port.close_port() self.m_reference_in_port.close_port() if self.m_res_mean_out_port is not None: self.m_res_mean_out_port.close_port() if self.m_res_median_out_port is not None: self.m_res_median_out_port.close_port() if self.m_res_weighted_out_port is not None: self.m_res_weighted_out_port.close_port() if self.m_res_rot_mean_clip_out_port is not None: self.m_res_rot_mean_clip_out_port.close_port() if self.m_res_arr_out_ports is not None: for pca_number in self.m_components: self.m_res_arr_out_ports[pca_number].close_port() if self.m_basis_out_port is not None: self.m_basis_out_port.close_port() capsule = PcaMultiprocessingCapsule(self.m_res_mean_out_port, self.m_res_median_out_port, self.m_res_weighted_out_port, self.m_res_rot_mean_clip_out_port, cpu, deepcopy(self.m_components), deepcopy(self.m_pca), deepcopy(star_reshape), deepcopy(angles), im_shape, indices) capsule.run()
def _run_multi_processing(self, star_reshape: np.ndarray, im_shape: tuple, indices: Optional[np.ndarray]) -> None: """ Internal function to create the residuals, derotate the images, and write the output using multiprocessing. """ cpu = self._m_config_port.get_attribute('CPU') parang = -1. * self.m_star_in_port.get_attribute( 'PARANG') + self.m_extra_rot if self.m_ifs_data: if 'WAVELENGTH' in self.m_star_in_port.get_all_non_static_attributes( ): wavelength = self.m_star_in_port.get_attribute('WAVELENGTH') else: raise ValueError( 'The wavelengths are not found. These should be stored ' 'as the \'WAVELENGTH\' attribute.') scales = scaling_factors(wavelength) else: scales = None if self.m_processing_type in ['ADI', 'SDI']: pca_first = self.m_components pca_secon = [-1] # Not used elif self.m_processing_type in ['SDI+ADI', 'ADI+SDI']: pca_first = self.m_components[0] pca_secon = self.m_components[1] if self.m_ifs_data: if self.m_processing_type in ['ADI', 'SDI']: res_shape = (len(pca_first), len(wavelength), im_shape[-2], im_shape[-1]) elif self.m_processing_type in ['SDI+ADI', 'ADI+SDI']: res_shape = (len(pca_first), len(pca_secon), len(wavelength), im_shape[-2], im_shape[-1]) else: res_shape = (len(self.m_components), im_shape[1], im_shape[2]) tmp_output = np.zeros(res_shape) if self.m_res_mean_out_port is not None: self.m_res_mean_out_port.set_all(tmp_output, keep_attributes=False) if self.m_res_median_out_port is not None: self.m_res_median_out_port.set_all(tmp_output, keep_attributes=False) if self.m_res_weighted_out_port is not None: self.m_res_weighted_out_port.set_all(tmp_output, keep_attributes=False) if self.m_res_rot_mean_clip_out_port is not None: self.m_res_rot_mean_clip_out_port.set_all(tmp_output, keep_attributes=False) self.m_star_in_port.close_port() self.m_reference_in_port.close_port() if self.m_res_mean_out_port is not None: self.m_res_mean_out_port.close_port() if self.m_res_median_out_port is not None: self.m_res_median_out_port.close_port() if self.m_res_weighted_out_port is not None: self.m_res_weighted_out_port.close_port() if self.m_res_rot_mean_clip_out_port is not None: self.m_res_rot_mean_clip_out_port.close_port() if self.m_basis_out_port is not None: self.m_basis_out_port.close_port() capsule = PcaMultiprocessingCapsule( self.m_res_mean_out_port, self.m_res_median_out_port, self.m_res_weighted_out_port, self.m_res_rot_mean_clip_out_port, cpu, deepcopy(self.m_components), deepcopy(self.m_pca), deepcopy(star_reshape), deepcopy(parang), deepcopy(scales), im_shape, indices, self.m_processing_type) capsule.run()