Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add angular units #19

Closed
enourbakhsh opened this issue Feb 9, 2019 · 5 comments
Closed

Add angular units #19

enourbakhsh opened this issue Feb 9, 2019 · 5 comments

Comments

@enourbakhsh
Copy link

It would be very useful for astronomers to have a scale bar showing angular scales such as degree (°), arcmin (') and arcsec ('').

For example, this can be done by adding the so-called pixel scale in the units of arc seconds per pixel (or even more available units) as an input. For example pixel scale = 0.2 implies that each pixel spans 0.2 arcsec. Here is the best I could do with the current version of matplotlib-scalebar.

scalebar

@ppinard
Copy link
Owner

ppinard commented Jun 9, 2019

Thank you for this request. I made a first implementation in the branch angular. There is a new dimension Angular where the units can either be degree (°), minute of arc (′, 1/60 of °) or second of arc (′′, 1/3600 of °).

Here is how it looks like:

example_angular

Please let me know if this addresses your issue. If so, I will merge the branch and make a new release.

@ericpre
Copy link
Contributor

ericpre commented Jun 11, 2019

What's about using the pint library to manage the units and prefixes?

@ppinard
Copy link
Owner

ppinard commented Jul 7, 2019

@ericpre Regarding using pint, could you explain a bit more what you had in mind? I am not sure I would like to add a dependency to the project for something as simple as defining the conversion factor between units. While pint could be used to discover possible units within a unit group (e.g. [length]), I think the list of units available for a scale bar needs to be customized, hence the Dimension class. For instance, having "mile", "nautical mile" and "us nautical mile" as available units would be confusing for a scale bar.

@ericpre
Copy link
Contributor

ericpre commented Jul 7, 2019

This was a quick suggestion and I haven't thought properly about it but I find it convenient to use! I don't have anything particular in mind other than it is very convenient to get the appropriate prefix and a nice formatting, for example:

from pint import UnitRegistry
ureg = UnitRegistry()
length = 1550 * ureg.nm
print(f'{length.to_compact():~}')

Pint does more than what is needed here but it is pure python library and has no dependency, so it does not cost much to add it as dependencies!

@ppinard ppinard mentioned this issue Jul 12, 2019
ppinard added a commit that referenced this issue Jul 12, 2019
@ppinard
Copy link
Owner

ppinard commented Jul 12, 2019

Code merged. Please re-open if it doesn't address the original issue.

@ppinard ppinard closed this as completed Jul 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants