If I had started the
from gammapy.data import DataStore from gammapy.background import OffDataBackgroundMaker def test_background_model(): data_store = DataStore.from_dir('$GAMMAPY_EXTRA/datasets/hess-crab4-hd-hap-prod2/') out_dir = # somewhere where all temp / output files will go bgmaker = OffDataBackgroundMaker(data_store, out_dir) bgmaker.select_observations( ... options ... ) bgmaker.group_observations( ... options ... ) bgmaker.make_model(... options ... ) bgmaker.save() if __name__ == '__main__': test_background_model()
And then I'd comment in / out the method calls for the steps I want to test.
I'm not sure about how exactly the class should work. There's many detailed decisions to make, e.g. when to store things on disk or only as members on the
Actually it could be useful to have two or three such small
But that can also be done later ... the most important thing is that you get this example working with the new class (and get the same output):
Yes, I think in principle it's nicer if the user has control over when / what gets saved to disk.
There could also be some more control like:
and most users would use the default:
which saves the main result or also debug intermediate results (like counts, exposure cubes), to a given output folder.
But if you prefer to handle it some other way, that's fine with me, too.
You could also have a look at this class as an example, which is of similar purpose (run some algorithm, save some output):
I'm not saying that one is very well done or you should follow the same pattern ... just an example to look at before you implement things here in a way you like.