simularium / simulariumio

Python package that converts simulation outputs to the format consumed by the Simularium viewer website
Apache License 2.0
5 stars 3 forks source link

Center Smoldyn and MEDYAN data #145

Closed blairlyons closed 1 year ago

blairlyons commented 1 year ago

Use Case

As a computational user with data from Smoldyn or MEDYAN, I want to be able to center my spatial data as a part of the conversion process so that I don't have to filter it in a separate step after converting.

Acceptance Criteria

SmoldynData and MedyanData have a new center bool member that defaults to True and if True, the spatial values of the data are centered around the origin (0, 0, 0) during conversion.

Details

The examples notebooks for Smoldyn and MEDYAN include an extra step for filtering with the TranslateFilter after conversion. We want to elimate the need for this step.

The implementation of TranslateFilter shows basically how we want to do this, except there will be one translation value that is used for every agent, instead of different translations for different agent IDs.

In order to get the translation amount, after we parse through the data, we can get the min and max values for X, Y, and Z using numpy slicing, and then offset all the positions by -0.5 * (max - min).