GeoMop / MLMC

5 stars 2 forks source link

Quantity object does not have access to QuantitySpec object. #187

Open Paulie14 opened 2 years ago

Paulie14 commented 2 years ago

It would be nice to get from Quantity its QuantitySpec - get name, unit, time axis etc..

Currently, I have to get QuantitySpec by sample_storage.load_result_format() and search for selected quantity. When moving around, I have to pass QuantitySpec and Quantity together manually.

Paulie14 commented 2 years ago

I created auxiliary function fot that:

    def get_quantity(self, result_format, root_quantity, quantity_name):

        iqspec, qspec = next(((i, q) for i, q in enumerate(result_format) if q.name == quantity_name), (0, None))
        assert qspec is not None

        quantity = root_quantity[quantity_name]
        return qspec, quantity