In [1]:
%pylab inline
In [2]:
import pandas as pd
import numpy as np
import astropy.units as u
from starutils.populations import StarPopulation,StarPopulation_FromH5,BinaryPopulation,BGStarPopulation,BGStarPopulation_FromH5
from isochrones.dartmouth import Dartmouth_Isochrone
dar = Dartmouth_Isochrone()
In [3]:
n = 1e4
pri = dar(1*np.ones(n),9.7,0.0, return_df=True)
sec = dar(np.linspace(0.15,1,n),9.7,0, return_df=True)
In [4]:
import scipy.stats as stats
def random_period(N,mu=5.03,sigma=2.28):
dist = stats.norm(5.03,2.28)
return 10**dist.rvs(N)
def random_eccentricity(N,a=.697,b=3.3):
dist = stats.beta(a,b)
return dist.rvs(N)
In [5]:
from astropy.units import Quantity
import astropy.units as u
binpop = BinaryPopulation(pri,sec, Quantity(1000,'parsec'), period=random_period(n), ecc=random_eccentricity(n))
In [6]:
binpop.orbpop.scatterplot(rmax=1e4)
In [7]:
binpop.apply_trend_constraint(1*u.km/u.s,10*u.yr,overwrite=True)
binpop.set_maxrad(4*u.arcsec)
In [8]:
binpop.constraint_piechart()
In [9]:
binpop.constraints
Out[9]:
In [10]:
binpop.save_hdf('testpop.h5')
In [11]:
from starutils.populations import BinaryPopulation_FromH5
In [12]:
binpop2 = BinaryPopulation_FromH5('testpop.h5')
In [13]:
binpop2.orbpop.scatterplot(rmax=1e4)
In [14]:
ls
In [3]:
df = pd.read_hdf('test.h5','df')
In [4]:
bgpop = BGStarPopulation(df)
In [5]:
bgpop.Rsky
Out[5]:
In [9]:
bgpop.maxrad = 4
bgpop.Rsky
Out[9]:
In [8]:
print bgpop.density
In [10]:
bgpop.maxrad
Out[10]:
In [11]:
bgpop.save_hdf('testbgpop.h5')
In [3]:
bgpop2 = BGStarPopulation_FromH5('testbgpop.h5')
In [4]:
bgpop2.maxrad
Out[4]:
In [6]:
print bgpop2.density
In [8]:
bgpop2.maxrad = 2*u.arcsec
In [15]:
In [9]:
bgpop2.Rsky
Out[9]:
In [14]:
bgpop2._maxrad
Out[14]:
In [22]:
(2*u.arcmin / bgpop2._maxrad).decompose()
Out[22]:
In [ ]: