<jupyter_start><jupyter_text>Feature analysis on SDSS (non-lens) galaxies Author: <NAME> (mbaumer)This notebook includes some feature analysis on the SDSS (non-lens) galaxies. While it starts with some querying, the querying component has migrated to the `slrealizer/Preprocessing+the+SDSS+non-lens+catalog.ipynb` notebook.<jupyter_code>data.columns<jupyter_output><empty_output><jupyter_text>Cuts on Reasonableness<jupyter_code># no crazy magnitudes
data = data[(data['u'] < 30) & (data['u'] > 0)]
data = data[(data['g'] < 30) & (data['g'] > 0)]
data = data[(data['r'] < 30) & (data['r'] > 0)]
data = data[(data['i'] < 30) & (data['i'] > 0)]
data = data[(data['z'] < 30) & (data['z'] > 0)]

data = data[(data['err_u'] < 3)]
data = data[(data['err_g'] < 3)]
data = data[(data['err_r'] < 3)]
data = data[(data['err_i'] < 3)]
data = data[(data['err_z'] < 3)]

# no crazy offsets between bands (to deal with bad matches)
data = data[(data['offsetRa_u'] < 4) & (data['offsetRa_u'] > -4)]
data = data[(data['offsetRa_g'] < 4) & (data['offsetRa_g'] > -4)]
data = data[(data['offsetRa_r'] < 4) & (data['offsetRa_r'] > -4)]
data = data[(data['offsetRa_i'] < 4) & (data['offsetRa_i'] > -4)]
data = data[(data['offsetRa_z'] < 4) & (data['offsetRa_z'] > -4)]

data = data[(data['offsetDec_u'] < 4) & (data['offsetDec_u'] > -4)]
data = data[(data['offsetDec_g'] < 4) & (data['offsetDec_g'] > -4)]
data = data[(data['offsetDec_r'] < 4) & (data['offsetDec_r'] > -4)]
data = data[(data['offsetDec_i'] < 4) & (data['offsetDec_i'] > -4)]
data = data[(data['offsetDec_z'] < 4) & (data['offsetDec_z'] > -4)]

data = data[(~np.isnan(data['mE1_u'])) & (data['mE1_u'] < 15) & (data['mE1_u'] > -15)]
data = data[(~np.isnan(data['mE1_g'])) & (data['mE1_g'] < 15) & (data['mE1_g'] > -15)]
data = data[(~np.isnan(data['mE1_r'])) & (data['mE1_r'] < 15) & (data['mE1_r'] > -15)]
data = data[(~np.isnan(data['mE1_i'])) & (data['mE1_i'] < 15) & (data['mE1_i'] > -15)]
data = data[(~np.isnan(data['mE1_z'])) & (data['mE1_z'] < 15) & (data['mE1_z'] > -15)]

data = data[(~np.isnan(data['mE2_u'])) & (data['mE2_u'] < 15) & (data['mE2_u'] > -15)]
data = data[(~np.isnan(data['mE2_g'])) & (data['mE2_g'] < 15) & (data['mE2_g'] > -15)]
data = data[(~np.isnan(data['mE2_r'])) & (data['mE2_r'] < 15) & (data['mE2_r'] > -15)]
data = data[(~np.isnan(data['mE2_i'])) & (data['mE2_i'] < 15) & (data['mE2_i'] > -15)]
data = data[(~np.isnan(data['mE2_z'])) & (data['mE2_z'] < 15) & (data['mE2_z'] > -15)]

data = data[(data['mRrCc_u'] < 300) & (data['mRrCc_u'] > -300) & (np.abs(data['mRrCc_u']) > 1)]
data = data[(data['mRrCc_g'] < 300) & (data['mRrCc_g'] > -300) & (np.abs(data['mRrCc_g']) > 1)]
data = data[(data['mRrCc_r'] < 300) & (data['mRrCc_r'] > -300) & (np.abs(data['mRrCc_r']) > 1)]
data = data[(data['mRrCc_i'] < 300) & (data['mRrCc_i'] > -300) & (np.abs(data['mRrCc_i']) > 1)]
data = data[(data['mRrCc_z'] < 300) & (data['mRrCc_z'] > -300) & (np.abs(data['mRrCc_z']) > 1)]

data = data[(data['mE1E1Err_u'] > 0)]
data = data[(data['mE1E1Err_g'] > 0)]
data = data[(data['mE1E1Err_r'] > 0)]
data = data[(data['mE1E1Err_i'] > 0)]
data = data[(data['mE1E1Err_z'] > 0)]

#redundant if e1 err cuts pass, but w/e
data = data[(data['mE2E2Err_u'] > 0)]
data = data[(data['mE2E2Err_g'] > 0)]
data = data[(data['mE2E2Err_r'] > 0)]
data = data[(data['mE2E2Err_i'] > 0)]
data = data[(data['mE2E2Err_z'] > 0)]

#define normalized ellipticities
e1_u = data.mE1_u
e1_g = data.mE1_g
e1_r = data.mE1_r
e1_i = data.mE1_i
e1_z = data.mE1_z

e2_u = data.mE2_u
e2_g = data.mE2_g
e2_r = data.mE2_r
e2_i = data.mE2_i
e2_z = data.mE2_z

offset_u = np.sqrt(data.offsetRa_u**2+data.offsetDec_u**2)
offset_g = np.sqrt(data.offsetRa_g**2+data.offsetDec_g**2)
offset_r = np.sqrt(data.offsetRa_r**2+data.offsetDec_r**2)
offset_i = np.sqrt(data.offsetRa_i**2+data.offsetDec_i**2)
offset_z = np.sqrt(data.offsetRa_z**2+data.offsetDec_z**2)

def offset_between_bands(band1,band2):
    return np.sqrt((data['offsetRa_'+band1]-data['offsetRa_'+band2])**2
                   +(data['offsetDec_'+band1]-data['offsetDec_'+band2])**2)
len(data)<jupyter_output><empty_output><jupyter_text>Magnitudes/Colors<jupyter_code>corner(np.array([data.i,data.u-data.g,data.g-data.r,data.r-data.i,data.i-data.z]).T,labels=['i','u-g','g-r','r-i','i-z']);
corner(np.array([offset_u,offset_g,offset_i,offset_z]).T,bins=100,labels=['offset u','offset g','offset i','offset z']);
corner(np.array([e1_u,e1_g,e1_r,e1_i,e1_z]).T,labels=['e1_u','e1_g','e1_r','e1_i','e1_z']);
corner(np.array([e2_u,e2_g,e2_r,e2_i,e2_z]).T,labels=['e2_u','e2_g','e2_r','e2_i','e2_z']);
plt.hist(np.sqrt(data['mRrCc_u']/np.pi),bins=100);
plt.hist(np.sqrt(data['mRrCcPSF_u']/np.pi),bins=100);
plt.title('Galaxies are much bigger than the PSF')
plt.xlabel('Object radius (pixels)')<jupyter_output><empty_output><jupyter_text>Creating a "source-like" data table...or maybe we need the object table at this point?Yeah, I'm going with object tables, both bc it's simpler and since we need multiband info!<jupyter_code>data.columns
len(data)
fits.writeto('sdss_for_jenny.fits',data)
#test
data2 = fits.getdata('sdss_for_jenny.fits')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.24747278382581647, 'fraction_numerical': 0.04743390357698289, 'mean_word_length': 6.2772277227722775, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '178487', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 2533, 'n_tokens_neox': 2373, 'n_words': 363, 'path': 'slrealizer/demo/SDSS+Galaxies+Feature+Analysis.ipynb', 'repo_name': 'LSSTDESC/SLRealizer', 'size': '5149'}