Prescription
Bases: BaseModel
The prescription module contains methods to deal with spectacle prescriptions.
Examples:
Typical use:
>>> rx = Prescription(sphere=0, cylinder=-1, axis=180)
>>> str(rx)
'plano / -1.00 x 180'
>>> rx = Prescription(sphere=1, add={"add": 1})
>>> str(rx)
'+1.00 DS Add: +1.00 @ 40cm'
mean_sphere()
property
Provide mean sphere value of the prescription.
Returns:
Type | Description |
---|---|
float
|
The Mean Sphere. |
transpose(flag=None)
Transpose prescription from positive to negative and vice versa.
Flags, 'n'
and 'p'
, can be provided to force a negative or positive cylinder respectively.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
(Optional[[Literal["n", |
"p"]]
|
Flag to force negative ('n') and positive ('p') cylindrical format. Defaults to |
required |
Examples:
Transposing a prescription as normal:
>>> rx = Prescription("+1.00/-1.00x180")
>>> rx.transpose()
>>> str(rx)
"plano / +1.00 x 90"
>>> rx.transpose()
>>> str(rx)
"+1.00 / -1.00 x 180"
Transposing a prescription with the 'n' flag:
>>> rx = Prescription("+1.00/-1.00x180").transpose('n')
>>> str(rx)
"+1.00 / -1.00 x 180"
parse(rx)
Parse a prescription in a more typical format.
This is more familiar than setting a prescription using keyword arguments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rx |
str
|
The prescription as a string. |
required |
Examples:
Parsing a simple prescription:
>>> rx = Prescription().parse("+1.00/-1.00x180")
>>> rx.transpose()
>>> str(rx)
'pl / +1.00 x 90'
random(rx_range=30, seed=None)
Generate a random prescription.
All results will produce negative cylinderical results. Use the transpose() method to return positive cylindrical results.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rx_range |
float
|
The +/- range of prescription in dioptres. |
30
|
seed |
Optional[int]
|
Seed for setting random.seed(). |
None
|
Examples:
Typical use:
>>> rx = Prescription().random()
>>> str(rx)
'+1.00 / -1.00 x 173'