Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added DESCQAGEN directory to DESCQA #46

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions descqagen/app_mag_func_test/data/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This directory stores downloaded data products
Empty file.
57 changes: 57 additions & 0 deletions descqagen/app_mag_func_test/data/download_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
"""
run sql queries on HSC database
"""

from __future__ import print_function, division
import sys
sys.path.append("..")
from defaults import PROJECT_DIRECTORY, DATA_DIRECTORY


def main():
"""
run scripted SQL download.

to download the HSC data for this project, in the temrinal window type:
$user python download_data.py data

to download the HSC randoms for this project, in the temrinal window type:
$user python download_data.py randoms

Before running this script, edit the hsc_credentials.txt file in the sql directory.
"""

if sys.argv[1] == 'data':
sql_file = PROJECT_DIRECTORY + 'sql/hsc_data.sql'
savename = DATA_DIRECTORY + 'hsc_data.csv'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

savename is not used in the following script. Is this intended?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm, I dont see where the filename that is used to save the data is specified... let me try to reload this into my memory...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a gentle reminder: @duncandc any luck on solving this minor issue?

elif sys.argv[1] == 'randoms':
sql_file = PROJECT_DIRECTORY + 'sql/hsc_randoms.sql'
savename = DATA_DIRECTORY + 'hsc_randoms.csv'
else:
print("specify either 'data' or 'randoms' as a positional argument.")
sys.exit()

# read in username and password for HSC account
user_info_file = PROJECT_DIRECTORY + 'sql/hsc_credentials.txt'
f = open(user_info_file, 'r')
username = f.readline().strip()
password = f.readline().strip()
f.close()
if (username == 'username') | (password == 'password'):
print("Please alter the file: {0}, to be your username and password".format(user_info_file))
print("It is possible your username and password are 'username' and 'password'. Shame on you.")

# open sql query string
f = open(sql_file, 'r')
sql = f.read()
f.close()

# run query script
import subprocess
exec_script = PROJECT_DIRECTORY+'sql/hscReleaseQuery.py'
process = subprocess.call(['python', exec_script, '--user', username, '--password', password, sql_file])



if __name__ == "__main__":
main()
39 changes: 39 additions & 0 deletions descqagen/app_mag_func_test/data/hsc_data_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
cols = {'object_id':(0,'i8'),
'parent_id':(1,'i8'),
'ira':(2,'f4'),
'idec':(3,'f4'),
'imag_cmodel':(4,'f4'),
'imag_cmodel_err':(5,'f4'),
'iflux_cmodel_flags':(6,'bool_'),
'iflux_cmodel':(7,'f4'),
'iflux_cmodel_err':(8,'f4'),
'merge_measurement_i':(9,'f4'),
'a_g':(10,'f4'),
'a_r':(11,'f4'),
'a_i':(12,'f4'),
'a_z':(13,'f4'),
'a_y':(14,'f4'),
'rmag_forced_cmodel':(15,'f4'),
'rmag_forced_cmodel_err':(16,'f4'),
'rflux_forced_cmodel':(17,'f4'),
'rflux_forced_cmodel_err':(18,'f4'),
'rflux_forced_cmodel_flags':(19,'bool_'),
'imag_forced_cmodel':(20,'f4'),
'imag_forced_cmodel_err':(21,'f4'),
'iflux_forced_cmodel':(22,'f4'),
'iflux_forced_cmodel_err':(23,'f4'),
'iflux_forced_cmodel_flags':(24,'bool_'),
'gmag_forced_cmodel':(25,'f4'),
'zmag_forced_cmodel':(26,'f4'),
'ymag_forced_cmodel':(27,'f4'),
'tract':(28,'f4'),
'patch':(29,'f4'),
'gcountinputs':(30,'f4'),
'rcountinputs':(31,'f4'),
'icountinputs':(32,'f4'),
'zcountinputs':(33,'f4'),
'ycountinputs':(34,'f4'),
'iflags_pixel_bright_object_center':(35,'bool_'),
'iflags_pixel_bright_object_any':(36,'bool_'),
'iblendedness_flags':(37,'bool_'),
'iblendedness_abs_flux':(38,'f4')}
13 changes: 13 additions & 0 deletions descqagen/app_mag_func_test/data/hsc_randoms_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
cols = {'object_id':(0,'i8'),
'ra':(1,'f4'),
'dec':(2,'f4'),
'tract':(3,'f4'),
'patch':(4,'f4'),
'gcountinputs':(5,'f4'),
'rcountinputs':(6,'f4'),
'icountinputs':(7,'f4'),
'zcountinputs':(8,'f4'),
'ycountinputs':(9,'f4'),
'iflags_pixel_bright_object_center':(10,'bool_'),
'iflags_pixel_bright_object_any':(11,'bool_')
}
4 changes: 4 additions & 0 deletions descqagen/app_mag_func_test/defaults.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import os

PROJECT_DIRECTORY = os.path.dirname(os.path.abspath(__file__))+'/'
DATA_DIRECTORY = PROJECT_DIRECTORY + 'data/'
Loading