kernel.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:MOSFiT 作者: guillochon 项目源码 文件源码
def preprocess(self, **kwargs):
        """Construct kernel distance arrays."""
        new_times = np.array(kwargs.get('all_times', []), dtype=float)
        self._codeltatime = kwargs.get(self.key('codeltatime'), -1)
        self._codeltalambda = kwargs.get(self.key('codeltalambda'), -1)
        if np.array_equiv(new_times, self._times) and self._preprocessed:
            return
        self._times = new_times
        self._all_band_indices = kwargs.get('all_band_indices', [])
        self._are_bands = np.array(self._all_band_indices) >= 0
        self._freqs = kwargs.get('all_frequencies', [])
        self._u_freqs = kwargs.get('all_u_frequencies', [])
        self._waves = np.array([
            self._average_wavelengths[bi] if bi >= 0 else
            C_CGS / self._freqs[i] / ANG_CGS for i, bi in
            enumerate(self._all_band_indices)])
        self._observed = np.array(kwargs.get('observed', []), dtype=bool)
        self._n_obs = len(self._observed)

        self._o_times = self._times[self._observed]
        self._o_waves = self._waves[self._observed]

        if self._type == 'full':
            self._times_1 = self._times
            self._times_2 = self._times
            self._waves_1 = self._waves
            self._waves_2 = self._waves
        elif self._type == 'oa':
            self._times_1 = self._o_times
            self._times_2 = self._times
            self._waves_1 = self._o_waves
            self._waves_2 = self._waves
        elif self._type == 'ao':
            self._times_1 = self._times
            self._times_2 = self._o_times
            self._waves_1 = self._waves
            self._waves_2 = self._o_waves
        else:
            self._times_1 = self._o_times
            self._times_2 = self._o_times
            self._waves_1 = self._o_waves
            self._waves_2 = self._o_waves

        # Time deltas (radial distance) for covariance matrix.
        if self._codeltatime >= 0:
            self._dt2mat = self._times_1[:, None] - self._times_2[None, :]
            self._dt2mat **= 2
            self._dt2mat *= -0.5

        # Wavelength deltas (radial distance) for covariance matrix.
        if self._codeltalambda >= 0:
            self._dl2mat = self._waves_1[:, None] - self._waves_2[None, :]
            self._dl2mat **= 2
            self._dl2mat *= -0.5

        self._preprocessed = True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号