def extract_lcdata(filepath, silent=True): """Extracts luminosity versus time from kepler binary file (.lc) """ lumfile = lcdata.load(filepath, silent=silent, graphical=False) if lumfile is None: raise FileNotFoundError("lumfile doesn't exist") else: n = len(lumfile.time) lum = np.full((n, 2), np.nan) lum[:, 0] = lumfile.time lum[:, 1] = lumfile.xlum return lum
def extract_lightcurves(runs, path_data, path_target, basename='xrb'): """======================================================== Loads Kepler .lum binaries and saves txt file of [time, luminosity, radius] for input to kepler_analyser Returns No. of cycles for each run ======================================================== runs = [] : list of run numbers, eg. [324,325,340] path_data = str : path to directory where kepler output folders are located (include trailing slash) path_target = str : path to directory where output .txt files will be written (include trailing slash) in_name = str : base filename of input, eg. 'run' for run324 out_name = str : base filename of output, eg. 'xrb' for xrb324 NOTE: kepler_analyser overwrites summ.csv and db.csv, should put path_target as new directory ========================================================""" print_title() print(f'Loading binaries from {path_data}') print(f'Writing txt files to {path_target}') print_title() cycles = np.zeros(len(runs), dtype=int) for i, run in enumerate(runs): rname = grid_strings.get_run_string(run, basename) lcfile = f'{rname}.lc' savefile = f'{rname}.data' print(f'Loading kepler binary for {rname}') lcpath = os.path.join(path_data, rname, lcfile) data = lcdata.load(lcpath, graphical=False) print('Writing txt file') savepath = os.path.join(path_target, savefile) data.write_lc_txt(savepath) # --- Save number of cycles in model --- cycles[i] = len(data.time) print_dashes()