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 mas (milliarcsecond) unit #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

add mas (milliarcsecond) unit #7

wants to merge 1 commit into from

Conversation

aplavin
Copy link

@aplavin aplavin commented Jan 29, 2019

No description provided.

@giordano
Copy link
Member

I'm not sure it's worth a new unit for what is actually a submultiple of another unit. But yes, this is probably used only in Astronomy

@aplavin
Copy link
Author

aplavin commented Jan 29, 2019

It is widely used in interferometry (of course). I have mas in my package locally, and find myself using it pretty often. And I'm quite sure the abbreviation doesn't conflict with any other unit.

@aplavin
Copy link
Author

aplavin commented Apr 29, 2019

Any updates on this? As I understand you are not very opposed to this.
And by the way, basically all units are "multiple of another unit", so mas is not special in this sense.
In this case I think it would be useful to have other powers-of-ten as well, e.g. muas - but not sure if there is a general method.

@m-wells
Copy link
Contributor

m-wells commented Apr 29, 2019

Don't the SI prefixes already do this? m, dm, mm?

@m-wells
Copy link
Contributor

m-wells commented Apr 29, 2019

arcsecond belongs to UnitfulAngles so that is where you would need to modify things like using SI prefixes.

If you only want mas then you can do this

using UnitfulAngles
u = UnitfulAngles
mas = 1e-3*u.arcsecond

@giordano
Copy link
Member

As I understand you are not very opposed to this.

Yes, I'm not totally against because I know how much "mas" is used in astronomy, it's just that this isn't a brand-new unit but a power-of-ten multiple of another unit.

I was going to suggest to make arcseconds in UnitfulAngles.jl accept multiples, but I see that the unit there is registered as so that mas wouldn't work anyway. In the end I think I'll merge this in a few days.

@aplavin
Copy link
Author

aplavin commented Apr 29, 2019

arcsecond belongs to UnitfulAngles so that is where you would need to modify things like using SI prefixes.

If you only want mas then you can do this

using UnitfulAngles
u = UnitfulAngles
mas = 1e-3*u.arcsecond

It does not seem to work using u_str like 1u"mas".

@m-wells
Copy link
Contributor

m-wells commented Apr 29, 2019

u_str only works for registered units.

julia> using Unitful

julia> import UnitfulAngles.arcsecond

julia> @unit mas "mas" MilliArcsecond (1//1000)*arcsecond false
mas

julia> u"mas"
ERROR: LoadError: Symbol mas could not be found in registered unit modules.
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] replace_value(::Module, ::Symbol) at /home/mark/.julia/packages/Unitful/W0mMi/src/user.jl:542
 [3] @u_str(::LineNumberNode, ::Module, ::Any) at /home/mark/.julia/packages/Unitful/W0mMi/src/user.jl:495
in expression starting at REPL[7]:1

julia> mas
mas

julia> uconvert(arcsecond, 987.2mas)
0.9872000000000001 ″

here is a link to creating units

@aplavin
Copy link
Author

aplavin commented Jun 18, 2020

^up

In the end I think I'll merge this in a few days.

Much more has passed :)

@icweaver
Copy link
Member

icweaver commented Jul 8, 2020

As I understand you are not very opposed to this.

Yes, I'm not totally against because I know how much "mas" is used in astronomy, it's just that this isn't a brand-new unit but a power-of-ten multiple of another unit.

I was going to suggest to make arcseconds in UnitfulAngles.jl accept multiples, but I see that the unit there is registered as so that mas wouldn't work anyway. In the end I think I'll merge this in a few days.

Speaking of multiples of other base cgs/SI units, isn't angstrom already one? I'm all for commonly used astro units like this being supported!

@mileslucas
Copy link
Member

mileslucas commented Jul 8, 2020

I'm concerned about adding a special unit when it is explicitly a multiple of a base. Angstrom gets a pass because it is "Angstrom" and not "deci-nano-meter". A clear example of why we want natural prefix behavior would be reporting astrometry using micro-arcseconds or uas/\muas. To this end, I think we just need to alias u"as" as arc-second and the existing prefixes should work out.

