njcuk9999 / lbl

Line by line code for radial velocity
MIT License
15 stars 3 forks source link

NaN in drift corrected .rdb files #42

Open CharlesCadieux opened 7 months ago

CharlesCadieux commented 7 months ago

(SPIRou) The exact BJD time between _AB and _C files differ inside lbl_OBJECT_TEMPLATE.rdb and drift.rdb files which insert Nan in the drift corrected version.

Bug found by @clairem789 which can be solved by changing line 2754 in lbl/science/general.py to: file_mask = np.abs(timestamp[row] - drift_table['rjd']) < 0.0007 # less than 1 minute

We need to decide if we apply this fix or we try to understand why the BJD time differ in the first place.

njcuk9999 commented 7 months ago

Is this the BJD of the template that differs or between individual observations


If it is the template:

If I had to guess I would say this is because the BJD given in the template is a combination of all the input files and we are probably for some reason (like a crash) missing a pair of "AB" and "C" files (e.g. one too few AB or one to many C files) you should be able to find out what files went into the template and match them between AB and C to confirm this. Or maybe its AB files that have a DARK in the C fiber?

But yer I imagine some condition like this should be a good safety fix. You probably then should make sure only one of the BJDs (or a mean of both) is used after that point.

As for a more permanent fix, where are the templates being created? in APERO or in LBL? In APERO we could have a check that we had the same number of AB and C files, but in LBL it is harder as we make the the AB template and the C template (FP) separately.


If it is the individual observations maybe I'm more confused as the BJD is worked out in the extraction recipe before we extract AB and C do the files names for each row match? Maybe we are missing a file and everything goes off? What is the delta time between AB and C? Looking at the table where timestamp and drift_table come from may shed some light on this.


I think either way I would investigate this before implementing - if there is a reasonable explanation as to why it is happening (like a missing file in a mean of BJDs for the template) I'm fine with having a < 0.0007 if there is a bug and they should always be exactly the same time we should fix it and not just hide it behind this condition - I'd rather check in LBL and display a warning/error that AB and C don't match (if we can't find a good/reasonable explanation that means this is okay)