def setphi(self, phi): """ NAME: setphi PURPOSE: set initial azimuth INPUT: phi - desired azimuth OUTPUT: (none) HISTORY: 2010-08-01 - Written - Bovy (NYU) BUGS: Should perform check that this orbit has phi """ if len(self.vxvv) == 2: raise AttributeError("One-dimensional orbit has no azimuth") elif len(self.vxvv) == 3: #Upgrade vxvv = [self.vxvv[0], self.vxvv[1], self.vxvv[2], phi] self.vxvv = vxvv self._orb = planarROrbit(vxvv=vxvv) elif len(self.vxvv) == 4: self.vxvv[-1] = phi self._orb.vxvv[-1] = phi elif len(self.vxvv) == 5: #Upgrade vxvv = [ self.vxvv[0], self.vxvv[1], self.vxvv[2], self.vxvv[3], self.vxvv[4], phi ] self.vxvv = vxvv self._orb = FullOrbit(vxvv=vxvv) elif len(self.vxvv) == 6: self.vxvv[-1] = phi self._orb.vxvv[-1] = phi
def __init__(self, vxvv=None, uvw=False, lb=False, radec=False, vo=235., ro=8.5, zo=0.025, solarmotion='hogg'): """ NAME: __init__ PURPOSE: Initialize an Orbit instance INPUT: vxvv - initial conditions 3D can be either 1) in Galactocentric cylindrical coordinates [R,vR,vT(,z,vz,phi)] 2) [ra,dec,d,mu_ra, mu_dec,vlos] in [deg,deg,kpc,mas/yr,mas/yr,km/s] (all J2000.0; mu_ra = mu_ra * cos dec) 3) [ra,dec,d,U,V,W] in [deg,deg,kpc,km/s,km/s,kms] 4) (l,b,d,mu_l, mu_b, vlos) in [deg,deg,kpc,mas/yr,mas/yr,km/s) (all J2000.0; mu_l = mu_l * cos b) 5) [l,b,d,U,V,W] in [deg,deg,kpc,km/s,km/s,kms] 4) and 5) also work when leaving out b and mu_b/W OPTIONAL INPUTS: radec - if True, input is 2) (or 3) above uvw - if True, velocities are UVW lb - if True, input is 4) or 5) above vo - circular velocity at ro ro - distance from vantage point to GC (kpc) zo - offset toward the NGP of the Sun wrt the plane (kpc) solarmotion - 'hogg' or 'dehnen', or 'schoenrich', or value in [-U,V,W] OUTPUT: instance HISTORY: 2010-07-20 - Written - Bovy (NYU) """ if isinstance(solarmotion, str) and solarmotion.lower() == 'hogg': vsolar = nu.array([-10.1, 4.0, 6.7]) / vo elif isinstance(solarmotion, str) and solarmotion.lower() == 'dehnen': vsolar = nu.array([-10., 5.25, 7.17]) / vo elif isinstance(solarmotion,str) \ and solarmotion.lower() == 'schoenrich': vsolar = nu.array([-11.1, 12.24, 7.25]) / vo else: vsolar = nu.array(solarmotion) / vo if radec or lb: if radec: l, b = coords.radec_to_lb(vxvv[0], vxvv[1], degree=True) elif len(vxvv) == 4: l, b = vxvv[0], 0. else: l, b = vxvv[0], vxvv[1] if uvw: X, Y, Z = coords.lbd_to_XYZ(l, b, vxvv[2], degree=True) vx = vxvv[3] vy = vxvv[4] vz = vxvv[5] else: if radec: pmll, pmbb = coords.pmrapmdec_to_pmllpmbb(vxvv[3], vxvv[4], vxvv[0], vxvv[1], degree=True) d, vlos = vxvv[2], vxvv[5] elif len(vxvv) == 4: pmll, pmbb = vxvv[2], 0. d, vlos = vxvv[1], vxvv[3] else: pmll, pmbb = vxvv[3], vxvv[4] d, vlos = vxvv[2], vxvv[5] X, Y, Z, vx, vy, vz = coords.sphergal_to_rectgal(l, b, d, vlos, pmll, pmbb, degree=True) X /= ro Y /= ro Z /= ro vx /= vo vy /= vo vz /= vo vsun = nu.array([ 0., 1., 0., ]) + vsolar R, phi, z = coords.XYZ_to_galcencyl(X, Y, Z, Zsun=zo / ro) vR, vT, vz = coords.vxvyvz_to_galcencyl(vx, vy, vz, R, phi, z, vsun=vsun, galcen=True) if lb and len(vxvv) == 4: vxvv = [R, vR, vT, phi] else: vxvv = [R, vR, vT, z, vz, phi] self.vxvv = vxvv if len(vxvv) == 2: self._orb = linearOrbit(vxvv=vxvv) elif len(vxvv) == 3: self._orb = planarROrbit(vxvv=vxvv) elif len(vxvv) == 4: self._orb = planarOrbit(vxvv=vxvv) elif len(vxvv) == 5: self._orb = RZOrbit(vxvv=vxvv) elif len(vxvv) == 6: self._orb = FullOrbit(vxvv=vxvv)