def test_nice_colors(): for i in range(10): # check that the entrances are 3: assert len(col.nice_colors(i)) == 3 # check that they are positive and smaller than 1, i.e. it is legal RGB: for j in col.nice_colors(i): assert j >= 0.0 assert j <= 1.0
def test_nice_colors(): for i in xrange(10): # check that the entrances are 3: assert len(col.nice_colors(i))==3 # check that they are positive and smaller than 1, i.e. it is legal RGB: for j in col.nice_colors(i): assert j>=0.0 assert j<=1.0
# print to screen number of SN: if not args.quiet: for k in xrange(0, number_SN_mock): print 'Total number of SN in '+names[k]+' :', len(data[k][:,1]) print # plot SN redshift distribution and luminosity distance: ax_1 = plt.subplot(plot_grid[1,0]) # distribution ax_2 = plt.subplot(plot_grid[1,1]) # d_L # cycle over files: for k in xrange(0, number_SN_mock): # grab the x values: x_values = data[k][:,1] y_values = data[k][:,2] # do the instogram ax_1.hist(x_values, 50, histtype='step', color=fc.nice_colors(k) ) # do the luminosity plot: y_err = np.sqrt( data[k][:,5] ) # do the plot: ax_2.errorbar(x_values, y_values, yerr=y_err, fmt='o', color=fc.nice_colors(k), markersize=1, markeredgecolor = 'none', markerfacecolor=fc.nice_colors(k), errorevery=errorevery, capsize=0) # finalise the plot: ax_1.set_xlabel( '$z$' ) ax_1.set_ylabel( '$n_{\\rm SN}(z)$' ) ax_2.set_xlabel( '$z$' ) ax_2.set_ylabel( '$\mu_{\\rm obs}(z)$' ) # plot SN mock color:
np.place(y_values, y_values == 0.0, [cutoff]) # get the plot bounds: try: lower_y = 0.9 * np.amin( y_values[np.abs(y_values) > cutoff]) except: lower_y = cutoff try: upper_y = 1.1 * np.amax( y_values[np.abs(y_values) > cutoff]) except: upper_y = cutoff plotrange_x.append([np.amin(x_values), np.amax(x_values)]) plotrange_y.append([lower_y, upper_y]) # do the plot: ax.plot(x_values, y_values, color=fc.nice_colors(k)) # now set the appearence of the plot: plotrange_x = np.array(plotrange_x) plotrange_y = np.array(plotrange_y) # log scale: if not do_lin: ax.set_xscale('log') ax.set_yscale('log') # ranges: x_min = fu.v_nice_number(np.amin(plotrange_x[:, 0]), 1) x_max = fu.v_nice_number(np.amax(plotrange_x[:, 1]), 1) if (x_min != x_max): ax.set_xlim([x_min, x_max]) y_min = fu.v_nice_number(np.amin(plotrange_y[:, 0]), 2) y_max = fu.v_nice_number(np.amax(plotrange_y[:, 1]), 0) if (y_min != y_max):
if not args.quiet: for k in xrange(0, number_SN_mock): print 'Total number of SN in ' + names[k] + ' :', len(data[k][:, 1]) print # plot SN redshift distribution and luminosity distance: ax_1 = plt.subplot(plot_grid[1, 0]) # distribution ax_2 = plt.subplot(plot_grid[1, 1]) # d_L # cycle over files: for k in xrange(0, number_SN_mock): # grab the x values: x_values = data[k][:, 1] y_values = data[k][:, 2] # do the instogram ax_1.hist(x_values, 50, histtype='step', color=fc.nice_colors(k)) # do the luminosity plot: y_err = np.sqrt(data[k][:, 5]) # do the plot: ax_2.errorbar(x_values, y_values, yerr=y_err, fmt='o', color=fc.nice_colors(k), markersize=1, markeredgecolor='none', markerfacecolor=fc.nice_colors(k), errorevery=errorevery, capsize=0) # finalise the plot:
# get the Cls values: if do_abs: y_values = np.abs( factor*data[k][:,col] ) else: y_values = factor*data[k][:,col] # protect against zeroes: np.place(y_values, y_values==0.0, [cutoff]) # get the plot bounds: try: lower_y = 0.9*np.amin(y_values[np.abs(y_values)>cutoff]) except: lower_y = cutoff try: upper_y = 1.1*np.amax(y_values[np.abs(y_values)>cutoff]) except: upper_y = cutoff plotrange_x.append( [ np.amin(x_values), np.amax(x_values) ] ) plotrange_y.append( [ lower_y,upper_y ] ) # do the plot: ax.plot( x_values, y_values, color=fc.nice_colors(k) ) # now set the appearence of the plot: plotrange_x = np.array( plotrange_x ) plotrange_y = np.array( plotrange_y ) # log scale: if not do_lin: ax.set_xscale('log') ax.set_yscale('log') # ranges: x_min = fu.v_nice_number( np.amin(plotrange_x[:,0]),1) x_max = fu.v_nice_number( np.amax(plotrange_x[:,1]),1) if ( x_min != x_max ): ax.set_xlim( [ x_min,x_max ] ) y_min = fu.v_nice_number( np.amin(plotrange_y[:,0]),2) y_max = fu.v_nice_number( np.amax(plotrange_y[:,1]),0) if ( y_min != y_max ):