I am afraid that the whole code (the first one posted above) is needed.
Why can't you refer to/ run that?
If you do so, you will see the results I get.
The file I am using is too large to upload, so down here is a sample.
Let me please know if this is enough.
Again, if you run the first code I posted, it shouldn't be an issue for anyone
to see the results I am seeing.
here is the code that I am now running, and I am getting the outcome described before.
doesn't anyone know the answer or more info are needed?
Why can't you refer to/ run that?
If you do so, you will see the results I get.
The file I am using is too large to upload, so down here is a sample.
Let me please know if this is enough.
Again, if you run the first code I posted, it shouldn't be an issue for anyone
to see the results I am seeing.
here is the code that I am now running, and I am getting the outcome described before.
rom astral import Astral from scipy import * from pylab import* import numpy as np from numpy import array import matplotlib.pyplot as plt import datetime from datetime import timezone from datetime import timedelta import matplotlib.dates as dates import pandas as pd import pytz import sys def last_digits(num, last_digits_count=2): return abs(num) % (10**last_digits_count) orig_date=[] orig_time=[] movements=[] with open('bird_jan25jan16.txt', 'r') as f: for line in f: data = line.split() # Splits on whitespace orig_date.append(data[0][:]) orig_time.append((data[1][:])) movements.append(int(data[2][:])) for i in range(0,len(orig_date)): if ((len(str(movements[i-1])) - len(str(movements[1]))) >=2): if movements[i]==0 or ( (movements[i-1] == movements[i+1] ) and (last_digits(movements[i-1]) == last_digits(movements[i]))): movements[i]=((movements[i-1]+movements[i+1])/2) """ putting date and time together and converting them to datetime objects""" dt_fmt = '%Y-%m-%d %H:%M:%S.%f' timestamps = [] for col_dt in zip(orig_date , orig_time): new_dt_str = ' '.join(col_dt) new_dt = datetime.datetime.strptime(new_dt_str, dt_fmt) timestamps.append(new_dt) def convert_local_timezone(): converted_dates=[] for date in timestamps: local_tz = pytz.timezone('Europe/Berlin') local_time = date.replace(tzinfo=pytz.utc).astimezone(local_tz) converted_dates.append(local_time) return converted_dates CEU_times=convert_local_timezone() def mov_index(i,j): return sum(movements[i:j]) #x = pd.Timestamp('2015-01-25') #res = next((i for i, j in enumerate(CEU_times[0:5]) if j == x),10) #print(res) #print(CEU_times[0].year , CEU_times[0].month , CEU_times[0].day) position1 = orig_date.index(("2015-01-25")) position2 = orig_date.index('2015-01-26') position3 = orig_date.index('2015-01-27') from matplotlib.dates import date2num print(type(CEU_times[0])) print(CEU_times[position1].date()) # it correctly prints the date city_name = 'Berlin' a = Astral() a.solar_depression = 'civil' city = a[city_name] y = [mov_index(position1, position1+10), mov_index(position2, position2+10), mov_index(position3, position3+10)] x = [CEU_times[position1] + datetime.timedelta(days=i) for i in range(len(y))] sun1 = (city.sun(date=(CEU_times[position1]), local=True )) ax = plt.subplot(111) ax.bar(x, y, width=5) # by lowering the width the dates will have the format (month, day, hour) ax.xaxis_date() print('Dawn: %s' % str(sun1['dawn'])) print('Sunset: %s' % str(sun1['sunset'])) plt.setp(ax.get_xticklabels(), rotation=45, fontsize=10) plt.show()
doesn't anyone know the answer or more info are needed?