Skip to content

Workaround for angles not having a dimension #570

@DanDeepPhase

Description

@DanDeepPhase

Preface

Currently angles do not have a dimension, leading to several issues #531 #537 #392 #216 #38 and stems from a conversation in #9 . Personally, I believe that angles should have a dimension, and appreciate the arguments in this paper: https://iopscience.iop.org/article/10.1088/0026-1394/52/1/40. I suspect that the argument "the circumference of a circle should be (2π radians) * (radius) which better have dimensions of length." is incorrect, because its probably shorthand for a limit series of inscribed triangles. I think the correct definition of circumference is "(2π)*(radius)" and if you are taking an arc segment then you are multiplying by (arc-angle radians) / (2π radians).
Note: Similar issues have requested the ability to dispatch on angles, to which the suggestion has been to create a union Quantity type. This gets partway there, but the angles are still dimensionless
Note: The UnitfulAngles package does not address dimensions or union types
Note: SI currently treats angles as dimensionless, so i understand mine is a minority opinion.

My Pain point

I work with radiometric units, where steradians are used to distinguish between quantities. some typical units are:

Spectral Radiance = u"W/(m^2*μm*sr)"
Spectral Irradiance = u"W/(m^2*μm)"

A typical problem is that i might integrate over the wavelength (the μm term here) which sometimes comes in other units, like nanometers. This leads to a clumsy nm W μm^-1 m^-2 sr^-1 which i need to simplify. upreferred turns this into kg/s^3 so i've tried to dispatch on derived dimensions of

@derived_dimension Radiance 𝐌/(𝐋*𝐓^2) false
@derived_dimension Irradiance 𝐌/(𝐋*𝐓^2) false

unfortunately, due to the lack of an angular dimension, i have some errors in my math where angles are inappropriately eliminated or added.

Paths forward

  1. Add a dimension for angles - I understand that I am in the minority opinion here, and this seems like the kind of change that could break code for people comfortable ignoring units in small angle approximations. However, it seems like a problem that other people are running into.
    1B. Add a dimension for solid angles only - this is a hack compromise which would fix my code, and probably not break too many existing code bases.
  2. I create a package that respects dimensionality of angles. however, I'm not sure how to do this since i think i either need to redefine the definitions in pkgdefaults or create some workaround types like myradian mydegree mysteradian... etc...
  3. is there some way to determine if an angle is present in a quantity in order to preserve dimensions when converting units? ie since i cant tell the difference dimensionally, to check the units of the input Quantity, extract the angle units which would be lost, perform the conversion, then reapply the angle units to the result. The type generation macros have prevented me from fully understanding what is going on inside the Quantities or how to test parts of them.

Any willingness for #1? if not, any suggestions for #2/#3?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions