예제 #1
0
파일: chipy.py 프로젝트: alephu5/chipy
def main():
    args = parseargs()
    if args.l:
        # Load layout
        font = load_attribute(args.l + '.font')
        matplotlib.rc('font', **font)

    graph = None
    if args.show or args.s:
        fig = plt.figure()
        ax_main, ax_res = Grid(fig, rect=111, nrows_ncols=(2, 1),
                               axes_pad=0.2, label_mode='L')
        # ax_main.get_xaxis().set_visible(False)

        # div = make_axes_locatable(ax_main)
        # ax_res = div.append_axes('bottom', pad=0.05, label='Residuals',
        #                          size='50%')
        # ax_res = fig.add_subplot(212, label='Residuals')
        graph = (fig, (ax_main, ax_res))

    f_class = args.f()
    control = (None, None, None)

    colors = iter(cm.brg(np.linspace(0, 1, len(args.i) + bool(args.c))))

    if args.c:
        _, dat = unpack_data(args.c, args.delimiter).__next__()
        data = [('control', dat)]
        control = analysis_update(data, f_class, colors.__next__(), graph,
                                  report=False, control=control, notify=False)
    for path in args.i:
        color = colors.__next__()
        try:
            data = unpack_data(path, args.delimiter, filtr=args.filtr,
                               split_column=args.split)
            analysis_update(data, f_class, color, graph, args.r,
                            control=control, notify=True)

        except Exception as e:
            raise e
            print ('Could not process', path, os.linesep)
            return None

    if args.s:
        plt.tight_layout()
        bname = os.path.basename(path)
        name = os.path.splitext(bname)[0]
        fig.savefig(os.path.join(args.s, name + '.png'), dpi=160,
                    bbox_inches='tight', pad_inches=0)

    if args.show:
        plt.tight_layout()
        plt.show()
예제 #2
0
#REDVOL = ['90']
#REDVOL = ['85']
#REDVOL = ['80']
#REDVOL = ['75']
#REDVOL = ['70']
#REDVOL = ['65']

#fs = 24
#plt.figure(figsize=(14,12))
fs = 10
plt.figure(figsize=(6,4))
plt.rc('text',usetex=True)
plt.rc('font', family='serif')
#for redvol in REDVOL :
for redvol in REDVOL :
	color = iter(cm.brg(np.linspace(0.0,0.8, len(CONFIN))))
	for confin in CONFIN :
		c = next(color)
		#(STR, CA, EPS, REDVOL, LAMBDA, AREA, VLME, DP, ETA) = readMetrics(confin)
		(STR, CA, EPS, REDVOL, LAMBDA, AREA, VLME, DP, ETA, CURV) = readMetrics(redvol,confin)
	
		v = round(REDVOL[0],2)
		lam = LAMBDA[0]
	
		# calculate lamc from the cubic equuation: 2 v x^3 - 3 x + 1 = 0
		lamc = 1.0
		if (abs(v - 1.00) < 1e-12) :
			lamc = 1.000000000000000000000000
		if (abs(v - 0.99) < 1e-12) :
			lamc = 1.090275107548953613318768
		if (abs(v - 0.98) < 1e-12) :
예제 #3
0
def main():
    args = parseargs()
    if args.l:
        # Load layout
        font = load_attribute(args.l + '.font')
        matplotlib.rc('font', **font)

    graph = None
    if args.show or args.s:
        fig = plt.figure()
        ax_main, ax_res = Grid(fig,
                               rect=111,
                               nrows_ncols=(2, 1),
                               axes_pad=0.2,
                               label_mode='L')
        # ax_main.get_xaxis().set_visible(False)

        # div = make_axes_locatable(ax_main)
        # ax_res = div.append_axes('bottom', pad=0.05, label='Residuals',
        #                          size='50%')
        # ax_res = fig.add_subplot(212, label='Residuals')
        graph = (fig, (ax_main, ax_res))

    f_class = args.f()
    control = (None, None, None)

    colors = iter(cm.brg(np.linspace(0, 1, len(args.i) + bool(args.c))))

    if args.c:
        _, dat = unpack_data(args.c, args.delimiter).__next__()
        data = [('control', dat)]
        control = analysis_update(data,
                                  f_class,
                                  colors.__next__(),
                                  graph,
                                  report=False,
                                  control=control,
                                  notify=False)
    for path in args.i:
        color = colors.__next__()
        try:
            data = unpack_data(path,
                               args.delimiter,
                               filtr=args.filtr,
                               split_column=args.split)
            analysis_update(data,
                            f_class,
                            color,
                            graph,
                            args.r,
                            control=control,
                            notify=True)

        except Exception as e:
            raise e
            print('Could not process', path, os.linesep)
            return None

    if args.s:
        plt.tight_layout()
        bname = os.path.basename(path)
        name = os.path.splitext(bname)[0]
        fig.savefig(os.path.join(args.s, name + '.png'),
                    dpi=160,
                    bbox_inches='tight',
                    pad_inches=0)

    if args.show:
        plt.tight_layout()
        plt.show()
예제 #4
0
    x_real_validate = np.zeros(len(A1[0]))
    x_real_validate[get_index(1560+float(signals[i])/2.0, wavelengths)] = 0.8
    x_real_validate[get_index(1560-float(signals[i])/2.0, wavelengths)] = 1.0
    x_real_vals.append(x_real_validate)

