コード例 #1
0
    def generate(self):
        """Generate the view."""

        self.production()
        plt.clf()

        self.lactations()
        plt.clf()

        for lact in mongo.lacts(self.cow):
            self.lactation(lact)
            plt.clf()
コード例 #2
0
ファイル: crude.py プロジェクト: tartopum/MPF
    def generate(self):
        """Generate the view."""

        self.production()
        plt.clf()

        self.lactations()
        plt.clf()

        for lact in mongo.lacts(self.cow):
            self.lactation(lact)
            plt.clf()
コード例 #3
0
    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()
コード例 #4
0
ファイル: crude.py プロジェクト: tartopum/MPF
    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()
コード例 #5
0
def main():
    """Complete the crudedata collection with missing dates."""

    for cow in mongo.cows():
        print("Completing cow {}...".format(cow))

        dates = mongo.dates(cow)
        missing = get_missing_dates(dates)

        if missing:
            for lact in reversed(mongo.lacts(cow)):
                # The last date and day in database for this lactation
                last_date, last_day = get_last(cow, lact)

                # We start at the last day of the lactation then add the
                # missing lines till we reach the first day of the lactation
                while last_day > 1:
                    last_day -= 1
                    last_date -= dt.timedelta(1)

                    if last_date in missing:
                        # If day = 1, we'll have a problem of unique key in
                        # the second loop
                        missing.remove(last_date)

                        insert(cow, last_date, lact, last_day)

                last_date, last_day = get_last(cow, lact)

                # We start at the last day of the lactation then add the
                # missing lines till we reach the next lactation or the end of
                # the data if this lactation is the last one
                while last_date + dt.timedelta(1) in missing:
                    last_day += 1
                    last_date += dt.timedelta(1)

                    insert(cow, last_date, lact, last_day)
コード例 #6
0
ファイル: complete_db.py プロジェクト: tartopum/MPF
def main():
    """Complete the crudedata collection with missing dates."""

    for cow in mongo.cows():
        print("Completing cow {}...".format(cow))

        dates = mongo.dates(cow)
        missing = get_missing_dates(dates)

        if missing:
            for lact in reversed(mongo.lacts(cow)):
                # The last date and day in database for this lactation
                last_date, last_day = get_last(cow, lact)

                # We start at the last day of the lactation then add the
                # missing lines till we reach the first day of the lactation
                while last_day > 1:
                    last_day -= 1
                    last_date -= dt.timedelta(1)

                    if last_date in missing:
                        # If day = 1, we'll have a problem of unique key in
                        # the second loop
                        missing.remove(last_date)

                        insert(cow, last_date, lact, last_day)

                last_date, last_day = get_last(cow, lact)

                # We start at the last day of the lactation then add the
                # missing lines till we reach the next lactation or the end of
                # the data if this lactation is the last one
                while last_date + dt.timedelta(1) in missing:
                    last_day += 1
                    last_date += dt.timedelta(1)

                    insert(cow, last_date, lact, last_day)