3 from scipy.interpolate 
import interp1d
 
   11           Class to read and manage a winvn 
   21           Read the winvn. (stolen from Carlos) 
   23         with open(self.
__path,
'r') 
as winvn:
 
   24             """Open file with the context manager and extract data.""" 
   31             logT = np.array([int(self.
T_string[i:i+str_size])
 
   32                     for i 
in range(0,len(self.
T_string),str_size)])
 
   38             name1,name2 = (
"",
"-")
 
   42                 name1 = winvn.readline().strip()
 
   43                 nameList.append(name1)
 
   55             for element 
in nameList:
 
   58                 wv_l = winvn.readline().split()
 
   60                     name, A, Z, N, sp, mass_excess, no_idea = wv_l
 
   62                     name, A, Z, N, sp, mass_excess = wv_l
 
   71                     pf_list.extend(winvn.readline().split())
 
   72                 pf_values = np.array(pf_list,dtype=float)
 
   74                 func = 
interp1d(logT,pf_values,bounds_error=
False,kind=
"cubic",fill_value=
"extrapolate")
 
   76                 eleList.append([int(Z),int(N),name,float(A),float(sp),
 
   77                                     float(mass_excess),str(no_idea), pf_values,func] )
 
   80         column_names = [
'Z',
'N',
'name',
'A',
'spin',
'mass excess',
'mass model',
 
   81                         'partition function',
'function']
 
   83         self.
__df = pd.DataFrame(eleList)
 
   85         self.
__df.columns=column_names
 
   86         self.
__df = self.
__df.set_index(
"name")
 
   92         mexc_prot = self.
__df.loc[
"p",
"mass excess"]
 
   93         mexc_neut = self.
__df.loc[
"n",
"mass excess"]
 
   94         self.
__df[
"binding energy"] = mexc_prot*self.
__df[
"Z"]+mexc_neut*self.
__df[
"N"]-self.
__df[
"mass excess"]
 
  101           Save the winvn to a file. 
  108         for ind,row 
in self.
__df.iterrows():
 
  109             out+=row[
"name"].rjust(5)+
"\n" 
  110         out+=row[
"name"].rjust(5)+
"\n" 
  112         for ind,row 
in self.
__df.iterrows():
 
  113             out+=row[
"name"].rjust(5)+5*
" "+
"{:.3f}".
format(row[
"A"]).rjust(7)+\
 
  114                  " "+str(int(row[
"Z"])).rjust(3)+
" "+str(int(row[
"N"])).rjust(3)+\
 
  115                  "{:.1f}".
format(row[
"spin"]).rjust(6)+
"{:.3f}".
format(row[
"mass excess"]).rjust(10)+\
 
  116                  row[
"mass model"].rjust(6)+\
 
  120             for i 
in range(len(row[
'partition function'])):
 
  121                 out+=
"{:.5E}".
format(row[
'partition function'][i]).rjust(12)
 
  126         with open(path,
"w") 
as f:
 
  132           Calculate the neutron separation energies 
  134         mexc_n = self.
__df.loc[
"n",
"mass excess"]
 
  137         Zwinvn = self.
__df[
"Z"].values
 
  138         Nwinvn = self.
__df[
"N"].values
 
  139         mexc   = self.
__df[
"mass excess"].values
 
  142         Sn_Z_N_winvn = np.zeros((Zwinvn.max()+1,Nwinvn.max()+1))
 
  143         Sn_Z_N_winvn[:] = np.nan
 
  144         Sn_Z_N_winvn[Zwinvn,Nwinvn] = mexc
 
  147         Sn_Z_N_winvn[:,1:] = (Sn_Z_N_winvn[:,0:-1] + mexc_n) - Sn_Z_N_winvn[:,1:]
 
  150         self.
__df[
"Sn"] = Sn_Z_N_winvn[Zwinvn,Nwinvn]
 
  155             Calculate the rate factor for a given reaction 
  156             Reactants: List of nuclei of the reactants of the inverse reaction 
  157             Products: List of nuclei of the products of the inverse reaction 
  158             temperature: temperature in GK 
  162         for reac 
in reactants:
 
  163             nom= nom*self.
__df.loc[reac,
"function"](temperature)
 
  166         for prod 
in products:
 
  167             den= den*self.
__df.loc[prod,
"function"](temperature)
 
  185 if __name__==
"__main__":
 
  188     fac = w.rate_factor([
"mg24"],[
"he4",
"ne20"],np.linspace(1,5))