""" ---------------------------------------------------------------------------
PLOT THE RESULTS FROM x_vals & x_real_vals BELOW
--------------------------------------------------------------------------- """
font = {'size' : 16}
matplotlib.rc('font', **font)

f, ax = plt.subplots(ncols=1,nrows=len(x_vals), figsize=(6,7))
for i in xrange(len(x_vals)):
    dl = float(signals[i])
    plt.subplot(len(x_vals), 1, i+1)
    color=cm.brg(np.linspace(0.0,0.5,len(x_vals)))
    plt.plot(wavelengths, x_vals[i]/max(x_vals[i]), color=color[i], label="spacing = "+str(dl))
#    plt.plot(wavelengths, x_real_vals[i]/max(x_real_vals[i]), 'ko')
    if i==len(x_vals)//2:
        plt.ylabel("Intensity [a.u.]")
    plt.xlim([1550,1570])
    plt.ylim([-0.05, 1.05])
    frame = plt.gca()
    if i!=len(x_vals)-1:
        frame.axes.get_xaxis().set_ticklabels([])
    frame.axes.get_yaxis().set_ticklabels([])
    plt.yticks(np.linspace(0,1.,6))
    hl, hw = 0.7, 0.07
    arrow_height = 0.5
#    if i==2:
#        plt.text(1555.0, arrow_height, '400 pm', horizontalalignment='center', verticalalignment='center')
예제 #5
0
REDVOL = ['65','70','75','80','85','90','95']
#REDVOL = ['65','66','67','68','69','70','71','72','73','74','75','76','77','78','79','80','81','82','83','84','85','86','87','88','89','90','91','92','93','94','95','96','97','98','99','100']

CAPNUM = ['100']
CAPNUM = ['1']

#fs = 24
#plt.figure(figsize=(14,12))
fs = 10
plt.figure(figsize=(6,4))
plt.rc('text',usetex=True)
plt.rc('font', family='serif')
#for redvol in REDVOL :
for capnum in CAPNUM :
	color = iter(cm.brg(np.linspace(0.0,0.8, len(REDVOL))))
	for redvol in REDVOL :
		c = next(color)
		#(STR, CA, EPS, REDVOL, LAMBDA, AREA, VLME, DP, ETA) = readMetrics(confin)
		(STR, EPS, VOLRAT, LAMBDA, AREA, VLME, DP) = readMetrics(redvol,capnum)

		v = round(float(redvol)/100.0,2)
	
		# calculate lamc from the cubic equuation: 2 v x^3 - 3 x + 1 = 0
		lamc = 1.0
		if (abs(v - 0.99) < 1e-12) :
			lamc = 1.090275107548953613318768
		if (abs(v - 0.98) < 1e-12) :
			lamc = 1.133537870150389282270677
		if (abs(v - 0.97) < 1e-12) :
			lamc = 1.169545928031930431602916
예제 #6
0
from readMetrics import readMetrics
import numpy as np
from matplotlib import pyplot as plt
from matplotlib.pyplot import cm
from scipy.interpolate import splrep, splev, interp1d
from math import log10, floor

MAXRAD = ['90', '92', '94', '96']
MAXRAD = ['90', '99']
#MAXRAD = ['80','82','84','86','88','90', '92', '94', '96', '98']
MAXRAD = ['90','91','92','93','94','95','96','97','98','99']
#MAXRAD = ['99']

color = iter(cm.brg(np.linspace(0.0,0.8, len(MAXRAD))))
fs = 24
plt.figure(figsize=(14,12))
for maxrad in MAXRAD :
	c = next(color)
	(STR, CA, EPS, REDVOL, LAMBDA, AREA, VLME, LENGTH, DP, ETA) = readMetrics(maxrad)

	v = round(REDVOL[0],2)
	lam = LAMBDA[0]

	# calculate lamc from the cubic equuation: 2 v x^3 - 3 x + 1 = 0
	if (abs(v - 0.95) < 1e-12) :
		lamc = 1.2324
	if (abs(v - 0.90) < 1e-12) :
		lamc = 1.3712
	if (abs(v - 0.85) < 1e-12) :
		lamc = 1.5050
	if (abs(v - 0.80) < 1e-12) :
예제 #7
0
        vois = {}
        for filename in sys.argv[1:]:

            # Opens file and extract MNI coordinates
            # ----------------------------------------------------------

            f = open(filename, "r")
            tokens = [line.split() for line in f.readlines()[1:]]
            coords = [x[2:5] for x in tokens]
            mni = [[float(y) for y in x] for x in coords]
            name = tokens[0][1]
            vois[name] = mni

        #cols = cm.tab10(linspace(0,1,len(vois.keys())))
        #cols = cm.rainbow(linspace(0,1,len(vois.keys())))
        cols = cm.brg(linspace(0, 1, len(vois.keys())))

        # Adds transparency
        # ----------------------------------------------------------

        for c in cols:
            c[3] = 0.7  # Sets alpha

        # Plots and saves
        # ----------------------------------------------------------

        # Calculates the proper size of the marker
        L = [len(vois[x]) for x in vois.keys()]
        N = numpy.max(L)

        msize = 100