Esempio n. 1
0
 def solar_longitude(self, utc_date):
     jd = location.JulianDay(utc_date)
     D = jd - 2451545.0
     #Mean anomaly of the Sun:
     g = 357.529 + 0.98560028 * D
     #Mean longitude of the Sun:
     q = 280.459 + 0.98564736 * D
     g = angle.from_dms(g)
     #Geocentric apparent ecliptic longitude of the Sun (adjusted for aberration):
     L = q + 1.915 * g.sin() + 0.020 * math.sin(g.to_rad() * 2)
     L = angle.from_dms(angle.wrap_360(L))
     return L
Esempio n. 2
0
File: sun.py Progetto: tmolteno/TART
 def solar_longitude(self, utc_date):
   jd = location.JulianDay(utc_date)
   D = jd - 2451545.0
   #Mean anomaly of the Sun:
   g = 357.529 + 0.98560028*D
   #Mean longitude of the Sun:
   q = 280.459 + 0.98564736*D
   g = angle.from_dms(g)
   #Geocentric apparent ecliptic longitude of the Sun (adjusted for aberration):
   L = q + 1.915*g.sin() + 0.020*math.sin(g.to_rad()*2)
   L = angle.from_dms(angle.wrap_360(L))
   return L
Esempio n. 3
0
File: sun.py Progetto: tmolteno/TART
 def solar_longitude_to_RA(self, L, utc_date):  # require L to be an angle object!!!
   jd = location.JulianDay(utc_date)
   D = jd - 2451545.0 # where jd is the Julian date of interest. Then compute
   #Mean anomaly of the Sun:
   g = angle.from_dms(357.529 + 0.98560028*D)
   #g = angle.to_rad(g)
   #Mean longitude of the Sun:
   q = 280.459 + 0.98564736*D
   R = 1.00014 - 0.01671*g.cos() - 0.00014*math.cos(g.to_rad()*2) # The distance of the Sun from the Earth, R, in astronomical units (AU)
   e = angle.from_dms(23.439 - 0.00000036*D)  # mean obliquity of the ecliptic, in degrees:
   #L = angle.to_rad()
   #e = angle.to_rad(e)
   tan_RA = e.cos() * L.sin() / L.cos()
   sin_d  = e.sin() * L.sin()
   #RA = math.atan(tan_RA)
   RA = angle.atan2(e.cos()*L.sin(), L.cos())
   RA = RA.to_ra()
   delta = angle.asin(sin_d)
   return RA, delta
Esempio n. 4
0
  def equatorial_to_horizontal(self, utc_date, ra, dec):
    # [Peter Duffett-Smith, Jonathan_Zwart] Practical Astronomy with calculator and spreadsheet
    lha = self.LHA(utc_date,ra)
    lat = self.lat

    el = angle.asin(dec.sin()*lat.sin() + dec.cos()*lat.cos()*lha.cos())

    az = angle.atan2((-lha.sin())*dec.cos(), (dec.sin()-lat.sin()*el.sin())/lat.cos())

    if az.to_degrees() < 0.:
      az = angle.from_dms(360. + az.to_degrees())

    return el, az
Esempio n. 5
0
    def equatorial_to_horizontal(self, utc_date, ra, dec):
        # [Peter Duffett-Smith, Jonathan_Zwart] Practical Astronomy with calculator and spreadsheet
        lha = self.LHA(utc_date, ra)
        lat = self.lat

        el = angle.asin(dec.sin() * lat.sin() +
                        dec.cos() * lat.cos() * lha.cos())

        az = angle.atan2((-lha.sin()) * dec.cos(),
                         (dec.sin() - lat.sin() * el.sin()) / lat.cos())

        if az.to_degrees() < 0.:
            az = angle.from_dms(360. + az.to_degrees())

        return el, az
Esempio n. 6
0
 def solar_longitude_to_RA(self, L,
                           utc_date):  # require L to be an angle object!!!
     jd = location.JulianDay(utc_date)
     D = jd - 2451545.0  # where jd is the Julian date of interest. Then compute
     #Mean anomaly of the Sun:
     g = angle.from_dms(357.529 + 0.98560028 * D)
     #g = angle.to_rad(g)
     #Mean longitude of the Sun:
     q = 280.459 + 0.98564736 * D
     R = 1.00014 - 0.01671 * g.cos() - 0.00014 * math.cos(
         g.to_rad() * 2
     )  # The distance of the Sun from the Earth, R, in astronomical units (AU)
     e = angle.from_dms(
         23.439 -
         0.00000036 * D)  # mean obliquity of the ecliptic, in degrees:
     #L = angle.to_rad()
     #e = angle.to_rad(e)
     tan_RA = e.cos() * L.sin() / L.cos()
     sin_d = e.sin() * L.sin()
     #RA = math.atan(tan_RA)
     RA = angle.atan2(e.cos() * L.sin(), L.cos())
     RA = RA.to_ra()
     delta = angle.asin(sin_d)
     return RA, delta
