def v_hel(z, ra, dec, mjd, aband, longitude=keck_long, latitude=keck_lat, altitude=keck_alt, tanplane=False, delim=":"): """ Calculate the heliocentric velocity of stars given their redshift (z), RA and DEC, date of observation (mjd) and A-band correction Default longitude and latitude correspond to Keck Required arguments: - z: redshift - ra: right ascension as string or degree - dec: declination as string or degree - mjd: Julian Date of observation - abad: Aband correction Optional arguments - longitude: longitude of observatory - latitude: latitude of observatory - altitude: altitude of observatory - tanplane: are your positions already in the tangential plane - delim: delimiter if your positions are a string Note: helcorr.py, and its dependencies, are part of Sergey Koposov's astrolibpy library. I am not aware of an astropy equivalent, but there may well be one It is being imported here so as to not muck up all the other things that don't need it """ from helcorr import helcorr if isinstance(ra, str): ra_deg, dec_deg = hms2deg(ra, dec, delim=delim) else: ra_deg = ra dec_deg = dec if ~tanplane: ra_deg *= cosdg(d31) return (z * c) - (aband * c) - helcorr(longitude, latitude, altitude, ra_deg, dec_deg, mjd)[0]
#centroids = np.array(centroids) #centroid_errs = np.array(centroid_errs) centroids_redshifts = (centroids - rest_wavelengths)/rest_wavelengths # Compute errors on redshifts. centroids_redshifts_err = np.sqrt( (1.0/rest_wavelengths)**2*np.array(centroid_errs)**2 ) # Convert wavelength centroids into km/s using rest-wavelength comparison. centroids_vel = (np.array(centroids) - rest_wavelengths)/rest_wavelengths * speed_light # Compute heliocentric correction. # First, get observatory information. lon, lat, alt = ObservatoryInformation(config_file) # Then, get object coordinates from input file. ra, dec, jd = ObjectInformation(header) correction, hjd = helcorr(lon, lat, alt, ra, dec, 2455084.537578) # Apply heliocentric correction. centroids_vel_helio = centroids_vel + correction # Transform error bars accordingly. centroids_vel_helio_err = np.sqrt( (speed_light/rest_wavelengths)**2*np.array(centroid_errs)**2 + 1e-6) # Plot rotation curve / curves. fig2 = plt.figure(2) plt.xlabel("Distance from Center [arcsec]", fontsize=18) plt.ylabel("Heliocentric Radial Velocity [km/s]", fontsize=18) plt.title("For convenience, points with large errors not plotted.") for i in range(no_components): plt.errorbar( spatial_points_arc[filtered[:,i]], centroids_vel_helio[:,i][filtered[:,i]], centroids_vel_helio_err[:,i][filtered[:,i]], fmt="o" ) plt.show() raw_input()
cra = np.array([hms2deg(r,d)[0] for r,d in zip(cstars.RA, cstars.DEC)]) cra2 = cra*cosdg(d31) cdec = np.array([hms2deg(r,d)[1] for r,d in zip(cstars.RA, cstars.DEC)]) cdist = computeDist(cra, cdec) ara = np.array([hms2deg(r,d)[0] for r,d in zip(agb_noc.RA, agb_noc.DEC)]) ara2 = ara*cosdg(d31) adec = np.array([hms2deg(r,d)[1] for r,d in zip(agb_noc.RA, agb_noc.DEC)]) ara_all = np.array([hms2deg(r,d)[0] for r,d in zip(agb.RA, agb.DEC)]) ara2_all = ara_all*cosdg(d31) adec_all = np.array([hms2deg(r,d)[1] for r,d in zip(agb.RA, agb.DEC)]) cvel = np.array([((z*c) - (aband*c) - helcorr(keck_long,keck_lat,keck_alt,r,d, mjd)[0]) for z, aband, r, d, mjd in zip(cstars.Z, cstars.ABAND, cra, cdec, cstars.MJD)]) avel = np.array([((z*c) - (aband*c) - helcorr(keck_long, keck_lat,keck_alt, r,d, mjd)[0]) for z, aband, r, d, mjd in zip(agb_noc.Z, agb_noc.ABAND, ara, adec, agb_noc.MJD)]) averr = agb_noc.Z_ERR*c avel_all = np.array([((z*c) - (aband*c) - helcorr(keck_long, keck_lat,keck_alt, r,d, mjd)[0]) for z, aband, r, d, mjd in zip(agb.Z, agb.ABAND, ara_all, adec_all, agb.MJD)]) averr_all = agb.Z_ERR*c #Using the radius defined in Claire's paper r = 500 #arcseconds avr = [] avre = [] for i in range(len(cra)): adist = 3600*np.sqrt((cra2[i] - ara2)**2 + (cdec[i]-adec)**2) if len(adist[adist < r]) < 10: