Esempio n. 1
0
        rem2del_junk2 = False

    if w != None:
        d2 = ivlad.getout('sfget', ['parform=n','d2'], inp, verb)
        d2 = float(d2) * (n2-1)/float(w-1)
        out_transp1 = tmp + '3'
        sf.transp(out_remap1, out_transp1, verb=verb)
        if rem2del_junk2:
            sf.rm(out_remap1, verb)
        if w < n2:
            ready_for_remap_2 = tmp + '4'
            sf.bandpass(out_transp1, ready_for_remap_2, fhi=0.5/d2, verb=verb)
            rem2del_junk4 = True
        else:
            ready_for_remap_2 = out_transp1
            rem2del_junk4 = False
        ready_for_transp2 = tmp + '5'
        sf.remap1(ready_for_remap_2,ready_for_transp2,n1=w,d1=d2,verb=verb)
        sf.rm(out_transp1, verb)
        if rem2del_junk4:
            sf.rm(ready_for_remap_2, verb)
        sf.transp(ready_for_transp2, out, verb=verb)
        sf.rm(ready_for_transp2, verb)

    return ivlad.unix_success

###############################################################################

if __name__ == '__main__':
    ivlad.run(main, ['inp','out'])
Esempio n. 2
0
    f = 0

    for i in range(nslices_whole):

        i_str = ivlad.add_zeros(i,nslices_whole)
        i_slc = os.path.join(outdir, i_str + '_stdout' + ivlad.ext)

        cmd = '<%s sfwindow f%s=%d ' % (inp, lastdim,f)
        cmd += 'n%s=%d %s > %s' % (lastdim, nthick, dpath, i_slc)
        ivlad.exe(cmd, verb)

        f += nthick

    ist = n - nslices_whole * nthick # Incomplete Slice Thickness

    if ist > 0:
        i_str = ivlad.add_zeros(i+1,nslices_whole)
        i_slc = os.path.join(outdir, i_str + '_stdout' + ivlad.ext)

        cmd = '<%s sfwindow f%s=%d ' % (inp, lastdim, f)
        cmd += 'n%s=%d > %s' % (lastdim, ist, i_slc)
        ivlad.exe(cmd, verb)

    return ivlad.unix_success

##############################################

if __name__ == '__main__':
    ivlad.run(main, ['inp'])
Esempio n. 3
0
        d2 = float(d2) * (n2 - 1) / float(w - 1)
        out_transp1 = tmp + '3'
        sf.transp(out_remap1, out_transp1, verb=verb)
        if rem2del_junk2:
            sf.rm(out_remap1, verb)
        if w < n2:
            ready_for_remap_2 = tmp + '4'
            sf.bandpass(out_transp1,
                        ready_for_remap_2,
                        fhi=0.5 / d2,
                        verb=verb)
            rem2del_junk4 = True
        else:
            ready_for_remap_2 = out_transp1
            rem2del_junk4 = False
        ready_for_transp2 = tmp + '5'
        sf.remap1(ready_for_remap_2, ready_for_transp2, n1=w, d1=d2, verb=verb)
        sf.rm(out_transp1, verb)
        if rem2del_junk4:
            sf.rm(ready_for_remap_2, verb)
        sf.transp(ready_for_transp2, out, verb=verb)
        sf.rm(ready_for_transp2, verb)

    return ivlad.unix_success


###############################################################################

if __name__ == '__main__':
    ivlad.run(main, ['inp', 'out'])
Esempio n. 4
0
    recursive = par.bool('rec', False)  # Whether to go down recursively
    chk4nan = par.bool('chk4nan', False)  # Check for NaN values. Expensive!!

    invalid_files_list = []  # will contain tuples: (file, msg)

    if recursive:
        for root, dirs, files in os.walk(mydir):
            invalid_files_list += \
            ivlad.list_invalid_rsf_files(root, files, chk4nan)
    else:
        files = filter(lambda x: os.path.isfile(x), os.listdir(mydir))
        invalid_files_list += \
        ivlad.list_invalid_rsf_files(mydir, files, chk4nan)

    myline = ''

    for entry in invalid_files_list:
        myline = entry[0]
        if verb:
            myline += ': ' + entry[1]
        print(
            myline)  # This program's stdout is a list of files. Do not use msg

    return ivlad.unix_success


###############################################################################

if __name__ == '__main__':
    ivlad.run(main)