@icweaver
Copy link
Member

icweaver commented Jul 8, 2020

Ahh, that's a good point about naming conventions. Would this mean that doing both: 1) aliasing u"as" and 2) creating a mas unit, would be incompatible/break things downstream?

@mileslucas
Copy link
Member

Would this mean that doing both: 1) aliasing u"as" and 2) creating a mas unit, would be incompatible/break things downstream?

Properly registering u"as" would give us u"mas", as well as any other SI prefix, thus registering u"mas" would be explicitly over-writing. This wouldn't error, I believe, but it's unnecessary and might throw warnings.

@icweaver
Copy link
Member

icweaver commented Jul 8, 2020

Oh, that's so cool. Thanks for the info!

@cmichelenstrofer
Copy link

cmichelenstrofer commented Apr 30, 2022

Hey folks, this definition conflicts with Unitful's "attosecond". See: yakir12/UnitfulAngles.jl#30. Thoughts on the best solution?

@mileslucas
Copy link
Member

I'm eager to hear ideas as well. The least elegant solution I can think of is somehow disabling attosecond when UnitfulAngles is loaded.

@cmichelenstrofer
Copy link

cmichelenstrofer commented May 4, 2022

das is also problematic.

One option is to add the milliarcsecond and microarcsecond directly (and not allow prefixing). As far as I can tell these are the only two prefixes used with arcsecond. UnitfulAngles.jl would then include all units in this table. Something like:

@unit mas    "mas"    Milliarcsecond    Arcsecond//1_000        false 
@unit μas    "μas"    Microarcsecond    Arcsecond//1_000_000    false 

@mileslucas
Copy link
Member

I think I'm in favor of that, despite my reluctance previously.

@cmichelenstrofer
Copy link

cmichelenstrofer commented May 5, 2022

I should have read this thread more carefully. I see this common sentiment and I agree:

I'm not sure it's worth a new unit for what is actually a submultiple of another unit.

I'm concerned about adding a special unit when it is explicitly a multiple of a base.

I took a look at the actual SI Brochure (section 4 Non-SI units that are accepted for use with the SI) and they mention:

For some applications such as in astronomy, small angles are measured in arcseconds (i.e. seconds of
plane angle), denoted as or ″, milliarcseconds, microarcseconds and picoarcseconds, denoted mas, μas
and pas, respectively, where arcsecond is an alternative name for second of plane angle.

So indeed it seems that different prefixes are used other then milli- and micro- (even the symbol as without prefixes is mentioned).

Nonetheless, if possible we should try to avoid conflict with units in Unitful (however rare). Maybe a better option would be to keep it as an alias (as currently implemented) that displays as as but has a different typed name

@unit as_s            "as"            ArcsecondShort °//3600       true

Then

julia> 10u"as_s"
10 as

julia> 1.2u"μas_s"
1.2 μas

julia> 6.23u"mas_s"
6.23 mas

The typed name could be anything, here I used _s to match the "short" you have in the unit name.

@mileslucas
Copy link
Member

mileslucas commented Sep 24, 2022

@cmichelenstrofer good idea that compromises different approaches, but I actually think I prefer #7 (comment)

My thinking is that, I think that if we do

@unit mas    "mas"    Milliarcsecond    Arcsecond//1_000         false 
@unit μas    "μas"    Microarcsecond    Arcsecond//1_000_000     false 
@unit pas    "pas"    Picoarcsecond     Arcsecond//1_000_000_000 false

we simultaneously cover an overwhelming majority of use-cases (e.g., I never using anything more precise than mas) while not sacrificing user interface (having to type _s on every unit is tedious and unintuitive).

This is...not the most beautiful, idiomatic, or elegant solution, but I think it's more important to have something that works good enough rather than trying to perfectly engineer a solution.

@cmichelenstrofer
Copy link

FYI I recently created a new package, DimensionfulAngles.jl to treat angles as a dimension and I included the as as well as other astronomy units.

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

Successfully merging this pull request may close these issues.

6 participants