<p>I can assign a unit to a scalar using:
x = YTQuantity(scalar, 'kpc')</p>
<p>but how would I specify that the unit should be kpccm? Perhaps it doesn't even make sense to do so? Something as simple as this is not the answer:
x = YTQuantity(scalar, 'kpccm')</p>
<p>Thank you,
Paul</p>

CC BY-SA 4.0
2022-03-07T13:09:23.163Z
Your question clearly is about programming, but definitely misses some context. Most notably the language and the package(s) you are working with. Also: What unit is kpccm? It's not anything self-explanatory to me
planetmaker
CC BY-SA 4.0
2022-03-07T13:11:04.803Z
According to the [documentation](https://yt-project.org/doc/analyzing/units.html#comoving-units-for-cosmological-simulations), it seems to me that it _is_ in fact as simple as appending 'cm' to a length unit.
pela
CC BY-SA 4.0
2022-03-07T13:12:56.070Z
@planetmaker "yt" is a very astro-specific Python package for analyzing 3D data, and the "cm" should be the specificer for **c**o**m**oving units
pela
<cosmology><units>
How do I create a comoving quantity using YT?
Paul
# How do I create a comoving quantity using YT?

(Asked by: username_0 on 2022-03-07)

I can assign a unit to a scalar using:
x = YTQuantity(scalar, 'kpc')

but how would I specify that the unit should be kpccm? Perhaps it doesn't even make sense to do so? Something as simple as this is not the answer:
x = YTQuantity(scalar, 'kpccm')

Thank you,
Paul

**Tags:** cosmology, units
> **Comments:**
> **username_1**: Your question clearly is about programming, but definitely misses some context. Most notably the language and the package(s) you are working with. Also: What unit is kpccm? It's not anything self-explanatory to me  
> **username_2**: According to the [documentation](https://yt-project.org/doc/analyzing/units.html#comoving-units-for-cosmological-simulations), it seems to me that it _is_ in fact as simple as appending 'cm' to a length unit.  
> **username_2**: @planetmaker "yt" is a very astro-specific Python package for analyzing 3D data, and the "cm" should be the specificer for **c**o**m**oving units  

---

## 0 answers

