Esempio n. 1
0
def testName():
    c = City()
    assert c.name == 'Greenwich'
    c.name = 'London'
    assert c.name == 'London'
    c.name = 'Köln'
    assert c.name == 'Köln'
Esempio n. 2
0
def test_create_city():
    lat = 43.658931
    lon = -79.380341
    city = City(("Toronto","Canada",lat,-lon,"US/Eastern"))
    date = datetime(2012,1,9)
    sun = city.sun(date=date,local=False)
    pred = sun['sunrise'].replace(tzinfo=None)
    true = datetime(2012,1,9,12,50)
    _check(pred,true)
    pred = sun['sunset'].replace(tzinfo=None)
    true = datetime(2012,1,9,21,59)
    _check(pred,true)
Esempio n. 3
0
def compare_finders():
    az_correction = defaultdict(list)
    el_correction = defaultdict(list)
    
    empirical = EmpiricalSolarFinder(jeffs_data)
    upland = City(("Upland", "USA", "40°28'N", "85°30'W", "US/Eastern"))
    astral = AstralSolarFinder(upland)

    delta = datetime.timedelta(minutes=DELTA_MINUTES)
    from_time = datetime.datetime(2012, 8, 21, 9, 0, tzinfo=upland.tz)
    to_time = datetime.datetime(2012, 8, 21, 17, 0, tzinfo=upland.tz)
    sunrise = upland.sunrise(from_time)
    sunset = upland.sunset(from_time)
    when = from_time
    while when <= to_time:
        day_night = 'DAY' if sunrise < when < sunset else 'NIGHT'
        empirical_az, empirical_el = empirical.find(when)
        astral_az, astral_el = astral.find(when)
        if MODE == 'Full':
            print "{0:%H:%M},'EMPIRICAL',{1},{2},'ASTRAL',{3},{4},'DELTA',{5},{6},'{7}'".format(
                when,
                empirical_az, empirical_el,
                astral_az, astral_el,
                empirical_az - astral_az, empirical_el - astral_el,
                day_night)
        elif MODE == 'Delta':
            # print "{0},{1},{2},{3}".format(astral_az, empirical_az, astral_el, empirical_el)
            az_correction[astral_az].append(empirical_az)
            el_correction[astral_el].append(empirical_el)
        else:
            raise ValueException()

        when += delta

    if MODE == 'Delta':
        average_value_by_key('AZ', az_correction)
        average_value_by_key('EL', el_correction)
Esempio n. 4
0
def testTzError():
    c = City()
    c.tz = 1
Esempio n. 5
0
def testAzimuth():
    c = City()
    c.solar_azimuth()
Esempio n. 6
0
def testElevation():
    c = City()
    c.solar_elevation()
Esempio n. 7
0
def testSunset():
    c = City()
    c.sunset()
Esempio n. 8
0
def testDusk():
    c = City()
    c.dusk()
Esempio n. 9
0
def testSolarNoon():
    c = City()
    c.solar_noon()
Esempio n. 10
0
def testSunrise():
    c = City()
    c.sunrise()
Esempio n. 11
0
def testDawn():
    c = City()
    c.dawn()
Esempio n. 12
0
def testTimezone():
    c = City()
    assert c.tz == pytz.timezone('Europe/London')
    c.timezone='Europe/Stockholm'
    assert c.tz == pytz.timezone('Europe/Stockholm')
Esempio n. 13
0
def testTimezoneName():
    c = City()
    assert c.timezone == 'Europe/London'
    c.name = 'Asia/Riyadh'
    assert c.name == 'Asia/Riyadh'
Esempio n. 14
0
def testCountry():
    c = City()
    assert c.country == 'England'
    c.country = 'Australia'
    assert c.country == 'Australia'