pynbody / tangos

The Agile Numerical Galaxy Organisation System
BSD 3-Clause "New" or "Revised" License
19 stars 13 forks source link

Importing non-numeric properties from halo finder #156

Closed Martin-Rey closed 2 years ago

Martin-Rey commented 3 years ago

Hi @apontzen and @mtremmel ,

I have a case where I would like to import a numpy array as a pre-calculated property through the tangos-import command. However, the code here https://github.com/pynbody/tangos/blob/1d7e837b731e974087ceda4bcb61a1730be0243a/tangos/tools/property_importer.py#L34-L46 can only take float or integer values and will skip any other import otherwise.

Numpy arrays are pretty generic across other Tangos properties (a centre in x, y, z for example, or a pre-calculated density profile) but they will get skipped every time by this exclusion loop. Is there a reason why array properties cannot be currently imported through the tangos-import command (or anything else than float and integers for that matter)?

Best, Martin

apontzen commented 2 years ago

I don't think there is a particular reason that numpy arrays are ignored. It's probably an oversight, and an extra condition should be added.

Martin-Rey commented 2 years ago

I see. I'm happy to add a further test to include numerical numpy arrays.

As a curiosity, is the rest of Tangos forbidding non-numerical properties? I don't think I ever tried, but I couldn't store a boolean, or a string in the database?

apontzen commented 2 years ago

The actual mechanism by which things are stored in the database is all here:

https://github.com/pynbody/tangos/blob/master/tangos/core/data_attribute_mapper.py

Currently there aren't any mechanisms for strings or booleans. Of course a boolean could be stored as an int...