<jupyter_start><jupyter_text>If you are looking towards RA=0, Dec=0, at a sample of halo stars with Mr=5 and r = 21: a) what is their heliocentric distance?<jupyter_code>distance = coord.Distance(distmod=(21 - 5))
distance<jupyter_output><empty_output><jupyter_text>b) what is their galactocentric distance?<jupyter_code>c = coord.ICRS(ra=0*u.degree, dec=0*u.degree, distance=distance)
c_gal = c.transform_to(coord.Galactocentric)
c_gal.representation = 'spherical'
c_gal.distance<jupyter_output><empty_output><jupyter_text>c) what is the median and rms for their observed pmRA and pmDec?<jupyter_code># motion components; draw 10^6 samples
np.random.seed(420)
N = 1000000

v_rho = np.random.normal(loc=0, scale=135, size=N) * u.km/u.s
v_phi = np.random.normal(loc=0, scale=85, size=N) * u.km/u.s
v_z = np.random.normal(loc=0, scale=85, size=N) * u.km/u.s

# astropy hates things
v_phi /= c_gal.distance
v_phi *= u.rad
# check cylindrical representation quantities
c_cyl = c_gal.represent_as('cylindrical')
c_cyl
# set up new set of coordinates with c_cyl coordinates and generated velocities
c_new = coord.Galactocentric([c_cyl.rho]*N, [c_cyl.phi]*N, [c_cyl.z]*N,
                              d_rho=v_rho, d_phi=v_phi, d_z=v_z,
                              representation=coord.CylindricalRepresentation,
                              differential_cls=coord.CylindricalDifferential
                            ).transform_to(coord.Galactic)

# convert to spherical units
c_new.representation = 'spherical'
c_new
c_new_icrs = c_new.transform_to(coord.ICRS)
c_new_icrs.representation = 'spherical'
c_new_icrs
# plot PM distributions in galactic coordinates and print median + rms
ax = sns.distplot(c_new.pm_l, label='Galactic longitude PM')
sns.distplot(c_new.pm_b, label='Galactic latitude PM')
ax.legend()
ax.set_xlabel('Proper motion (mas/yr)')
ax.set_ylabel('Normalized frequency')
print('Median galactic longitude PM: {:.5f}'.format(np.median(c_new.pm_l)))
print('Median galactic latitude PM: {:.5f}'.format(np.median(c_new.pm_b)))
print('RMS galactic longitude PM: {:.5f}'.format(np.std(c_new.pm_l)))
print('RMS galactic latitude PM: {:.5f}'.format(np.std(c_new.pm_b)))
# plot PM distributions in ICRS coordinates and print median + rms
ax = sns.distplot(c_new_icrs.pm_ra, label='RA PM')
sns.distplot(c_new_icrs.pm_dec, label='Dec PM')
ax.legend()
ax.set_xlabel('Proper motion (mas/yr)')
ax.set_ylabel('Normalized frequency')
print('Median RA PM: {:.5f}'.format(np.median(c_new_icrs.pm_ra)))
print('Median Dec PM: {:.5f}'.format(np.median(c_new_icrs.pm_dec)))
print('RMS RA PM: {:.5f}'.format(np.std(c_new_icrs.pm_ra)))
print('RMS Dec PM: {:.5f}'.format(np.std(c_new_icrs.pm_dec)))<jupyter_output>Median RA PM: 1.52319 mas / yr
Median Dec PM: -2.28355 mas / yr
RMS RA PM: 0.98341 mas / yr
RMS Dec PM: 1.62508 mas / yr<jupyter_text>d) what is the median and rms for their observed radial velocity?<jupyter_code>ax = sns.distplot(c_new.radial_velocity)
ax.set_xlabel('Radial velocity (km/s)')
ax.set_ylabel('Normalized frequency')
print('Median radial velocity: {:.5f}'.format(np.median(c_new.radial_velocity)))
print('RMS radial velocity: {:.5f}'.format(np.std(c_new.radial_velocity)))<jupyter_output>Median radial velocity: -107.75269 km / s
RMS radial velocity: 90.68151 km / s
{'fraction_non_alphanumeric': 0.13911719939117198, 'fraction_numerical': 0.024961948249619482, 'mean_word_length': 5.073937153419593, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '202425', 'license': 'BSD-2-Clause', 'n_tokens_mistral': 1350, 'n_tokens_neox': 1241, 'n_words': 266, 'path': 'homeworks/HW2-part1_Group1_revised.ipynb', 'repo_name': 'dirac-institute/uw-astr598-w18', 'size': '3285'}