In [1]:
%pylab inline
from astropy.io import fits as pyfits
from astropy.table import Table,join
import numpy as np
from astropy.io.fits import Column
from datetime import datetime
import matplotlib.pyplot as plt
import requests
warnings.filterwarnings('ignore', category=RuntimeWarning, append=True)
warnings.filterwarnings('ignore', category=UserWarning, append=True);
In [2]:
# Load data from Dropbox folder instead of clogging up Github
def download_from_dropbox(url):
local_filename = "../{:}".format(url.split("/")[-1].split("?")[0])
r = requests.get(url, stream=True)
with open(local_filename, 'wb') as f:
for chunk in r.iter_content(chunk_size=1024):
if chunk: # filter out keep-alive new chunks
f.write(chunk)
f.flush()
return local_filename
In [ ]:
# 3 tables:
# Table 1 - gz_hst_table_raw_and_weighted_votes.fits; contains all the vote data except for goods_full, but I hope to add that as soon as I get that data.
votes_fname = download_from_dropbox("https://www.dropbox.com/s/drdl6mht4kh2d7m/gz_hst_table_raw_and_weighted_votes.fits?dl=1")
votes_data = Table.read(votes_fname)
# Table 2 - lo_hi_limits.fits: just need low, high limits on p_features (2 columns).
lohi_fname = download_from_dropbox("https://www.dropbox.com/s/n1zxkqe3q9rx2ve/lo_hi_limits.fits?dl=1")
lohi_data = Table.read(lohi_fname)
#Table 3 - gzh_t01_z_mu_categorized.fits, want z, mu, and category information (4 columns)
meta_fname = download_from_dropbox("https://www.dropbox.com/s/hppphpzujretywn/gzh_t01_z_mu_categorized.fits?dl=1")
meta_data = Table.read(meta_fname)
In [4]:
lohi_data.remove_column('Z_BEST')
lohi_data.remove_column('GZ_MU_I')
lohi_data.remove_column('OBJNO')
lohi_data.remove_column('survey_id')
lohi_data.remove_column('Table')
lohi_data.remove_column('t01_smooth_or_features_a02_features_or_disk_weighted_fraction')
meta_data.remove_column('OBJNO')
meta_data.remove_column('survey_id')
meta_data.remove_column('Table')
meta_data.remove_column('Correctable_Category')
meta_data.remove_column('t01_smooth_or_features_a02_features_or_disk_weighted_fraction')
In [5]:
#Join Table 2 and Table 3- will have z, mu, low/hi limits on p_features
lohi_meta = join(meta_data, lohi_data, keys='zooniverse_id',join_type='left')
In [6]:
meta_data[0]
Out[6]:
In [7]:
votes_data[0]
Out[7]:
In [8]:
#strip Table names of blank spaces:
for i in range(0,len(votes_data)):
votes_data['Table'][i]=votes_data['Table'][i].strip()
In [9]:
#join Table 1 (votes + Imaging) with the other stuff:
input_table=join(votes_data,lohi_meta,keys='zooniverse_id',join_type='left')
In [10]:
len(input_table)
Out[10]:
In [11]:
#Set path for output
fname = '/home/mel/Dropbox/gzhubble/hubble_files/catalog_debiasing_files/new_sb_method/input_for_hubble_debiased_catalog.fits'
input_table.write(fname,overwrite=True)
In [ ]: