flo-schu / pymob

Python model building platform
MIT License
0 stars 0 forks source link

Refactor: Harmonize coordinate handling #92

Open flo-schu opened 2 weeks ago

flo-schu commented 2 weeks ago

sim.coordinates are modified by a whole bunch of different methods in different contexts. They need to track the sometimes unique and non-unique indices of the different dimensions of the data and the parameters. If they are combined with indices they are non-unique and otherwise they are unique. Maybe coordinates should also get a config section. The problem is that coordinates emerge from the data, but maybe this should not prevent me from using coordinates in the config section. This goes hand in hand together with providing an interface for specifying an experimental setup (indices and coordinates). Remember that sim.coordinates provide a simple way to interact with the coordinates of the simulation. Try not to make it too complex; and in the config backend I will not have access to the dimensions and parameters. So, I think I already decided that it is a simulation level object, but the API should be simpler

flo-schu commented 2 weeks ago

sim.dimension_coords are a hot candidate for harmonization, because they look in multiple places for coordinates and obtain them from multiple dimensions

self.data_structure.dimensions:

look up coordinates in self.coordinates

self.model_parameters.dimensions:

look up coordinates in self.coordinates and self.indices and create an unsorted unique coordinate list. Finally they check if the added unique coordinates were already in the self.coordinates and raise an error if they exists

Together they comprise an exhaustive list of any coordinates relevant to the simulation.

ON top of that: self.parameter_shapes gives a dictionary of the shapes of the parameters. A dictionary self.dimension_shapes could give simply a count dictionary of the counts of the coordinates mapped to the dimensions.

self.data_shapes could be analogous to self.parameter_shapes.

**Renaming of the properties is recommended. E.g.

With this work, also address subsetting of coordinates. self.coordinates should probably remain exposed as a user interface to subset time, batch and other coordinates