Esempio n. 1
0
def runopt(menu):
    '''The function defines the content of each menu item, the order is the same as the when the the menu was created.'''
    if menu.boolopt[0]:  #0th menu item
        end1 = "1"
        fn = mf.find_file(end1 + ".s1p")
        m = re_matrix(fn)
        tdb = "-0.1"
        in1 = "25"
        int1 = "50"
        out1 = "0"
        [smallv, end1v] = print_file(m, tdb, in1, int1, out1, fn)
    elif menu.boolopt[1]:  #1th menu item.. etc
        end1 = raw_input(
            'Enter the last, digit/character before file extension, (etc: N.s1p)\n'
        )
        fn = mf.find_file(end1 + ".s1p")
        m = re_matrix(fn)
        tdb = "-0.1"
        in1 = "25"
        int1 = "50"
        out1 = "0"
        [smallv, end1v] = print_file(m, tdb, in1, int1, out1, fn)
    elif menu.boolopt[2]:
        end1 = raw_input(
            'Enter the last, digit(s)/character(s) before file extension, (etc: yyyyyXXX.s1p)\n'
        )
        fn = mf.find_file(end1 + ".s1p")
        m = re_matrix(fn)
        tdb = raw_input('Enter the tol-db:\n')
        in1 = raw_input(
            'Enter the inner step length\n(beween min and mean(trough):\n')
        int1 = raw_input(
            'Enter the intermediate step length\n(beween tol-db and mean(trough):\n'
        )
        out1 = raw_input('Enter the outer step length:\n')
        [smallv, end1v] = print_file(m, tdb, in1, int1, out1, fn)
    elif menu.boolopt[3]:
        try:
            plot_fig(m, smallv, end1v)
        except UnboundLocalError:
            print(
                'ERROR, this option has to be used together with one of the above, (-q,qn,f-)'
            )
            exit()
    elif menu.boolopt[4]:
        end1 = raw_input(
            'Enter the last, digit(s)/character(s) before file extension, (etc: yyyyyXXX.s1p)\n'
        )
        fn = mf.find_file(end1 + ".s1p")
        m = re_matrix(fn)
        plot_freq_vs_db(m, fn)
    elif menu.boolopt[5]:
        end1 = raw_input(
            'Enter the last, digit(s)/character(s) before file extension, (etc: yyyyyXXX.s1p)\n'
        )
        fn = mf.find_file(end1 + ".s1p")
        m = re_matrix(fn)
        plot_freq(m, fn)
    return
Esempio n. 2
0
def get_mh(fn='output.txt'):
	try:
		fn=mf.find_file(fn)
	except:
		inp=input('Specify output file to evaluate: ')
		fn=mf.find_file(inp)	
	for i in fn:
		[m,h]=read_file(fn=i)
		fname=i
		print(i)
	return [m,h,fname]
Esempio n. 3
0
def runscript():
    '''Combines files of a specified file extension into one file'''
    os.path.abspath(__file__)
    fend = input('Specify file extension to combine, eg. ".DAT":\n')
    #fend=".s1p"
    ex = input('Specify unique str/char(s) in unwanted lines, eg. "#,!": \n')
    #ex="!,#"
    name = input('Specify the output name, eg. "out.txt":\n')
    #name="out.txt"

    if ex.find(',') != -1:
        try:
            exv = ex.split(',')
        except:
            print('ERROR, wrong delimiter, use ","')
            exit()
    else:
        exv = []
        exv.append(ex)
    print(exv)
    fn1 = m.find_file(fend)
    rf = []
    h = []
    for i in fn1:
        print('Opening %s' % i)
        r = m.read_file(i, exv)
        h.append(i + '=' + str(r.shape))
        rf.append(r)
    h = "!" + ''.join(h)
    m.print_to_file(rf, fn=name, topheader=h)
    print('Files combined and saved in %s' % name)

    return
Esempio n. 4
0
def dump2pickle():
    fn = mf.find_file('metcal2.txt')
    [m, h] = mf.read_file2(fn[0])
    print(m)
    with open("met.pickle", "wb") as f:
        pickle.dump([m, h], f)
    return
Esempio n. 5
0
def save_all_mh():
	try:
		fn=mf.find_file(".txt")
	except:
		inp=input('No .txt files in current directory:')
		exit()
	a=[]
	for i in fn:
		print("Opening file %s"%i)
		[m,h]=read_file(fn=i)
		a.append([m,h,i])
	return a
Esempio n. 6
0
def dump2pickle():
    fn = mf.find_file('ethcal2.txt')
    [m, h] = mf.read_file2(fn[0])
    with open("eth.pickle", "wb") as f:
        pickle.dump([m, h], f)
    return