def pysynth(x0, id_el, elements, dw, g_fwhm, selected_model, region, dwin, b_win): ''' Function: Wrtie a parameter file for synth module called batch.par Variables: x0 = abundance values id_el = element numbers which are allowed to vary elements = full array of tuples, [(element number,abundance)] dw = wavelength offset between data and model g_fwhm = convolve model with gaussian selected_model = MOOG capable stelalr model region = wavelength in region of interest dwin = resolution of model in Angstoms, should be higher than data resolution b_win = bounds of plotting window Expectations: None ''' from SRP import create_moog_file_synth from SRP import pymoogsilent from SRP import moog_synth_chisqr for i, e in enumerate(elements): t1, t2 = e s = np.where(t1 == id_el) elements[i] = (t1, x0[s]) create_moog_file_synth('../DATS/' + selected_model, region - 6, region + 6, dwin, 1.00, b_win, 1.1, elements, g_fwhm) pymoogsilent() #wave_m,flux_m = SRP.read_out3('out3') #plt.plot(wave_m,flux_m,'--') return moog_synth_chisqr('out3', 'star.xy', dw)
def pysynth_rot_metal_mcmc(x0, args): ''' Function: Wrtie a parameter file for synth module called batch.par, amended to use rotational broadening parameter which can varry in fit, metals a fixed to singular value from solar Variables: x0 = abundance values id_el = element numbers which are allowed to vary elements = full array of tuples, [(element number,abundance)] dw = wavelength offset between data and model rot = convolve model with rotationally brodened profile selected_model = MOOG capable stelalr model region = wavelength in region of interest dwin = resolution of model in Angstoms, should be higher than data resolution b_win = bounds of plotting window ''' #print args," : args" id_el, elements, dw, selected_model, region, dwin, b_win = args #print x0," : x0" from SRP import create_moog_file_synth from SRP import pymoogsilent from SRP import moog_synth_chisqr #print x0," : x0" rot = x0[0] x = x0[1] if (rot > 300.0 / 100.0) | (rot < 0.0): return -np.inf if (x > 2.0) | (x < -2.0): return -np.inf for i, e in enumerate(elements): t1, t2 = e elements[i] = (t1, x) #print elements," : elements" create_moog_file_synth_rot('../DATS/' + selected_model, region - 6, region + 6, dwin, 1.00, b_win, 1.1, elements, rot * 100.0) fyiwdwytm = pymoogsilent() #wave_m,flux_m = SRP.read_out3('out3') #plt.plot(wave_m,flux_m,'--') if fyiwdwytm: #jack up chisqr if moog failed prob = -np.inf else: chisqr = moog_synth_chisqr('out3', 'star.xy', dw) prob = 1 / chisqr return np.log(prob)
def pysynth_rot(x0, id_el, elements, dw, selected_model, region, dwin, b_win): ''' Function: Wrtie a parameter file for synth module called batch.par, amended to use rotational broadening parameter which can varry in fit Variables: x0 = abundance values id_el = element numbers which are allowed to vary elements = full array of tuples, [(element number,abundance)] dw = wavelength offset between data and model rot = convolve model with rotationally brodened profile selected_model = MOOG capable stelalr model region = wavelength in region of interest dwin = resolution of model in Angstoms, should be higher than data resolution b_win = bounds of plotting window ''' from SRP import create_moog_file_synth from SRP import pymoogsilent from SRP import moog_synth_chisqr #print x0," : x0 rot" rot = x0[0] x0 = x0[1:] if (rot > 300) | (rot < 0): return 10 if (x0 > 2) | (x0 < -2): return 10 for i, e in enumerate(elements): t1, t2 = e s = np.where(t1 == id_el) elements[i] = (t1, x0[s[0][0]]) #print elements," : elements" create_moog_file_synth_rot('../DATS/' + selected_model, region - 6, region + 6, dwin, 1.00, b_win, 1.1, elements, rot) fyiwdwytm = pymoogsilent() #wave_m,flux_m = SRP.read_out3('out3') #plt.plot(wave_m,flux_m,'--') if fyiwdwytm: #jack up chisqr if moog failed chisqr = 1E6 else: chisqr = moog_synth_chisqr('out3', 'star.xy', dw) #print chisqr," : chisqr" return chisqr
def pysynth_rot_fxd_mcmc(x0, id_el, elements, dw, rot, selected_model, region, dwin, b_win): ''' Function: Wrtie a parameter file for synth module called batch.par, amended to use rotational broadening parameter (fixed) Variables: x0 = abundance values id_el = element numbers which are allowed to vary elements = full array of tuples, [(element number,abundance)] dw = wavelength offset between data and model rot = convolve model with rotationally brodened profile selected_model = MOOG capable stelalr model region = wavelength in region of interest dwin = resolution of model in Angstoms, should be higher than data resolution b_win = bounds of plotting window Expectation: selected models are in a local directory './DATS/' (probably should make that a var) ''' print x0, " : x0" from SRP import create_moog_file_synth from SRP import pymoogsilent from SRP import moog_synth_chisqr #sanity check if (np.max(np.abs(x0)) > 5): return 1E3 #print x0," : x0",rot for i, e in enumerate(elements): t1, t2 = e s = np.where(t1 == id_el) #print list(s),id_el,t1 elements[i] = (t1, x0[s[0][0]]) create_moog_file_synth_rot('../DATS/' + selected_model, region - 6, region + 6, dwin, 1.00, b_win, 1.1, elements, rot) fyiwdwytm = pymoogsilent() #wave_m,flux_m = SRP.read_out3('out3') #plt.plot(wave_m,flux_m,'--') if fyiwdwytm: #jack up chisqr if moog failed prob = -np.inf else: chisqr = moog_synth_chisqr('out3', 'star.xy', dw) prob = 1 / chisqr return np.log(prob)