コード例 #1
0
def _intial_gui_setup(sys_argv):

    global inifname  # name of .ini file
    inifname = os.curdir + '/.' + os.path.basename(__file__).replace(
        '.py', '.ini')

    for i, argv in enumerate(sys_argv):
        print('arg {}: '.format(i) + argv)

    if len(sys_argv) == 1:

        default_ini = wpu.load_ini_file(inifname)
        foldername = default_ini['Files']['Folder Name']

        if easyqt.get_yes_or_no('Select new folder?\n' +
                                '[ESC load folder of previous run]'):

            foldername = easyqt.get_directory_name(title='Select Folder that' +
                                                   '\ncontains *csv files')

    elif len(sys_argv) == 2:

        foldername = sys_argv[1]

    else:

        print('ERROR: wrong number of inputs: {} \n'.format(len(argv) - 1) +
              'Usage: \n'
              '\n' + os.path.basename(__file__) +
              ' : (no inputs) load dialogs \n'
              '\n' + os.path.basename(__file__) + ' [args] \n'
              '\n'
              'arg1: folder that contains the *csv files\n'
              '\n')

        exit(-1)

    wpu.set_at_ini_file(inifname, 'Files', 'Folder Name', foldername)

    list_of_files = sorted(glob.glob(foldername + '/*csv'))

    nfiles = len(list_of_files)

    data, header_list = wpu.load_csv_file(list_of_files[0])

    wpu.print_blue('MESSAGE: Header of data files:')
    wpu.print_blue(header_list)

    ncurves = data.shape[1] - 1

    label_list = [
        fname.rsplit('_', 1)[1].split('.')[0] for fname in list_of_files
    ]

    #[fname.rsplit('/', 1)[1].split('_Y_integrated')[0]
    #                  for fname in list_of_files]

    return list_of_files, nfiles, ncurves, label_list, header_list
コード例 #2
0
ファイル: diff_image.py プロジェクト: yxqd/wavepytools
def gui_load_data_directory(directory='', title="File name with Data"):

    originalDir = os.getcwd()

    fname1 = easyqt.get_directory_name(title)

    if len(fname1) == 0:
        fname_last = None

    else:
        fname_last = fname1

    os.chdir(originalDir)

    return fname_last
コード例 #3
0
ref_p = [0, -50]
# if the perfect wavefront is used as the target wavefront
target_perfect = True

voltage4response = 1.00

phenergy = 1e20
wavelength = wpu.hc / phenergy

# here is to choose which collum in the csv fitting data is used for the response function calculation
profilenumber = 1

# %%

if len(sys.argv) == 1:
    dirName = easyqt.get_directory_name('Directory to the data:')
else:
    dirName = sys.argv[1]

# here the response function initialization file
inifname = '.Revise_response_func.ini'
defaults = wpu.load_ini_file(inifname)

if dirName == '':
    dirName = defaults['Files'].get('Folder with csv files')

else:
    wpu.set_at_ini_file(inifname, 'Files', 'Folder with csv files', dirName)

print(dirName)
'''
コード例 #4
0
import wavepy.utils as wpu
import wavepy.grating_interferometry as wgi
import wavepy.surface_from_grad as wps

import itertools
from multiprocessing import Pool, cpu_count
import time

import os
from wavepy.utils import easyqt

# =============================================================================
# %% Load Image
# =============================================================================

data_dir = easyqt.get_directory_name("Choose directory with all files")

os.chdir(data_dir)

listOfDataFiles = glob.glob(data_dir + '/**.tif')

listOfDataFiles.sort()

#wpu.print_blue('MESSAGE: Loading files ' + \
#                samplefileName.rsplit('_',1)[0] + '*.tif')

#fname_dark =  easyqt.get_file_names("Dark File")[0]

nfiles = len(listOfDataFiles)

#dark_im = dxchange.read_tiff(fname_dark)
コード例 #5
0
from labellines import labelLine, labelLines

# %%

import wavepy.utils as wpu
from wavepy.utils import easyqt
import glob

from scipy.optimize import curve_fit
from scipy.interpolate import interp1d

wpu._mpl_settings_4_nice_graphs(otheroptions={'lines.linewidth': 2})

# %%
dirName = easyqt.get_directory_name()

print(dirName)
listOfFiles = glob.glob(dirName + '/*.csv')
listOfFiles.sort()
n_files = len(listOfFiles)

# %% Load data

listOfArrays = []
listOfShapes = []

for fname in listOfFiles:
    fileContent = wpu.load_csv_file(fname)
    listOfArrays.append(fileContent[0])
コード例 #6
0
phenergy = 14000	#in eV
wavelength = wpu.hc/phenergy

profilenumber = 3	#profile index in the target and RF csv files

subtractnominal = 1	#subtract a norminal spherical wf with Radius below
Radius = -0.71


npoints_interp = 200	#number of points to interpolate both the target and the RF

# %%

if len(sys.argv) == 1:
    dirName = easyqt.get_directory_name(title='Select folder contains RF')
else:
    dirName = sys.argv[1]


inifname = '.response_function.ini'
defaults = wpu.load_ini_file(inifname)

if dirName == '':
    dirName = defaults['Files'].get('Folder with csv files')

else:
    wpu.set_at_ini_file(inifname,
                        'Files',
                        'Folder with csv files', dirName)