Skip to content

Commit

Permalink
Doc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
hover2pi committed Feb 20, 2016
1 parent 25e1383 commit d23c830
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 22 deletions.
26 changes: 18 additions & 8 deletions astrodbkit/astrodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,11 @@ def inventory(self, source_id, plot=False, fetch=False):
"""
data_tables = {}
try:
for table in ['sources']+[t for t in self.query("SELECT * FROM sqlite_master WHERE type='table'", unpack=True)[1] if t not in ['sources','sqlite_sequence']]:

for table in ['sources']+[t for t in zip(*self.list("SELECT * FROM sqlite_master WHERE type='table'"))[1] if t not in ['sources','sqlite_sequence']]:

try:

# Get the columns, pull out redundant ones, and query the table for this source's data
columns, types = self.query("PRAGMA table_info({})".format(table), unpack=True)[1:3]

Expand All @@ -301,20 +303,28 @@ def inventory(self, source_id, plot=False, fetch=False):
try:
id = 'id' if table.lower()=='sources' else 'source_id'
data = self.query("SELECT {} FROM {} WHERE {}={}".format(','.join(columns),table,id,source_id), fmt='table')
except: data = None

if not data and table.lower()=='sources':
print 'No source with id {}. Try db.search() to search the database for a source_id.'.format(source_id)

except:
data = None

# If there's data for this table, save it
if data:
data_tables[table] = data
data = data[list(columns)]
if not fetch: pprint(data, title=table.upper())
if not fetch: pprint(data, title=table.upper())

# Plot all the spectra
if plot and table.lower()=='spectra' and data:
for i in self.query("SELECT id FROM spectra WHERE source_id={}".format(source_id), unpack=True)[0]:
self.plot_spectrum(i)

else: pass

if plot:
for i in self.query("SELECT id FROM spectra WHERE source_id={}".format(source_id), unpack=True)[0]: self.plot_spectrum(i)

except: print 'No source with id {}. Try db.identify() to search the database for a source_id.'.format(source_id)
except:
print 'Could not retrieve data from {} table.'.format(table.upper())

if fetch: return data_tables

Expand Down
7 changes: 0 additions & 7 deletions docs/astrodb.rst

This file was deleted.

7 changes: 0 additions & 7 deletions docs/votools.rst

This file was deleted.

3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
numpy
astropy
matplotlib

0 comments on commit d23c830

Please sign in to comment.