def test_aperturephotometry(): INPUT_DIR = os.path.join(os.path.dirname(__file__), 'input') OUTPUT_DIR = tempfile.mkdtemp(prefix='tessphot_tests_aperture') for datasource in ('tpf', 'ffi'): with AperturePhotometry(182092046, INPUT_DIR, OUTPUT_DIR, plot=True, datasource=datasource, camera=1, ccd=1) as pho: pho.photometry() pho.save_lightcurve() print( pho.lightcurve ) # It should set the status to one of these: assert(pho.status in (STATUS.OK, STATUS.WARNING)) plt.figure() plot_image(pho.sumimage, title=datasource) plt.show() # They shouldn't be exactly zero: assert( ~np.all(pho.lightcurve['flux'] == 0) ) assert( ~np.all(pho.lightcurve['pos_centroid'][:,0] == 0) ) assert( ~np.all(pho.lightcurve['pos_centroid'][:,1] == 0) ) # They shouldn't be NaN (in this case!): assert( ~np.all(np.isnan(pho.lightcurve['flux'])) ) assert( ~np.all(np.isnan(pho.lightcurve['pos_centroid'][:,0])) ) assert( ~np.all(np.isnan(pho.lightcurve['pos_centroid'][:,1])) )
def test_aperturephotometry(): with TemporaryDirectory() as OUTPUT_DIR: for datasource in ('tpf', 'ffi'): with AperturePhotometry(DUMMY_TARGET, INPUT_DIR, OUTPUT_DIR, plot=True, datasource=datasource, **DUMMY_KWARG) as pho: pho.photometry() pho.save_lightcurve() print(pho.lightcurve) # It should set the status to one of these: assert (pho.status in (STATUS.OK, STATUS.WARNING)) plt.figure() plot_image(pho.sumimage, title=datasource) plt.show() # They shouldn't be exactly zero: assert (~np.all(pho.lightcurve['flux'] == 0)) assert (~np.all(pho.lightcurve['pos_centroid'][:, 0] == 0)) assert (~np.all(pho.lightcurve['pos_centroid'][:, 1] == 0)) # They shouldn't be NaN (in this case!): assert (~np.all(np.isnan(pho.lightcurve['flux']))) assert ( ~np.all(np.isnan(pho.lightcurve['pos_centroid'][:, 0]))) assert ( ~np.all(np.isnan(pho.lightcurve['pos_centroid'][:, 1])))
ax.set_yscale('log') plt.legend() # Plot the new barycentric time correction and the old one: fig2 = plt.figure(figsize=(8,10)) ax3 = fig2.add_subplot(111) ax3.axhline(1.0, color='k', ls='--', lw=1) ax3.plot(time_nocorr, np.abs(ffi_timecorr - f(time_nocorr))*86400, '.-', label='FFI centre') ax3.plot(time_nocorr, np.abs(timecorr_greenwich - f(time_nocorr))*86400*1000, '.-', label='Elenor') ax3.plot(time_nocorr, np.abs(timecorr_astropy - f(time_nocorr))*86400*1000, '.-', label='Astropy') ax3.plot(time_nocorr, np.abs(timecorr_knl - f(time_nocorr))*86400*1000, '.-', label='Kernel') ax3.set_ylabel('abs(TimeCorr - TPF TimeCorr) [ms]') ax3.set_xlabel('Uncorrected Time [TJD]') ax3.set_yscale('log') ax3.set_ylim(bottom=0.1) ax3.legend() ax3.grid(axis='y', which='both', color='0.7', ls=':', lw=0.5) ax3.set_title('TIC %d' % starid) plt.tight_layout() assert np.all(86400000*np.abs(timecorr_astropy - f(time_nocorr)) < 1), "AstroPy method: More than 1 ms away" assert np.all(86400000*np.abs(timecorr_knl - f(time_nocorr)) < 1), "HomeMade method: More than 1 ms away" print("="*72) #-------------------------------------------------------------------------------------------------- if __name__ == '__main__': plt.switch_backend('Qt5Agg') pytest.main([__file__]) plt.show()
label='Elenor', alpha=0.5) ax.scatter(time_nocorr, 86400 * (time_astropy - f2(time_nocorr)), marker='.', c='r', label='Ours', alpha=0.5) tab = Table([ time_nocorr, f2(time_nocorr), ffi_time, time_greenwich, time_astropy ], names=[ 'time_nocorr', 'time_spoc', 'time_fficentre', 'time_greenwich', 'time_ours' ]) print(tab) tab.write('time_TIC%d.ecsv' % starid, format='ascii.ecsv', delimiter=',') ax.set_xlabel('Uncorrected Time [TJD]') ax.set_ylabel('Time - SPOC time [s]') #ax.set_title('TIC %d' % starid) #ax.set_yscale('log') plt.legend() print("=" * 72) plt.show(block=True)