Exemplo n.º 1
0
    def test_diel_cycles(self):
        data = open(os.path.normpath(os.path.join(os.path.dirname(__file__),"./resources/files/cycles.json"))).read()
        lifestage = LifeStage(json=data)
        
        eastern = pytz.timezone("US/Eastern")
        
        loc4d = self.loc

        # RISING:2013-05-13 05:55:35 -04:00
        # SETTING: 2013-05-14 20:05:33 -04:00

        loc4d.time = self.start_time.astimezone(eastern).replace(hour=5, minute=45)
        assert lifestage.get_active_diel(loc4d) == lifestage.diel[0]

        loc4d.time = self.start_time.astimezone(eastern).replace(hour=6, minute=45)
        assert lifestage.get_active_diel(loc4d) == lifestage.diel[0]

        loc4d.time = self.start_time.astimezone(eastern).replace(hour=8, minute=30)
        assert lifestage.get_active_diel(loc4d) == lifestage.diel[1]

        loc4d.time = self.start_time.astimezone(eastern).replace(hour=19, minute=10)
        assert lifestage.get_active_diel(loc4d) == lifestage.diel[2]

        loc4d.time = self.start_time.astimezone(eastern).replace(hour=20, minute=00)
        assert lifestage.get_active_diel(loc4d) == lifestage.diel[2]

        loc4d.time = self.start_time.astimezone(eastern).replace(hour=21, minute=06)
        assert lifestage.get_active_diel(loc4d) == lifestage.diel[3]

        loc4d.time = self.start_time.astimezone(eastern).replace(hour=2, minute=45) + timedelta(hours=24)
        assert lifestage.get_active_diel(loc4d) == lifestage.diel[3]
    def test_diel_cycles(self):
        data = open(os.path.normpath(os.path.join(os.path.dirname(__file__), "./resources/files/cycles.json"))).read()
        lifestage = LifeStage(json=data)

        eastern = pytz.timezone("US/Eastern")

        loc4d = self.loc

        # RISING:2013-05-13 05:55:35 -04:00
        # SETTING: 2013-05-14 20:05:33 -04:00

        # 1 hour before sunrise, the first migration
        loc4d.time = eastern.localize(datetime(2013, 5, 13,  5, 45))
        assert lifestage.get_active_diel(loc4d) == lifestage.diel[0]

        # still working off of the 1 hour before runrise, because we haven't hit 1 hour after
        loc4d.time = eastern.localize(datetime(2013, 5, 13,  6, 45))
        assert lifestage.get_active_diel(loc4d) == lifestage.diel[0]

        loc4d.time = eastern.localize(datetime(2013, 5, 13,  8, 30))
        assert lifestage.get_active_diel(loc4d) == lifestage.diel[1]

        loc4d.time = eastern.localize(datetime(2013, 5, 13, 19, 10))
        assert lifestage.get_active_diel(loc4d) == lifestage.diel[2]

        loc4d.time = eastern.localize(datetime(2013, 5, 13, 20,  0))
        assert lifestage.get_active_diel(loc4d) == lifestage.diel[2]

        loc4d.time = eastern.localize(datetime(2013, 5, 13, 21,  6))
        assert lifestage.get_active_diel(loc4d) == lifestage.diel[3]

        loc4d.time = eastern.localize(datetime(2013, 5, 14, 02, 45))
        assert lifestage.get_active_diel(loc4d) == lifestage.diel[3]
Exemplo n.º 3
0
    def test_diel_cycles(self):
        data = open(
            os.path.normpath(
                os.path.join(os.path.dirname(__file__),
                             "./resources/files/cycles.json"))).read()
        lifestage = LifeStage(json=data)

        eastern = pytz.timezone("US/Eastern")

        loc4d = self.loc

        # RISING:2013-05-13 05:55:35 -04:00
        # SETTING: 2013-05-14 20:05:33 -04:00

        loc4d.time = self.start_time.astimezone(eastern).replace(hour=5,
                                                                 minute=45)
        assert lifestage.get_active_diel(loc4d) == lifestage.diel[0]

        loc4d.time = self.start_time.astimezone(eastern).replace(hour=6,
                                                                 minute=45)
        assert lifestage.get_active_diel(loc4d) == lifestage.diel[0]

        loc4d.time = self.start_time.astimezone(eastern).replace(hour=8,
                                                                 minute=30)
        assert lifestage.get_active_diel(loc4d) == lifestage.diel[1]

        loc4d.time = self.start_time.astimezone(eastern).replace(hour=19,
                                                                 minute=10)
        assert lifestage.get_active_diel(loc4d) == lifestage.diel[2]

        loc4d.time = self.start_time.astimezone(eastern).replace(hour=20,
                                                                 minute=00)
        assert lifestage.get_active_diel(loc4d) == lifestage.diel[2]

        loc4d.time = self.start_time.astimezone(eastern).replace(hour=21,
                                                                 minute=06)
        assert lifestage.get_active_diel(loc4d) == lifestage.diel[3]

        loc4d.time = self.start_time.astimezone(eastern).replace(
            hour=2, minute=45) + timedelta(hours=24)
        assert lifestage.get_active_diel(loc4d) == lifestage.diel[3]
Exemplo n.º 4
0
    def test_diel_cycles(self):
        data = open(
            os.path.normpath(
                os.path.join(os.path.dirname(__file__),
                             "./resources/files/cycles.json"))).read()
        lifestage = LifeStage(json=data)

        eastern = pytz.timezone("US/Eastern")

        loc4d = self.loc

        # RISING:2013-05-13 05:55:35 -04:00
        # SETTING: 2013-05-14 20:05:33 -04:00

        # 1 hour before sunrise, the first migration
        loc4d.time = eastern.localize(datetime(2013, 5, 13, 5, 45))
        assert lifestage.get_active_diel(loc4d) == lifestage.diel[0]

        # still working off of the 1 hour before runrise, because we haven't hit 1 hour after
        loc4d.time = eastern.localize(datetime(2013, 5, 13, 6, 45))
        assert lifestage.get_active_diel(loc4d) == lifestage.diel[0]

        loc4d.time = eastern.localize(datetime(2013, 5, 13, 8, 30))
        assert lifestage.get_active_diel(loc4d) == lifestage.diel[1]

        loc4d.time = eastern.localize(datetime(2013, 5, 13, 19, 10))
        assert lifestage.get_active_diel(loc4d) == lifestage.diel[2]

        loc4d.time = eastern.localize(datetime(2013, 5, 13, 20, 0))
        assert lifestage.get_active_diel(loc4d) == lifestage.diel[2]

        loc4d.time = eastern.localize(datetime(2013, 5, 13, 21, 6))
        assert lifestage.get_active_diel(loc4d) == lifestage.diel[3]

        loc4d.time = eastern.localize(datetime(2013, 5, 14, 2, 45))
        assert lifestage.get_active_diel(loc4d) == lifestage.diel[3]