示例#1
0
	def setUp(self):
		self.d = datetime.datetime(2003, 10, 17, 19, 30, 30, tzinfo = datetime.timezone.utc)  # only works with Python 3
		self.d += datetime.timedelta(seconds = stime.get_delta_t(self.d) - stime.tt_offset - stime.get_leap_seconds(self.d))
		  # Reda & Andreas say that this time is in "Local Standard Time", which they
		  # define as 7 hours behind UT (not UTC). Hence the adjustment to convert UT
		  # to UTC.
		self.longitude = -105.1786
		self.latitude = 39.742476
		self.pressure = 82000.0 # pascals
		self.elevation = 1830.14 # meters
		self.temperature = 11.0 + constants.celsius_offset # kelvin
		self.slope = 30.0 # degrees
		self.slope_orientation = -10.0 # degrees east from south
		self.jd = stime.get_julian_solar_day(self.d)
		self.jc = stime.get_julian_century(self.jd)
		self.jde = stime.get_julian_ephemeris_day(self.d)
		self.jce = stime.get_julian_ephemeris_century(self.jde)
		self.jme = stime.get_julian_ephemeris_millennium(self.jce)
		self.geocentric_longitude = solar.get_geocentric_longitude(self.jme)
		self.geocentric_latitude = solar.get_geocentric_latitude(self.jme)
		self.nutation = solar.get_nutation(self.jce)
		self.sun_earth_distance = solar.get_sun_earth_distance(self.jme)
		self.true_ecliptic_obliquity = solar.get_true_ecliptic_obliquity(self.jme, self.nutation)
		self.aberration_correction = solar.get_aberration_correction(self.sun_earth_distance)
		self.apparent_sun_longitude = solar.get_apparent_sun_longitude(self.geocentric_longitude, self.nutation, self.aberration_correction)
		self.apparent_sidereal_time = solar.get_apparent_sidereal_time(self.jd, self.jme, self.nutation)
		self.geocentric_sun_right_ascension = solar.get_geocentric_sun_right_ascension(self.apparent_sun_longitude, self.true_ecliptic_obliquity, self.geocentric_latitude)
		self.geocentric_sun_declination = solar.get_geocentric_sun_declination(self.apparent_sun_longitude, self.true_ecliptic_obliquity, self.geocentric_latitude)
		self.local_hour_angle = solar.get_local_hour_angle(318.5119, self.longitude, self.geocentric_sun_right_ascension) #self.apparent_sidereal_time only correct to 5 sig figs, so override
		self.equatorial_horizontal_parallax = solar.get_equatorial_horizontal_parallax(self.sun_earth_distance)
		self.projected_radial_distance = solar.get_projected_radial_distance(self.elevation, self.latitude)
		self.projected_axial_distance = solar.get_projected_axial_distance(self.elevation, self.latitude)
		self.topocentric_sun_right_ascension = solar.get_topocentric_sun_right_ascension(self.projected_radial_distance,
		self.equatorial_horizontal_parallax, self.local_hour_angle, self.apparent_sun_longitude, self.true_ecliptic_obliquity, self.geocentric_latitude)
		self.parallax_sun_right_ascension = solar.get_parallax_sun_right_ascension(self.projected_radial_distance, self.equatorial_horizontal_parallax, self.local_hour_angle, self.geocentric_sun_declination)
		self.topocentric_sun_declination = solar.get_topocentric_sun_declination(self.geocentric_sun_declination, self.projected_axial_distance, self.equatorial_horizontal_parallax, self.parallax_sun_right_ascension, self.local_hour_angle)
		self.topocentric_local_hour_angle = solar.get_topocentric_local_hour_angle(self.local_hour_angle, self.parallax_sun_right_ascension)
		self.topocentric_zenith_angle = solar.get_topocentric_zenith_angle(self.latitude, self.topocentric_sun_declination, self.topocentric_local_hour_angle, self.pressure, self.temperature)
		self.topocentric_azimuth_angle = solar.get_topocentric_azimuth_angle(self.topocentric_local_hour_angle, self.latitude, self.topocentric_sun_declination)
		self.incidence_angle = solar.get_incidence_angle(self.topocentric_zenith_angle, self.slope, self.slope_orientation, self.topocentric_azimuth_angle)
		self.pressure_with_elevation = elevation.get_pressure_with_elevation(1567.7)
		self.temperature_with_elevation = elevation.get_temperature_with_elevation(1567.7)
 def test_solartime_get_delta_t_raise_error(self):
     with self.assertRaises(NoTimeZoneInfoError):
         solartime.get_delta_t(self.unaware)
    def test_solartime_get_delta_t_no_error(self):
        try:
            solartime.get_delta_t(self.aware)
        except NoTimeZoneInfoError:
            self.fail("""'NoTimeZoneInfoError' should not be raised \
as 'datetime' object is tz-aware.""")