コード例 #1
0
ファイル: rwkbode.py プロジェクト: ryanGT/research
 def autolim(self, myattr, freqvect, margin=0.1,db=0):
     if self.freqlim:
         ind1=thresh(freqvect,self.freqlim[0])
         ind2=thresh(freqvect,self.freqlim[1])
     else:
         ind1=0
         ind2=-1
     mymatrix=getattr(self,myattr)
     if len(shape(mymatrix))==1:
         submat=mymatrix[ind1:ind2]
     else:
         mymatrix=colwise(mymatrix)
         submat=mymatrix[ind1:ind2,:]
     if db:
         submat=20*log10(submat)
     # max and min need to be done columnwise
     # (maybe a Krauss matrix max)
     if len(shape(submat))==2:
         mymax=[]
         mymin=[]
         for q in range(shape(submat)[1]):
             mymax.append(max(submat[:,q]))
             mymin.append(min(submat[:,q]))
     else:
         mymax=max(submat)
         mymin=min(submat)
     if len(shape(mymax))>0:
         mymax=max(mymax)
         mymin=min(mymin)
     myspan=mymax-mymin
     mymargin=margin*myspan
     limout=[mymin-mymargin, mymax+mymargin]
     setattr(self,myattr+"lim",limout)
     return limout
コード例 #2
0
ファイル: DataProcMixins.py プロジェクト: ryanGT/research
    def Trunc(self, trigger, threshlevel=None, duration=0.05, backup=0.01):
        """Truncate channel based on a trigger time that comes from
        trigger.FindTrig(threshlevel).  trigger is expected to be an
        instance of Trigger (or something that derives from it)."""
        ind1 = trigger.FindTrig(threshlevel)
        t0 = self.t[ind1]
        self.t0 = t0
        ind0 = thresh(self.t, t0-backup)
        try:
            ind2 = thresh(self.t, self.t[ind0]+duration)
        except:
            ind2 = len(self.t)

        self.sigtrunc = copy.copy(self.signal[ind0:ind2])
        self.ttrunc = copy.copy(self.t[ind0:ind2])-t0
        return ind0, ind2
コード例 #3
0
ファイル: rwkbode.py プロジェクト: ryanGT/research
def CreateVariableMask(vector, ranges, factors):
    mask=[]
    prev=0
    for range, factor in zip(ranges,factors):
        if type(range)==list:
            i1=thresh(vector,range[0])
            i2=thresh(vector,range[1])
        else:
            i1=thresh(vector,prev)
            i2=thresh(vector,range)
            prev=range
        tempv=vector[i1:i2]
        tmask=CreateDownSampleMask(tempv,factor)
        mask.extend(tmask)
    pad=len(vector)-len(mask)
    mypad=[0]*pad
    mask.extend(mypad)
    return mask
コード例 #4
0
ファイル: rwkbode.py プロジェクト: ryanGT/research
 def truncate(self, freq, flow, fhigh=None):
     """Truncate the mag, phase, and coherence of the rwkbode
     instance based on the indices returned by thresh(flow) and
     thresh(fhigh).  If fhigh is not given, it is assumed that flow
     is a list of [flow, fhigh]."""
     if fhigh is None:
         fhigh=flow[1]
         flow=flow[0]
     i1=thresh(freq,flow)
     i2=thresh(freq,fhigh)
     if i2-i1<max(shape(self.mag)):#test if already truncated
         self.mag=colwise(self.mag)[i1:i2,:]
         self.phase=colwise(self.phase)[i1:i2,:]
         self.coh=colwise(self.coh)[i1:i2,:]
     tfreq=freq[i1:i2]
     if self.freqlim:
         if self.freqlim[0]<min(tfreq):
             self.freqlim[0]=min(tfreq)
         if self.freqlim[1]>max(tfreq):
             self.freqlim[1]=max(tfreq)
     else:
         self.freqlim=[min(tfreq),max(tfreq)]
     return tfreq
コード例 #5
0
ファイル: JVC_model.py プロジェクト: ryanGT/research
import pylab_util as PU

import exp_data
reload(exp_data)
import sympy_bode_analysis
reload(sympy_bode_analysis)
import rwkbode, txt_mixin
from rwkmisc import my_import
#from sympy_bode_analysis import calc_and_plot_Bodes
from sympy_optimize_utils import myoptimize, _cost, fexp
from rwkdataproc import thresh

import sympy_utils
reload(sympy_utils)

ind1 = thresh(fexp,5)

from sympy import Symbol
import sympy_TMM
reload(sympy_TMM)

import os, copy, time

from IPython.core.debugger import Pdb

mu = Symbol('mu')
EI = Symbol('EI')
L1 = Symbol('L1')
beta1 = Symbol('beta1')
beam_params1 = {'mu':mu, 'EI':EI, 'L':L1, 'beta':beta1}
beam1 = sympy_TMM.Sympy_Beam_Element(beam_params1, label='_1')
コード例 #6
0
def find_second_mode_peak(dB_accel, fvect):
    ind1 = thresh(fvect, 12.0)
    ind2 = thresh(fvect, 25.0)
    max_ind = dB_accel[ind1:ind2].argmax() + ind1
    f_peak = fvect[max_ind]
    return f_peak
コード例 #7
0
def find_valley(dB_theta, fvect):
    ind1 = thresh(fvect, 1.0)
    ind2 = thresh(fvect, 5.0)
    min_ind = dB_theta[ind1:ind2].argmin() + ind1
    f_valley = fvect[min_ind]
    return f_valley
コード例 #8
0
ファイル: DataProcMixins.py プロジェクト: ryanGT/research
 def FindTrig(self, threshlevel=None, startind=0, above=True):
     #thresh(iterin, value, startind=0, above=1)
     if threshlevel is None:
         threshlevel = self.threshlevel
     ind = thresh(self.signal, threshlevel, startind=startind, above=above)
     return ind