Convert geometry objects to & from JSON compatible dicts#123
Conversation
|
My first thought, and it's something I regret way too often already, is whether we want to add some format version information to said JSON? This can quickly escalate the reading code, but if we introduce changes only sparingly, may allow us that one really useful break in format later down the road. |
|
That's a good point - I think it's always worth giving a data format some kind of version number. |
|
Hi @takluyver, thanks for starting this. The essential functions of EXtra-geom to me are: Thus, as long as it can provide the essential functions, I don't care if I think Version number is definitely needed. Based on the above, I think:
Not so much. But I'm not against making the current
I would suggest saving the details and being flexible with the exact numbers. Testing different parameters in simulation is essential and helpful for designing better detectors.
As long as
I don't know. But I feel self-consistency should be better assured. |
This is the first part of something @JunCEEE asked for: a way to roundtrip any geometry object to & from a text based format.
We can go to CrystFEL
.geomformat for a lot of detectors, but reading an arbitrary geometry file back gets complicated, because of some differences in how the information is represented. So my thinking was to add an option to make dicts suitable for saving as JSON, closely based on the internal model of EXtra-geom.This will need some care, because the information is likely to be saved and then reloaded with future versions of EXtra-geom, so we can't casually change things it relies upon (such as
detector_type_name).For starters, I have only implemented this for the specific detector types. There are some questions we'll need to answer to make it more generic:
GenericGeometryclass which limits modules to a single strip of tiles arranged along either the slow-scan or fast-scan axis - but this cannot represent LPD modules, with tiles in a 2 × 8 grid. In some ways the representation is easier if we allow totally arbitrary tile arrangements, but then we kind of need to make a more generic class to handle it..geomfiles), but more complicated if we stick to partially generic options.(I deliberately didn't add tests or docs yet, because I want to figure out what we're doing before that)