Writing zero-sized datasets in snapshots instead of omitting them when npart=0
This is a small annoyance with Swift/Gadget snapshots which I've been reminded about while working on the halo properties code. It's not urgent but it might be nice to fix for future runs.
Both Swift and Gadget omit particle datasets from the snapshot if the dataset would have zero size. In my experience this is a source of bugs. Analysis code typically works fine at z=0 but then falls over on earlier snapshots where datasets are missing because stars or black holes haven't formed yet and the code doesn't contain all of the necessary 'if n=0' special casing.
It's also a problem with multi-file snapshots. If you want to find which datasets are present you need to keep opening files until you've seen at least one particle of each type. And if you have MPI processes reading different files then communication is needed to make sure everyone agrees on which datasets are present and their data types and units.
Would it be practical to have Swift always create the same set of datasets in every snapshot file within a run, and just make the leading dimension zero if there are no particles? E.g a snapshot with star formation enabled but no stars formed yet would have a (0,3) Coordinates dataset of the appropriate data type and with unit attributes attached.