<commit_before>from EXOSIMS.Prototypes.SimulatedUniverse import SimulatedUniverse
import numpy as np
import astropy.units as u  

class DulzPlavchanUniverseEarthsOnly(SimulatedUniverse):
    """Simulated Universe module based on Dulz and Plavchan occurrence rates.

    """

    def __init__(self, **specs):

        SimulatedUniverse.__init__(self, **specs)

    def gen_physical_properties(self, **specs):
        """Generating universe based on Dulz and Plavchan occurrence rate tables.

        """

        PPop = self.PlanetPopulation
        TL = self.TargetList

        # treat eta as the rate parameter of a Poisson distribution
        targetSystems = np.random.poisson(lam=PPop.eta, size=TL.nStars)
        plan2star = []
        for j, n in enumerate(targetSystems):
            plan2star = np.hstack((plan2star, [j] * n))

        a, e, p, Rp = PPop.gen_plan_params(len(plan2star))

        #filter to just Earth candidates
        #modify as needed NB: a has no yet been scaled by \sqrt{L}
        #so effectively everything is at 1 solar luminosity
        inds = (a < 1.67*u.AU) & (a > 0.95*u.AU) & (Rp < 1.4*u.R_earth ) & (Rp >0.8/np.sqrt(a.value)*u.R_earth)  

        self.a = a[inds]
        self.e = e[inds]
        self.p = p[inds]
        self.Rp = Rp[inds]
        plan2star = plan2star[inds]


        self.plan2star = plan2star.astype(int)
        self.sInds = np.unique(self.plan2star)
        self.nPlans = len(self.plan2star)

        if PPop.scaleOrbits:
            self.a *= np.sqrt(TL.L[self.plan2star])


        # sample all of the orbital and physical parameters
        self.I, self.O, self.w = PPop.gen_angles(self.nPlans)
        self.gen_M0()  # initial mean anomaly
        self.Mp = PPop.MfromRp(self.Rp)  # mass

        self.phiIndex = None #Used to switch select specific phase function for each planet
<commit_msg>adding Earth Phase Function to Dulz Plavchan<commit_after>from EXOSIMS.Prototypes.SimulatedUniverse import SimulatedUniverse
import numpy as np
import astropy.units as u  

class DulzPlavchanUniverseEarthsOnly(SimulatedUniverse):
    """Simulated Universe module based on Dulz and Plavchan occurrence rates.
    attributes:
        earthPF (boolean):
            indicates whether to use Earth's phase function or not
    """

    def __init__(self, earthPF=True, **specs):

        self.earthPF = earthPF
        SimulatedUniverse.__init__(self, **specs)

    def gen_physical_properties(self, **specs):
        """Generating universe based on Dulz and Plavchan occurrence rate tables.

        """

        PPop = self.PlanetPopulation
        TL = self.TargetList

        # treat eta as the rate parameter of a Poisson distribution
        targetSystems = np.random.poisson(lam=PPop.eta, size=TL.nStars)
        plan2star = []
        for j, n in enumerate(targetSystems):
            plan2star = np.hstack((plan2star, [j] * n))

        a, e, p, Rp = PPop.gen_plan_params(len(plan2star))

        #filter to just Earth candidates
        #modify as needed NB: a has no yet been scaled by \sqrt{L}
        #so effectively everything is at 1 solar luminosity
        inds = (a < 1.67*u.AU) & (a > 0.95*u.AU) & (Rp < 1.4*u.R_earth ) & (Rp >0.8/np.sqrt(a.value)*u.R_earth)  

        self.a = a[inds]
        self.e = e[inds]
        self.p = p[inds]
        self.Rp = Rp[inds]
        plan2star = plan2star[inds]


        self.plan2star = plan2star.astype(int)
        self.sInds = np.unique(self.plan2star)
        self.nPlans = len(self.plan2star)

        if PPop.scaleOrbits:
            self.a *= np.sqrt(TL.L[self.plan2star])


        # sample all of the orbital and physical parameters
        self.I, self.O, self.w = PPop.gen_angles(self.nPlans)
        self.gen_M0()  # initial mean anomaly
        self.Mp = PPop.MfromRp(self.Rp)  # mass

        #Use Earth Phase Function
        if self.earthPF == True:
            self.phiIndex = np.ones(self.nPlans,dtype=int)*2 #Used to switch select specific phase function for each planet
        else:
            self.phiIndex = np.zeros(self.nPlans)

{'fraction_non_alphanumeric': 0.10221130221130222, 'fraction_numerical': 0.011547911547911549, 'mean_word_length': 2.4587935429056924, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2012067', 'n_tokens_mistral': 1407, 'n_tokens_neox': 1325, 'n_words': 349}