Exemplo n.º 1
0
 def _load_mod(self):
     try:
         self.mod = my_import(self.mod_name)
         reload(self.mod)
         self.func = self.mod.Bodes
     except ImportError:
         self.mod = None
         self.func = None
Exemplo n.º 2
0
def run_simulation(pkl_name, mod_name, param_dict={},
                   f=f2, plot=True, startfi=1, **kwargs):
    params = SFLR_TMM.load_params('temp_params.pkl')
    params.update(param_dict)
    print('params.c_clamp = %s' % params.c_clamp)
    mymod = my_import(mod_name)
    myfunc = mymod.Bodes

    th_bode, a_bode = calc_and_massage_Bodes(f, params, func=myfunc)
    a_th_bode = calc_and_massage_a_th_Bode(f, th_bode, a_bode)
    if plot:
        #plot_exp(startfi=startfi)
        plot_Bodes(f, th_bode, a_bode, a_th_bode, startfi=startfi, \
                   **kwargs)
    return th_bode, a_bode, a_th_bode
Exemplo n.º 3
0
def LoadDatafromSavedModules(filelist,deschannels,xlabel='t'):
    """Builds matrices for each channel assuming that each filename
    has been saved to a module using scipy.io.save.  filelist is a
    list of the modules that will be imported using my_import, so that
    need to be somewhere on sys.path.  deschannels are the keys from
    the saved modules that will be kept."""
    outdict=_initializedict(deschannels)
    for modname in filelist:
        mod=my_import(modname)
        mydict=ConvertSaveModuletoDict(mod)
        for chn in deschannels:
           outdict[chn].append(mydict[chn])
    for key, value in outdict.iteritems():
        if key != xlabel:
#           print('key='+str(key))
#           print('type(value)='+str(type(value)))
#           print('shape(value)='+str(shape(value)))
           outdict[key]=mystack(value)
           myN=max(outdict[key].shape)
    outdict[xlabel]=mydict[xlabel][0:myN]
    return outdict
Exemplo n.º 4
0
def BodeFromModname(modname,expbode,f,funcname=None,ucv=[],optargs=(),PhaseMassage=True):
    """Generate one Bode from its module name, i.e. the name of a
    module that contains the symbolic Bode function funcname.  If
    funcname is not given, it is assumed to be the same as modname.
    expbode is used to determine the inputs and outputs as well as the
    seedfreq and seedphase."""
    s=2.0j*pi*f
    if not modname:
        bodefunc=funcname
    elif callable(modname):
        bodefunc=modname
    else:
        bodemod=my_import(modname)
        if funcname:
            bodefunc=getattr(bodemod,funcname)
        else:
            bodefunc=getattr(bodemod,modname)
#    if ucv:
    if ucv==[]:
        compv=bodefunc(s,*optargs)
    else:
        compv=bodefunc(s,ucv,*optargs)
    mybode=BodeFromComp(compv, expbode, f, PhaseMassage)
    return mybode
Exemplo n.º 5
0
from scipy import optimize

from rwkmisc import my_import

import time, copy

import SFLR_TMM
reload(SFLR_TMM)

import rwkbode

#import sympy_bodes
#reload(sympy_bodes)

mod_name = 'sympy_bodes_tau'
mod = my_import(mod_name)
reload(mod)

import exp_data

f2 = exp_data.f2
fexp = exp_data.f


def plot_exp(startfi=1):
    exp_data.plot_exp(startfi=startfi)
    

def calc_and_massage_a_th_Bode(f, th_bode, a_bode, \
                               **kwargs):
    a_th_bode = a_bode/th_bode
                  '"Exceeds expectation (5)"', \
                  '"Meets expectation (3)"', \
                  '"Does not meet expectation (1)"', \
                  '"Ave. Score"', \
                  '"Exceeds"', \
                  '"Meets"', \
                  '"Does Not Meet"', \
                  '"Previous Year Ave. Score"', \
                  ]
#last_years_ave = last_years_sheet.ave_score.astype('float')

#make a dictionary with the number of members in each group
import rwkmisc
#modname = 'spring_%s_484' % year_str
modname = 'fall_%s_482' % year_str
mymod = rwkmisc.my_import(modname)

group_list = mymod.group_list
alts = mymod.alts

group_names = mymod.group_list[1]
team_names = group_names
member_list = mymod.group_list[2]
number_of_members = [0] * len(group_names)

for i, cur_members in enumerate(member_list):
    cur_list = cur_members.split(',')
    cur_num = len(cur_list)
    number_of_members[i] = cur_num

group_members_dict = dict(zip(group_names, number_of_members))
                  '"Exceeds expectation (5)"', \
                  '"Meets expectation (3)"', \
                  '"Does not meet expectation (1)"', \
                  '"Ave. Score"', \
                  '"Exceeds"', \
                  '"Meets"', \
                  '"Does Not Meet"', \
                  '"Previous Year Ave. Score"', \
                  ]
#last_years_ave = last_years_sheet.ave_score.astype('float')

#make a dictionary with the number of members in each group
import rwkmisc
#modname = 'spring_%s_484' % year_str
modname = 'fall_%s_482' % year_str
mymod = rwkmisc.my_import(modname)

group_list = mymod.group_list
alts = mymod.alts

group_names = mymod.group_list[1]
team_names = group_names
member_list = mymod.group_list[2]
number_of_members = [0]*len(group_names)

for i, cur_members in enumerate(member_list):
    cur_list = cur_members.split(',')
    cur_num = len(cur_list)
    number_of_members[i] = cur_num

group_members_dict = dict(zip(group_names, number_of_members))