Skip to content

Pint's usage with Numpy's concatenate  #619

@winash12

Description

@winash12
import numpy as np

from pint import UnitRegistry

ureg = UnitRegistry()

Q_ = ureg.Quantity

args = []

for k in range(0,17):
   uwnd = Q_(np.ones((1,73,144)),'meter / second')
    args.append(uwnd)
uwndTot = np.vstack(args)
print(uwndTot.shape)
for element in args:
   print(type(element)

I am using Pint and when I print the shape uwndTot I get
(17,73,144).

When I print the values of element it turns out to be

<class 'pint.quantity.build_quantity_class..Quantity'>

However if I iterate through uwndTot I get

for element in uwndTot:
    print(type(element))

I get

<class 'numpy.ndarray'>

I want to be able to use numpy's concatenate with Pint. Is that not possible ? I need the units of meters /second in the 3d dimensional array uwndTot. How do I do that ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions