Ejemplo n.º 1
0
 def shot_chart_player_game(self, id_game, id_player_team, tci):
     #get stats of shots from opponent team and players
     id_team = self.params["home"] if self.params["destiny"] == self.params[
         "home"] else self.params["away"]
     ss = SeasonShots(self.params["competition"],
                      self.get_season(self.params["competition"]))
     ts = TeamShots(id_team, self.params["competition"])
     ps = ts.df.query(
         f"id_game == {id_game} and id_player_team == {id_player_team}")
     #ps = PlayerShots(ts.id_team_club, ts.competition)
     errores = ps.query("position.isnull()")
     self.set_advertencia(tci, ps, len(errores))
     #get image and set stats over image
     image = ShotChartImage(IMAGES.BASKET_COURT)
     image.resize_from_width(500)
     image.set_data_over_image(ps, ss.df)
     name = f"{id_team}-{id_player_team}.png"
     image.save_image(IMAGES.IMAGE_ROUTE + name)
     #Tabla Estadísticas de tiro
     #Tabla Estadísticas de tiro
     self.pdf.set_font("Arial", "B", 14)
     self.pdf.set_y(75)
     #self.pdf.cell(self.pdf.get_string_width("Carta de tiro equipo") + 5, 15, "Carta de tiro equipo", "B: 1", 1, "L")
     self.pdf.image(IMAGES.IMAGE_ROUTE + name, 28, 65)
     image.remove_image(IMAGES.IMAGE_ROUTE + name)
Ejemplo n.º 2
0
 def shot_chart_team_game(self, id_game, id_team, tci):
     '''
         Short chart for an only game.
     :param id_game:
     :param id_team:
     :param tci:
     :return:
     '''
     #get stats from shots from opponent team
     ss = SeasonShots(self.params["competition"],
                      self.get_season(self.params["competition"]))
     ts = TeamShots(id_team, self.params["competition"])
     data = ts.df.query(f"id_game == {id_game}")
     errores = data.query(f"id_game == {id_game} and position.isnull()")
     #print(f"Total lanzamientos equipo: {len(ts.df)}")
     #print(f"Total lanzmientos temporada: {len(ss.df)}")
     self.set_advertencia(tci, data, len(errores))
     #get image and set stats over image
     image = ShotChartImage(IMAGES.BASKET_COURT)
     image.resize_from_width(500)
     #Set data over image
     image.set_data_over_image(data, ss.df)
     #Save image
     name = f"{id_team}.png"
     image.save_image(IMAGES.IMAGE_ROUTE + name)
     #self.pdf.cell(self.pdf.get_string_width("Carta de tiro equipo") + 5, 15, "Carta de tiro equipo", "B: 1", 1, "L")
     self.pdf.image(IMAGES.IMAGE_ROUTE + name, 28, 65)
     image.remove_image(IMAGES.IMAGE_ROUTE + name)
Ejemplo n.º 3
0
 def shot_chart_opp_team(self, tci):
     #get stats from shots from opponent team
     ss = SeasonShots(self.params["competition"], self.get_season(self.params["competition"]))
     ts = AccumulatedOppShots(self.params["destiny"], self.params["competition"])
     #print(f"Total lanzamientos equipo: {len(ts.df)}")
     #print(f"Total lanzmientos temporada: {len(ss.df)}")
     self.set_advertencia(tci, ts.df, ts.errores)
     #get image and set stats over image
     image = ShotChartImage(IMAGES.BASKET_COURT)
     image.resize_from_width(500)
     #Set data over image
     image.set_data_over_image(ts.df, ss.df)
     #Save image
     name = f"accOpp-{self.params['destiny']}.png"
     image.save_image(IMAGES.IMAGE_ROUTE + name)
     self.pdf.image(IMAGES.IMAGE_ROUTE + name, 28, 65)
     image.remove_image(IMAGES.IMAGE_ROUTE + name)
 def shot_chart_player(self, tci):
     #get stats of shots from opponent team and players
     ss = SeasonShots(self.params["competition"], self.get_season(self.params["competition"]))
     ps = PlayerShots(self.params)
     self.set_advertencia(tci, ps.df, ps.errores)
     #get image and set stats over image
     image = ShotChartImage(IMAGES.BASKET_COURT)
     image.resize_from_width(500)
     image.set_data_over_image(ps.df, ss.df)
     id1 = self.params["id"] if id in self.params else self.params["id_player_team"]
     name = f"{id1}.shotchart.png"
     image.save_image(IMAGES.IMAGE_ROUTE + name)
     #Tabla Estadísticas de tiro
     self.pdf.set_font("Arial", "B", 14)
     self.pdf.set_y(75)
     self.pdf.cell(self.pdf.get_string_width("Carta de tiro equipo") + 5, 15, "Carta de tiro equipo", "B: 1", 1, "L")
     self.pdf.image(IMAGES.IMAGE_ROUTE + name, 28, 65)
     image.remove_image(IMAGES.IMAGE_ROUTE + name)
Ejemplo n.º 5
0
 def shot_chart_team(self, id_team, tci):
     #get stats from shots from opponent team
     ss = SeasonShots(self.params["competition"],
                      self.get_season(self.params["competition"]))
     ts = TeamShots(id_team, self.params["competition"])
     #print(f"Total lanzamientos equipo: {len(ts.df)}")
     #print(f"Total lanzmientos temporada: {len(ss.df)}")
     self.set_advertencia(tci, ts.df, ts.errores)
     #get image and set stats over image
     image = ShotChartImage(IMAGES.BASKET_COURT)
     image.resize_from_width(500)
     #Set data over image
     image.set_data_over_image(ts.df, ss.df)
     #Save image
     name = "test.png"
     image.save_image(IMAGES.IMAGE_ROUTE + name)
     #self.pdf.cell(self.pdf.get_string_width("Carta de tiro equipo") + 5, 15, "Carta de tiro equipo", "B: 1", 1, "L")
     self.pdf.image(IMAGES.IMAGE_ROUTE + name, 28, 65)
     image.remove_image(IMAGES.IMAGE_ROUTE + name)
Ejemplo n.º 6
0
 def test_set_position(self):
     ss = SeasonShots(COMPETITIONS.LF1, 45)