Esempio n. 1
0
    def test_cycle(self):

        t = datetime.utcnow().replace(tzinfo=pytz.utc)
        loc = Location4D(time=t, latitude=35, longitude=-76)
        c = SunCycles.cycles(loc=loc)
        sunrise = c[SunCycles.RISING]
        sunset = c[SunCycles.SETTING]

        d = Diel()
        d.min_depth = -4
        d.max_depth = -10
        d.pattern = 'cycles'
        d.cycle = 'sunrise'
        d.plus_or_minus = '+'
        d.time_delta = 4
        assert d.get_time(loc4d=loc) == sunrise + timedelta(hours=4)

        d = Diel()
        d.min_depth = -4
        d.max_depth = -10
        d.pattern = 'cycles'
        d.cycle = 'sunset'
        d.plus_or_minus = '-'
        d.time_delta = 2
        assert d.get_time(loc4d=loc) == sunset - timedelta(hours=2)
Esempio n. 2
0
    def test_cycle(self):

        t = datetime.utcnow().replace(tzinfo=pytz.utc)
        loc = Location4D(time=t, latitude=35, longitude=-76)
        c = SunCycles.cycles(loc=loc)
        sunrise = c[SunCycles.RISING]
        sunset = c[SunCycles.SETTING]

        d = Diel()
        d.min_depth = -4
        d.max_depth = -10
        d.pattern = 'cycles'
        d.cycle = 'sunrise'
        d.plus_or_minus = '+'
        d.time_delta = 4
        assert d.get_time(loc4d=loc) == sunrise + timedelta(hours=4)

        d = Diel()
        d.min_depth = -4
        d.max_depth = -10
        d.pattern = 'cycles'
        d.cycle = 'sunset'
        d.plus_or_minus = '-'
        d.time_delta = 2
        assert d.get_time(loc4d=loc) == sunset - timedelta(hours=2)
Esempio n. 3
0
    def test_specifictime_object_from_dict(self):
        data = open(os.path.normpath(os.path.join(os.path.dirname(__file__),"./resources/files/diel_behavior_specifictime.json"))).read()
        d = Diel(data=json.loads(data))

        t = datetime.utcnow().replace(tzinfo=pytz.utc)
        loc = Location4D(time=t, latitude=35, longitude=-76)

        assert d.pattern == "specifictime"
        assert d.min_depth == -4.0
        assert d.max_depth == -5.0
        assert d.get_time(loc4d=loc).year == t.year
        assert d.get_time(loc4d=loc).month == t.month
        assert d.get_time(loc4d=loc).day == t.day
        assert d.get_time(loc4d=loc).hour == 17
        assert d.get_time(loc4d=loc).minute == 0
        assert d.get_time(loc4d=loc).second == 0
        assert d.get_time(loc4d=loc).microsecond == 0
Esempio n. 4
0
    def test_specifictime_object_from_dict(self):
        data = open(
            os.path.normpath(
                os.path.join(
                    os.path.dirname(__file__),
                    "./resources/files/diel_behavior_specifictime.json"))
        ).read()
        d = Diel(data=json.loads(data))

        t = datetime.utcnow().replace(tzinfo=pytz.utc)
        loc = Location4D(time=t, latitude=35, longitude=-76)

        assert d.pattern == "specifictime"
        assert d.min_depth == -4.0
        assert d.max_depth == -5.0
        assert d.get_time(loc4d=loc).year == t.year
        assert d.get_time(loc4d=loc).month == t.month
        assert d.get_time(loc4d=loc).day == t.day
        assert d.get_time(loc4d=loc).hour == 17
        assert d.get_time(loc4d=loc).minute == 0
        assert d.get_time(loc4d=loc).second == 0
        assert d.get_time(loc4d=loc).microsecond == 0