def setup_pycecream(self, test_project_folder='test_pycecream_output', dream=False): ''' test pycecream using yasamans script :return: ''' #instantiate and remove previous test if present os.system('rm -rf ' + test_project_folder) a = pycecream.pycecream() a.project_folder = test_project_folder #set the hyperparameters a.p_accretion_rate_step = 0.1 a.bh_mass = self.BHMass a.p_inclination = self.disk_inc a.bh_efficieny = self.BHefficiency a.p_inclination_step = 0.0 a.hi_frequency = 0.5 a.N_iterations = 20 #add the light curves one at a time previous_wavelength = np.nan wavelengths = self.datnorm['wavelength'] names = self.datnorm['name'] LightCurveData = self.datnorm['light curve'] if dream is False: for i in range(len(names)): wavelength, lc, name = wavelengths[i], LightCurveData[ i], names[i] if wavelength == previous_wavelength: share_previous_lag = True else: share_previous_lag = False a.add_lc(lc, kind='continuum', name=name, wavelength=wavelength, share_previous_lag=share_previous_lag) previous_wavelength = wavelength elif dream is True: wav_tophat = 0.0 for i in range(len(names)): wavelength, lc, name = wavelengths[i], LightCurveData[ i], names[i] if wavelength == previous_wavelength: share_previous_lag = True else: share_previous_lag = False wav_tophat += -1.0 a.add_lc(lc, kind='line', name=name, wavelength=np.round(wav_tophat, 1), share_previous_lag=share_previous_lag) previous_wavelength = wavelength return a
def run_pycecream(self, test_project_folder='test_pycecream_output'): ''' test pycecream using yasamans script :return: ''' cream_lc0, cream_lc1, cream_lc4, cream_lc2, cream_lc3, cream_lc8, cream_lc5, cream_lc6, cream_lc7 = self.dat #instantiate and remove previous test if present os.system('rm -rf ' + test_project_folder) a = pycecream.pycecream() a.project_folder = test_project_folder #step accretion rate? a.p_accretion_rate_step = 0.1 a.bh_mass = 6.6e8 # MgII Line lightcurve a.add_lc(cream_lc0, name='line 0 (MgII)', kind='line', background_polynomials=[0.1, 0.1]) a.p_linelag_centroids_step = 0.0 # g-band photometric lightcurves a.add_lc(cream_lc1, name='continuum (Bok)', kind='continuum', wavelength=4680) a.add_lc(cream_lc2, name='continuum 4720 (CFHT 1)', kind='continuum', wavelength=4720, share_previous_lag=True) a.add_lc(cream_lc3, name='continuum 4720 (CFHT 2)', kind='continuum', wavelength=4720, share_previous_lag=True) a.add_lc(cream_lc4, name='continuum 4686 (SynthPhot)', kind='continuum', wavelength=4686, share_previous_lag=True) # i-band photometric lightcurves a.add_lc(cream_lc5, name='continuum (Bok)', kind='continuum', wavelength=7760, share_previous_lag=False) a.add_lc(cream_lc6, name='continuum (CFHT 1)', kind='continuum', wavelength=7764, share_previous_lag=True) a.add_lc(cream_lc7, name='continuum (CFHT 2)', kind='continuum', wavelength=7764, share_previous_lag=True) a.add_lc(cream_lc8, name='continuum (SynthPhot)', kind='continuum', wavelength=7480, share_previous_lag=True) a.hi_frequency = 0.5 a.N_iterations = 20 a.run(ncores=4) self.pc = a
def run_pycecream(self): ''' test pycecream using yasamans script :return: ''' cream_lc0, cream_lc1, cream_lc4, cream_lc2, cream_lc3, cream_lc8, cream_lc5, cream_lc6, cream_lc7 = self.dat a = pycecream.pycecream() #step accretion rate? a.p_accretion_rate_step = 0.1 # MgII Line lightcurve a.add_lc(cream_lc0, name='line 0 (MgII)', kind='line') a.p_linelag_centroids_step = 0.0 # g-band photometric lightcurves a.add_lc(cream_lc1, name='continuum (Bok)', kind='continuum', wavelength=4680) a.add_lc(cream_lc2, name='continuum 4720 (CFHT 1)', kind='continuum', wavelength=4720, share_previous_lag=True) a.add_lc(cream_lc3, name='continuum 4720 (CFHT 2)', kind='continuum', wavelength=4720, share_previous_lag=True) a.add_lc(cream_lc4, name='continuum 4686 (SynthPhot)', kind='continuum', wavelength=4686, share_previous_lag=True) # i-band photometric lightcurves a.add_lc(cream_lc5, name='continuum (Bok)', kind='continuum', wavelength=7760, share_previous_lag=True) a.add_lc(cream_lc6, name='continuum (CFHT 1)', kind='continuum', wavelength=7764, share_previous_lag=True) a.add_lc(cream_lc7, name='continuum (CFHT 2)', kind='continuum', wavelength=7764, share_previous_lag=True) a.add_lc(cream_lc8, name='continuum (SynthPhot)', kind='continuum', wavelength=7480, share_previous_lag=True) a.hi_frequency = 0.5 a.N_iterations = 20 a.run() self.pc = a
background_data[:,0] = t background_data[:,1] = x background_data[:,2] = sig dat.append(background_data) # # Section 2: Settup and run PyceCREAM # # # In[2]: import pycecream #instantiate a pycecream object a = pycecream.pycecream() ''' If you use a fortran compiler other than gfortran please indicate here. I just re-enter gfortran here for demonstration purposes even though this is unecassary as gfortran is the default argument. ''' a.fortran_caller = 'gfortran' '''Choose an output directory in which to save the results. This will be a new directory that you have not previously created (pycecream will make it automatically). NOTE: Each new cream simulation must have a new name for "output_directory argument below otherwise an excpetion is raised. This is to prevent accidentally overwriting previous simulations.
for lcf in lightcurve_files: idxrmid = lcf.find('_rm') filter = lcf[idxrmid+7] wavelength_list.append(filter_wavelengths[filter]) ''' sort by increasing wavelength (should already be sorted) ''' idxsort = np.argsort(wavelength_list) wavelength_list = [wavelength_list[idx] for idx in idxsort] lightcurve_files = [lightcurve_files[idx] for idx in idxsort] ''' instantiate pycecream ''' pcfit = pycecream.pycecream() ''' customize for current target (set output directory and bh mass) ''' pcfit.project_folder = pycecream_output_dir+'/'+group_dir+'/'+target.replace(batch_directory+'/','') idx_bh_mass = np.where(sdssrm_masses[:,0] == rmid)[0] if len(idx_bh_mass) > 0: pcfit.bh_mass = sdssrm_masses[idx_bh_mass[0],1] else: pcfit.bh_mass = default_bh_mass ''' iteratively add each lightcurve ''' previous_wavelength = -999