def set_3D(self, use=False): if use: # already in 3D mode, nothing to do! if self.use_3D: return # create the 3D model # Very important to have center = True for the line profiles. self.m3d = pc.C3D(self.model, dims=self.dim_3D, center=True, n_dim=1) self.use_3D = True # need to read the observations as the IR and UV cross-calibration depends on the apertures self.read_obs() else: self.use_3D = False self.read_obs()
dim = 101 n_cut = (dim - 1) / 2 proj_axis = 0 set_models(dir_, model_name) pc.run_cloudy(dir_=dir_, n_proc=3, model_name=model_name, use_make=True) liste_of_models = pc.load_models( '{0}/{1}'.format(dir_, model_name), list_elem=['H', 'He', 'C', 'N', 'O', 'Ar', 'Ne'], read_cont=False, read_grains=False) m3d = pc.C3D(liste_of_models, dims=[dim, dim, dim], angles=[45, 45, 0], plan_sym=True) def_profiles(m3d) im = m3d.get_RGB(list_emis=[0, 3, 7]) plt.imshow(im, origin='lower') m3d.plot_profiles(ref=3, i_fig=1, Nx=20, Ny=20) plot_profiles(m3d, 55, 55) other_plots(m3d, proj_axis) plot_RGB(m3d) plt.show() pc.log_.message('Finished')
bigCloud_sim.read_emis_file('lines.dat') bigCloud_sim.print_input(to_file = True, verbose = False) #Display input code bigCloud_sim.print_input(verbose=False) #Run the model #bigCloud_sim.run_cloudy(dir_=simu_folder) #Read the simulation data bigCloud_output = pc.CloudyModel(simu_folder + name_big, read_emis=True) #bigCloud_output.print_stats() #Generate 3D grid bigCloud_sphere = pc.C3D(bigCloud_output, dims=cube_size, center=True, n_dim=1) arcsec = lambda cm: conv_arc(dist=dist_big/pc_to_cm/1000, dist_proj=cm) mask = make_mask_slit(arcsec, bigCloud_sphere, ap_center=[0, 0], ap_size=[50, 1.5]) #ap_size=[50, 1.5] mask_cirleB = make_mask_circle(arcsec, bigCloud_sphere) #ap_size=[50, 1.5] mask_big = ~np.logical_not(mask) & np.logical_not(mask_cirleB) mask_small = ~np.logical_not(mask_cirleB) #plotting_the_mask(mask_big, arcsec, bigCloud_sphere) #Calculate abundance big_lines_dict = extract_fluxes_pure_slits(bigCloud_sphere, mask_big) big_abund_dict = calculate_abundances(big_lines_dict) print 'Big abund', big_abund_dict['S_tot'], big_abund_dict['S_slit']
def make_3D(self, cube_size, doplot=False, verbose=True, no_VIS=False): self.M_sphere = pc.C3D(self.Mod, dims=cube_size, center=False, n_dim=1) # Slits for UVB and VIS have different widths # integrate inside these masks self.maskUVB = self._mk(0.5) if no_VIS: self.maskVIS = np.nan else: self.maskVIS = self._mk(0.4) Hb_label = 'H__1_486133A' self.Ib = self.Mod.get_emis_vol(Hb_label, at_earth=True) self.Ib_redenned = self.Ib * self.RC.getCorr(4863) factor = 4. * np.pi * (self.distance * pc.CST.KPC)**2 Fhb_UVB = ((self.M_sphere.get_emis(Hb_label) * self.M_sphere.cub_coord.cell_size).sum(1) * self.maskUVB).sum() / factor Fhb_VIS = ((self.M_sphere.get_emis(Hb_label) * self.M_sphere.cub_coord.cell_size).sum(1) * self.maskVIS).sum() / factor Fhb_full = ((self.M_sphere.get_emis(Hb_label) * self.M_sphere.cub_coord.cell_size).sum()) / factor self.flux_mod = {} self.difs = {} self.QF = {} for line in self.line_ordered: if verbose: print('Doing line {}'.format(line)) if self.Obs_Tc1_wave[line] < 2500.: mask = 1.0 Fhb = Fhb_full elif self.Obs_Tc1_wave[line] < 5500.: mask = self.maskUVB Fhb = Fhb_UVB elif self.Obs_Tc1_wave[line] < 10000.: mask = self.maskVIS Fhb = Fhb_VIS else: mask = 1.0 Fhb = Fhb_full fObs = self.Obs_Tc1[line] flux = 100.0 * ((self.M_sphere.get_emis(line) * self.M_sphere.cub_coord.cell_size).sum(1) * mask).sum() / factor / Fhb self.flux_mod[line] = flux # flux in in erg/cm2/s dif = 100.0 * (flux - fObs) / fObs self.difs[line] = dif if fObs < 1.: deltaI = 0.5 elif fObs < 10.: deltaI = 0.3 else: deltaI = 0.2 if self.Obs_Tc1_wave[line] < 2500: deltaI += 0.15 if self.Obs_Tc1_wave[line] > 10000: deltaI += 0.15 tol = np.log10(1 + deltaI) self.QF[line] = np.log10(flux / fObs) / tol