You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add "extragalactic" and "galactic" unit systems #703
#579 added the to_system functionality to units. This provides an easy way to convert units between cgs and si. A nice addition would be to also support galactic and extragalactic unit systems. These systems would be like cgs, but with the natural length scale in kpc or possibly Mpc for extragalactic and pc for galactic, and with km/s the natural velocity scale.
This may require more work, because km/s is not an irreducible unit. But I haven't looked closely enough to know how one might do this with the to_system logic.
@eteq - do you still feel this would be useful? (am trying to go over really old issues so we can reduce the number of open issues, and feel that this is one of those that will just remain open forever until someone just implements it -- which would probably not be triggered by the issue).
@mhvk - Yes, I think this is still worth doing, but it is not a high priority. So I added the "low priority" tag.
I also don't think it's bad to keep issues like this open: the intent of the "future" category is for things like this: ideas that are not high priority, but are relatively straightforward to implement when someone has time. I think this is useful for people who are looking for ways to contribute to Astropy, but aren't sure how (I get a few people asking about this, and I direct them either to the "easy" label, or "future", depending on how skilled the are in Python/programming). But it's also good to check on these from time-to-time, because sometimes they get outpaced by other developments. In this case I think it's worth keeping, though.
@adrn - your example makes me wonder how this would work: Wouldn't velocity necessarily be in length-unit / time-unit? Also, while the scales are reasonable, I might pick pc for length and Gyr for Galactic. Which suggests a bit of a problem: unlike si and cgs these are not defined by anybody. Do we really want to be setting standards? Or would it be sufficient to be able to do something like:
(1./(10.*u.Gyr)).decompose((u.Mpc, u.km/u.s))
(not currently possible, though it may get better with #2559)
Anyway, clearly enough reasons to leave this issue open for now!
Sorry this totally fell off of my radar. It's something I deal with all the time, though long ago I just accepted it and adapted all of my code to work in the system (kpc, Myr, Msun). This lets me use decompose() everywhere, but it would be kind of cool if we had some kind of specialized support for decomposing into composite units, e.g.
Of course, the showstopper is the question of what to do with something like <Quantity 15.0 mi2 / s3>... I wonder if it would be useful enough to match on physical type of the decomposing system, and if no explicit match is found, take the base units? Something like:
But then again, maybe adding too many bells & whistles is not good either...
Funny how this habit of printing many copies of one's thesis influences things. And scary to think I still use optimal extraction code I developed at the time (which, who knows, may at some point enter specutils in a python incarnation...).
Understood -- in principle, I think it would be good if the example I gave would work, i.e., one could decompose into any bases with which it is possible to construct the unit given.
FYI: I implemented something that might help for this in one of my own packages as a trial implementation / demo of one possible way to deal with unit systems. In my UnitSystem object, you can override base unit combinations by specifying composite units. For example, this unit system would always convert down to combinations of base units:
I'm looking into using the Units framework for galpy and stumbled on this issue; obviously having a galactic unit system would make that support much easier!
I only glanced through the thread, but wouldn't many of the issues raised here be resolved by not having time as a fundamental unit (i.e., just have length and velocity; similar to WD_units in NEMO)? If you use kpc and km/s, the derived time unit would be ~Gyr.
Also don't see how there can be any argument against kpc as the appropriate length unit for galaxies (there's fewer than 1 star / pc^3 near the Sun...). And Gyr is much closer to the dynamical time than Myr...
Activity
mhvk commentedon Jul 8, 2014
@eteq - do you still feel this would be useful? (am trying to go over really old issues so we can reduce the number of open issues, and feel that this is one of those that will just remain open forever until someone just implements it -- which would probably not be triggered by the issue).
eteq commentedon Jul 8, 2014
@mhvk - Yes, I think this is still worth doing, but it is not a high priority. So I added the "low priority" tag.
I also don't think it's bad to keep issues like this open: the intent of the "future" category is for things like this: ideas that are not high priority, but are relatively straightforward to implement when someone has time. I think this is useful for people who are looking for ways to contribute to Astropy, but aren't sure how (I get a few people asking about this, and I direct them either to the "easy" label, or "future", depending on how skilled the are in Python/programming). But it's also good to check on these from time-to-time, because sometimes they get outpaced by other developments. In this case I think it's worth keeping, though.
adrn commentedon Jul 8, 2014
Oo, I would use this -- can we agree on the systems though? To me,
Galactic:
km/skpcMyrM_sun(?)Extragalactic:
km/s(?)MpcGyrM_sun(?)mhvk commentedon Jul 8, 2014
@adrn - your example makes me wonder how this would work: Wouldn't velocity necessarily be in
length-unit / time-unit? Also, while the scales are reasonable, I might pickpcfor length andGyrfor Galactic. Which suggests a bit of a problem: unlikesiandcgsthese are not defined by anybody. Do we really want to be setting standards? Or would it be sufficient to be able to do something like:(not currently possible, though it may get better with #2559)
Anyway, clearly enough reasons to leave this issue open for now!
mhvk commentedon Jan 13, 2015
Just for the record: with #2559, the above
(1./(10.*u.Gyr)).decompose((u.Mpc, u.km/u.s))does not work (astropy version 1.0.dev11386)adrn commentedon Jan 13, 2015
Sorry this totally fell off of my radar. It's something I deal with all the time, though long ago I just accepted it and adapted all of my code to work in the system (kpc, Myr, Msun). This lets me use
decompose()everywhere, but it would be kind of cool if we had some kind of specialized support for decomposing into composite units, e.g.Of course, the showstopper is the question of what to do with something like
<Quantity 15.0 mi2 / s3>... I wonder if it would be useful enough to match on physical type of the decomposing system, and if no explicit match is found, take the base units? Something like:(BTW @mhvk I was just found a copy of your thesis in my office...not sure what the universe is trying to tell me)
mhvk commentedon Jan 13, 2015
But then again, maybe adding too many bells & whistles is not good either...
Funny how this habit of printing many copies of one's thesis influences things. And scary to think I still use optimal extraction code I developed at the time (which, who knows, may at some point enter specutils in a python incarnation...).
adrn commentedon Jan 13, 2015
@mhvk Totally agree -- oops, I didn't mean to imply that the above belongs in the core, just bringing it up for discussion!
mhvk commentedon Jan 13, 2015
Understood -- in principle, I think it would be good if the example I gave would work, i.e., one could decompose into any bases with which it is possible to construct the unit given.
adrn commentedon Dec 20, 2015
FYI: I implemented something that might help for this in one of my own packages as a trial implementation / demo of one possible way to deal with unit systems. In my
UnitSystemobject, you can override base unit combinations by specifying composite units. For example, this unit system would always convert down to combinations of base units:But this has a specified representation for 'speed'-like units, so it doesn't return kpc/Myr:
(note: I chose not to monkey-patch the
.decompose()method onQuantity, thats why this special method call is on the unit system instead).The
UnitSystemthen acts like a dictionary for physical types (which, right now, are strings):If the (non-base) physical type wasn't specified on creation, it puts together the base units:
Unit("solMass / (kpc Myr2)")
jobovy commentedon Jan 4, 2016
I'm looking into using the Units framework for galpy and stumbled on this issue; obviously having a
galacticunit system would make that support much easier!I only glanced through the thread, but wouldn't many of the issues raised here be resolved by not having time as a fundamental unit (i.e., just have length and velocity; similar to WD_units in NEMO)? If you use
kpcandkm/s, the derived time unit would be ~Gyr.Also don't see how there can be any argument against
kpcas the appropriate length unit for galaxies (there's fewer than 1 star / pc^3 near the Sun...). And Gyr is much closer to the dynamical time thanMyr...adrn commentedon Apr 12, 2021
Closed to discuss the broader issue in #11525