How to use the mudpy.forward.round_time function in mudpy

To help you get started, we’ve selected a few mudpy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dmelgarm / MudPy / src / python / mudpy / inverse.py View on Github external
e=read(GFfiles[i[ksta],kgf]+'.e')
        u=read(GFfiles[i[ksta],kgf]+'.u')
        if velocity_bandpass is not None: #Apply low pass filter to data
            fsample=1./n[0].stats.delta
            n[0].data=lfilt(n[0].data,velocity_bandpass,fsample,2)
            e[0].data=lfilt(e[0].data,velocity_bandpass,fsample,2)
            u[0].data=lfilt(u[0].data,velocity_bandpass,fsample,2)
        #Decimate
        if decimate!=None:
            n[0]=stdecimate(n[0],decimate)
            e[0]=stdecimate(e[0],decimate)
            u[0]=stdecimate(u[0],decimate)
        #Make sure they are rounded to a dt interval
        dt=e[0].stats.delta
        e[0].stats.starttime=round_time(e[0].stats.starttime,dt)
        n[0].stats.starttime=round_time(n[0].stats.starttime,dt)
        u[0].stats.starttime=round_time(u[0].stats.starttime,dt)
        dvel=append(dvel,r_[n[0].data,e[0].data,u[0].data])
    
    #Tsunami
    kgf=3
    dtsun=array([])
    i=where(GF[:,kgf]==1)[0]
    for ksta in range(len(i)):
        if quiet==False:  
            print('Assembling tsunami waveforms from '+stations[i[ksta]]+' into data vector.')
        tsun=read(GFfiles[i[ksta],kgf])
        if tsunami_bandpass is not None: #Apply low pass filter to data
            fsample=1./tsun[0].stats.delta
            tsun[0].data=lfilt(tsun[0].data,tsunami_bandpass,fsample,2)
            
        dtsun=append(dtsun,tsun)
github dmelgarm / MudPy / src / python / mudpy / inverse.py View on Github external
Resample a synthetic to the time samples contained in the input data
    IN:
        synth: synthetic stream object
        data: data stream object
    OUT:
        st: resampled synthetic
    '''
    from numpy import interp,arange
    from mudpy.forward import round_time
    
    #Get data sampling interval
    delta=data.stats.delta
    #Get synthetic start time
    t1synth=synth.stats.starttime
    #Get start time sampled at data interval and correction encessary
    t1=round_time(t1synth,delta)
    dt=t1-t1synth #This is the correctiont hat needs to be applied
    #Make current time vector
    tsynth=synth.times()
    tcorrect=arange(tsynth[0],tsynth[-1],delta)+dt
    #Interpolate to new time vector
    synth_data=synth.data
    synth_correct=interp(tcorrect,tsynth,synth_data)
    #Place in output stream object
    synth.starttime=t1
    synth.data=synth_correct
    synth.stats.delta=delta
    return synth
github dmelgarm / MudPy / src / python / mudpy / inverse.py View on Github external
e=read(GFfiles[i[ksta],kgf]+'.e')
        u=read(GFfiles[i[ksta],kgf]+'.u')
        if displacement_bandpass is not None: #Apply low pass filter to data
            fsample=1./n[0].stats.delta
            n[0].data=lfilt(n[0].data,displacement_bandpass,fsample,2)
            e[0].data=lfilt(e[0].data,displacement_bandpass,fsample,2)
            u[0].data=lfilt(u[0].data,displacement_bandpass,fsample,2)
        #Decimate
        if decimate!=None:
            n[0]=stdecimate(n[0],decimate)
            e[0]=stdecimate(e[0],decimate)
            u[0]=stdecimate(u[0],decimate)
        #Make sure they are rounded to a dt interval
        dt=e[0].stats.delta
        e[0].stats.starttime=round_time(e[0].stats.starttime,dt)
        n[0].stats.starttime=round_time(n[0].stats.starttime,dt)
        u[0].stats.starttime=round_time(u[0].stats.starttime,dt)
        ddisp=append(ddisp,r_[n[0].data,e[0].data,u[0].data])
    
    #Velocities
    kgf=2
    dvel=array([])
    i=where(GF[:,kgf]==1)[0]
    for ksta in range(len(i)):
        if quiet==False:  
            print('Assembling acceleration waveforms from '+stations[i[ksta]]+' into data vector.')
        n=read(GFfiles[i[ksta],kgf]+'.n')
        e=read(GFfiles[i[ksta],kgf]+'.e')
        u=read(GFfiles[i[ksta],kgf]+'.u')
        if velocity_bandpass is not None: #Apply low pass filter to data
            fsample=1./n[0].stats.delta
            n[0].data=lfilt(n[0].data,velocity_bandpass,fsample,2)
github dmelgarm / MudPy / src / python / mudpy / inverse.py View on Github external
Resample a synthetic to the time samples contained in the input data
    IN:
        synth: synthetic stream object
        data: data stream object
    OUT:
        st: resampled synthetic
    '''
    from numpy import interp
    from mudpy.forward import round_time
    
    #Get data sampling interval
    delta=data.stats.delta
    #Get synthetic start time
    t1synth=synth.stats.starttime
    #Get start time sampled at data interval and correction encessary
    t1=round_time(t1synth,delta)
    dt=t1-t1synth #This is the correctiont hat needs to be applied
    #Make current time vector
    tsynth=synth.times()
    tcorrect=tsynth+dt
    #Interpolate to new time vector
    synth_data=synth.data
    synth_correct=interp(tcorrect,tsynth,synth_data)
    #Place in output stream object
    synth.starttime=t1
    synth.data=synth_correct
    return synth