Hardware Reference
In-Depth Information
numberOfSeconds = dateRange.seconds + dateRange.days *;
24 * 3600
#chop the data up into roughly 20 min intervals (in seconds)
intervalSize = 20*60
#calculate how many intervals are there in numberOfSeconds
#round up so there is always at least one
histogramBins = math.ceil(float(numberOfSeconds)/;
float(intervalSize))
#draw the graph
fig = plotDatehist(events, bins=histogramBins, title=;
“Bird Box Activity”, intervalSize=intervalSize)
#save the graph to a file
pyplot.savefig(filename)
he code contains two functions, drawGraph and plotDatehist . drawGraph sets up the
parameters for drawing the chart. It calculates the number of bins (bars) for the histogram. It
then calls the plotDatehist function, which actually creates the graph.
plotDatehist uses the histogram function from the numpy library to gather the visits
together into time periods which correspond to the bins for the histogram. he histogram
function takes the array of data (in this case the times when the nest box was visited) and the
number of bins it should be split into. It returns both the number of items in each bin and the
highest and lowest points for each bin. he function sets up the layout of where the charts will
be drawn. In this case subplot(111) states that one chart will be drawn. he line
ax.bar(bin_edges[:-1], hist, width=width, facecolor='orange')
draws the bar chart.
he remainder of plotDatehist function sets up the axes - setting labels and grid lines.
Finally, the graph is saved to ile as a PDF.
To draw graphs from the analysis program, edit the ile analyseBirdDataFiltered.py
and make the following additions:
1. At the start of the ile, add
import drawgraph
Search WWH ::




Custom Search