def draw_soft_with_selector(self): selector = popsynth.SoftFluxSelection() selector.boundary = 1e-4 selector.strength = 10 self.pop_gen.set_flux_selection(selector) pop = self.pop_gen.draw_survey(flux_sigma=0.5) self.reset() return pop
def draw_soft(self): s = popsynth.SoftFluxSelection() s.boundary = 1e-4 s.strength = 10 self.pop_gen.set_flux_selection(s) pop = self.pop_gen.draw_survey(flux_sigma=0.1, ) self.reset() return pop
def draw_z_select(self): s1 = popsynth.BernoulliSelection() s1.probability = 0.5 s2 = popsynth.SoftFluxSelection() s2.boundary = 1e-6 s2.strength = 10 self.pop_gen.set_distance_selection(s1) self.pop_gen.set_flux_selection(s2) pop = self.pop_gen.draw_survey(flux_sigma=0.5) self.reset() return pop
def test_basic_population(): homo_pareto_synth = ( popsynth.populations.ParetoHomogeneousSphericalPopulation(Lambda=0.25, Lmin=1, alpha=2.0)) population = homo_pareto_synth.draw_survey() homo_pareto_synth.display() population.display() print(homo_pareto_synth) population.display_fluxes() population.display_flux_sphere() # Test the dist prob extremes flux_selector = popsynth.SoftFluxSelection() flux_selector.boundary = 1e-2 flux_selector.strength = 50 homo_pareto_synth.clean(reset=True) homo_pareto_synth.set_flux_selection(flux_selector) population = homo_pareto_synth.draw_survey(flux_sigma=1) ### homo_pareto_synth.clean(reset=True) b_selector = popsynth.BernoulliSelection() b_selector.probability = 0.5 homo_pareto_synth.set_flux_selection(flux_selector) homo_pareto_synth.set_distance_selection(b_selector) population = homo_pareto_synth.draw_survey(flux_sigma=0.1) homo_pareto_synth.clean(reset=True) u_select = popsynth.UnitySelection() homo_pareto_synth.set_distance_selection(u_select) population = homo_pareto_synth.draw_survey(flux_sigma=0.1, ) homo_pareto_synth.clean(reset=True) homo_sch_synth = ( popsynth.populations.SchechterHomogeneousSphericalPopulation( Lambda=0.1, Lmin=1, alpha=2.0)) homo_sch_synth.display() flux_selector = popsynth.HardFluxSelection() flux_selector.boundary = 1e-5 homo_sch_synth.set_flux_selection(flux_selector) population = homo_sch_synth.draw_survey(flux_sigma=0.1) population.display_fluxes() population.display_flux_sphere() print(population.truth) homo_sch_synth.clean(reset=True) homo_sch_synth.set_flux_selection(u_select) homo_sch_synth.draw_survey(flux_sigma=0.1, ) population.writeto("_saved_pop.h5") population_reloaded = popsynth.Population.from_file("_saved_pop.h5") os.remove("_saved_pop.h5") sfr_synth = popsynth.populations.ParetoSFRPopulation( r0=10.0, rise=0.1, a=0.015, decay=2.0, peak=5.0, Lmin=1e52, alpha=1.0, seed=123, )