Last active
August 29, 2015 14:05
-
-
Save dannygoldstein/48d318553a3621994206 to your computer and use it in GitHub Desktop.
query to get fakes from a subtraction
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
import cx_Oracle | |
username = 'your_username' | |
password = 'your_password' | |
dsn = 'leovip148.ncsa.uiuc.edu/destest' | |
db = cx_Oracle.connect(username, password, dsn) | |
cursor = db.cursor() | |
cursor.execute('begin fixSynonyms(\'\',\'SNY1REPROC\'); end;') # this points you to the right | |
# tablespace | |
sub_name = 'SNp1_259300_SN-E2_combined_g_08+fakeSN_diff_mh.fits' # for the sake of example | |
query = 'SELECT DISTINCT SNFAKE_ID FROM SNOBS ' \ | |
'WHERE IMAGE_NAME_DIFF = :sub_name AND SNFAKE_ID != 0' | |
cursor.execute(query, sub_name=sub_name) | |
result = cursor.fetchall() |
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
[(247023,), (247024,), (247022,), (247021,), (216601,), (216753,)] |
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
import cx_Oracle | |
username = 'your_username' | |
password = 'your_password' | |
dsn = 'leovip148.ncsa.uiuc.edu/destest' | |
db = cx_Oracle.connect(username, password, dsn) | |
cursor = db.cursor() | |
cursor.execute('begin fixSynonyms(\'\',\'SNY1REPROC\'); end;') # this points you to the right | |
# tablespace | |
sub_name = 'SNp1_259300_SN-E2_combined_g_08+fakeSN_diff_mh.fits' # for the sake of example | |
query = 'SELECT DISTINCT c.ID FROM (SNOBS o JOIN SNFAKE f on o.SNFAKE_ID = f.ID) '\ | |
'JOIN SNCAND c ON (f.ra > c.ra - :tol AND f.ra < c.ra + :tol and f.dec > '\ | |
'c.dec - :tol and f.dec < c.dec + :tol) WHERE o.IMAGE_NAME_DIFF = :sub_name AND o.SNFAKE_ID != 0' | |
cursor.execute(query, sub_name=sub_name, tol=0.0001) | |
result = cursor.fetchall() |
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
[(1059883,), (1060191,), (1059887,), (1059889,), (1059884,), (1060190,)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment