Example #1
0
def magnSatRing(JD, lon, lat):
    """Compute the apparent visual magnitude of Saturn's rings.
    
    Args:
      JD (float):   Julian Day (days).
      lon (float):  Geocentric ecliptical longitude of Saturn (rad).
      lat (float):  Geocentric ecliptical latitude of Saturn (rad).
    
    Returns:
      float:  magnSatRing: Apparent visual magnitude of the planet.
    
    References:
      - [Explanatory Supplement to the Astronomical Almanac 3rd Ed, Table 10.6, p.413 +
        errata](https://aa.usno.navy.mil/publications/docs/exp_supp.php)
    
    Note:
      - This is a simplified expression, which uses phi instead of Delta U.  The mean absolute deviation from
        the full expression: is 0.014m, the maximum deviation found: 0.041m in 10^5 trials, over the last 5000
        years.

    """

    tJC = dt.jd2tjc(JD)  # Time since 2000 in Julian centuries

    incl = 0.49  # Inclination of Saturn's rotation axis (rad)
    ascNod = 2.96 + 0.024 * tJC  # Ascending node of Saturn's orbit (rad)

    sinB = np.sin(incl) * np.cos(lat) * np.sin(lon - ascNod) - np.cos(
        incl) * np.sin(lat)
    magnSatRing = -2.60 * abs(sinB) + 1.25 * (sinB)**2

    return magnSatRing
Example #2
0
def precessHip(jd, ra,dec):
    """Compute precession in equatorial coordinates from the Hipparcos equinox (J2000) to that of the specified JD.
    
    Arguments:
      jd (float):   Julian day (days).
      ra (float):   Right ascension (rad).
      dec (float):  Declination (rad).
    
    Returns:
      tuple (float,float): tuple containing (raTarget, decTarget):
    
        - raNew (float):   Right ascension for the target equinox (rad).
        - decNew (float):  Declination for the target equinox (rad).
    
    """
    
    tJC  = dt.jd2tjc(jd)  # Time in Julian centuries since J2000.0
    tJC2 = tJC**2
    tJC3 = tJC*tJC2
    
    zeta  = (2306.2181*tJC + 0.30188*tJC2 + 0.017998*tJC3)*as2r
    z     = (2306.2181*tJC + 1.09468*tJC2 + 0.018203*tJC3)*as2r
    theta = (2004.3109*tJC - 0.42665*tJC2 - 0.041833*tJC3)*as2r
    
    raNew  = (np.arctan2( np.sin(ra + zeta) * np.cos(dec),  np.cos(ra + zeta) * m.cos(theta) * np.cos(dec) - m.sin(theta) * np.sin(dec) ) + z) % pi2
    decNew = np.arcsin( np.cos(ra + zeta) * m.sin(theta) * np.cos(dec)  +  m.cos(theta) * np.sin(dec) )
    
    return raNew,decNew
Example #3
0
def par2horiz(ha,dec, phi):
    """Convert parallactic coordinates to horizontal.

    Arguments:
      ha (float):   Hour angle (rad).
      dec (float):  Declination (rad).
      phi (float):  Geographical latitude (rad, N>0).
    
    Returns:
      tuple (float,float): tuple containing (az, alt):
    
        - az (float):   Azimuth (rad, S=0).
        - alt (float):  Altitude (rad).
    
    """
    
    az  = np.arctan2( np.sin(ha),   np.cos(ha) * m.sin(phi) - np.tan(dec) * m.cos(phi) ) % pi2
    alt = np.arcsin(  np.sin(dec) * m.sin(phi) + np.cos(ha) * np.cos(dec) * m.cos(phi) )
    
    return az,alt
