Curling
from sportypy.surfaces.curling import CurlingSheet
CurlingSheet
A subclass of BaseSurfacePlot to make a generic curling sheet.
This allows for the creation of the curling sheet in a way that is entirely parameterized by the sheet's baseline characteristics.
All attributes should default to 0.0 (if of a numeric type) or an empty string (if of a string type). Customized parameters may be specified via a child class (see below) or by directly specifying all necessary attributes of a valid curling sheet. The attributes needed to instantiate a particular league's surface must be specified in the sheet_params dictionary. For many leagues, these will be provided in the surface_dimensions.json file in the data/ subdirectory of sportypy.
See the BaseSurfacePlot and BaseSurface class definitions for full details.
Attributes
-
league_code(str): The league for which the plot should be drawn. This is case-insensitive but should be the shortened name of the league (e.g. "World Curling Federation" should be either "WCF" or "wcf"). The default is an empty string -
rotation_amt(float): The angle (in degrees) through which to rotate the final plot. The default is0.0 -
x_trans(float): The amount that thexcoordinates are to be shifted. By convention, the +xaxis extends from the center of the surface towards the right-hand side wall when viewing the sheet in TV view. The default is0.0 -
y_trans(float): The amount that theycoordinates are to be shifted. By convention, the +yaxis extends from the center of the surface towards the top house when viewing the sheet in TV view. The default is0.0 -
feature_colors(dict): A dictionary of coloring parameters to pass to the plot -
sheet_params(dict): A dictionary containing the following parameters of the sheet:sheet_length(float): The full length of the sheet. Length is defined as the distance between the inner edge of the boards behind each housesheet_width(float): The full width of the sheet. Width is defined as the distance between the inner edge of the side wallssheet_units(str): The units with which to draw the sheetapron_behind_back(float): The dimension of the sheet's apron behind the back board. In TV view, this is in theydirectionapron_along_side(float): The dimension of the sheet's apron beyond the side wall. In TV view, this is in the +xdirectiontee_line_to_center(float): The distance from the center of the shet to the center of the tee linetee_line_thickness(float): The thickness of the tee line. This is the line that runs through the center of the house, from side wall to side wallback_line_thickness(float): The thickness of the back line. This is the line between the house and the hackback_line_to_tee_line(float): The distance from the center of the tee line to the outside edge of the back line (which runs between the house and the hack)hack_line_thickness(float): The thickness of the hack linehack_foothold_width(float): The width of a foothold of the hack. In TV view, this is the dimension of the foothold in thexdirection (parallel to the tee line)hack_foothold_gap(float): The interior separation between the two footholds in the hackhack_foothold_depth(float): The distance from the house-side to the back wall side of the foothold of the hack. The back of the foothold will lie along the hack linehog_line_to_tee_line(float): The distance from the inside edge of the hog line (the edge nearest the house) to the tee linehog_line_thickness(float): The thickness of the hog linecentre_line_extension(float): The distance beyond the center of the tee line that the centre line extends towards the back wallcentre_line_thickness(float): The thickness of the centre linehouse_ring_radii(list of floats): The radii of the house rings. These will be reordered to be descending by default. This should NOT include the button, as this will be handled separatelybutton_radius(float): The radius of the button (the center ring of the house)courtesy_line_thickness(float): The thickness of the courtesy lines. These are the lines marking where players on the non-throwing team should stand while awaiting their next throw. This dimension should be in theydirection when viewing the sheet in TV viewcourtesy_line_length(float): The distance outward from the inner edge of the side wall that the courtesy line extends towards the center of the sheetcourtesy_line_to_hog_line(float): The distance between the outer edges of the hog line and the courtesy line
Leagues
Each class below is a CurlingSheet with that league's rule-book dimensions.
| Class | league_code | Description |
|---|---|---|
WCFSheet | wcf | A subclass of CurlingSheet specific to the WCF. |
CurlingCanadaSheet | curling canada | A subclass of CurlingSheet specific to Curling Canada. |
Methods
draw
CurlingSheet.draw(ax = None, display_range = 'full', xlim = None, ylim = None, rotation = None)
Draw the sheet.
Parameters
-
ax(matplotlib.Axes): An axes object onto which the plot can be drawn. IfNoneis supplied, then the currently-active Axes object will be used -
display_range(str): The portion of the surface to display. The entire surface will always be drawn under the hood, however this parameter limits what is shown in the final plot. The following explain what each display range corresponds to:"full": The entire surface"in bounds only": The full in-bounds area of the sheet"in_bounds_only": The full in-bounds area of the sheet"house": The top house on the surface when viewing the sheet in TV view
The default is
"full" -
xlim(float or tuple of floats or None): The display range in thexdirection to be used. If a single float is provided, this will be used as the lower bound of thexcoordinates to display and the upper bound will be the +xend of the sheet. If a tuple, the two values will be used to determine the bounds. IfNone, then thedisplay_rangewill be used instead to set the bounds. The default isNone -
ylim(float or tuple of floats or None): The display range in theydirection to be used. If a single float is provided, this will be used as the lower bound of the y coordinates to display and the upper bound will be the +yside of the sheet. If a tuple, the two values will be used to determine the bounds. IfNone, then thedisplay_rangewill be used instead to set the bounds. The default isNone -
rotation(float or None): Angle (in degrees) through which to rotate the sheet when drawing. If used, this will set the class attribute of_rotation. A value of0.0will correspond to a TV view of the sheet, where +xis to the right and +yis on top. The rotation occurs counterclockwise. The default isNone
cani_plot_leagues
CurlingSheet.cani_plot_leagues(league_code = None)
Show if a league can be plotted, or what leagues are pre-defined.
A user may wish to know if a specific curling league can be plotted. This method allows a user to check if that specific league code comes shipped with sportypy for easier plotting (if they provide the league code), or can also show what leagues are available to be plotted
Parameters
league_code(str or None): A league code that may or may not be shipped with the package. If the league code isNone, this will display all leagues that do come shipped withsportypy. The default isNone
Returns
Nothing, but a message will be printed out:
cani_color_features
CurlingSheet.cani_color_features()
Determine what features of the sheet can be colored.
This function is a helper function for the user to aid in plot styling and customization. The printed result of this method will be the names of the features that are able to be colored
Returns
Nothing, but a message will be printed out:
cani_change_dimensions
CurlingSheet.cani_change_dimensions()
Determine what features of the sheet can be re-parameterized.
This function is a helper function for the user to aid in customizing a sheet's parameters. The printed result of this method will be the names of the features that are able to be reparameterized. This method is also useful when defining new features and using an existing league's sheet dimensions as a starting point
Returns
Nothing, but a message will be printed out:
update_colors
CurlingSheet.update_colors(color_updates = {}, *args, **kwargs)
Update the colors currently used in the plot.
The colors can be passed at the initial instantiation of the class via the color_updates parameter, but this method allows the colors to be updated after the initial instantiation and will re-instantiate the class with the new colors
Parameters
color_updates(dict): A dictionary where the keys correspond to the name of the feature that's color is to be updated (seecani_color_features()method for a list of these names). The default is an empty dictionary
Returns
Nothing, but the class is re-instantiated with the updated colors:
update_sheet_params
CurlingSheet.update_sheet_params(sheet_param_updates = {}, *args, **kwargs)
Update the sheet's defining parameters.
This method should primarily be used in cases when plotting a league not currently supported by sportypy
Parameters
sheet_updates(dict): A dictionary where the keys correspond to the name of the parameter of the sheet that is to be updated (seecani_change_dimensions()method for a list of these parameters). The default is an empty dictionary
Returns
Nothing, but the class is re-instantiated with the updated parameters:
reset_colors
CurlingSheet.reset_colors()
Reset the features of the sheet to their default color set.
The colors can be passed at the initial instantiation of the class via the color_updates parameter, and through the update_colors() method, these can be changed. This method allows the colors to be reset to their default values after experiencing such a change
reset_sheet_params
CurlingSheet.reset_sheet_params()
Reset the features of the sheet to their default parameterizations.
The sheet parameters can be passed at the initial instantiation of the class via the sheet_updates parameter, and through the update_sheet_params() method, these can be changed. This method allows the feature parameterization to be reset to their default values after experiencing such a change