def main_reader(path='../dat/23JUL12', fref='Bsteel_BB_00.txt', fn_sf='YJ_Bsteel_BB.sff', icheck=False, isym=False, fc=None, fn_str=None): """ Arguments ========= path (path that contains the data file) fref (reference data that gives strain and date-named for X-ray) fn_sf (stress factor file name) icheck isym fc (flow curve object) fn_str (stress-strain data file) """ if type(fc) == type(None) and type(fn_str) == type(None): print '---------------------------------------------' print 'Strain information where SF/IG were measured' print 'requires either fc or fn_str specified' print 'If not the strain column in fn_sf is used,' print 'subsequent analysis is performed by assuming' print 'that the sample is in equibiaxial strain' print '---------------------------------------------\n' # raw_input('press enter to proceed>>') # # dat = open('%s%s%s'%(path,sep,fn_sf)).read() # fn = os.path.join(path,fn_sf) # if os.path.isfile(fn): # dat = open(fn).read() if os.path.isfile(fn_sf): dat = open(fn_sf).read() else: print 'Could not find fn_sf: ' + fn_sf raise IOError, 'tip: use the fully pathed file name' ## Find proper line-breaker lbs = ['\r', '\n'] lns = [] for i in xrange(len(lbs)): lns.append(len(dat.split(lbs[i]))) lns = np.array(lns) lb = lbs[lns.argmax()] ## -- dat_line = dat.split(lb) e1 = np.array(map(float, dat_line[4].split()[1:])) e2 = e1[::] e3 = -e1 - e2 from MP.mat.mech import FlowCurve as FC flow = FC() flow.get_strain(e1, 0, 0) flow.get_strain(e2, 1, 1) flow.get_strain(e3, 2, 2) flow.set_zero_shear_strain() flow.get_vm_strain() fc = flow elif type(fc) != type(None): print 'fc was given' pass import copy EXP, SF, IG = rs_exp.read_main(path=path, fref=fref, fn_sf=fn_sf, fc=fc, fn_str=fn_str, icheck=icheck, isym=isym) ## interpolate based on experimental phis, psis, IG # EXP.plot(istps=[0,10,20]) # SF.plot() # IG.plot() print print '#-----------------------------------------------------#' print ' Interpolate SF and IG for matching with D-spacings' SF_orig = copy.deepcopy(SF) IG_orig = copy.deepcopy(IG) SF_orig.flow.get_vm_strain() IG_orig.flow.get_vm_strain() SF.interp_strain(EXP.flow.epsilon_vm) SF.interp_psi(EXP.psis) ## in case that IG strain is available IG.interp_strain(EXP.flow.epsilon_vm) IG.interp_psi(EXP.psis) ## if not? if SF.phi != EXP.phis: print ' ** Phi angles of SF are different **' if IG.phi != EXP.phis: print ' ** Phi angles of IG are different **' print '#-----------------------------------------------------#' # SF.plot() # IG.plot() SF.determine_phis(phi_new=EXP.phi) IG.determine_phis(phi_new=EXP.phi) SF.plot() IG.plot() #EXP.plot(istps=np.arange(EXP.flow.nstp)[::7]) return EXP, SF, IG, SF_orig, IG_orig
def main_reader( path="../dat/23JUL12", fref="Bsteel_BB_00.txt", fn_sf="YJ_Bsteel_BB.sff", icheck=False, isym=False, fc=None, fn_str=None, ): """ Arguments ========= path (path that contains the data file) fref (reference data that gives strain and date-named for X-ray) fn_sf (stress factor file name) icheck isym fc (flow curve object) fn_str (stress-strain data file) """ if type(fc) == type(None) and type(fn_str) == type(None): print "---------------------------------------------" print "Strain information where SF/IG were measured" print "requires either fc or fn_str specified" print "If not the strain column in fn_sf is used," print "subsequent analysis is performed by assuming" print "that the sample is in equibiaxial strain" print "---------------------------------------------\n" # raw_input('press enter to proceed>>') # # dat = open('%s%s%s'%(path,sep,fn_sf)).read() # fn = os.path.join(path,fn_sf) # if os.path.isfile(fn): # dat = open(fn).read() if os.path.isfile(fn_sf): dat = open(fn_sf).read() else: print "Could not find fn_sf: " + fn_sf raise IOError, "tip: use the fully pathed file name" ## Find proper line-breaker lbs = ["\r", "\n"] lns = [] for i in xrange(len(lbs)): lns.append(len(dat.split(lbs[i]))) lns = np.array(lns) lb = lbs[lns.argmax()] ## -- dat_line = dat.split(lb) e1 = np.array(map(float, dat_line[4].split()[1:])) e2 = e1[::] e3 = -e1 - e2 from MP.mat.mech import FlowCurve as FC flow = FC() flow.get_strain(e1, 0, 0) flow.get_strain(e2, 1, 1) flow.get_strain(e3, 2, 2) flow.set_zero_shear_strain() flow.get_vm_strain() fc = flow elif type(fc) != type(None): print "fc was given" pass import copy EXP, SF, IG = rs_exp.read_main(path=path, fref=fref, fn_sf=fn_sf, fc=fc, fn_str=fn_str, icheck=icheck, isym=isym) ## interpolate based on experimental phis, psis, IG # EXP.plot(istps=[0,10,20]) # SF.plot() # IG.plot() print print "#-----------------------------------------------------#" print " Interpolate SF and IG for matching with D-spacings" SF_orig = copy.deepcopy(SF) IG_orig = copy.deepcopy(IG) SF_orig.flow.get_vm_strain() IG_orig.flow.get_vm_strain() SF.interp_strain(EXP.flow.epsilon_vm) SF.interp_psi(EXP.psis) ## in case that IG strain is available IG.interp_strain(EXP.flow.epsilon_vm) IG.interp_psi(EXP.psis) ## if not? if SF.phi != EXP.phis: print " ** Phi angles of SF are different **" if IG.phi != EXP.phis: print " ** Phi angles of IG are different **" print "#-----------------------------------------------------#" # SF.plot() # IG.plot() SF.determine_phis(phi_new=EXP.phi) IG.determine_phis(phi_new=EXP.phi) SF.plot() IG.plot() # EXP.plot(istps=np.arange(EXP.flow.nstp)[::7]) return EXP, SF, IG, SF_orig, IG_orig
def main_reader(path='../dat/23JUL12', fref='Bsteel_BB_00.txt', fn_sf ='YJ_Bsteel_BB.sff',icheck=False,isym=False, fc=None,fn_str=None): """ Arguments ========= path fref fn_sf icheck isym fc fn_str """ if type(fc)==type(None) and type(fn_str)==type(None): print '---------------------------------------------' print 'Strain information where SF/IG were measured' print 'requires either fc or fn_str specified' print 'If not the strain column in fn_sf is used,' print 'subsequent analysis is performed by assuming' print 'that the sample is in equibiaxial strain' print '---------------------------------------------\n' raw_input('press enter to proceed>>') # # dat = open('%s%s%s'%(path,sep,fn_sf)).read() # fn = os.path.join(path,fn_sf) # if os.path.isfile(fn): # dat = open(fn).read() if os.path.isfile(fn_sf): dat = open(fn_sf).read() else: print 'Could not find fn_sf: '+fn_sf raise IOError, 'tip: use the fully pathed file name' ## Find proper line-breaker lbs=['\r','\n']; lns = [] for i in range(len(lbs)): lns.append(len(dat.split(lbs[i]))) lns = np.array(lns) lb = lbs[lns.argmax()] ## -- dat_line = dat.split(lb) e1 = np.array(map(float,dat_line[4].split()[1:])) e2 = e1[::] e3 = -e1-e2 from MP.mat.mech import FlowCurve as FC flow = FC() flow.get_strain(e1,0,0) flow.get_strain(e2,1,1) flow.get_strain(e3,2,2) flow.set_zero_shear_strain() flow.get_vm_strain() fc = flow elif type(fc)!=type(None): print 'fc was given' pass import copy EXP, SF, IG = rs_exp.read_main( path=path,fref=fref,fn_sf=fn_sf,fc=fc,fn_str=fn_str, icheck=icheck,isym=isym) ## interpolate based on experimental phis, psis, IG # EXP.plot(istps=[0,10,20]) # SF.plot() # IG.plot() print print '#-----------------------------------------------------#' print ' Interpolate SF and IG for matching with D-spacings' SF_orig = copy.deepcopy(SF) IG_orig = copy.deepcopy(IG) SF_orig.flow.get_vm_strain() IG_orig.flow.get_vm_strain() SF.interp_strain(EXP.flow.epsilon_vm) IG.interp_strain(EXP.flow.epsilon_vm) SF.interp_psi(EXP.psis) IG.interp_psi(EXP.psis) if SF.phi!=EXP.phis: print ' ** Phi angles of SF are different **' if IG.phi!=EXP.phis: print ' ** Phi angles of IG are different **' print '#-----------------------------------------------------#' # SF.plot() # IG.plot() SF.determine_phis(phi_new=EXP.phi) IG.determine_phis(phi_new=EXP.phi) SF.plot() IG.plot() #EXP.plot(istps=np.arange(EXP.flow.nstp)[::7]) return EXP, SF, IG, SF_orig, IG_orig