Example #4
0
def eq2ecl(ra,dec, eps):
    """
    Convert equatorial coordinates to ecliptical.

    Arguments:
      ra (float):   Right ascension (rad).
      dec (float):  Declination (rad).
      eps (float):  Obliquity of the ecliptic (rad).
    
    Returns:
      tuple (float,float): tuple containing (lon, lat):
    
        - lon (float):  Ecliptical longitude (rad).
        - lat (float):  Ecliptical latitude (rad).
    
    """
    
    lon = np.arctan2( np.sin(ra)  * m.cos(eps) + np.tan(dec) * m.sin(eps),  np.cos(ra) ) % pi2
    lat =  np.arcsin( np.sin(dec) * m.cos(eps) - np.cos(dec) * m.sin(eps) * np.sin(ra) )
    
    return lon,lat
Example #5
0
def ecl2eq(lon,lat, eps):
    """Convert (geocentric) spherical ecliptical coordinates to spherical equatorial coordinates.
    
    Arguments:
      lon (float):  Ecliptical longitude (rad).
      lat (float):  Ecliptical latitude (rad).
      eps (float):  Obliquity of the ecliptic (rad).
    
    Returns:
      tuple (float,float): tuple containing (ra, dec):
    
        - ra (float):   Right ascension (rad).
        - dec (float):  Declination (rad).
    
    References:
      - [Explanatory Supplement to the Astronomical Almanac 3rd Ed,
        Eq.14.43](https://aa.usno.navy.mil/publications/docs/exp_supp.php)

    """
    
    ra  = np.arctan2( np.sin(lon) * np.cos(eps)  -  np.tan(lat) * np.sin(eps),  np.cos(lon) ) % pi2
    dec =  np.arcsin( np.sin(lat) * np.cos(eps)  +  np.cos(lat) * np.sin(eps) * np.sin(lon) )
    
    return ra,dec
Example #6
0
            object.__setattr__(self, attr, value)

    # Only called after other approaches fail.
    def __getattr__(self, attr):
        if (attr == 'array'):
            return object.__getattribute__(self, attr)
        return self.array.__getattribute__(attr)


#############################################################
# Test of class container
#############################################################
if __name__ == '__main__':
    temp = reshape(arange(10000), (100, 100))

    ua = container(temp)
    # new object created begin test
    print dir(ua)
    print shape(ua), ua.shape  # I have changed Numeric.py

    ua_small = ua[:3, :5]
    print ua_small
    ua_small[
        0, 0] = 10  # this did not change ua[0,0], which is not normal behavior
    print ua_small[0, 0], ua[0, 0]
    print sin(ua_small) / 3. * 6. + sqrt(ua_small**2)
    print less(ua_small, 103), type(less(ua_small, 103))
    print type(ua_small * reshape(arange(15), shape(ua_small)))
    print reshape(ua_small, (5, 3))
    print transpose(ua_small)
Example #7
0
            self.array.__setattr__(attr, value)
        except AttributeError:
            object.__setattr__(self, attr, value)

    # Only called after other approaches fail.
    def __getattr__(self,attr):
        if (attr == 'array'):
            return object.__getattribute__(self, attr)
        return self.array.__getattribute__(attr)

#############################################################
# Test of class container
#############################################################
if __name__ == '__main__':
    temp=reshape(arange(10000),(100,100))

    ua=container(temp)
    # new object created begin test
    print dir(ua)
    print shape(ua),ua.shape # I have changed Numeric.py

    ua_small=ua[:3,:5]
    print ua_small
    ua_small[0,0]=10  # this did not change ua[0,0], which is not normal behavior
    print ua_small[0,0],ua[0,0]
    print sin(ua_small)/3.*6.+sqrt(ua_small**2)
    print less(ua_small,103),type(less(ua_small,103))
    print type(ua_small*reshape(arange(15),shape(ua_small)))
    print reshape(ua_small,(5,3))
    print transpose(ua_small)
        except AttributeError:
            object.__setattr__(self, attr, value)

    # Only called after other approaches fail.
    def __getattr__(self, attr):
        if (attr == 'array'):
            return object.__getattribute__(self, attr)
        return self.array.__getattribute__(attr)

