def plotfitstats(p1a, p2a, p1d, p2d, rmsda, biasa, title, fname): """image plot for rmsda with contour lines of bias""" sns.set_style("white", {"image.cmap": "Greens"}) sns.set_color_palette("pastel") sns.set_palette("pastel") x, y = np.meshgrid(p1a, p2a) fig, ax = plt.subplots() # im = ax.imshow(rmsda) # im.set_interpolation('bilinear') p = ax.pcolor(x, y, rmsda.T) # p = ax.pcolor(rmsda, cmap = sns.color_palette('pastel', 100, as_cmap = True)) cb = fig.colorbar(p, ax=ax) cnt = ax.contour( x, y, biasa.T, colors="black", # colors = sns.color_palette('bright', 100), # origin = 'upper', origin="lower", linewidth=3, ) plt.clabel(cnt, inline=1, fontsize=10, fmt="%.2f") ax.set_title( "%s, p1_default = %.3g, p2_default = %.3g\nBias (line) and RMSE (image) -- min(RMSE) = %.1f" % (title, p1d, p2d, np.min(rmsda)) ) ax.set_xlabel("p1") ax.set_ylabel("p2") fig.savefig(fname)
def realign_report(target_file, realign_params, displace_params): """Create files summarizing the motion correction.""" # Create a DataFrame with the 6 motion parameters rot = ["rot_" + dim for dim in ["x", "y", "z"]] trans = ["trans_" + dim for dim in ["x", "y", "z"]] df = pd.DataFrame(np.loadtxt(realign_params), columns=rot + trans) abs, rel = displace_params df["displace_abs"] = np.loadtxt(abs) df["displace_rel"] = pd.Series(np.loadtxt(rel), index=df.index[1:]) df.loc[0, "displace_rel"] = 0 motion_file = os.path.abspath("realignment_params.csv") df.to_csv(motion_file, index=False) # Write the motion plots seaborn.set() seaborn.set_color_palette("husl", 3) f, (ax_rot, ax_trans) = plt.subplots(2, 1, figsize=(8, 3.75), sharex=True) ax_rot.plot(df[rot] * 100) ax_rot.axhline(0, c="#444444", ls="--", zorder=1) ax_trans.plot(df[trans]) ax_trans.axhline(0, c="#444444", ls="--", zorder=1) ax_rot.set_xlim(0, len(df) - 1) ax_rot.set_ylabel(r"Rotations (rad $\times$ 100)") ax_trans.set_ylabel("Translations (mm)") plt.tight_layout() plot_file = os.path.abspath("realignment_plots.png") f.savefig(plot_file, dpi=100, bbox_inches="tight") plt.close(f) # Write the example func plot data = nib.load(target_file).get_data() n_slices = data.shape[-1] n_row, n_col = n_slices // 8, 8 start = n_slices % n_col // 2 figsize = (10, 1.375 * n_row) f, axes = plt.subplots(n_row, n_col, figsize=figsize, facecolor="k") vmin, vmax = 0, moss.percentiles(data, 99) for i, ax in enumerate(axes.ravel(), start): ax.imshow(data[..., i].T, cmap="gray", vmin=vmin, vmax=vmax) ax.set_xticks([]) ax.set_yticks([]) f.subplots_adjust(hspace=1e-5, wspace=1e-5) target_file = os.path.abspath("example_func.png") f.savefig(target_file, dpi=100, bbox_inches="tight", facecolor="k", edgecolor="k") plt.close(f) return [motion_file, plot_file, target_file], motion_file
def histogram(dataset, xlabel, title): seaborn.set_color_palette("deep", desat=.6) matplotlib.rc("figure", figsize=(8, 4)) #seaborn.distplot(dataset) density = stats.gaussian_kde(dataset) density.covariance_factor = lambda : .25 density._compute_covariance() xgrid = numpy.linspace(min(dataset), max(dataset), 100) pyplot.hist(dataset, bins=100, log=True) #pyplot.plot(xgrid, density.evaluate(xgrid), label='kde', color='r') #pyplot.plot(xgrid, stats.norm.pdf(xgrid), label='DGP normal', color="g") pyplot.xlabel(xlabel) pyplot.ylabel('Frequency (logarithmic)') pyplot.title(title) pyplot.show()
def init_graph_style(): sns.set_color_palette("deep", desat=.6) mpl.rc("figure", figsize=(8, 4)) np.random.seed(9221999)
import pandas import matplotlib.pyplot as plt import numpy as np import matplotlib import seaborn as sns from scipy import stats sns.set_color_palette("deep", desat=.6) sns.set_axes_style("whitegrid", "talk") import heroespy from heroespy.util import times file = "/Users/schriste/Dropbox/Developer/HEROES/HEROES-Telescope/SAS1_pointing_data.csv" data = pandas.read_csv(file, parse_dates=True, index_col = 0) ind = data['ctl el'].index time_index=ind.indexer_between_time(times.solarobs_target2[0], times.solarobs_target2[1]) sas1_obs = data.iloc[time_index] # in arcseconds ctl_el = sas1_obs['ctl el'] * 60 * 60 plt.figure() ax = ctl_el.plot() ax.set_title('HEROES/SAS PYAS-F') ax.set_xlabel('2013-09-21 [UTC]') ax.set_ylabel('Elevation Offset [arcsec]') ax.set_ybound(-100,100) plt.savefig('PYASF_el_timeseries.pdf')
import pandas import matplotlib.pyplot as plt import numpy as np import matplotlib import seaborn as sns from scipy import stats sns.set_color_palette("deep", desat=.6) sns.set_axes_style("whitegrid", "talk") import heroespy from heroespy.util import times file = "/Users/schriste/Dropbox/Developer/HEROES/HEROES-Telescope/SAS1_pointing_data.csv" data = pandas.read_csv(file, parse_dates=True, index_col=0) ind = data['ctl el'].index time_index = ind.indexer_between_time(times.solarobs_target2[0], times.solarobs_target2[1]) sas1_obs = data.iloc[time_index] # in arcseconds ctl_el = sas1_obs['ctl el'] * 60 * 60 plt.figure() ax = ctl_el.plot() ax.set_title('HEROES/SAS PYAS-F') ax.set_xlabel('2013-09-21 [UTC]') ax.set_ylabel('Elevation Offset [arcsec]') ax.set_ybound(-100, 100)
fit_high = [] for i in range(1, 41): fitness = float(0) with open('reproduction/pairs/dom-%s.org-B' %i, 'r') as org: for line in org: if line.startswith('# Fitness'): fitness = float(line.split()[2]) fit_high.append(fitness) fit_high.sort() fit_high.reverse() with open('fitness.csv', 'wb') as f: w = csv.writer(f,delimiter=',', quoting = csv.QUOTE_ALL) w.writerow('CLH') for row in zip(fit_comp, fit_low, fit_high): w.writerow(row) # must specify that blank space " " is NaN experimentDF = read_csv("fitness.csv", na_values=[" "]) print experimentDF sns.set_color_palette("hls") mpl.rc("figure", figsize=(16, 8)) experimentDF.dropna().plot(kind='kde')