Bow and Limb Objects¶
Bow Objects¶
-
class
pybow.
Bow
(name, source[, tags=()[, limbs=()[, *attrs]]])¶ Describes a bow by collecting measurements and metadata. Its data attributes
name
andsource
are mandatory for initialisation, whilematerial
et al. are optional.Parameters: - name (str) – The bow’s
name
. - source (str) – The bow’s
source
. - tags (list[str]) – A list of tags to initialise the bow’s
tags
with. - limbs (list[pandas.DataFrame] or list[list]) – A list of arguments for the
add_limbs()
method, to add limbs to the bow on initialisation. Either a list ofpandas.DataFrame
s, or a list of lists with complete inputs for .meth:add_limbs.
-
abslength
¶ Returns: The overall length of the bow, as derived from its Limb.data
. This includes incomplete limbs and protrusions beyond the nock.Return type: float
-
date
¶ A date identifier for sorting or grouping.
-
description
¶ A free text metadata field for an extended description of the bow.
-
material
¶ The name of the bow’s material. What language to use for identifying wood species is unspecified.
-
name
¶ A name describing the bow.
-
ntnlength
¶ Returns: The effective length of the bow, from nock to nock, as derived from its Limb.data
.NaN
if the bow has fewer than 2 complete limbs.Return type: float or NaN
-
source
¶ A statement identifying the source of the bow data. Depending on the bow described, this can be the name of its maker/designer, literature, or similar.
A set of strings acting as categorical descriptors. For more information on the tag system, see Using the Tag System.
-
add_limb
(df, complete=True, tags=())¶ Add a
Limb
to the bow.Parameters: - df (pandas.DataFrame) – The limb’s
Limb.data
DataFrame with measurements. - complete (bool) – The limb’s
Limb.complete
. - tags (list[str]) – Tags to attach to the limb’s
Limb.tags
.
Raises: - df (pandas.DataFrame) – The limb’s
-
del_limb
(ix)¶ Delete a limb from the bow.
Parameters: ix (int) – The index position of the limb to be deleted. Raises: IndexError – For values of ix
with no correlating limb in the bow.
-
write
(fname)¶ Write the bow object to disk. Up to three files get written:
- an
fname.yaml
containing the metadata and a manifest - up to two
fname_n.csv
files containing the limb measurement DataFrames.
Parameters: fname (str) – A filename of file basename. If a full filename is given, its extension will be ignored. - an
- name (str) – The bow’s
Limb Objects¶
-
class
pybow.
Limb
¶ Describes a bow limb, or more precisely: a half-bow. These objects generally don’t get created directly, but rather through
Bow.add_limb()
.Raises: ValueError – When trying to initialise a limb with a DataFrame that does not conform to minimum specifications. (See data
)-
abslength
¶ Returns: The limb’s absolute length, including protrusions beyond the nock. Return type: float or int
-
data
¶ The DataFrame containing limb measurements. It must contain, at a minimum, contain columns named
l
,width
, andthickness
. See Limb Measurement Conventions for further information.
-
length
¶ Returns: The limb’s effective length, i.e. from a point with \(l = 0\) to the maximum value of \(l\).
-
material
¶ Returns: The parent Bow.material
.Return type: str
A set of strings acting as categorical descriptors. For more information on the tag system, see Using the Tag System.
-
Indexing and Iterating¶
Bow objects behave to their limbs like lists behave to their items:
Indexing by number:
>>> my_bow[0]
[pd.DataFrame(...), True, set('some_tag', 'another_tag')]
Iterating:
>>> for l in my_bow:
... print(l.name)
...
'my_bow_name_0'
'my_bow_name_1'
And also:
>>> len(my_bow)
2
Read/Write¶
-
pybow.
read
(fname)¶ Reads a bow object from the files
Bow.write()
writes.Parameters: fname (str) – The file name of a bow’s .yaml
file.Returns: A bow object. Return type: Bow
See also: Bow.write()
.