File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -114,3 +114,23 @@ function aff_uparse(s::AbstractString)
114114 ex = AffineUnits. map_to_scope (Meta. parse (s))
115115 return eval (ex):: AffineUnit{DEFAULT_DIM_BASE_TYPE}
116116end
117+
118+ """
119+ ustrip(unit::AffineUnit, q::UnionAbstractQuantity)
120+
121+ Convert a quantity `q` to the numerical value in terms of affine units specified by `unit`,
122+ then strip the units. This allows getting the numerical value in terms of degrees Celsius or Fahrenheit.
123+
124+ # Examples
125+ ```julia
126+ julia> ustrip(ua"degC", 27ua"degC")
127+ 27.0
128+
129+ julia> ustrip(ua"degF", 300u"K")
130+ 80.33000000000003
131+ ```
132+ """
133+ function ustrip (unit:: AffineUnit , q:: UnionAbstractQuantity )
134+ unit. basedim == dimension (q) || throw (DimensionError (unit, q))
135+ return (ustrip (q) - unit. offset) / unit. scale
136+ end
You can’t perform that action at this time.
0 commit comments