Ejemplo n.º 1
0
def elastic_chi(val,fresco,data,pot,term,var):
    for i,j in zip(var,val):
        fresco.change_pot(pot,term,i,str(j)) #Change potentials
    fresco.update_all()
    fresco.write('new_input')
    fc.filerun('new_input')
    cross = fc.read_cross('fort.201')
    spline = cross_interpolate(cross)
    theory = interpolate.splev(data.theta,spline)
    exper = data.sigma
    err = data.errx #Might need to consider aysmmetric data in future. Keep eye out.
    chi_list = map(chi_sq,theory,exper,err)
    return .5*np.sum(chi_list)
Ejemplo n.º 2
0
def read_data(filelist):
    theta = []
    sigma = []
    for ele in filelist:
        theta.append(float(ele[0]))                  
        sigma.append(float(ele[1]))
    graphline = fc.dataobject(theta,sigma)
    return graphline
Ejemplo n.º 3
0
    def __init__(self,files,data=None,q_name=None):
        self.lines = []
        #Create the list of lineobjects from file names given. If not given iterable it is assumed to be a single file.
        #Can also pass list of lineobjects
        if isinstance(files,tuple):
            for ele in files:
                self.lines.append(fc.read_cross(ele))
        elif isinstance(files,str):
            self.lines.append(fc.read_cross(files))
        else:
            for ele in files:
                self.lines.append(ele)
            
        self.data = data

        #Initialize the plot
        self.fig = plt.figure()
        self.ax = self.fig.add_subplot(111)
Ejemplo n.º 4
0
    def __init__(self,fresco,data,pot,term,var,percent_range=.2): #user selects what range they want to vary potentials within defualts to 20%
        self.fresco = fc.FrescoInput(fresco)
        self.data = fc.read_data(data)
        self.f_args = (self.fresco,self.data,pot,term,var) #tuple of arguments to be passed to chi square function 
        self.x0 = [] #inital potential parameters
        for ele in self.f_args[4]: 
            for line in self.fresco.sorted_pots[self.f_args[2]][self.f_args[3]]:#Just in case potential has two lines
                if ele in line:
                    init = self.fresco.find_value(ele,line,'=')
                    self.x0.append(float(init))
        self.x0 = np.asarray(self.x0)
        self.init_chi = elastic_chi(self.x0,*self.f_args) #get inital chi square value
        print "The initial chi squared value is ",self.init_chi 
        self.init_cs = fc.read_cross('fort.201') #the inital cross section data
        self.iterations = 0 #number of basin hops completed
        self.bounds = self.set_bounds(percent_range) #range we are allowed to jump around in. We will still sample, but auto rejected outside this range 

        #These are default parameters that can be set with set_basin
        self.T = 1.0
        self.steps = 50
        self.step_size = .1
Ejemplo n.º 5
0
def readfres200(filelist):
    
    #Initialize lists for angular information
    theta = []
    sigma = []
    for ele in filelist:
        #This picks out the cross section at each angle.
        if len(ele) == 2 and ele[0] != '@legend' and ele[0] != '@subtitle':
            theta.append(float(ele[0]))                  
            sigma.append(float(ele[1]))
        
        #looks for lab energy. Let this haunt your dreams until you think of a better way.
        elif ele[0] == '@legend' or ele[0] == '#legend':
            if 'energy' in ele:
                energy = findall('[0-9.0]+',ele[6])
                E = float(energy[0])

        # End of file create the lineobject ask user for state information
        elif ele[0] == 'END':
            J,par = raw_input("What is the spin parity of the state?\n")
            graphline = fc.lineobject(theta,sigma,E,J,par)
            
    return graphline
Ejemplo n.º 6
0
 def plot(self):
     new_cs = fc.read_cross('fort.201') #the cross section for the fitted data
     plot = fp.CrossSectionPlot([self.init_cs,new_cs],self.data) #create the plot with new_cs vs init_cs vs the data
     plot.ax.set_title('Best Fit')
     plot.plot()