def F(x): len_gap_kpc = np.deg2rad(sss.gap_size( mass, dist=dist, timpact=x))/auni.rad*dist vel = 1 # kms len_gap_km = 3.086e16*len_gap_kpc time_fill_gap = len_gap_km/vel/3.15e7/1e9 # in gyr return time_fill_gap/x-1
def find_gap_size_depth(mass, dist, maxt=1, **kwargs): # if gap_fill = True """ Arguments: --------- mass: subhalos mass in units of 1e7 Msun dist: distance of stream in kpc Returns: --- (len_gap_deg, depth_gap): length of gap in degrees gap depth """ # time to fill the gap created by subhalo of the given mass and impact parameter time = find_gap_fill_time(mass, dist, **kwargs) # cap time after the impact to the time required to fill the gap time = min(time, maxt) # time to fill gap if less than max t (default 0.5 Gyr) #print ('x',F(0.5),F(0.001),F(10),time,maxt) print('time', time, mass) # ,maxt) len_gap_deg = sss.gap_size(mass, dist=dist, timpact=float(time), ** kwargs) / auni.deg depth_gap = 1 - sss.gap_depth(mass, timpact=time, **kwargs) return len_gap_deg, depth_gap
def find_gap_size_depth(mass, dist, maxt=1): def F(x): len_gap_kpc = np.deg2rad(sss.gap_size( mass, dist=dist, timpact=x))/auni.rad*dist vel = 1 # kms len_gap_km = 3.086e16*len_gap_kpc time_fill_gap = len_gap_km/vel/3.15e7/1e9 # in gyr return time_fill_gap/x-1 R = scipy.optimize.root(F, 0.1) time = R['x'][0] time = min(time, maxt) #print ('x',F(0.5),F(0.001),F(10),time,maxt) print('time', time, mass) # ,maxt) len_gap_deg = sss.gap_size(mass, dist=dist, timpact=float(time))/auni.deg depth_gap = 1 - sss.gap_depth(mass, timpact=time) return len_gap_deg, depth_gap
def predict_gap_depths(mu, distance_kpc, survey, width_pc=20, maglim=None, timpact=1, gap_fill=True): """ Arguments: --------- mu: real Surface brightness of the stream in mag/sq.arcsec^2 distance_kpc: real Distance to the stream in kpc survey: str Name of the survey width_pc: real The width of the stream in pc timpact: real The time of impact in Gyr gap_fill: bool If true we take into account the filling of the gaps. I.e. we use the depth of the gap and the size of the gap up to a point in time when the gap is supposed to be filled (assuming that it fills with 1km/s velocity) Returns: --- (masses,tdepths,odepths): Tuple of 3 numpy arrays The array of halo masses The array of theoretically predicted gap depths The array of potentially observable gap depths """ isoname = 'iso_a12.0_z0.00020.dat' mockarea = 100 mockfile = 'stream_gap_mock.fits' width_deg = np.rad2deg(width_pc/distance_kpc/1e3) mgrid = 10**np.linspace(3., 10, 100) mgrid7 = mgrid / 1e7 if not gap_fill: gap_depths = np.array( [1 - sss.gap_depth(_, timpact=timpact) for _ in mgrid7]) # We do 1-gap_depth() because sss_gap_depth returns the height of # the gap from zero rather than from 1. gap_sizes_deg = np.array( [sss.gap_size(_, dist=distance_kpc * auni.kpc, timpact=timpact) / auni.deg for _ in mgrid7]) else: gap_depths = np.zeros(len(mgrid)) gap_sizes_deg = np.zeros(len(mgrid)) for i, curm in enumerate(mgrid7): gap_sizes_deg[i], gap_depths[i] = find_gap_size_depth( curm, dist=distance_kpc, maxt=timpact) if maglim is None: maglim_g = getMagLimit('g', survey) maglim_r = getMagLimit('r', survey) else: maglim_g, maglim_r = [maglim]*2 dens_stream = snc.nstar_cal(mu, distance_kpc, maglim_g=maglim_g, maglim_r=maglim_r) dens_bg = get_mock_density(distance_kpc, isoname, survey, mockfile=mockfile, mockarea=mockarea, maglim_g=maglim_g, maglim_r=maglim_r) print('Background/stream density [stars/sq.deg]', dens_bg, dens_stream) max_gap_deg = 10 # this the maximum gap length that we consider reasonable N = len(gap_sizes_deg) detfracs = np.zeros(N) for i in range(N): area = 2 * width_deg * gap_sizes_deg[i] # twice the width and the length of the gap nbg = dens_bg * area nstr = dens_stream * area print('Nstream', nstr, 'Nbg', nbg) detfrac = 5 * np.sqrt(nbg + nstr) / nstr # this is smallest gap depth that we could detect # we the poisson noise on density is sqrt(nbg+nstr) # and the stream density (per bin) is nstr detfracs[i] = detfrac if gap_sizes_deg[i] > max_gap_deg: detfracs[i] = np.nan return (mgrid, gap_depths, detfracs)