Skip to content

Conceptual difference between units.DN and units.adu? #20851

Open

Description

@cgobat

Carrying this discussion over from Slack.

#11591 added a DN unit, which stands for either "data number" or "digital number". There is also adu, which stands for "analog-to-digital unit". To me, it seems like both of these represent the same (or very similar) concepts, but the two units are not compatible or convertible (i.e., u.DN.is_equivalent(u.adu) is False and (1*u.adu).to(u.DN) raises an error). Is there a good reason for this? Could they be made compatible/equivalent?

Both are separate from units.ct, which implies a raw count (as opposed to something that may have had a gain factor applied). I agree that this should be kept conceptually separate, since the distinction matters for things like whether or not $\sqrt{N}$ is a valid representation of Poisson error, etc.

Activity

  1. pllim commented on Nov 13, 2026

    @pllim
    Member

    Thanks! cc @jdavies-st and @mhvk

  2. mhvk commented on Nov 13, 2026

    @mhvk
    Contributor

    looking back at #11591, I see we had quite a bit of a discussion (e.g., #11591 (comment)), but ended up deciding it was its own unit. A data number indeed does not have to come from an analog to digital converter. To me, it seems best to stay with the status quo, refusing the temptation to guess and letting users be explicit if they want ADU and DN to be equivalent. In principle, we could document the solution (easy, see link), though of course one always has to wonder where to put that documentation such that people will actually find it...

  3. cgobat commented on Nov 13, 2026

    @cgobat
    MemberAuthor

    Right, I also saw that discussion, but it seemed to mostly focus on whether DN should be equivalent to count (which I concur; it should not). There didn't seem to be as much conversation at the time about DN and adu relative to one another.

  4. cgobat commented on Nov 13, 2026

    @cgobat
    MemberAuthor

    Maybe there is also some clarification to be had about whether DN is digital or data number (or if astropy is agnostic). I see that the changelog entry for #11591 originally said "digital number", but was later changed to "data number" before it was merged. If it's "digital" (or if that's an accepted interpretation) that strengthens the case in my mind for it being equatable to adu.

  5. ayshih commented on Nov 13, 2026

    @ayshih
    Contributor

    My perspective:

    • adu is an "analog-to-digital (converter) unit" and is enshrined in the FITS standard. This unit has a specific physical meaning.
    • DN is a "digital number", which simply means that the value is based on a discretized unit. It does not attach any assumptions about the nature of the source of the value. It shouldn't be used in unit conversions without an explicit relationship/equivalency because, for example, the the unit of a DN quantity could be considered DN as well (just a different flavor of DN).

    That is, adu is a specific type of DN, but an arbitrary DN unit should not be treated as equivalent to adu.

  6. pllim commented on Nov 13, 2026

    @pllim
    Member

    If nothing else, should such reasoning be documented somewhere on astropy doc for these units?

  7. mhvk commented on Nov 13, 2026

    @mhvk
    Contributor

    If nothing else, should such reasoning be documented somewhere on astropy doc for these units?

    I think it should, including with a nice example of using equivalencies to convert one to the other. The main questions are where would be good, and who has the time to do it...

  8. pllim commented on Nov 13, 2026

    @pllim
    Member

    Where is a good question. This is a very instrumentation specific discussion... Current topics at https://docs.astropy.org/en/latest/units/index.html#using-astropy-units

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions