Last active
August 29, 2015 14:06
-
-
Save LeoHuckvale/132197408345d6daa3b3 to your computer and use it in GitHub Desktop.
Joining two lists of MJDs (or any two lists of floats) to within some tolerance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mjd_join(mjd1, mjd2, tol=0.0001): | |
""" | |
Return indices of rows in mjd1 and mjd2 matching within tol | |
""" | |
diff = abs(mjd1 - mjd2[:, np.newaxis]) | |
match = diff < tol | |
idx1 = np.mgrid[:len(mjd1), :len(mjd2)][0].T[match] | |
idx2 = np.mgrid[:len(mjd1), :len(mjd2)][1].T[match] | |
return idx1, idx2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example use with two similar lightcurves,
lc1
andlc2
: