# NUMERIC true_params = { 'log_orbital_period': np.log(p_orbit), 'log_rotation_period': np.log(p_rotation), 'logit_cos_inc': logit(np.cos(inclination)), 'logit_cos_obl': logit(np.cos(obliquity)), 'logit_phi_orb': logit(phi_orb, low=0, high=2 * np.pi), 'logit_obl_orientation': logit(phi_rot, low=0, high=2 * np.pi) } truth = IlluminationMapPosterior(times, np.zeros_like(times), measurement_std, nside=nside) truth.fix_params(true_params) p = np.concatenate([np.zeros(truth.nparams), one_point_map]) numeric_lightcurve = truth.lightcurve(p) run_times_analytic = np.array([]) run_times_numeric = np.array([]) nside_resolutions = np.array([1, 2, 4, 8]) print("Test:") for i in np.nditer(nside_resolutions): nside = i whitenoise_relative_amp = 0.2 length_scale = 30 * np.pi / 2 albedo_mean = 0.5 albedo_std = 0.2 while True: one_point_map = draw_map(nside, albedo_mean, albedo_std, whitenoise_relative_amp, length_scale)
'log_orbital_period': np.log(p_orbit), 'log_rotation_period': np.log(p_rotation), 'logit_cos_inc': logit(np.cos(inclination)), 'logit_cos_obl': logit(np.cos(obliquity)), 'logit_phi_orb': logit(phi_orb, low=0, high=2 * np.pi), 'logit_obl_orientation': logit(phi_rot, low=0, high=2 * np.pi) } truth.fix_params(true_params) p_1 = np.concatenate([np.zeros(truth.nparams), sim_map_1]) p_2 = np.concatenate([np.zeros(truth.nparams), sim_map_2]) p_3 = np.concatenate([np.zeros(truth.nparams), sim_map_3]) p_4 = np.concatenate([np.zeros(truth.nparams), sim_map_4]) p_5 = np.concatenate([np.zeros(truth.nparams), sim_map_5]) numeric_1 = truth.lightcurve(p_1) numeric_2 = truth.lightcurve(p_2) numeric_3 = truth.lightcurve(p_3) numeric_4 = truth.lightcurve(p_4) numeric_5 = truth.lightcurve(p_5) # Plotting all the curves together print("making plots...") plt.subplots(1, 2) # Subplot 1 plt.subplot(1, 2, 1) f, (ax1, ax2, ax3, ax4, ax5) = plt.subplots(5, sharex=True, sharey=True) f.suptitle('Analytic and numeric lightcurves at different locations') ax1.plot(times, analytic_1, label='analytic 1') ax1.plot(times, numeric_1, label='numeric 1')
true_params = { 'log_orbital_period':np.log(p_orbit), 'logit_cos_inc':logit(np.cos(inclination)), 'logit_cos_obl':logit(np.cos(obliquity)), 'logit_phi_orb':logit(phi_orb, low=0, high=2*np.pi), 'logit_obl_orientation':logit(phi_rot, low=0, high=2*np.pi), 'mu':0.5, 'log_sigma':np.log(0.25), 'logit_wn_rel_amp':logit(0.02), 'logit_spatial_scale':logit(30. * np.pi/180), 'log_error_scale': np.log(1.)} truth.fix_params(true_params) # fixing the parameters with the measurements p = np.concatenate([[np.log(day)], sim_map]) # create an array with the map and the rotation period # Generate and save a lightcurve true_lightcurve = truth.lightcurve(p) # lightcurve from known parameters, map and period obs_lightcurve = true_lightcurve.copy() # copy the lightcurve and add noise (below) obs_lightcurve += truth.sigma_reflectance * np.random.randn(len(true_lightcurve)) np.savetxt('obs_lightcurve.csv', obs_lightcurve, delimiter=',') # save the lightcurve with noise as a csv file # Posterior from lightcurve logpost = IlluminationMapPosterior(times, obs_lightcurve, # posterior from lightcurve and parameters measurement_std, nside=sim_nside) fix = true_params.copy() logpost.fix_params(fix) # fix the parameters to the true parameters # Chi-square minimization and initial guess # Grid search for chi-square and period
np.zeros_like(times), measurement_std, nside=nside) true_params = { 'log_orbital_period': np.log(p_orbit), 'log_rotation_period': np.log(p_rotation), 'logit_cos_inc': logit(np.cos(inclination)), 'logit_cos_obl': logit(np.cos(obliquity)), 'logit_phi_orb': logit(phi_orb, low=0, high=2 * np.pi), 'logit_obl_orientation': logit(phi_rot, low=0, high=2 * np.pi) } truth.fix_params(true_params) p = np.concatenate([np.zeros(truth.nparams), simulated_map]) lightcurve = truth.lightcurve(p) plt.figure(figsize=(16, 6)) plt.subplot(2, 1, 1) # plt.figure(figsize=(16, 3)) plt.plot(times, lightcurve, lw=0.5) plt.xlim(0, p_orbit / p_rotation) plt.ylim(ymin=0) plt.xlabel(r'time$/P_\mathrm{rot}$') plt.ylabel('reflectance') w_rot = 1 / p_rotation w_orb = 1 / p_orbit time_data = np.arange(0.0, 20.0, 0.1) # time_data = times obq = 0
'logit_cos_obl': logit(np.cos(obliquity)), 'logit_phi_orb': logit(phi_orb, low=0, high=2 * np.pi), 'logit_obl_orientation': logit(phi_rot, low=0, high=2 * np.pi), 'mu': 0.5, 'log_sigma': np.log(0.25), 'logit_wn_rel_amp': logit(0.02), 'logit_spatial_scale': logit(30. * np.pi / 180), 'log_error_scale': np.log(1.) } truth_1.fix_params(true_params) truth_2.fix_params(true_params) truth_3.fix_params(true_params) truth_4.fix_params(true_params) p = np.concatenate([[np.log(day)], sim_map]) true_lightcurve_1 = truth_1.lightcurve(p) true_lightcurve_2 = truth_2.lightcurve(p) true_lightcurve_3 = truth_3.lightcurve(p) true_lightcurve_4 = truth_4.lightcurve(p) true_posterior_1 = IlluminationMapPosterior(epoch_1, true_lightcurve_1, measurement_std, nside=sim_nside) true_posterior_2 = IlluminationMapPosterior(epoch_2, true_lightcurve_2, measurement_std, nside=sim_nside) true_posterior_3 = IlluminationMapPosterior(epoch_3, true_lightcurve_3, measurement_std,