Last active
          August 29, 2015 13:59 
        
      - 
      
- 
        Save joezuntz/10840618 to your computer and use it in GitHub Desktop. 
    My script for plotting im3shape versus truth in the end-end test
  
        
  
    
      This file contains hidden or 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 astropy.table | |
| import numpy as np | |
| import pylab | |
| # Filenames | |
| im3shape_cat = 'im3shape-end2end-v3.fits.gz' | |
| truth_cat = 'end2end-truth.fits.gz' | |
| match_cat = 'match.fits.gz' | |
| #Load in data | |
| im3shape = astropy.table.Table.read(im3shape_cat, format='fits') | |
| truth = astropy.table.Table.read(truth_cat, format='fits') | |
| match = astropy.table.Table.read(match_cat, format='fits') | |
| #The MEDS index is not the same as the MEDS object number | |
| #They are off by one | |
| indices = im3shape['identifier'] - 1 | |
| #Space for results | |
| n = len(indices) | |
| true1 = np.zeros(n) | |
| true2 = np.zeros(n) | |
| fit1 = np.zeros(n) | |
| fit2 = np.zeros(n) | |
| #Loop through rows in im3shape catalogs | |
| for row in xrange(n): | |
| #Find matching row in truth catalog | |
| index = indices[row] | |
| truth_index = int(match['index'][index]) | |
| # Skip if truth = -999 (I assume this means star or not real or something?) | |
| # So there will be a bunch of (true,fit) = (0,0) - important | |
| # to mask them if e.g. fitting a line | |
| if truth['true_g1'][truth_index] <-900: | |
| continue | |
| #Get truth and fit for this row in each catalog | |
| fit1[row] = im3shape['e1'][row] | |
| true1[row] = truth['true_g1'][truth_index] | |
| fit2[row] = im3shape['e2'][row] | |
| true2[row] = truth['true_g2'][truth_index] | |
| # Plot e1 | |
| pylab.figure(figsize=(6,6)) | |
| pylab.plot(true1, fit1, '.', markersize=1) | |
| pylab.grid() | |
| pylab.xlim(-0.5,0.5) | |
| pylab.ylim(-0.5,0.5) | |
| pylab.xlabel("True g1") | |
| pylab.ylabel("Im3shape e1") | |
| pylab.savefig("im3shape-truth-e1.png") | |
| pylab.close() | |
| # Plot e2 | |
| pylab.figure(figsize=(6,6)) | |
| pylab.plot(true2, fit2, '.', markersize=1) | |
| pylab.grid() | |
| pylab.xlim(-0.5,0.5) | |
| pylab.ylim(-0.5,0.5) | |
| pylab.xlabel("True g2") | |
| pylab.ylabel("Im3shape e2") | |
| pylab.savefig("im3shape-truth-e2.png") | |
| pylab.close() | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
Creating a “truth table” is not hard, you can use an useful tool (CKod, at http://ckod.sourceforge.net/_/) to make a “truth table”.
Good luck to you!