def run_chain_get_element_abund(moogfile, element): run_path = 'running_dir/' save_path = 'save_folder/' teff, logg, feh, vtur = isp.read_parameters_moogfile(moogfile) linelist_element = rp.get_install_dir()+rc.read_config_param('linelists', element+'_abund').replace("'", "") rp.ares_make_mine_opt(run_path, linelist_element) rp.run_ares(run_path) filename_ares = rc.read_config_param('ares', 'fileout').replace("'", "") filename_out = 'lines.' + filename_ares isp.ares_to_lines(run_path+filename_ares, linelist_element, run_path+filename_out, 4000, 9999, 5, 150) rp.create_abfind_par(run_path, filename_out) rp.create_model_kurucz(run_path, teff, logg, feh, vtur) rp.run_MOOG(run_path, 'abfind.par') (ele1, ele1_sig, nele1, ele2, ele2_sig, nele2) = rmoog.read_moog_ele_sigma(run_path+'abund_plan_tspec.test', element, 2.) return (ele1, ele1_sig, nele1, ele2, ele2_sig, nele2)
def error(filename, fix_logg=False): """ Computes the errors """ # Read the file logout = readmoog(filename) # First determine the set of variables that will be needed to # determine the errors. teff = logout[0] logg = logout[1] vt = logout[2] metal = logout[3] abundfe = logout[5] # abundfe = (logout[5] + logout[8])/2. sigmafe1 = logout[6]/np.sqrt(logout[4]) sigmafe2 = logout[9]/np.sqrt(logout[7]) # Do least squaresfits for FeI vs EW and EP a1, b1, siga1, sigb1 = lsq(logout[19], logout[12]) a2, b2, siga2, sigb2 = lsq(logout[18], logout[12]) # Build new abfind.par file linesfile = filename.replace('Out_moog_', '') linesfile = linesfile.replace('b.', '') rp.create_abfind_par('./', linesfile) ############################## # VT: Run MOOG with +0.1 dex # ############################## # Make intermod and transform file run_moog(teff, logg, metal, vt + 0.10) # Read the results logoutvt = readmoog('abund_plan_tspec.test') # Error on microturbulence if logoutvt[11] == 0: errormicro = abs(siga1/0.001) * 0.10 else: errormicro = abs(siga1/logoutvt[11]) * 0.10 # Determine the variation of FeI deltafe1micro = abs((errormicro/0.10) * (logoutvt[5]-abundfe)) ######### # TEFF: # ######### # With these values, calculate the error on the slope of FeI with # excitation potential addslope = (errormicro/0.10) * logoutvt[10] # Add this quadratically to the error on the original FeI-EP slope errorslopeEP = np.hypot(addslope, siga2) # Run MOOG with teff 100K extra run_moog(teff + 100, logg, metal, vt) # Read the results logoutteff = readmoog('abund_plan_tspec.test') # Error on temperature (assume the variation on the slope is linear # with the error) errorteff = abs(errorslopeEP/logoutteff[10]) * 100 # Determine the variation of FeI deltafe1teff = abs((errorteff/100.) * (logoutteff[5]-abundfe)) ######### # logg: # ######### if not fix_logg: # Calculate the variation that the error in Teff caused in the # abundances of FeII addfe2error = abs((errorteff/100.) * (logoutteff[8]-abundfe)) # Quadratically add it to the original abundance error sigmatotalfe2 = np.hypot(sigmafe2, addfe2error) # Run MOOG with logg minus 0.20 run_moog(teff, logg - 0.20, metal, vt) # Read the results logoutlogg = readmoog('abund_plan_tspec.test') # Error on logg errorlogg = abs(sigmatotalfe2 / (logoutlogg[8]-abundfe) * 0.2) else: errorlogg = 0.0 ########### # [Fe/H]: # ########### # Take into account the dispersion errors on FeI by teff and vt errors # Add them quadratically print sigmafe1, deltafe1teff, deltafe1micro errormetal = math.sqrt(sigmafe1**2 + deltafe1teff**2 + deltafe1micro**2) teff, errorteff = int(teff), int(errorteff) logg, errorlogg = round(logg, 2), round(errorlogg, 2) vt, errorvt = round(vt, 2), round(errormicro, 2) metal, errormetal = round(metal, 2), round(errormetal, 2) logg, errorlogg = round(logg, 2), round(errorlogg, 2) result = (teff, errorteff, logg, errorlogg, vt, errormicro, metal, errormetal, logout[4], logout[7], logout[6], logout[9]) return result