#############################################################
# Test of class container
#############################################################
if __name__ == '__main__':
    temp = reshape(arange(10000), (100, 100))

    ua = container(temp)
    # new object created begin test
    print(dir(ua))
    print(shape(ua), ua.shape)  # I have changed Numeric.py

    ua_small = ua[:3, :5]
    print(ua_small)
    # this did not change ua[0,0], which is not normal behavior
    ua_small[0, 0] = 10
    print(ua_small[0, 0], ua[0, 0])
    print(sin(ua_small) / 3. * 6. + sqrt(ua_small ** 2))
    print(less(ua_small, 103), type(less(ua_small, 103)))
    print(type(ua_small * reshape(arange(15), shape(ua_small))))
    print(reshape(ua_small, (5, 3)))
    print(transpose(ua_small))
Example #9
0
            object.__setattr__(self, attr, value)

    # Only called after other approaches fail.
    def __getattr__(self, attr):
        if (attr == 'array'):
            return object.__getattribute__(self, attr)
        return self.array.__getattribute__(attr)


#############################################################
# Test of class container
#############################################################
if __name__ == '__main__':
    temp = reshape(arange(10000), (100, 100))

    ua = container(temp)
    # new object created begin test
    print(dir(ua))
    print(shape(ua), ua.shape)  # I have changed Numeric.py

    ua_small = ua[:3, :5]
    print(ua_small)
    # this did not change ua[0,0], which is not normal behavior
    ua_small[0, 0] = 10
    print(ua_small[0, 0], ua[0, 0])
    print(sin(ua_small) / 3. * 6. + sqrt(ua_small**2))
    print(less(ua_small, 103), type(less(ua_small, 103)))
    print(type(ua_small * reshape(arange(15), shape(ua_small))))
    print(reshape(ua_small, (5, 3)))
    print(transpose(ua_small))
Example #10
0
        except AttributeError:
            object.__setattr__(self, attr, value)

    # Only called after other approaches fail.
    def __getattr__(self, attr):
        if attr == "array":
            return object.__getattribute__(self, attr)
        return self.array.__getattribute__(attr)


#############################################################
# Test of class container
#############################################################
if __name__ == "__main__":
    temp = reshape(arange(10000), (100, 100))

    ua = container(temp)
    # new object created begin test
    print dir(ua)
    print shape(ua), ua.shape  # I have changed Numeric.py

    ua_small = ua[:3, :5]
    print ua_small
    ua_small[0, 0] = 10  # this did not change ua[0,0], which is not normal behavior
    print ua_small[0, 0], ua[0, 0]
    print sin(ua_small) / 3.0 * 6.0 + sqrt(ua_small ** 2)
    print less(ua_small, 103), type(less(ua_small, 103))
    print type(ua_small * reshape(arange(15), shape(ua_small)))
    print reshape(ua_small, (5, 3))
    print transpose(ua_small)
Example #11
0
            object.__setattr__(self, attr, value)

    # Only called after other approaches fail.
    def __getattr__(self, attr):
        if attr == "array":
            return object.__getattribute__(self, attr)
        return self.array.__getattribute__(attr)


#############################################################
# Test of class container
#############################################################
if __name__ == "__main__":
    temp = reshape(arange(10000), (100, 100))

    ua = container(temp)
    # new object created begin test
    print(dir(ua))
    print(shape(ua), ua.shape)  # I have changed Numeric.py

    ua_small = ua[:3, :5]
    print(ua_small)
    # this did not change ua[0,0], which is not normal behavior
    ua_small[0, 0] = 10
    print(ua_small[0, 0], ua[0, 0])
    print(sin(ua_small) / 3.0 * 6.0 + sqrt(ua_small**2))
    print(less(ua_small, 103), type(less(ua_small, 103)))
    print(type(ua_small * reshape(arange(15), shape(ua_small))))
    print(reshape(ua_small, (5, 3)))
    print(transpose(ua_small))