Curling#
Curling is currently supported for the following leagues (in alphabetical order):
Extension of the BaseSurfacePlot
class to create a curling sheet.
This is a second-level child class of the BaseSurface
class, and as such
will have access to its attributes and methods. sportypy
will ship with
pre-defined leagues that will have their own subclass, but a user can manually
specify their own sheet parameters to create a totally-customized sheet. The
sheet’s features are parameterized by the basic dimensions of the sheet, which
comprise the attributes of the class.
@author: Ross Drucker
- class sportypy.surfaces.curling.CurlingSheet(league_code='', sheet_updates={}, color_updates={}, rotation=0.0, x_trans=0.0, y_trans=0.0, units='default', **added_features)#
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 thesheet_params
dictionary. For many leagues, these will be provided in the surface_dimensions.json file in the data/ subdirectory ofsportypy
.See the
BaseSurfacePlot
andBaseSurface
class definitions for full details.- league_code#
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
- Type:
str
- rotation_amt#
The angle (in degrees) through which to rotate the final plot. The default is
0.0
- Type:
float
- x_trans#
The amount that the
x
coordinates are to be shifted. By convention, the +``x`` axis extends from the center of the surface towards the right-hand side wall when viewing the sheet in TV view. The default is0.0
- Type:
float
- y_trans#
The amount that the
y
coordinates are to be shifted. By convention, the +``y`` axis extends from the center of the surface towards the top house when viewing the sheet in TV view. The default is0.0
- Type:
float
- feature_colors#
A dictionary of coloring parameters to pass to the plot
- Type:
dict
- sheet_params#
A dictionary containing the following parameters of the sheet:
- sheet_lengthfloat
The full length of the sheet. Length is defined as the distance between the inner edge of the boards behind each house
- sheet_widthfloat
The full width of the sheet. Width is defined as the distance between the inner edge of the side walls
- sheet_unitsstr
The units with which to draw the sheet
- apron_behind_backfloat
The dimension of the sheet’s apron behind the back board. In TV view, this is in the
y
direction
- apron_along_sidefloat
The dimension of the sheet’s apron beyond the side wall. In TV view, this is in the +``x`` direction
- tee_line_to_centerfloat
The distance from the center of the shet to the center of the tee line
- tee_line_thicknessfloat
The thickness of the tee line. This is the line that runs through the center of the house, from side wall to side wall
- back_line_thicknessfloat
The thickness of the back line. This is the line between the house and the hack
- back_line_to_tee_linefloat
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_thicknessfloat
The thickness of the hack line
- hack_foothold_widthfloat
The width of a foothold of the hack. In TV view, this is the dimension of the foothold in the
x
direction (parallel to the tee line)
- hack_foothold_gapfloat
The interior separation between the two footholds in the hack
- hack_foothold_depthfloat
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 line
- hog_line_to_tee_linefloat
The distance from the inside edge of the hog line (the edge nearest the house) to the tee line
- hog_line_thicknessfloat
The thickness of the hog line
- centre_line_extensionfloat
The distance beyond the center of the tee line that the centre line extends towards the back wall
- centre_line_thicknessfloat
The thickness of the centre line
- house_ring_radiilist 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 separately
- button_radiusfloat
The radius of the button (the center ring of the house)
- courtesy_line_thicknessfloat
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 the
y
direction when viewing the sheet in TV view
- courtesy_line_lengthfloat
The distance outward from the inner edge of the side wall that the courtesy line extends towards the center of the sheet
- courtesy_line_to_hog_linefloat
The distance between the outer edges of the hog line and the courtesy line
- Type:
dict
- 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
- Return type:
Nothing, but a message will be printed out
- 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
- Return type:
Nothing, but a message will be printed out
- 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 is
None
, this will display all leagues that do come shipped withsportypy
. The default isNone
- Return type:
Nothing, but a message will be printed out
- 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. If
None
is supplied, then the currently-active Axes object will be useddisplay_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 thesheet in TV view
The default is
"full"
xlim (float or tuple of floats or None) – The display range in the
x
direction to be used. If a single float is provided, this will be used as the lower bound of thex
coordinates to display and the upper bound will be the +``x`` end of the sheet. If a tuple, the two values will be used to determine the bounds. IfNone
, then thedisplay_range
will be used instead to set the bounds. The default isNone
ylim (float or tuple of floats or None) – The display range in the
y
direction 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 +``y`` side of the sheet. If a tuple, the two values will be used to determine the bounds. IfNone
, then thedisplay_range
will 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.0
will correspond to a TV view of the sheet, where +``x`` is to the right and +``y`` is on top. The rotation occurs counterclockwise. The default isNone
- 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 theupdate_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()#
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 theupdate_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
- 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 (see
cani_color_features()
method for a list of these names). The default is an empty dictionary- Return type:
Nothing, but the class is re-instantiated with the updated colors
- 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 (see
cani_change_dimensions()
method for a list of these parameters). The default is an empty dictionary- Return type:
Nothing, but the class is re-instantiated with the updated parameters