Ejemplo n.º 1
0
from rajab_roza import RajabRoza

filename = "data/london-durations.yml"
years = range(1430, 1461)

def duration_in_hours(duration):
    return duration.total_seconds()/3600.0

def minimal_duration_years(years, durations, amount=10):
    sorted_durations = argsort(durations)
    minimal_years = [years[i] for i in sorted_durations[:amount]]
    return sort(minimal_years)

if __name__ == '__main__':
    rajab_roza = RajabRoza.load_from_yaml(filename)
    start_index = years[0] - rajab_roza.start_year
    data_index_range = range(start_index, start_index + len(years))

    min_durations = [
        duration_in_hours(rajab_roza.durations[i][0])
        for i in data_index_range
    ]
    max_durations = [
        duration_in_hours(rajab_roza.durations[i][1])
        for i in data_index_range
    ]
    avg_durations = [
        0.5*(min_durations[i] + max_durations[i])
        for i in range(len(years))
    ]
Ejemplo n.º 2
0
#!/usr/bin/env python

from rajab_roza import RajabRoza

lat = 51.0 + 32.0/60.0
lng = -22.0/60.0
start_year = 1400
end_year = 1500
filename = "data/london-durations.yml"

if __name__ == '__main__':
    rajab_roza = RajabRoza(lat, lng, start_year, end_year)
    rajab_roza.get_roza_durations()
    rajab_roza.save_to_yaml(filename)