def test_fitter_designmatrix(self): fitter = WidebandTOAFitter([self.toas], self.model, additional_args={}) fitter.model.free_params = self.fit_params_lite assert set(fitter.model.free_params) == set(self.fit_params_lite) # test making design matrix d_matrix = fitter.get_designmatrix() assert d_matrix.shape == (2 * self.toas.ntoas, len(self.fit_params_lite) + 1) assert [lb[0] for lb in d_matrix.labels[0]] == ["toa", "dm"] assert d_matrix.derivative_params == (["Offset"] + fitter.model.free_params)
dm_resids.value, yerr=dm_error.value, fmt="x") plt.ylabel("pc/cm^3") plt.xlabel("MJD") # %% [markdown] # ### Matrices # # We're now fitting a mixed set of data, so the matrices used in fitting now have different units in different parts, and some care is needed to keep track of which part goes where. # %% [markdown] # #### Design Matrix are combined # %% d_matrix = fitter.get_designmatrix() # %% print("Number of TOAs:", toas.ntoas) print("Number of DM measurments:", len(fitter.resids.dm.dm_data)) print("Number of fit params:", len(fitter.model.free_params)) print("Shape of design matrix:", d_matrix.shape) # %% [markdown] # #### Covariance Matrix are combined # %% c_matrix = fitter.get_noise_covariancematrix() # %% print("Shape of covariance matrix:", c_matrix.shape)