Esempio n. 5
0
        valid_files_list += \
        ivlad.list_valid_rsf_files(mydir, files, chk4nan=False)

    for f in valid_files_list:
        ivlad.msg(f + ': ' + ivlad.getout('sfin', ['info=n', f]), verb)
        sf.rm(f, verb)

    # Clean up headers with no binaries

    if recursive:
        hdr_str = ivlad.getout('find',
                               [mydir, '-type', 'f', '-name', '"*.rsf"'])
        hdr_list = hdr_str.split('\n')
    else:
        hdr_list = [
            x for x in glob.glob(os.path.join(mydir, '*.rsf'))
            if os.path.isfile(x)
        ]

    for f in hdr_list:
        ivlad.msg(f)
        os.remove(f)

    return ivlad.unix_success


###############################################################################

if __name__ == '__main__':
    ivlad.run(main, ['dir'])
Esempio n. 6
0
except: # Use distributed version
    import rsf.user.ivlad as ivlad

###############################################################################

def main(par):

    prog = par.string('prog') # Non-madagascar utility
    inp  = par.string('inp') # Input file
    tpar_str = par.string('tpar') # Translated params, i.e.: "ni1=n1 ni2=n2"
    ipar_str = par.string('ipar') # Independent params, i.e. "perc=100 cmap=rgb"
    verb = par.bool('verb',False)

    tpar_out = ''
    if tpar_str != None:
        for tpar in tpar_str.split():
            thispar = tpar.split('=')
            tpar_out += thispar[0] + '=' + \
                ivlad.getout('sfget', ['parform=n', thispar[1]], inp, verb) +' '
           
    data = ivlad.getout('sfin',['info=n',inp])

    ivlad.exe(prog + ' <' + data + ' ' + tpar_out + ' ' + ipar_str, verb)
    
    return ivlad.unix_success

##############################################

if __name__ == '__main__':
    ivlad.run(main, ['prog', 'inp'])
Esempio n. 7
0
def main(par):

    f1 = sys.argv[1] + ' '
    f2 = sys.argv[2]

    f1_type = ivlad.getout('sfgettype', stdin=f1)
    if f1_type != 'SF_FLOAT':
        raise m8rex.TypeHandlingNotImplemented(f1_type)

    dims_str = ivlad.getout('sffiledims','parform=n',f1)
    ndims = int(dims_str.split(':')[0])

    cmd = 'sfspike mag=0 '
    fields = 'n o d unit label'.split()

    for i in range(ndims):
        for z in fields:            
            cmd += ivlad.getout('sfget',['parform=y',z+str(i+1)],f1) + ' '

    cmd += ' >' + f2

    ivlad.exe(cmd)

    return ivlad.unix_success

###############################################################################

if __name__ == '__main__':
    ivlad.run(main, nminarg=2, nmaxarg=2)
Esempio n. 8
0
    f = 0

    for i in range(nslices_whole):

        i_str = ivlad.add_zeros(i, nslices_whole)
        i_slc = os.path.join(outdir, i_str + '_stdout' + ivlad.ext)

        cmd = '<%s sfwindow f%s=%d ' % (inp, lastdim, f)
        cmd += 'n%s=%d %s > %s' % (lastdim, nthick, dpath, i_slc)
        ivlad.exe(cmd, verb)

        f += nthick

    ist = n - nslices_whole * nthick  # Incomplete Slice Thickness

    if ist > 0:
        i_str = ivlad.add_zeros(i + 1, nslices_whole)
        i_slc = os.path.join(outdir, i_str + '_stdout' + ivlad.ext)

        cmd = '<%s sfwindow f%s=%d ' % (inp, lastdim, f)
        cmd += 'n%s=%d > %s' % (lastdim, ist, i_slc)
        ivlad.exe(cmd, verb)

    return ivlad.unix_success


##############################################

if __name__ == '__main__':
    ivlad.run(main, ['inp'])
Esempio n. 9
0
    if n1 == 1:
        ndim_out = 1
        n = [n2]
        o = [o[0]]
        d = [d[0]]
        unit = [unit[0]]
        lbl = [lbl[0]]
    else:
        ndim_out = 2
        n = [n2, n1]

    out = ooio.RSFfile(ooio.stdout,par,ndim=ndim_out,intent='out',dtype=numtype) 
    out.set_hdr_info(n, o, d, unit, lbl)
    
    if debug:
        out.print_self('out')
        out.hdr.print_self('out.hdr')
        out.dat.print_self('out.dat')
        ivlad.msg(ivlad.hr)

    for line in lines:
        for val in line:
            out.write(val)

    return ivlad.unix_success

##############################################

if __name__ == '__main__':
    ivlad.run(main)
Esempio n. 10
0
###############################################################################


