def extract_theta_dot_xi(dataFiles): """ return the polytroic index assosiated solution for every given binary file path Positional Arguments: dataFiles -- iterator of path to binary data files produced from c executable itegrate Returns -> (N, STATE): STATE -- List of data from binary file paths (parallel to N) META -- Metadata extracted from header of dump files """ STATE = list() META = list() for dataFile in dataFiles: state, metadata = load_C_output(dataFile) META.append(metadata) STATE.append(state) return STATE, META
import numpy as np from readCPython import load_C_output if __name__ == "__main__": state, meta = load_C_output( "../data/laneEmdenDataFile_1.000000-nonDegenerate.dat") ftheta = lambda xi: np.sin(xi) / xi theta = ftheta(state[0]) print("Mean Differnce between exact and numeric solution: {}".format( np.mean(theta - state[1])))
if __name__ == "__main__": parser = argparse.ArgumentParser( description="Plot WD Mass vs Central Density") parser.add_argument("files", nargs="+", type=str, help="Path to file") parser.add_argument("-o", "--output", type=str, help="save path") parser.add_argument('-t', '--tex', action='store_true', help='Use the tex rendering engine when plotting') args = parser.parse_args() rho_c = list() R = list() for file in args.files: state, meta = load_C_output(file) # convert dimensionless values to physical equivilents rho_c.append(3.789e6 * meta['theta_c']) xi1, theta_xi1 = find_root(state[0], state[1]) R.append(alpha * xi1 * 100) set_style(usetex=args.tex) fig, ax = plt.subplots(1, 1, figsize=(10, 7)) ax.semilogx(rho_c, R, 'kx') ax.set_ylabel(r'Radius [R$_{\odot}$/100]', fontsize=17) ax.set_xlabel(r'Central Density [g cm$^{-3}$]', fontsize=17) plt.savefig(args.output, bbox_inches='tight')
default=0.24) parser.add_argument("-Z", type=float, help="Meltallicity", default=0) parser.add_argument("-o", "--output", type=str, help="Output Location", default="NULL") args = parser.parse_args() # Exctract the polytropic index from the file name convention n = float(args.path.split('/')[-1].split('_')[1][:-7]) # Load data from the c dump binary state, metadata = load_C_output(args.path) xi1, thetaXi1 = find_root(state[0], state[1]) dthetaXdxi1, _ = find_root(state[2], state[1]) # Select only the portion of the the solution less than the radius of the star conditional = state[0] <= xi1 xi = state[0][conditional] theta = state[1][conditional] dtheta = state[2][conditional] M = args.mass # Select a-priori radius or given luminosity and temperature if args.radius: R = args.radius
parser.add_argument("-o", "--output", type=str, help="save path") parser.add_argument('-t', '--tex', action='store_true', help='Use the tex rendering engine when plotting') parser.add_argument('-m', '--mass', nargs="+", type=float, help='Given mass') args = parser.parse_args() masses = list() for file in args.files: state, meta = load_C_output(file, oh=True) # convert dimensionless values to physical equivilents masses.append(0.09 * meta['m']) masses = np.array(masses) set_style(usetex=args.tex) fig, ax = plt.subplots(1, 1, figsize=(10, 7)) for mass in args.mass: # select the closest mass to the given mass idx = (np.abs(masses - mass)).argmin() state, meta = load_C_output(args.files[idx]) ax.plot(alpha * state[0] * 100, 3.789e6 * state[1], label=r"M: {:0.2f} M$_{{\odot}}$".format(0.09 * meta['m'])) ax.legend(fontsize=17)