예제 #1
0
def local2solar(local_time, latitude, longitude, time_zone, temperature=25.):
    """Calculates UTC time and Solar time in decimal hours (solar noon is 12.00), based on
    :func:`pvlib.solarposition.ephemeris`.

    Args:
        local_time (datetime): local time
        latitude (float): [°] latitude at which local time is given
        longitude (float): [°] longitude at which local time is given
        time_zone (str): a 'pytz.timezone' (e.g. 'Europe/Paris')
        temperature (float): [°C] air temperature

    Returns:
        (datetime): utc time
        (float): [decimal hours] solar time

    """

    time_zone = timezone(time_zone)
    local_time = time_zone.localize(local_time)
    date_utc = local_time.astimezone(utc)
    datet = date_range(local_time, local_time)
    lst = ephemeris(datet, latitude, longitude,
                    temperature).solar_time.values[0]

    return date_utc, lst
예제 #2
0
def test_ephemeris_physical_dst():
    times = pd.date_range(datetime.datetime(2003,10,17,13,30,30),
                          periods=1, freq='D')
    ephem_data = solarposition.ephemeris(times, golden, pressure=82000,
                                         temperature=11).ix[0]
    
    assert_almost_equals(50.111622, ephem_data['apparent_zenith'], 2)
    assert_almost_equals(194.340241, ephem_data['azimuth'], 2)
    assert_almost_equals(39.888378, ephem_data['apparent_elevation'], 2)
예제 #3
0
def test_ephemeris_physical_dst(expected_solpos):
    times = pd.date_range(datetime.datetime(2003,10,17,13,30,30),
                          periods=1, freq='D', tz=golden.tz)
    ephem_data = solarposition.ephemeris(times, golden.latitude,
                                         golden.longitude, pressure=82000,
                                         temperature=11)
    expected_solpos.index = times
    expected_solpos = np.round(expected_solpos, 2)
    ephem_data = np.round(ephem_data, 2)
    assert_frame_equal(expected_solpos, ephem_data[expected_solpos.columns])
예제 #4
0
def test_ephemeris_physical_dst(expected_solpos):
    times = pd.date_range(datetime.datetime(2003,10,17,13,30,30),
                          periods=1, freq='D', tz=golden.tz)
    ephem_data = solarposition.ephemeris(times, golden.latitude,
                                         golden.longitude, pressure=82000,
                                         temperature=11)
    expected_solpos.index = times
    expected_solpos = np.round(expected_solpos, 2)
    ephem_data = np.round(ephem_data, 2)
    assert_frame_equal(expected_solpos, ephem_data[expected_solpos.columns])
def test_ephemeris_physical():
    times = pd.date_range(datetime.datetime(2003,10,17,12,30,30),
                          periods=1, freq='D', tz=golden_mst.tz)
    ephem_data = solarposition.ephemeris(times, golden_mst.latitude,
                                         golden_mst.longitude,
                                         pressure=82000,
                                         temperature=11)
    this_expected = expected.copy()
    this_expected.index = times
    this_expected = np.round(this_expected, 2)
    ephem_data = np.round(ephem_data, 2)
    assert_frame_equal(this_expected, ephem_data[this_expected.columns])
def test_ephemeris_physical():
    times = pd.date_range(datetime.datetime(2003, 10, 17, 12, 30, 30),
                          periods=1,
                          freq='D',
                          tz=golden_mst.tz)
    ephem_data = solarposition.ephemeris(times,
                                         golden_mst.latitude,
                                         golden_mst.longitude,
                                         pressure=82000,
                                         temperature=11)
    this_expected = expected.copy()
    this_expected.index = times
    this_expected = np.round(this_expected, 2)
    ephem_data = np.round(ephem_data, 2)
    assert_frame_equal(this_expected, ephem_data[this_expected.columns])
예제 #7
0
 def time_ephemeris_localized(self, ndays):
     solarposition.ephemeris(self.times_localized, self.lat, self.lon)
예제 #8
0
 def time_ephemeris(self, ndays):
     solarposition.ephemeris(self.times, self.lat, self.lon)