예제 #1
0
    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
예제 #2
0
    def __init__(self, pop_class, **params):

        self.pop_gen = pop_class(**params)

        self.d1 = DemoSampler()
        self.d2 = DemoSampler2()
        self.d2.set_secondary_sampler(self.d1)
        self.d3 = DemoSampler3()
        self.d4 = DemoSampler4()
        self.d4.set_secondary_sampler(self.d3)

        b = popsynth.BernoulliSelection()
        b.probability = 0.5

        self.d2.set_selection_probability(b)

        for k, v in params.items():

            if k != "is_rate":

                assert k in self.pop_gen._params
예제 #3
0
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,
    )