def main(par):

    prog = par.string('prog')  # Non-madagascar utility
    inp = par.string('inp')  # Input file
    tpar_str = par.string('tpar')  # Translated params, i.e.: "ni1=n1 ni2=n2"
    ipar_str = par.string(
        'ipar')  # Independent params, i.e. "perc=100 cmap=rgb"
    verb = par.bool('verb', False)

    tpar_out = ''
    if tpar_str != None:
        for tpar in tpar_str.split():
            thispar = tpar.split('=')
            tpar_out += thispar[0] + '=' + \
                ivlad.getout('sfget', ['parform=n', thispar[1]], inp, verb) +' '

    data = ivlad.getout('sfin', ['info=n', inp])

    ivlad.exe(prog + ' <' + data + ' ' + tpar_out + ' ' + ipar_str, verb)

    return ivlad.unix_success


##############################################

if __name__ == '__main__':
    ivlad.run(main, ['prog', 'inp'])
Esempio n. 11
0
            valid_files_list += \
            ivlad.list_valid_rsf_files(root, files, chk4nan)
    else:
        files = filter(lambda x:os.path.isfile(x),os.listdir(mydir))
        valid_files_list += \
        ivlad.list_valid_rsf_files(mydir, files, chk4nan=False)

    for f in valid_files_list:
        ivlad.msg(f + ': ' + ivlad.getout('sfin',['info=n',f]), verb)
        sf.rm(f, verb)

    # Clean up headers with no binaries

    if recursive:
        hdr_str = ivlad.getout('find',[mydir, '-type', 'f', '-name', '"*.rsf"'])
        hdr_list = hdr_str.split('\n')
    else:
        hdr_list = filter(lambda x:os.path.isfile(x),
                          glob.glob(os.path.join(mydir,'*.rsf')))

    for f in hdr_list:
        ivlad.msg(f)
        os.remove(f)

    return ivlad.unix_success

###############################################################################

if __name__ == '__main__':
    ivlad.run(main, ['dir'])
Esempio n. 12
0
    f1 = sys.argv[1] + ' '
    f2 = sys.argv[2]

    f1_type = ivlad.getout('sfgettype', stdin=f1)
    if f1_type != 'SF_FLOAT':
        raise m8rex.TypeHandlingNotImplemented(f1_type)

    dims_str = ivlad.getout('sffiledims', 'parform=n', f1)
    ndims = int(dims_str.split(':')[0])

    cmd = 'sfspike mag=0 '
    fields = 'n o d unit label'.split()

    for i in range(ndims):
        for z in fields:
            cmd += ivlad.getout('sfget', ['parform=y', z + str(i + 1)],
                                f1) + ' '

    cmd += ' >' + f2

    ivlad.exe(cmd)

    return ivlad.unix_success


###############################################################################

if __name__ == '__main__':
    ivlad.run(main, nminarg=2, nmaxarg=2)
Esempio n. 13
0
                                                           local_output_directory,
                                                           print_to_stdout=print_to_stdout,
                                                           logging_level=logging_level)
        weighted_trace = math_op.weightSignalByDomainExponentiated(
            domain_time_sample, data_by_trace_time,
            median_balance_output.domain_exponent_power)
        processed_data_by_trace_time = weighted_trace

        # output data as rsf
    #output = rsf.api.Output(output_rsf_file_name)
    output = out
    output.put("n1", num_time_sample)
    output.put("o1", origin_time_sample)
    output.put("d1", delta_time_sample)
    output.put("n2", num_trace)
    output.put("o2", origin_trace)
    output.put("d2", delta_trace)
    output.put("label1", rsf_input.string("label1"))
    output.put("label2", rsf_input.string("label2"))
    output.put("unit1", rsf_input.string("unit1"))
    output.put("unit2", rsf_input.string("unit2"))

    output.write(processed_data_by_trace_time)
    return ivlad.unix_success


if __name__ == '__main__':
    ivlad.run(balance_amplitude_via_median_balancing, cpar=['inp', 'out'])
    # balance_amplitude_via_median_balancing(output_rsf_file_name='family_gained.rsf',
    #                                        treat_traces_individually=0)
Esempio n. 14
0
            # output data as rsf
    #output = rsf.api.Output(output_rsf_file_name)
    output = out
    output.put("n1", num_time_sample)
    output.put("o1", origin_time_sample)
    output.put("d1", delta_time_sample)
    output.put("n2", num_trace)
    output.put("o2", origin_trace)
    output.put("d2", delta_trace)
    output.put("label1", rsf_input.string("label1"))
    output.put("label2", rsf_input.string("label2"))
    output.put("unit1", rsf_input.string("unit1"))
    output.put("unit2", rsf_input.string("unit2"))

    output.write(processed_data_by_trace_time)
    return ivlad.unix_success







if __name__ == '__main__':
    ivlad.run(balance_amplitude_via_median_balancing, cpar=['inp','out'])
    # balance_amplitude_via_median_balancing(output_rsf_file_name='family_gained.rsf',
    #                                        treat_traces_individually=0)