import numpy as np import matplotlib.pyplot as plt import lather time = np.linspace(0, 25.05, 100, endpoint=False) sim = lather.Simulation('soap.toml') rv, ccfs = sim.observe_rv(time, 5293e-10, 5294e-10) soap_rv = np.loadtxt('soap_rv.txt') * 1e3 plt.plot(time, rv, label='lather') plt.plot(time, soap_rv, label='SOAP-2') plt.legend() plt.show() plt.plot(time, rv - soap_rv) plt.show()
import numpy as np import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import lather f = 40 #set to 1 to see a single rotation period, >1 for more than one time = np.linspace(0, f * 30., f * 30) print(time) ##randomized star spots, fill sim = lather.Simulation('sun.toml') print(sim) flux_b = sim.observe_flux(time, 4000e-10, 5000e-10) flux_r = sim.observe_flux(time, 7000e-10, 8000e-10) rv_b, bisectors_b = sim.observe_rv(time, 4000e-10, 5000e-10) rv_r, bisectors_r = sim.observe_rv(time, 7000e-10, 8000e-10) plt.subplot(211) plt.plot(time, flux_r, 'r') plt.plot(time, flux_b, 'b') plt.title('Flux') plt.subplot(212) plt.plot(time, rv_r, 'r') plt.plot(time, rv_b, 'b') plt.title('RV') plt.tight_layout()
import numpy as np import matplotlib.pyplot as plt import lather time = np.linspace(0, 25.05, 100) sim = lather.Simulation('random.toml') print(sim) flux = sim.observe_flux(time, 4000e-10, 7000e-10) plt.plot(time, flux) plt.title('A lather light curve') plt.xlabel('Time (days)') plt.ylabel('Relative flux') plt.show() rv, ccfs = sim.observe_rv(time, 4000e-10, 7000e-10) plt.plot(time, rv) plt.title('A lather RV curve') plt.xlabel('Time (days)') plt.ylabel('RV (m/s)') plt.show() plt.plot(np.linspace(-2e4, 2e4, 401), ccfs[50]) plt.title('A lather CCF') plt.xlabel('Velocity (m/s)') plt.show() bisector = lather.compute_bisector(ccfs[50]) plt.plot(bisector, np.linspace(0.0, 1.0, bisector.size)) plt.title('A lather bisector')
import argparse import lather import cv2 import numpy as np parser = argparse.ArgumentParser("Lather Visualizer") parser.add_argument("config_file") parser.add_argument("-o", "--output", default="lather.avi", help="output filename, should probably end with .avi") parser.add_argument("-fps", "--framerate", type=int, default=60, help="framerate for the video") parser.add_argument("-d", "--duration", type=float, default=25.05, help="durations (days) of the simulation") parser.add_argument("-fc", "--frame-count", type=int, default=1000, help="number of frames in the video evenly spaced over the provided duration") args = parser.parse_args() sim = lather.Simulation(args.config_file) writer = cv2.VideoWriter(args.output, cv2.VideoWriter_fourcc(*'DIVX'), args.framerate, (1000, 1000)) frame = np.ones((1000, 1000, 3), dtype=np.uint8) import time for t in np.linspace(0, args.duration, args.frame_count): frame = sim.draw_bgr(t, out=frame) writer.write(frame)