Esempio n. 7
0
    def ecef_to_horizontal(self, x_in, y_in, z_in):

        ex, ey, ez = self.get_ecef()  # My position in ECEF

        rx, ry, rz = [x_in - ex, y_in - ey, z_in - ez]
        enu = self.ecef_to_enu(rx, ry, rz)

        r = np.sqrt(enu.dot(enu))
        rho = enu / r

        el = angle.asin(rho[2])

        n = rho[1]  #n
        e = rho[0]  #e

        az = angle.atan2(e, n)
        if az.to_degrees() < 0.:
            az = angle.from_dms(360. + az.to_degrees())

        return [r, el, az]
Esempio n. 8
0
  def ecef_to_horizontal(self, x_in, y_in, z_in):

    ex,ey,ez = self.get_ecef() # My position in ECEF

    rx,ry,rz = [x_in - ex, y_in - ey, z_in - ez]
    enu = self.ecef_to_enu(rx,ry,rz)

    r = np.sqrt(enu.dot(enu))
    rho = enu / r

    el = angle.asin(rho[2])

    n = rho[1] #n
    e = rho[0] #e

    az = angle.atan2(e, n)
    if az.to_degrees() < 0.:
      az = angle.from_dms(360. + az.to_degrees())


    return [r, el, az]
Esempio n. 9
0
    return el, az

  ''' Convert an azimuth and elevation to RA/Decl
      Useful for looking straight up, and working out the RA/Declination
      Return RA , Decl (in degrees)
  '''

  def horizontal_to_equatorial(self, utc_date, el, az):
    lat = self.lat
    dec_sin = (el.sin() * lat.sin()) + (el.cos() * lat.cos() * az.cos())
    dec = angle.asin(dec_sin)

    LST = self.LST(utc_date)

    H = angle.atan2(-1.*el.cos()*lat.cos()*az.sin(), (el.sin()-(lat.sin()*dec_sin)))

    ra = LST - H

    return ra.to_ra(), dec.to_declination()


'''Convenient helper function for the location of the Physics Department Roof'''
Dunedin = Location(lat=angle.from_dms(-45.86391200), lon=angle.from_dms(170.51348452), alt=46.5)

'''Convenient helper function for the location of the rural TART'''
Dunedin_Farm = Location(lat=angle.from_dms(-45.851868), lon=angle.from_dms(170.545558), alt=266.5)

'''Convenient helper function for somewhere cold and damp in the far north'''
Aachen = Location(lat=angle.from_dms(50.778), lon=angle.from_dms(6.086), alt=46.5)
Esempio n. 10
0
import sun
import location
import sky_object
import utc
import angle
import numpy as np

class SunObject(sky_object.SkyObject):
    
    def __init__(self):
        sky_object.SkyObject.__init__(self, "Sun")

    def get_az_el(self, utc_date, lat, lon, alt):
        s = sun.Sun()
        loc = location.Location(lat, lon, alt=alt)
        ra, decl = s.radec(utc_date)
        _el, _az = loc.equatorial_to_horizontal(utc_date, ra,decl)
        el, az = np.round([_el.to_degrees(), _az.to_degrees()], decimals=6)
        ret = []
        ret.append({'name': 'sun', 'r': 1e10, 'el':el, 'az':az, 'jy':10000.0})
        return ret

if __name__=="__main__":
    cache = SunObject()
    print(cache.get_az_el(utc.now(), lat=angle.from_dms(-45.86391200), lon=angle.from_dms(170.51348452), alt=46.5))
Esempio n. 11
0
      Return RA , Decl (in degrees)
  '''

    def horizontal_to_equatorial(self, utc_date, el, az):
        lat = self.lat
        dec_sin = (el.sin() * lat.sin()) + (el.cos() * lat.cos() * az.cos())
        dec = angle.asin(dec_sin)

        LST = self.LST(utc_date)

        H = angle.atan2(-1. * el.cos() * lat.cos() * az.sin(),
                        (el.sin() - (lat.sin() * dec_sin)))

        ra = LST - H

        return ra.to_ra(), dec.to_declination()


'''Convenient helper function for the location of the Physics Department Roof'''
Dunedin = Location(lat=angle.from_dms(-45.86391200),
                   lon=angle.from_dms(170.51348452),
                   alt=46.5)
'''Convenient helper function for the location of the rural TART'''
Dunedin_Farm = Location(lat=angle.from_dms(-45.851868),
                        lon=angle.from_dms(170.545558),
                        alt=266.5)
'''Convenient helper function for somewhere cold and damp in the far north'''
Aachen = Location(lat=angle.from_dms(50.778),
                  lon=angle.from_dms(6.086),
                  alt=46.5)