Example #1
0
def find_dataType(S):
    s=browse.get_string(S.fileCine,'/PIV','.cine')
    if not s=='':
        return '2D_PIVmovie'

    s=browse.get_string(S.fileCine,'Bubbles','.cine')
    if not s=='':
        return '2D_bubbles'
    
    return 'Unknown'
Example #2
0
def get_parameters(file):
    List_key = ['zl', 'yl', 'xl', 't0', 'tl', 'y0', 'x0', 'z0']

    param = {}
    for k in List_key[:-1]:
        param[k] = int(
            browse.get_string(file, '_' + k + '_', end='_', display=False))
    k = List_key[-1]
    param[k] = int(
        browse.get_string(file, '_' + k + '_', end='/', display=False))

    return param
Example #3
0
def draw_grid(M,ax,x0,y0,Mesh=50,Bar=10,H=10,N=5,facecolor='y',edgecolor='k',linewidth=2):
    """
    Draw the grid at the specified position.
    """
    file = M.Sdata.fileCine
    ind = browse.get_string(os.path.basename(file),'_M',end='mm')
    
    if M.Id.date=='2016_03_05':
        ind = 24
        
    if not ind=='':
        Bar = 4
        H = 8
        Mesh = int(ind)#print(int(ind))
        N = 9
    else:
        Mesh = 50
        
    positions = [(i*Mesh+x0,y0) for i in range(-(N//2),N//2+1)]
    width = Bar
    height = H
   # grid = []
    for p in positions:
        square = patches.Rectangle(centered(p,width,height),width,height,facecolor=facecolor,edgecolor=edgecolor,linewidth=linewidth)    
        ax.add_patch(square)
Example #4
0
def saveDir(file, post=''):
    fileroot = browse.get_string(file, '', '.cine', 0)
    if not (fileroot == ''):
        Dir = fileroot + post + '/'
        root = 'im'
        if not os.path.isdir(Dir):
            os.makedirs(Dir)
    else:
        print('not a cine file')

    return Dir, root
Example #5
0
def make_movie(cinefile,nimage,start=0,stop=1,step=1,folder='',framerate=30,quality=50):
    #generate a folder with tiff images : it would be easier if a avi file is generated directly
    root = os.path.basename(cinefile)
    base = browse.get_string(root,'',end='.cine')
    
    if folder=='':
        folder = os.path.dirname(cinefile)

    folder = '/References'
    print(folder+base)

    cine2pic.cine2tiff(cinefile,mode='Sample',step=step,ctime=2,start=start,stop=nimage*step+start,folder=folder,post=base)
Example #6
0
def make_timestep_files(fileList, Dt=1, starts=[], ends=[], Dt_list=[]):
    """
    Generate a timestep .txt file that will be used to process the data with the right time step
    INPUT
    -----
    fileList : list of filename to process
    Dt : int. timestep to be applied. Default value : 1
        Rmq : could be switched to a list of timestep and associated start/end indexes for each timestep 
    Optionnal variables (not implemented yet) : starts, ends and Dt_list to set a list of timestep for different instants in the movie.
    OUTPUT
    -----
    NONE
    """

    keys = ['start', 'end', 'Dt']

    for file in fileList[args.start:args.end]:

        n = str(browse.get_string(file, start='_n', end='_'))
        try:
            int(n)
        except:
            n = ''
        if n == '':
            #get the number of images from the cinefile
            c = cine.Cine(file)
            n = c.len() - 1
            print(n)

        values = [[0], [n], [Dt]]

        base = browse.get_string(os.path.basename(file), '', '.cine')
        file_timestep = os.path.dirname(
            file) + '/PIV_timestep_' + base + '.txt'

        if not os.path.isfile(file_timestep):
            rw_data.write_dictionnary(file_timestep, keys, values)
Example #7
0
def get_data(fileList):
    dataList = []
    for name in fileList:
        W = browse.get_number(name, '_W', 'pix_')
        Dt = int(browse.get_string(name, 'pix_Dt_', '_'))
        Header, Data = rw_data.read_dataFile(name, ',', ',')
        #    indexA=browse.get_number(Header[1],'A: im','.tiff') #name of the image is localized on the second line of the ASCII file
        #    indexB=browse.get_number(Header[1],'B: im','.tiff')
        Data = pivlab.switch_keys(Data)
        dataList.append(Data)
        for key in ['u', 'v']:
            Data[key] = (cdata.rm_nans([np.asarray(Data[key])], d=1,
                                       rate=0.05))[0]

    return dataList
Example #8
0
def chose_label(M):
    base=os.path.basename(M.dataDir)
  #  i=browse.get_string(base,'olymer')
    print(base)
    c=browse.get_string(base,start='_',end='ppm',from_end=True)
    print(c)
    if len(c)>0:
        print(c)
        if int(c)==100:
            color = 'b'     
            symbol = ''
        if int(c)==200:
            color = 'r'     
            symbol = ''
        label = color + symbol
        
    else:
        label = ''
    return label
Example #9
0
def make_result_folder(fileList,
                       type_analysis='Sample',
                       algo='PIVlab',
                       W=32,
                       ratio=None):
    """
    Create folders for storing the PIVlab Data (now processed in matlab)    
    INPUT
    -----	
    fileList : List of string
        filename List to be read
    type_analysis : string (default value 'Sample')
        Standard presaved types of analysis (Sample = 1/10 images processed, Full_single', every images, Full_double every pair of image (effective ratio = 2))
                Full_single : ratio = 1
                Full_double : ratio = 2
                Sample : ratio = 10
    algo : string (default value 'PIVlab')
        Name of the PIV algorithm used to processed the data
    W : int (default value = 16)
        Window size used for PIV processing.
    ratio : number of images / number of pair of images processed. default value = 10. Can be set to standard values using type_analysis
    OUTPUT
    ------
    None
    0	"""
    types = dict(Sample=ratio, Full_double=2, Full_single=1)
    if type_analysis in types.keys():
        ratio = types[type_analysis]
    else:
        #use the value given in argument for ratio
        pass

    for file in fileList[args.start:args.end]:
        Dir = os.path.dirname(file)
        rootDir = Dir + '/PIV_data'
        basename = browse.get_string(os.path.basename(file), '', end='.cine')
        foldername = rootDir + '/' + algo + '_ratio' + str(ratio) + '_W' + str(
            W) + 'pix_' + basename

        if not os.path.isdir(foldername):
            os.makedirs(foldername)
Example #10
0
def make_ref_file(cinefile,folder=''):
    keys = ['fx','im0','x0','y0','angle']
    List_info = [[0] for i in range(len(keys))]
    
    if folder=='':
        folder = os.path.dirname(cinefile)

    #generate an empty ref file associated to each cine file 
    #Should be manually filled out from images measurements
    
    cinebase = browse.get_string(os.path.basename(cinefile),'','.cine')
    name = folder +'Ref_'+cinebase+'.txt'
    
    if not os.path.isfile(name):    
        print(name)
    #check first if a Ref file exists already    
#    Ref_PIV_sv_vp_zoom_Polymer_200ppm_X25mm_fps5000_n18000_beta500mu_H1180mm_S300mm
        rw_data.write_dictionnary(name,keys,List_info)
    else:
        print('Reference file exists already')
        pass
    
#directory = '/Volumes/labshared3/Stephane/Experiments/Accelerated_grid/2015_03_24/'
#gen(directory)
Example #11
0
def title(M):
    date = M.Id.date    
    typ = browse.get_string(M.dataDir,'piston12mm_',end='_f5Hz')
    savedir = './Vortex_Turbulence/Vortex_propagation/'+date+'/'+typ+'/'
    print(savedir)
    return savedir
Example #12
0
def compile(Mlist, V=None, method='circulation'):
    symbol = {'50': '^', '125': 'o', '250': 's'}
    color = {'circulation': 'r', 'vorticity': 'b', 'joseph': 'k'}
    labels = {key: color[method] + symbol[key] for key in symbol.keys()}
    if V == None:
        sub_labels = labels
        piston_v = None
    else:
        piston_v = str(V)
        sub_labels = {piston_v: labels[piston_v]}  #,'125':'ro','250':'bs'}

    figs = {}

    for i, M in enumerate(Mlist):
        piston1 = browse.get_string(M.Sdata.fileCine,
                                    '_v',
                                    end='.cine',
                                    shift=0,
                                    display=False,
                                    from_end=True)
        piston2 = browse.get_string(M.Sdata.fileCine,
                                    '_v',
                                    end='_p30mum',
                                    shift=0,
                                    display=False,
                                    from_end=True)

        error = 0.25
        for piston in [piston1, piston2]:
            if piston in sub_labels.keys():
                print(M.dataDir)
                dx = np.mean(np.diff(M.x[0, :]))
                print('Spatial scale : ' + str(dx) + ' mm/box')
                lc, std_lc, Gamma, std_Gamma = compute(M,
                                                       method=method,
                                                       display=False,
                                                       fignum=(i + 1) * 2)

                #                print(piston,dx,lc,std_lc)
                if std_lc / lc < error:
                    graphes.errorbar(dx,
                                     lc, [0],
                                     std_lc,
                                     label=labels[piston],
                                     fignum=250)
                    figs.update(graphes.legende('mm/box', 'Core size (mm)',
                                                ''))
                    graphes.set_axis(0, 1.5, 0, 6.)

                    if method == 'circulation':
                        #   if np.abs(std_Gamma/Gamma)<error:
                        graphes.errorbar(dx,
                                         Gamma, [0],
                                         std_Gamma,
                                         label=labels[piston],
                                         fignum=251)
                        figs.update(
                            graphes.legende('mm/box', 'Circulation (mm^2/s)',
                                            ''))
                        graphes.set_axis(0, 1.5, -2 * 10**4, 0)
                #print(piston,dx,lc,std_lc
                print('')

    print('figure', figs)
    print(figs)
    graphes.save_figs(figs,
                      suffix='Compilation_method_' + method + '_v' + piston_v)