def production(self): """Plot production against days.""" prods = mongo.prods(self.cow) days = list(range(len(prods))) plt.plot(days, prods) plt.xlabel(self.DAY_LABEL) plt.ylabel(self.PROD_LABEL) with self.doc.create(pylatex.Section('Production')): self.add_plot()
def lactations(self): """Plot lactations of ``cow`` together.""" for lact in sorted(mongo.lacts(self.cow)): prods = mongo.prods(self.cow, lact) days = mongo.days(self.cow, lact) plt.plot(days, prods, label="{}".format(lact)) plt.xlabel(self.DAY_LABEL) plt.ylabel(self.PROD_LABEL) plt.legend() with self.doc.create(pylatex.Section('Lactations')): self.add_plot()
def lactation(self, lact): """Plot lactation ``lact``. :param lact: The lactation of the cow to be plotted. :type lact: int """ plt.xlabel(self.DAY_LABEL) plt.ylabel(self.PROD_LABEL) plt.xlim(xmax=self.MIN_DAY_RANGE) prods = mongo.prods(self.cow, lact) days = mongo.days(self.cow, lact) plt.plot(days, prods) with self.doc.create(pylatex.Section('Lactation {}'.format(lact))): self.add_plot()
def main(): """Create analysis with crude data in the analysis collection.""" for cow in mongo.cows(): type_ = TYPES['identity'] label = LABELS['prods'] parents = [] settings = {'cow': cow} if mongo.is_analysis(type_, label, parents, settings): print('The document must be unique: {}'.format(cow)) else: mongo.db.analysis.insert_one({ 'type': type_, 'label': label, 'parents': parents, 'settings': settings, 'data': mongo.prods(cow), })