def join_eventlists(event_file1, event_file2, new_event_file=None): """Join two event files. Parameters ---------- event_file1 : str First event file event_file2 : str Second event file Other parameters ---------------- new_event_file : str, default None Output event file. If not specified uses `hendrics.utils.common_name` to figure out a good name to use mixing up the two input names. Returns ------- new_event_file : str Output event file """ if new_event_file is None: new_event_file = \ common_name(event_file1, event_file2) + '_ev' + HEN_FILE_EXTENSION events1 = load_events(event_file1) events2 = load_events(event_file2) events = events1.join(events2) events.header = events1.header save_events(events, new_event_file) return new_event_file
def test_load_and_save_events(self): events = EventList([0, 2, 3.], pi=[1, 2, 3], mjdref=54385.3254923845, gti = np.longdouble([[-0.5, 3.5]])) events.energy = np.array([3., 4., 5.]) save_events(events, self.dum) events2 = load_events(self.dum) assert np.allclose(events.time, events2.time) assert np.allclose(events.pi, events2.pi) assert np.allclose(events.mjdref, events2.mjdref) assert np.allclose(events.gti, events2.gti) assert np.allclose(events.energy, events2.energy)
def test_orbital(self): import pandas as pd events = load_events(self.dum) csv_file = decide_binary_parameters(137430, [0.03, 0.035], [2. * 86400, 2.5 * 86400], [0., 1.], fdot_range=[0, 5e-10], reset=False, NMAX=10) table = pd.read_csv(csv_file) assert len(table) == 10 folding_orbital_search(events, csv_file, chunksize=10, outfile='out.csv') table = pd.read_csv('out.csv') assert len(table) == 10 assert np.all(table['done']) os.unlink(csv_file) os.unlink('out.csv')