Change candidate file writing to facilitate faster single candidate retrieval#115
Conversation
|
Would you mind double checking the detection statistic still reads and writes correctly with the new dict method? As I recall that was the pain in the patella when reading/writing candidates. The observation id used to do the same thing but doesn't anymore. |
|
It sounds like this is a pretty good trade off, but I'm not 100% sure. Is this only a thing you're doing to make test ML sets? Or do you think it will it be a regular part of the ML pipeline? |
I remember there having been some trouble with it as well, but it now worked. I wanted to also check if I can improve things for the multi-pointing writing, but not sure yet what exactly to do there. A while ago I changed it to use attr.asdict() instead of the as_dict method to but just .dict is faster. I think in general one can just just use the .dict method and if something does not work, fix it in the post init.
I have not heard that expression, but I have luxated my patella once which was the absolute worst.^^ |
Hmm, I checked the stack search for 10k pointings and there reading took 6 minutes and clustering 8. With this PR with the new format I suppose reading would take 3 minutes( with the old format) and 4 with the new one. Checked a single day with 2500 pointings and there reading and clustering took like 70 and 150 seconds respectively. So, I think reading there is not the most expensive operation. If we want to speedup that operation I could also consider splitting up candidates further up in the npz file, so we don't need to read all the arrays if we do not need them. I'll think about it and test to see if that makes sense. I am still a bit torn whether I want to throw the classifiers on all single pointing candidates or just a subset of those based on the multi pointing result. In the latter case the performance would profit greatly from using the new format. |

This PR includes the following minor changes:
data["candidate_dicts"]twice, when data is a npz file loaded with np.load, it will load the candidates twice.The major change is the introduction of the
split_candsargument in spcc.write. When this is used, the different candidates are saved separately into different keys of the npz file. Sincenp.loadloads npz files lazily, this allows quick retrieval of individual candidates without loading all candidates. But when loading all candidates it is a bit slower. From my tests up to 50% but it is still faster than previously because of the double reading issue.Whether this option is really used, depends on how often each files is read in which mode.
From my parts of the pipeline I read all candidates during the multi pointing clustering, but I do not write the individual candidates into the mp candidates files, to not write redundant data. This would be slower with this option.
But as part of my ML efforts when I create test sets, I read sp candidates based on the mp candidates. In this case the new method is probably more than 10 times faster usually.
Are there any more reads of the sp candidates?
A picture illustrating the performance of full and partial reading of SinglePointingCandidateCollections based on the method.
Any thoughts?