In [1]:
# This changes the current directory to the base saga directory - make sure to run this first!
# This is necessary to be able to import the py files and use the right directories,
# while keeping all the notebooks in their own directory.
import os
import sys

if 'saga_base_dir' not in locals():
    saga_base_dir = os.path.abspath('..')

if saga_base_dir not in sys.path:
    os.chdir(saga_base_dir)

In [2]:
from __future__ import print_function, division

from collections import Counter, OrderedDict

import hosts
import targeting
import mmthecto
import numpy as np

from astropy import units as u
from astropy.coordinates import *
from astropy import table
from astropy.visualization import hist as ahist

In [3]:
%matplotlib inline
from matplotlib import pyplot as plt
from matplotlib import rcParams
from matplotlib import patches

rcParams['image.interpolation'] = 'none'
rcParams['figure.figsize'] = (16, 10)
plt.rcParams['image.cmap'] = 'viridis'

In [19]:
DATESUFFIX = 'oct2016'

In [104]:
proposed_targets = [126115, 150578, 135879, 132339, 129237, 161174]

Choose hosts and Load stuff


In [105]:
hostlst = hosts.get_saga_hosts_from_google() #'named' hosts


Using cached version of google hosts list from file "hosts_dl.pkl2"

In [106]:
hosts_to_target = []
for nsanum in proposed_targets:
    for h in hostlst:
        if h.nsaid == nsanum:
            hosts_to_target.append(h)
            break
    else:
        # new target
        hosts_to_target.append(hosts.NSAHost(nsanum))
hosts_to_target


Out[106]:
[<hosts.NSAHost object w/ name 'Bandamanna' AKA: ['NGC7818', 'NSA126115']>,
 <hosts.NSAHost object w/ name 'NSA150578'>,
 <hosts.NSAHost object w/ name 'NSA135879'>,
 <hosts.NSAHost object w/ name 'Narnia' AKA: ['NGC1015', 'NSA132339']>,
 <hosts.NSAHost object w/ name 'NSA129237'>,
 <hosts.NSAHost object w/ name 'NSA161174'>]

In [107]:
# now set to the latest base catalogs
for h in hosts_to_target:
    h.fnsdss = 'SAGADropbox/base_catalogs/base_sql_nsa{0}.fits.gz'.format(h.nsaid)
    h._cached_sdss = None

In [108]:
# actually make sure they're loaded
torem = []
for h in hosts_to_target:
    try:
        h.get_sdss_catalog()
    except IOError:
        torem.append(h)
        print('Failed to load base catalog for', h, 'so removing from hosts_to_target')
        
hosts_to_target_orig = hosts_to_target[:]
for h in torem:
    hosts_to_target.remove(h)

In [109]:
# preview the catalog
hosts_to_target[0].get_sdss_catalog()


Out[109]:
<Table length=62799>
OBJIDRADECPHOTPTYPEPHOT_SGFLAGScleanSATURATEDBAD_COUNTS_ERRORBINNED1TOO_FEW_GOOD_DETECTIONSugrizu_errg_errr_erri_errz_errMODELMAGERR_UMODELMAGERR_GMODELMAGERR_RMODELMAGERR_IMODELMAGERR_ZEXTINCTION_UEXTINCTION_GEXTINCTION_REXTINCTION_IEXTINCTION_ZDERED_UDERED_GDERED_RDERED_IDERED_ZPETRORAD_UPETRORAD_GPETRORAD_RPETRORAD_IPETRORAD_ZPETRORADERR_UPETRORADERR_GPETRORADERR_RPETRORADERR_IPETRORADERR_ZDEVRAD_UDEVRADERR_UDEVRAD_GDEVRADERR_GDEVRAD_RDEVRADERR_RDEVRAD_IDEVRADERR_IDEVRAD_ZDEVRADERR_ZDEVAB_UDEVAB_GDEVAB_RDEVAB_IDEVAB_ZCMODELMAG_UCMODELMAGERR_UCMODELMAG_GCMODELMAGERR_GCMODELMAG_RCMODELMAGERR_RCMODELMAG_ICMODELMAGERR_ICMODELMAG_ZCMODELMAGERR_ZPSFMAG_UPSFMAGERR_UPSFMAG_GPSFMAGERR_GPSFMAG_RPSFMAGERR_RPSFMAG_IPSFMAGERR_IPSFMAG_ZPSFMAGERR_ZFIBERMAG_UFIBERMAGERR_UFIBERMAG_GFIBERMAGERR_GFIBERMAG_RFIBERMAGERR_RFIBERMAG_IFIBERMAGERR_IFIBERMAG_ZFIBERMAGERR_ZFRACDEV_UFRACDEV_GFRACDEV_RFRACDEV_IFRACDEV_ZQ_UU_UQ_GU_GQ_RU_RQ_IU_IQ_ZU_ZEXPAB_UEXPRAD_UEXPPHI_UEXPAB_GEXPRAD_GEXPPHI_GEXPAB_REXPRAD_REXPPHI_REXPAB_IEXPRAD_IEXPPHI_IEXPAB_ZEXPRAD_ZEXPPHI_ZFIBER2MAG_RFIBER2MAGERR_REXPMAG_REXPMAGERR_RPETROR50_RPETROR90_RPETROMAG_RSB_EXP_RSB_PETRO_RJJERRHHERRKKERRSPEC_ZSPEC_Z_ERRSPEC_Z_WARNPHOTOZPHOTOZ_ERRW1W1ERRW2W2ERRHOST_RAHOST_DECHOST_DISTHOST_VHOSTHOST_MKHOST_MRHOST_MGHOST_NSAIDHOST_SAGA_NAMERHOST_ARCMRHOST_KPCOBJ_NSAIDSATSPROBABILITY_CLASS1RESCALED_PROBABILITY_CLASS1REMOVETELNAMEMASKNAMEZQUALITYSPEC_CLASSSPECOBJIDSPEC_REPEATAifibermag_zrhostfibermag_rfibermag_uAgfibermag_iAzArdecAufibermag_gtyperaobjIDpsf_rpsf_upsf_zrhost_kpcphot_sgpsf_gpsf_iUBVRIpsf_Upsf_Bpsf_Vpsf_Rpsf_I
int64float64float64int16str40int64int32int64int64int64int64float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float64float64float32float32float32float32float32float32float32float32int32float32float32float64float64float64float64float64float64float64float64float64float64float64int64str48float64float64int64int64float64float64int64str6str48int64str2str48str48float32float32float64float32float32float32float32float32float32float64float32float32int16float64int64float32float32float32float64str40float32float32float32float32float32float32float32float32float32float32float32float32
12376802473516729570.99557512226720.75240998893GALAXY105656498651152100268435456014.285312.804411.937711.427911.02220.009490190.0009354070.0005734010.0005695790.001465530.2582060.04264840.0240650.01836030.03028810.2995140.220380.1598380.12120.085932421.499320.459719.321518.553117.90551.322351.341691.374611.435161.493630.3533290.1041880.05611470.04335490.07594780.0041268222.68170.01018192.499690.1598610.03929060.2405420.03503210.2627770.08029930.1104890.08033860.9997820.9997060.99576821.86160.91103220.76950.063272119.48140.024674118.58470.018275217.89880.032697921.83490.32635420.77070.13888219.61150.11771318.86140.11676118.16340.10388220.6550.11063418.96680.029520617.8810.028562817.24980.033274616.76050.03501371.01.00.00.00.00.0303149-0.0324050.005740950.0204381-0.004525980.00751923-0.001066030.00650571-0.01038880.003678180.2499210.0666017161.3660.050.247797159.0020.9999310.25448964.41670.9971710.37675961.94230.9930130.37910239.994118.79810.044300719.48140.02467410.7049811.2248819.638818.505163041920.875167629713.3850.10712.5690.12812.3650.1190.00770201-1.00-1.0-1.0-1.0-1.0-1.0-1.00.99557512226720.752409988932.47405242922309.00366211-24.1402868602-20.7677388042-19.9616489036126115Bandamanna0.05241931838680.49516960004126115-10.213378154151-1.0-1NSAned40.121216.76050.052419318386817.88120.6550.2203817.24980.08593240.15983820.75240998890.29951418.966830.995575122267123768024735167295719.611521.834918.16340.49516960004GALAXY20.770718.861413.704113.294712.298711.742710.874321.700321.352520.099719.379718.1949
12376802473516729590.9965874679920.75103360486STAR105656498651152100268435456021.787720.518719.631219.170618.53050.2500560.03531590.02575730.02580750.04495740.2500560.03531590.02575730.02580750.04495740.2995070.2203740.1598340.1211970.085930221.488220.298319.471419.049418.44461.357481.333221.312361.358031.363751.168720.06983740.05189940.05445270.02826170.024549999.8230.1221240.07703420.181750.07430630.2361050.05030960.2421910.1157330.09165620.2859760.2337450.6548860.79980221.82960.84134720.5470.049263819.63130.025757319.10310.025721818.42810.061309921.80620.36741420.57320.085600619.72070.077271319.29620.098587918.64710.10705920.60520.12657519.10240.024045418.13970.021343217.61910.026530917.18350.03436111.00.00.00.00.0-0.1513180.01053890.003197940.01941840.008772930.02812890.01295710.02450.005201230.007863550.09697320.0750944100.5520.3501140.20685939.40660.3668530.28436836.93420.6999350.34114927.72060.7954250.37904742.076818.98590.031046619.63130.02575730.6811131.192919.791318.896104416820.95283467639999.09999.09999.09999.09999.09999.0-1.0-1.0-1-1.0-1.0-1.0-1.0-1.0-1.00.99557512226720.752409988932.47405242922309.00366211-24.1402868602-20.7677388042-19.9616489036126115Bandamanna0.1002308217150.946812309329-1-1-1.0-1.02-10.12119717.18350.10023082171518.139720.60520.22037417.61910.08593020.15983420.75103360480.29950719.102460.99658746799123768024735167295919.720721.806218.64710.946812309329STAR20.573219.296221.325721.015420.001319.443818.526521.33221.05920.075519.538718.6486
12376802473516729490.99233041329920.751739073GALAXY1161153268027920100268435456014.945713.442412.61112.128211.70640.00838790.0021020.001950970.001961880.002617740.00838790.0021020.001950970.001961880.002617740.2995640.2204170.1598650.121220.085946814.646213.221912.451112.00711.620462.43446.965544.105543.409140.528513.75847.593468.729487.293127.0839729.67481.1489529.66760.40506829.68110.069859829.67420.18742829.68320.1173160.8151070.7705890.6214580.6426810.69987814.6910.0082123913.36210.0020881512.63220.0019626112.15280.0019765611.64830.0026137319.99690.059529417.80050.033930316.6550.024441416.17490.01938215.85590.024019520.03010.054602817.88540.018122316.74970.016582616.25130.01571815.94930.01536660.00.00.0536770.06886480.0-0.08217490.000850375-0.09058570.00170316-0.1076570.00144549-0.110560.0024102-0.1194830.003184860.26493238.244249.02130.29992630.703951.72420.29994128.32853.76740.29992328.393253.80530.28826230.706354.624817.35590.017986412.6110.0019509718.318445.255312.460921.86754405320.77078180849999.09999.09999.09999.09999.09999.0-1.0-1.0-1-9999.0-9999.0-1.0-1.0-1.0-1.00.99557512226720.752409988932.47405242922309.00366211-24.1402868602-20.7677388042-19.9616489036126115Bandamanna0.1864494733811.76126119075-1-1-1.0-1.02-10.1212215.94930.18644947338116.749720.03010.22041716.25130.08594680.15986520.751739070.29956417.885430.992330413299123768024735167294916.65519.996915.85591.76126119075GALAXY17.800516.174914.323913.921612.956612.420111.568419.307218.37817.137316.464615.6548
12376802473516729520.99622797591220.755112913GALAXY123214324957200100268435456020.676219.84819.407919.29719.15980.1135420.02616060.025920.03404830.08988190.1135420.02616060.025920.03404830.08988190.2995190.2203830.159840.1212020.085933820.376719.627619.248119.175819.07381.449721.470881.449651.419471.399490.5222460.05201550.08210690.1027790.2283970.194320.3699420.2844860.09715590.2941080.1126010.313950.105990.3415820.9670560.2128060.4461510.5755250.6502670.46370620.73550.19601319.86410.030198319.40790.054344619.27260.045184819.140.32440320.78130.14794920.01680.082472719.6080.075558319.53550.088683219.38620.15579119.77110.065196118.41190.020235217.64670.014817717.23940.013763916.92260.02078690.00.00.00.00.00.0239817-0.03230230.01833650.02234470.0244406-0.001728240.03036250.01628210.0367386-0.007112690.07940720.308609178.6020.5143990.39628115.29890.6441930.3995915.734060.7029690.4212622.054740.5453550.45904116.028918.49390.021580619.40790.05434460.7621061.3889519.526819.411436864420.93235064179999.09999.09999.09999.09999.09999.0-1.0-1.0-10.158820.082149-1.0-1.0-1.0-1.00.99557512226720.752409988932.47405242922309.00366211-24.1402868602-20.7677388042-19.9616489036126115Bandamanna0.166260446951.57054920826-1-1-1.0-1.02-10.12120216.92260.1662604469517.646719.77110.22038317.23940.08593380.1598420.755112910.29951918.411930.996227975912123768024735167295219.60820.781319.38621.57054920826GALAXY20.016819.535520.048720.204819.583419.273918.84720.157920.363819.769819.479919.0809
12376802473516729610.99582905965220.75051883693GALAXY105656498651152100268435456021.854420.225119.467818.826218.26970.2822450.03012080.02440190.02125690.03952660.2822450.03012080.02440190.02125690.03952660.2995160.2203810.1598390.1212010.085932921.554920.004719.30818.70518.18381.59041.447431.437571.483511.497481.436780.05680960.04748310.04228570.1806260.2121995.256560.2348790.1533460.2940560.08685620.3758530.05545140.4618970.1256220.09877330.6999470.6667640.7451180.64596621.9020.95783720.25020.044331319.46780.024401918.75910.02119318.16170.050340221.92930.42250220.39240.088149119.67690.092164319.09660.095506118.5370.11366920.67980.13898219.04890.027647818.11140.025904317.56210.029215117.13960.03868131.00.00.00.00.00.02591680.123515-0.0109494-0.02205-0.0152416-0.0399477-0.00481345-0.0225869-0.0173249-0.06502990.09876350.36307327.09930.7497790.339801126.2610.7638280.388237126.1760.8242020.472248128.8240.6891420.555141125.29718.96580.037948719.46780.02440190.7633671.3512919.59719.408754994321.00608672689999.09999.09999.09999.09999.09999.0-1.0-1.0-10.2344240.18289-1.0-1.0-1.0-1.00.99557512226720.752409988932.47405242922309.00366211-24.1402868602-20.7677388042-19.9616489036126115Bandamanna0.114360141371.08028236912-1-1-1.0-1.02-10.12120117.13960.1143601413718.111420.67980.22038117.56210.08593290.15983920.75051883690.29951619.048930.995829059652123768024735167296119.676921.929318.5371.08028236912GALAXY20.392419.096621.109820.681219.781319.252718.214421.193820.835419.972219.471118.4836
12376802473516729730.99772720133820.74967904986STAR31672837145012800026843545628147497671065620.425221.936824.80224.361822.82690.2097930.3565584.060024.347293.536350.2097930.3565584.060024.347293.536350.2994890.2203610.1598240.121190.085925120.125721.716424.642224.240622.7411.552781.147192.970652.970552.971060.2069920.995573-1000.0-1000.0-1000.00.1445881.30651.58223e-0511.68365.094690.03.924810.02.858870.00.7886210.3080860.4528650.4769420.43323921.03540.34740722.59240.50826124.8026.5496124.35985.7306622.826910.007421.07180.16088822.56180.43488924.8023.2821324.36182.283522.82691.4659220.50370.09811519.63760.034394618.920.035645918.50990.025757518.1990.05127261.01.00.01.00.00.04036170.09656240.06109720.05987140.328384-0.1326110.328384-0.1326110.328384-0.1326110.8235090.221366138.7380.07018490.00049974459.00850.3385174.1002577.43570.4391223.9492779.55320.5183694.94263108.66719.74520.050860524.8026.549613.924954.2979924.801929.861540184429.76654604129999.09999.09999.09999.09999.09999.0-1.0-1.0-1-1.0-1.0-1.0-1.0-1.0-1.00.99557512226720.752409988932.47405242922309.00366211-24.1402868602-20.7677388042-19.9616489036126115Bandamanna0.2035412586041.92271564494-1-1-1.0-1.03-10.1211918.1990.20354125860418.9220.50370.22036118.50990.08592510.15982420.74967904980.29948919.637660.997727201338123768024735167297324.80221.071822.82691.92271564494STAR22.561824.361818.134421.25923.539724.617723.372319.297522.079623.811524.617723.3723
12376802473516729500.99918875379420.75530320426STAR35253394739216100268435456022.30419.734218.438517.503217.04350.3757130.02041360.01100850.0080810.01454750.3757130.02041360.01100850.0080810.01454750.2995090.2203760.1598350.1211980.085930822.004419.513918.278617.38216.95751.228511.444371.442621.447831.456491.085430.04820780.03224630.02223670.05031820.002498949.660260.1221360.03629770.1667220.02243550.1895430.01140350.1334920.02736690.050.9996890.7560750.83120.99981922.3420.6877919.74880.022294718.43850.011008517.49080.0080799417.05040.018176322.29260.55211419.79940.078927418.53530.04343617.62030.026010917.13740.036312320.61840.14401418.79950.033049717.75340.02301217.09370.017787716.65360.02442971.00.00.00.01.0-0.012329-0.217131-0.01498280.0234505-0.03115360.0109549-0.02217990.0278907-0.06536850.0194940.1152820.00281418132.4840.9999850.18654972.97310.7927160.24674377.93860.8555970.26005681.91820.9760610.18929972.864818.51860.031095518.43850.01100850.7307831.5037218.504317.395136755419.81865193939999.09999.09999.09999.09999.09999.0-1.0-1.0-1-1.0-1.0-1.0-1.0-1.0-1.00.99557512226720.752409988932.47405242922309.00366211-24.1402868602-20.7677388042-19.9616489036126115Bandamanna0.2669112352622.52132865422-1-1-1.0-1.02-10.12119816.65360.26691123526217.753420.61840.22037617.09370.08593080.15983520.75530320420.29950918.799560.999188753794123768024735167295018.535322.292617.13742.52132865422STAR19.799417.620321.561820.358818.986118.178416.928721.560520.414119.069218.278317.0369
12376802473516729540.9938079931620.74931868193GALAXY105656498651152100268435456021.307919.869319.339618.941518.47570.173560.02340490.02176880.02261050.04469350.173560.02340490.02176880.02261050.04469350.2995410.22040.1598520.1212110.085940221.008419.648919.179818.820318.38981.352651.400261.341921.359661.390190.2201950.04874050.04322440.04629370.09121720.0001784070.5276520.1920860.06653110.1641410.04834410.2360680.06832980.2569770.177820.5784740.1000140.6401140.6997890.54986521.36250.52121519.87390.029421719.33960.025023918.88090.031605918.40870.085805521.33670.27294119.94060.1043119.44130.070447719.08260.076923218.60270.095481120.25840.10486818.66760.035070917.87060.019495317.39630.020492617.03170.02782371.00.00.00.00.0-0.04293780.01373240.0224320.02463320.009912690.00256110.01550710.02532630.00315015-0.0133030.6058990.0006393263.86560.09991210.3073757.882480.7034310.255797168.6010.7499980.33943916.45820.6264550.379153165.42718.710.028183819.33960.02502390.6917131.2228919.488118.374537168620.6831423479999.09999.09999.09999.09999.09999.0-1.0-1.0-10.0821990.06389-1.0-1.0-1.0-1.00.99557512226720.752409988932.47405242922309.00366211-24.1402868602-20.7677388042-19.9616489036126115Bandamanna0.2103162162421.98671405548-1-1-1.0-1.02-10.12121117.03170.21031621624217.870620.25840.220417.39630.08594020.15985220.74931868190.29954118.667630.99380799316123768024735167295419.441321.336718.60271.98671405548GALAXY19.940619.082620.462920.254119.55419.161718.364720.486520.315919.642519.269418.5003
12376802473516729550.99332855263420.7492867846STAR72163250536579088100268435456021.565620.182619.906519.449618.84130.2129960.02945250.03444820.03416440.06066120.2129960.02945250.03444820.03416440.06066120.2995480.2204040.1598560.1212140.08594221.266119.962219.746719.328418.75541.346171.334451.319951.346781.38310.3183160.06964260.08147220.07611060.132370.1220972.87280.1401270.08899030.1895240.09694610.2361130.1010990.2882650.3968210.1930.1240920.3235720.597170.39991321.59840.60842120.21470.033385419.90650.048530619.38620.063570418.77590.12304521.57330.29118620.21320.12503720.00450.14552619.58430.1388118.96450.14382820.37380.10113418.75120.035819117.93250.025987517.45610.024791317.07880.03168651.00.9993750.00.00.00.1665810.008421460.02808650.09158070.02018590.005565090.02874950.02090330.04125150.001844640.050.221119170.5370.06502640.22160719.90740.3924060.29771211.90490.6499740.3566527.538140.4999140.39124214.759818.81240.038957819.90650.04853060.6846441.1974320.068619.270946263521.24133101339999.09999.09999.09999.09999.09999.0-1.0-1.0-1-1.0-1.0-1.0-1.0-1.0-1.00.99557512226720.752409988932.47405242922309.00366211-24.1402868602-20.7677388042-19.9616489036126115Bandamanna0.2258417435712.13337313803-1-1-1.0-1.02-10.12121417.07880.22584174357117.932520.37380.22040417.45610.0859420.15985620.7492867840.29954818.751260.993328552634123768024735167295520.004521.573318.96452.13337313803STAR20.213219.584320.533520.48820.010619.719618.817820.495520.497620.079319.823218.9481
12376802473516729650.99718373481120.75555135716STAR246359627268112100268435456021.281420.06919.814719.774219.62670.1775220.02860770.03299970.04629030.1227960.1775220.02860770.03299970.04629030.1227960.2995130.2203790.1598370.12120.085932120.981819.848619.654819.65319.54081.44721.396331.354861.350991.357710.2665560.06447170.08036480.118340.2363620.003642248.626980.1038250.0005649970.1366160.1503140.1722160.1895960.1522120.8098840.180040.9817380.9588490.9999480.89190521.31180.34435620.08420.036111819.81470.061310219.73110.12077619.6150.52504721.32130.26836820.14560.083817319.90810.081868119.89680.11229119.72830.18826419.9540.073692218.54480.019957817.79670.014169317.38170.014343217.05530.02095810.00.00.00.00.0-0.02428130.0166917-0.01731720.0413869-0.01248190.0109495-0.01499490.02953610.00415294-0.01010080.1870790.20190975.73360.9874650.18183140.26280.9797650.21210477.26750.9258340.27829375.82830.9141960.23984944.922618.64750.020705819.81470.06131020.6878561.2390719.961418.442873075221.14432270379999.09999.09999.09999.09999.09999.0-1.0-1.0-1-1.0-1.0-1.0-1.0-1.0-1.00.99557512226720.752409988932.47405242922309.00366211-24.1402868602-20.7677388042-19.9616489036126115Bandamanna0.2089766816141.97406038417-1-1-1.0-1.02-10.121217.05530.20897668161417.796719.9540.22037917.38170.08593210.15983720.75555135710.29951318.544860.997183734811123768024735167296519.908121.321319.72831.97406038417STAR20.145619.896820.312820.367619.909319.691519.320320.356120.438919.995419.789419.4347
.....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
12376802972815205270.95081260629921.73548306436STAR28154396462310410026843545628147497671065624.753124.237122.097621.182720.89131.155830.4885340.1500350.1013130.2897141.155830.4885340.1500350.1013130.2897140.2053240.1510760.1095730.08308570.058908824.547824.08621.98821.099620.83242.970432.969681.46111.120281.01867-1000.0-1000.00.4761430.1518580.4333770.03185448.918580.05178910.83590.3661730.8057460.2132270.5864215.7225e-050.005614160.05275820.9986570.050.09746440.0524.71661.0804824.33040.59836622.10380.19516121.2720.1251920.98910.26535624.68631.0124924.30070.43387822.26860.14443521.37580.096516420.92960.24070724.16031.0446424.30850.49468922.57140.2324421.7630.1884821.94740.7127851.00.00.8031960.01.01.56203-3.614840.04853570.01279370.06733520.0830813-0.04963970.0342563-0.291139-0.4265720.0776070.00302923129.9560.9994920.0552197137.6390.05648680.42596430.71110.050.27943650.73680.050.0027316147.017723.04440.23554522.12930.1949940.7952462.3600222.087622.271622623923.58551098949999.09999.09999.09999.09999.09999.0-1.0-1.0-1-1.0-1.0-1.0-1.0-1.0-1.00.99557512226720.752409988932.47405242922309.00366211-24.1402868602-20.7677388042-19.9616489036126115Bandamanna59.0374764374557.659419808-1-1-1.0-1.0-1-10.083085721.947459.037476437422.571424.16030.15107621.7630.05890880.10957321.73548306430.20532424.308560.950812606299123768029728152052722.268624.686320.9296557.659419808STAR24.300721.375825.70825.125723.012321.840620.673225.613225.155723.136522.01520.8066
12376802972815858961.0342861084521.74820114163GALAXY28154396462310410026843545628147497671065619.518520.081218.429324.560616.12960.6345680.3859660.16155731.67610.1248780.6345680.3859660.16155731.67610.1248780.2082440.1532240.1111310.08426730.059746519.310319.92818.318224.476316.06992.970252.9697343.7650.94188843.7652-1000.0-1000.0-1000.00.150169-1000.029.668143.17780.2943380.92568829.662519.49910.1366790.47902529.66992.214210.050.0723370.3802980.1060740.61252618.69770.41562223.26450.25149818.68420.17544722.38890.25433315.25290.096100524.89371.0042523.38670.22045122.53350.1754322.43370.23961721.33240.32399324.88091.1101523.60.30036822.88360.30629922.86970.49146321.37240.4682360.00.7624690.3221261.00.111682-3.005410.279438-66.5537-0.5708726.0758-0.0209371-0.874926-0.0232918-0.263005-0.01013340.31785759.337467.3660.05962560.516085120.4880.17551559.0265158.4110.1462290.2938987.18780.57626959.3276106.17423.33840.30048618.42930.16155717.015326.743219.664129.279986289227.81376177839999.09999.09999.09999.09999.09999.0-1.0-1.0-1-9999.0-9999.0-1.0-1.0-1.0-1.00.99557512226720.752409988932.47405242922309.00366211-24.1402868602-20.7677388042-19.9616489036126115Bandamanna59.7866704608564.735488625-1-10.0029675824607-1.0-1-10.084267321.372459.786670460822.883624.88090.15322422.86970.05974650.11113121.74820114160.20824423.631.03428610845123768029728158589622.533524.893721.3324564.735488625GALAXY23.386722.433720.580220.817319.131919.250420.909324.288523.872722.888622.401321.6116
12376802972815201600.89878416975921.71373715863GALAXY28154396475417610026843545628147497671065624.475822.973522.35822.447222.81771.149680.1844290.187270.3022620.8555871.149680.1844290.187270.3022620.8555870.2060670.1516220.1099690.0833860.059121724.269722.821922.24822.363822.75860.2948721.715951.3721.198542.96950.08130660.4710430.2110410.276842-1000.029.67785.59350.4116110.7193570.7207870.9017980.1899760.6187264.106830.91540.2191950.050.050.1482040.0520.47380.65968722.88250.20141922.26840.23340322.45330.42236121.77810.97164224.18370.9351423.12170.17980722.57880.19005622.64960.28952822.91410.69983424.14931.0418723.36130.24834622.79560.28241422.81650.46808522.37970.8820881.00.00.5203010.00.0-0.01897770.784511-0.1116850.307772-0.08423090.0729395-0.00776891-0.06813170.9999432.237650.19999711.7486146.3960.050.66745762.44410.1477720.47198772.2640.1110370.36131412.09450.052.196170.71723.22160.27223222.3580.2324940.7563861.0307522.491422.723107477723.88059383889999.09999.09999.09999.09999.09999.0-1.0-1.0-10.4132670.114187-1.0-1.0-1.0-1.00.99557512226720.752409988932.47405242922309.00366211-24.1402868602-20.7677388042-19.9616489036126115Bandamanna57.9330791542547.228440587-1-1-1.0-1.0-1-10.08338622.379757.933079154222.795624.14930.15162222.81650.05912170.10996921.71373715860.20606723.361330.898784169759123768029728152016022.578824.183722.9141547.228440587GALAXY23.121722.649623.672623.385222.609822.254622.193223.530723.510722.79922.472622.3547
12376802972815203660.98367009003721.74878505183GALAXY28170932086400000026843545628147497671065624.289322.818922.036621.295421.81241.451630.2085870.1856990.1532060.8138321.451630.2085870.1856990.1532060.8138320.2065240.1519590.1102130.08357120.05925324.082822.66721.926421.211921.75322.970432.969682.969062.06240.821964-1000.0-1000.0-1000.00.4696230.69045915.350964.82530.8784091.856654.105934.302481.140581.1113829.66965.84670.050.2995150.635060.3728640.065514821.80060.87472623.0140.22475821.42460.21543121.27150.17787119.27010.72816324.0850.91147723.21530.19384622.79260.22611221.97760.16289121.89370.49929324.71381.1362823.47640.27159722.57230.23326421.87230.20788322.39750.8847331.00.00.00.2504751.0-0.04128650.2157520.2730820.2767880.05910190.0789852-0.002009840.2275311.241141.160250.054.24989.065910.06585860.58801127.5880.6870141.7658292.72380.5848790.8933347.55440.057893130.6914115.30723.25450.28062921.42460.2154311.521493.0152421.557124.654741822524.4638493669999.09999.09999.09999.09999.09999.0-1.0-1.0-10.3024260.156316-1.0-1.0-1.0-1.00.99557512226720.752409988932.47405242922309.00366211-24.1402868602-20.7677388042-19.9616489036126115Bandamanna59.7862102872564.731142335-1-1-1.0-1.0-1-10.083571222.397559.786210287222.572324.71380.15195921.87230.0592530.11021321.74878505180.20652423.476430.983670090037123768029728152036622.792624.08521.8937564.731142335GALAXY23.215321.977623.64223.282822.360921.806221.09823.422923.566622.960522.550921.5482
12376802972815203050.95947613488821.71347706886STAR72163216142238480100268435456025.084422.917121.867320.216919.41040.9273970.1564890.1057490.03796240.06814910.9273970.1564890.1057490.03796240.06814910.2043740.1503760.1090650.08270110.058636124.8822.766821.758320.134219.35184.584841.360431.129071.069153.84078-1000.00.3905080.2757120.07758560.6879580.04756147.762140.2222940.58450.00020850.1628520.000121050.004480850.1545110.1084610.1352650.050.3073120.2112120.0525.08580.9302122.83930.19093521.86730.11139420.21730.050423719.35280.076865824.63340.99780622.89070.14861721.83070.090378720.21410.037875819.40390.066549524.86251.0933923.26510.22864222.34020.10815920.59850.066778919.78360.08783491.01.00.01.01.020.24190.1107680.129386-0.1414220.130603-0.02779460.0189605-0.0526273-0.0557471-0.07757080.99844712.8511123.8320.05600970.279468155.7160.1142030.0012564347.99880.2935520.000109807129.7670.1104750.212034122.58222.75840.097393321.86730.1113940.5201331.2213222.08789.3584624548822.66380170659999.09999.09999.09999.09999.09999.0-1.0-1.0-1-1.0-1.0-1.0-1.0-1.0-1.00.99557512226720.752409988932.47405242922309.00366211-24.1402868602-20.7677388042-19.9616489036126115Bandamanna57.6993552653545.020922421-1-1-1.0-1.0-1-10.082701119.783657.699355265322.340224.86250.15037620.59850.05863610.10906521.71347706880.20437423.265160.959476134888123768029728152030521.830724.633419.4039545.020922421STAR22.890720.214124.328123.464722.30821.497819.508624.089423.441422.275821.466419.5044
12376802972815202680.94705027717521.7147851633GALAXY158398662443264100268435456025.141121.976620.452819.967719.50751.407560.1062140.04868870.04880410.121061.407560.1062140.04868870.04880410.121060.2051280.1509310.1094680.0830060.058852324.93621.825620.343419.884719.44862.970431.938792.35711.822231.1547-1000.00.4031750.4154350.5659360.15076729.66390.00.4980220.4456420.7581340.3072160.3382220.1531290.1894790.4077370.050.9884640.7383010.5560230.0998821.66031.2160622.09590.10640420.45290.06103720.28570.048219119.91480.13610525.42820.7831222.51380.10871221.03780.051858720.5730.049301520.04030.12890824.32071.0956322.7090.14195421.17660.067359620.76480.076665720.3310.1857091.00.8803021.01.00.66860.206927-1.291140.04802780.142901-0.00774135-0.0724881-0.0346231-0.06307820.1036130.03429240.058.21943118.9180.9416090.48676154.53220.7964980.610339114.7210.6062680.375522130.0270.1196120.33034682.226121.75150.077126820.63260.05302091.119923.0908320.471821.555946703322.71324055859999.09999.09999.09999.09999.09999.0-1.0-1.0-10.337460.061944-1.0-1.0-1.0-1.00.99557512226720.752409988932.47405242922309.00366211-24.1402868602-20.7677388042-19.9616489036126115Bandamanna57.806246694546.030510466-1-15.83054436212e-05-1.0-1-10.08300620.33157.80624669421.176624.32070.15093120.76480.05885230.10946821.7147851630.20512822.70930.947050277175123768029728152026821.037825.428220.0403546.030510466GALAXY22.513820.57324.305622.672521.099720.261619.39324.672623.194821.663920.849719.9704
12376802972815860301.0185012818321.70935431793GALAXY28154396475827200026843545628147497671065624.008623.801822.832321.440321.05831.044450.3766090.2892420.1337380.3448331.044450.3766090.2892420.1337380.3448330.2049850.1508260.1093910.08294830.058811323.803623.650922.722921.357420.99940.9571462.969732.969651.704161.082960.43487-1000.0-1000.00.3484460.6160890.0020484539.29920.04180282.833880.4565510.8788410.568390.73850229.459485.71420.08576090.4003280.050.5257110.11105623.93310.99047423.81750.37913722.81170.33782721.35440.13435220.9790.34176223.74950.7534123.88710.32618523.09260.28296221.77450.134821.62770.39967524.70821.119124.3530.50842323.23310.40849221.84330.20153121.47420.4381060.00.00.6524230.6097410.0-3.080282.642150.4044690.2076530.07929230.5513410.0614362-0.2065460.3103220.2802050.1194577.03816e-05101.7870.06087150.31983212.32490.07592730.58810844.85490.5541630.487869146.1190.5344040.588169178.44623.62790.37200322.80630.3370310.4683710.62218923.789123.649071667724.13745332869999.09999.09999.09999.09999.09999.0-1.0-1.0-10.6761070.060363-1.0-1.0-1.0-1.00.99557512226720.752409988932.47405242922309.00366211-24.1402868602-20.7677388042-19.9616489036126115Bandamanna57.4309743706542.486066316-1-1-1.0-1.0-1-10.082948321.474257.430974370623.233124.70820.15082621.84330.05881130.10939121.70935431790.20498524.35331.01850128183123768029728158603023.092623.749521.6277542.486066316GALAXY23.887121.774524.125624.324223.23822.502320.895923.884324.354823.422222.773921.3208
12376802972815205280.95110851082421.74353860663GALAXY28164060138726410026843545628147497671065625.293324.600521.921221.447421.00291.036390.6225130.1360890.1376640.3422161.036390.6225130.1360890.1376640.3422160.2059310.1515220.1098970.08333120.059082925.087324.448921.811321.364120.94382.970432.969682.117191.88042.3095-1000.0-1000.00.607330.04909542.162770.0001447313.227921.082798.902780.8596571.048161.884831.455760.4750451.045630.0504780.050.5637710.152240.0525.14930.98584724.31980.66592621.78440.14157821.02750.13337121.01610.34988724.85180.99271524.51280.48363722.20810.137221.86470.14773521.19510.30016824.63331.1407824.53690.55531222.35090.19150921.78490.19230121.42740.492110.01.00.4385570.1385030.06657441.518611.19434-3.43958-0.681814-0.0188283-0.00393996-0.1629980.0190596-1.653840.07277480.05995578.00683e-0673.89830.050.910287129.1880.3484780.58801769.7030.2500491.3404176.06690.050.60487599.292222.88660.20647721.92120.1400311.049333.5512521.662822.763606900723.76279347079999.09999.09999.09999.09999.09999.0-1.0-1.0-10.2831410.042736-1.0-1.0-1.0-1.00.99557512226720.752409988932.47405242922309.00366211-24.1402868602-20.7677388042-19.9616489036126115Bandamanna59.5196813462562.21380399-1-1-1.0-1.0-1-10.083331221.427459.519681346222.350924.63330.15152221.78490.05908290.10989721.74353860660.20593124.536930.951108510824123768029728152052822.208124.851821.1951562.21380399GALAXY24.512821.864726.618325.658123.070721.731720.878826.03125.453223.194722.038621.2092
12376802972815203880.99356719938121.71304429586STAR68987912448100268435456023.092222.300220.724219.761219.17890.4911970.09406490.04076320.02681950.05694280.4911970.09406490.04076320.02681950.05694280.2036520.1498460.108680.08240910.058429122.888522.150320.615619.678819.12050.8130432.969681.464651.183070.9289190.654615-1000.00.2344730.1259370.05501110.001111672.904490.7072740.6237520.0893730.1241450.00132770.1928360.0001918460.07579060.3806510.050.1405570.3060790.26398423.08220.48066321.9820.099006220.72430.048539419.78160.028863719.19680.059124822.93240.41219322.31030.091493620.73560.041176719.77460.028061519.18170.055056323.6340.77787122.57810.1266521.07820.061757720.12760.043629719.68070.1078630.01.01.00.00.02.971218.42985-0.118123-0.07056310.0388973-0.0461217-0.0187133-0.07378330.03507810.06638220.05846820.0020646347.80560.050.66658198.95510.2490230.126439137.5320.4731870.000694552135.620.2086730.00021683197.686921.57410.066179920.7290.04849910.7131791.8216820.682318.233818964821.94379208379999.09999.09999.09999.09999.09999.0-1.0-1.0-1-1.0-1.0-1.0-1.0-1.0-1.00.99557512226720.752409988932.47405242922309.00366211-24.1402868602-20.7677388042-19.9616489036126115Bandamanna57.6381678038544.443007468-1-18.11874648678e-05-1.0-1-10.082409119.680757.638167803821.078223.6340.14984620.12760.05842910.1086821.71304429580.20365222.578160.993567199381123768029728152038820.735622.932419.1817544.443007468STAR22.310319.774623.439523.012421.393820.459919.139523.360323.022221.404620.471619.1487
12376802972815205300.95517950363621.70893422953GALAXY28154396462310410026843545628147497671065622.90523.343221.953921.323620.48650.547960.2971550.1590790.1388940.2494670.547960.2971550.1590790.1388940.2494670.2047380.1506440.109260.08284850.058740622.700323.192521.844721.240820.42772.173817.35851.853643.082122.171692.06374-1000.00.464670.8829341.996280.3172381.8116512.321218.62730.712870.9430162.088072.527072.646174.009650.050.1315120.2362190.5707910.0522.98530.59964322.33480.31470221.95390.25378120.87870.16965920.14440.31460123.14470.48875623.89070.33218122.40460.16216121.87510.148421.1650.29271723.30160.61531323.77480.34537222.52820.2232221.76770.18833721.03820.3581530.00.00.00.00.0-0.4004350.412246-0.316057-0.483982-0.149873-0.0161462-0.13438-0.0849788-0.491338-0.125630.050.60225683.80460.2499983.4101369.30330.3500390.81453589.12780.6528311.29474112.240.09890081.7641885.145423.05880.23780921.95390.2537810.930942.2594722.004523.503942845723.8445529889999.09999.09999.09999.09999.09999.0-1.0-1.0-10.613480.090705-1.0-1.0-1.0-1.00.99557512226720.752409988932.47405242922309.00366211-24.1402868602-20.7677388042-19.9616489036126115Bandamanna57.4359036453542.532623319-1-1-1.0-1.0-1-10.082848521.038257.435903645322.528223.30160.15064421.76770.05874060.1092621.70893422950.20473823.774830.955179503636123768029728152053022.404623.144721.165542.532623319GALAXY23.890721.875123.685523.99722.542221.740520.603524.154624.574923.035122.206621.204

In [110]:
# these are the already-observed objects
spectra = h.load_and_reprocess_sdss_catalog('SAGADropbox/data/saga_spectra_clean_jan15.fits.gz')

Ranking

rank desc
1 Flux Stars
2 Special targets
3 r<300 kpc, ugri cuts, M_r<20
4 r<300 kpc, ugri cuts, M_r<20.75
5 r<300 kpc, gri cuts, M_r<20.75
6 300<r<450 kpc, ugri cuts, M_r<20.75
7 300<r<450 kpc, gri cuts, M_r<20.75
8 other

The ugr cut is: $ u-g > 1.5(g-r) - 0.25$ (that's the cut, not the accept condition)

Fix up wrong-distance hosts if need be


In [111]:
for h in hosts_to_target:
    fix = False
    cat = h.get_sdss_catalog()
    if np.median(cat['RHOST_KPC']) > 600:
        print('RHOST distances wrong for', h)
        fix = 1
    if np.abs(np.median(cat['HOST_DIST'])-h.distmpc)/h.distmpc > 0.05:
        print('HOST_DIST wrong on', h)
        fix = 2
        
    if fix:
        scs = SkyCoord(cat['RA'], cat['DEC'], unit=u.deg)
        cat['RHOST_ARCM'] = scs.separation(h.coords).to(u.arcmin).value
        cat['RHOST_KPC'] = scs.separation(h.coords).to(u.radian).value * h.distmpc*1000

In [112]:
def rank_targets(cat, ugoffset=-0.25):
    corrmag = {band: cat[band] - cat['A'+band]  for band in 'ugri'}
    
    phot_good = (cat['r']<21.25)& (cat['fibermag_r']<23)&(cat['phot_sg']=='GALAXY')
    
    gmr_wunc = corrmag['g']- corrmag['r'] - 2*np.hypot(cat['g_err'], cat['r_err'])
    rmi_wunc = corrmag['r']- corrmag['i'] - 2*np.hypot(cat['g_err'], cat['r_err'])
    
    gmr_accept = gmr_wunc < 0.85
    rmi_accept = rmi_wunc < 0.55
    if ugoffset is None:
        # this is a *cut*, meaning True means get rid of it
        ug_cut = np.zeros_like(gmr_accept)
    else:
        ug_cut = corrmag['u'] - corrmag['g'] < (1.5*(corrmag['g'] - corrmag['r']) + ugoffset)
    
    gri_accept  = gmr_accept&gmr_accept
    ugri_accept  = gri_accept&~ug_cut
    
    r_bright = corrmag['r'] < 20.
    r_ok = corrmag['r'] < 20.75
    r_faint = r_ok&~r_bright
    
    near = cat['RHOST_KPC']<300
    nearish = (cat['RHOST_KPC']<450) & ~near
    
    ranks = np.zeros(len(cat), dtype=int)
    
    
    ranks[r_ok & gri_accept & nearish & phot_good] = 7
    ranks[r_ok & ugri_accept & nearish & phot_good] = 6
    ranks[r_ok & gri_accept & near & phot_good] = 5
    ranks[r_ok & ugri_accept & near & phot_good] = 4
    ranks[r_bright & ugri_accept & near & phot_good] = 3
    
    ranks[(ranks==0)&phot_good] = 8  # other
    
    do_checks(cat, ranks)
    
    return ranks

def do_checks(cat, ranks):
    
    zq = cat['ZQUALITY'].copy()
    # ranks ~-100 are removed due to already-observed
    havespec = zq>=3
    ranks[havespec] = -100 - zq[havespec]
    
    # this *shouldn't* be necessary, as ZQUALITY should be in the base catalog.  
    # But as a sanity check we look to see if anything in the spectral catalog is still being included
    spec_this_host = spectra[spectra['HOST_NSAID']==h.nsaid]
    spec_this_host = spec_this_host[np.in1d(spec_this_host['OBJID'], cat['OBJID'])]

    for i, zqi in zip(spec_this_host['OBJID'], spec_this_host['ZQUALITY']):
        zq[cat['OBJID']==i] = zqi
    if np.any(ranks[zq>2]>=0):
        print('POSSIBLE PROBLEM: Found some objects in spectrum list that are *not* claimed ' 
              'as having spectra in the base catalogs.  Setting them to -11x:', dict(Counter(ranks[ranks<-110])))
        ranks[zq>2] = -110 - zq[zq>2]
    
    # remove list
    tokeep = cat['REMOVE']==-1
    ranks[~tokeep] = -cat['REMOVE'][~tokeep] # sets the REMOVE objects to -their remove value
    remmskval =  np.min(ranks)-1
    # remove anything in the remove list online but not in the catalog as remove
    ranks[~targeting.remove_targets_with_remlist(cat, h, maskonly=True, verbose='warning')&(ranks>-1)] = remmskval
    if np.sum(ranks==remmskval) > 0:
        print('Removed', np.sum(ranks==remmskval), 'due to online remove list. Remmsk val:', remmskval)
    
    #de-duplicate
    if len(np.unique(cat['OBJID'])) != len(cat):
        _, idxs = np.unique(cat['OBJID'], return_index=True)
        msk = np.ones_like(cat, dtype=bool)
        msk[idxs] = 0
        ranks[msk] = -1000
        
        print('WARNING: some duplicate objid found.  Setting', np.sum(ranks==-1000), 'dupes to pri=-1000')

In [113]:
for h in hosts_to_target:
    print('On host', h.name)
    cat = h.get_sdss_catalog()

    cat['mmt_ranks'] = rank_targets(cat)
    print(Counter(cat['mmt_ranks']), end='\n\n')


On host Bandamanna
WARNING: some duplicate objid found.  Setting 8 dupes to pri=-1000
Counter({0: 38678, -3: 12218, 8: 8821, 6: 867, -104: 533, 7: 517, 5: 359, 4: 334, 3: 305, -2: 81, -4: 47, -1: 31, -1000: 8})

On host NSA150578
WARNING: some duplicate objid found.  Setting 8 dupes to pri=-1000
Counter({0: 41519, -3: 12360, 8: 7840, 6: 1115, -104: 749, 7: 701, 5: 532, 4: 488, 3: 440, -2: 92, -4: 63, -1: 9, -1000: 8})

On host NSA135879
No matches found for host "NSA135879" in remove list. Maybe you mis-typed something?
WARNING: some duplicate objid found.  Setting 7 dupes to pri=-1000
Counter({0: 51442, -3: 12350, 8: 8281, 6: 1118, -104: 760, -2: 606, 7: 588, 4: 454, 5: 454, 3: 427, -4: 75, -1000: 7, -1: 1})

On host Narnia
POSSIBLE PROBLEM: Found some objects in spectrum list that are *not* claimed as having spectra in the base catalogs.  Setting them to -11x: {}
WARNING: some duplicate objid found.  Setting 12 dupes to pri=-1000
Counter({0: 51489, -3: 14316, 8: 11040, -114: 2536, 6: 742, -2: 430, 7: 340, -113: 201, -4: 189, 4: 87, 5: 73, 3: 19, -1: 14, -1000: 12})

On host NSA129237
POSSIBLE PROBLEM: Found some objects in spectrum list that are *not* claimed as having spectra in the base catalogs.  Setting them to -11x: {}
WARNING: some duplicate objid found.  Setting 15 dupes to pri=-1000
Counter({0: 40954, -3: 12988, 8: 7557, -114: 724, 6: 644, 7: 349, 5: 343, 4: 258, 3: 244, -2: 172, -113: 49, -4: 45, -1: 42, -1000: 15})

On host NSA161174
WARNING: some duplicate objid found.  Setting 12 dupes to pri=-1000
Counter({0: 65581, 8: 9044, -3: 4948, -104: 1417, 6: 673, 7: 342, -2: 243, 5: 231, 4: 225, 3: 200, -4: 145, -103: 29, -1000: 12, -1: 6})

Plot catalogs w/ ranks


In [114]:
for h in hosts_to_target:
    cat = h.get_sdss_catalog()
    ranks = cat['mmt_ranks']

    plt.figure()
    
    msk_good = (ranks>1)&(ranks<8)
    msk_bad = (ranks>7)
    
    ras = Angle(cat['ra'], u.deg).wrap_at(180*u.deg)
    decs = cat['dec']
    
    plt.scatter(ras[msk_bad], decs[msk_bad], 
                lw=0, alpha=.3, c=ranks[msk_bad],s=8, vmin=2, vmax=np.max(ranks))
    plt.scatter(ras[msk_good], decs[msk_good], 
                lw=0, alpha=.9, c=ranks[msk_good],s=20, vmin=2, vmax=np.max(ranks))
    
    plt.colorbar()
    
    ell = patches.Ellipse((Angle(h.ra, u.deg).wrap_at(180*u.deg).value, h.dec),
                          1./np.cos(np.radians(h.dec)), 1,
                         fc='none', ec='k', lw=3, ls='--')
    plt.gca().add_patch(ell)
    
    
    plt.title('{}, {:.1f} {}'.format(h.name, h.dist, np.unique(cat['HOST_DIST'])[0]), fontsize=24)
    
    plt.tight_layout()



In [115]:
needmorefluxstars = [129237, 150578]

generated_cats = {}
for h in hosts_to_target:
    if generated_cats:
        print('') # makes a newline except for on the first one
    print('On host', h.name)
    sys.stdout.flush()

    cat = h.get_sdss_catalog()
    ranks = cat['mmt_ranks']
    
    fnout = 'mmthecto/{0}_{1}.cat'.format(h.name, DATESUFFIX)
    fluxfnout = fnout.replace('.cat', '.fluxstars')
    print('Going to write', fnout)
    
    msk = (cat['RHOST_ARCM']<40) & (ranks>0) & (ranks<8)
    
    if h.nsaid in needmorefluxstars:
        fluxrng = (17., 18.)
        removefluxdistance = (20*u.arcsec, ranks[msk]<6)
    else:
        fluxrng = (17., 17.7)
        removefluxdistance = (40*u.arcsec, ranks[msk]<6)
    
    generated_cats[h] = mmthecto.generate_catalog(h, cat[msk], ranks[msk],
                                                  fnout=fnout, fluxfnout=fluxfnout,
                                                  repeatflux=4, fluxrng=fluxrng,
                                                  removefluxdistance=removefluxdistance)


On host Bandamanna
Going to write mmthecto/Bandamanna_oct2016.cat
Including 1620 targets
Found 86 Flux stars
Removing 12 Flux stars too close to program stars
Final flux star count: 74 and 10 are in 1 deg FOV
Found 447 guide stars

On host NSA150578
Going to write mmthecto/NSA150578_oct2016.cat
Including 2420 targets
Found 88 Flux stars
Removing 7 Flux stars too close to program stars
Final flux star count: 81 and 19 are in 1 deg FOV
Found 413 guide stars

On host NSA135879
Going to write mmthecto/NSA135879_oct2016.cat
Including 1520 targets
Found 57 Flux stars
Removing 4 Flux stars too close to program stars
Final flux star count: 53 and 13 are in 1 deg FOV
Found 336 guide stars

On host Narnia
Going to write mmthecto/Narnia_oct2016.cat
Including 1100 targets
Found 46 Flux stars
Removing 1 Flux stars too close to program stars
Final flux star count: 45 and 13 are in 1 deg FOV
Found 270 guide stars

On host NSA129237
Going to write mmthecto/NSA129237_oct2016.cat
Including 1833 targets
Found 72 Flux stars
Removing 2 Flux stars too close to program stars
Final flux star count: 70 and 12 are in 1 deg FOV
Found 339 guide stars

On host NSA161174
Going to write mmthecto/NSA161174_oct2016.cat
Including 1460 targets
Found 70 Flux stars
Removing 7 Flux stars too close to program stars
Final flux star count: 63 and 16 are in 1 deg FOV
Found 192 guide stars

Inspect those that seem to be lacking in flux stars


In [84]:
for h in [h for h in hosts_to_target if h.nsaid in toofewflux]:
    cat = h.get_sdss_catalog()
    gcat = generated_cats[h]
    ranks = cat['mmt_ranks']
    
    fstars = gcat[gcat['rank']=='1'][::4]

    plt.figure()
    
    msk_good = (ranks>1)&(ranks<8)
    msk_bad = (ranks>7)
    
    ras = Angle(cat['ra'], u.deg).wrap_at(180*u.deg)
    decs = cat['dec']
    
    plt.scatter(ras[msk_bad], decs[msk_bad], 
                lw=0, alpha=.3, c=ranks[msk_bad],s=8, vmin=2, vmax=np.max(ranks))
    plt.scatter(ras[msk_good], decs[msk_good], 
                lw=0, alpha=.9, c=ranks[msk_good],s=20, vmin=2, vmax=np.max(ranks))
    
    fra = Angle(fstars['ra'], u.deg).wrap_at(180*u.deg)
    fdec = Angle(fstars['dec'], u.deg)
    plt.scatter(fra, fdec, color='r', s=60, marker='*')
    
    ell = patches.Ellipse((Angle(h.ra, u.deg).wrap_at(180*u.deg).value, h.dec),
                          1./np.cos(np.radians(h.dec)), 1,
                         fc='none', ec='k', lw=3, ls='--')
    plt.gca().add_patch(ell)
    
    
    plt.title('{}, {:.1f} {}'.format(h.name, h.dist, np.unique(cat['HOST_DIST'])[0]), fontsize=24)
    
    plt.tight_layout()


Now try making xfitfibs test configs


In [18]:
def compute_percentage(matched, targets):
    """
    Inputs should come from "By rank" table of xfitfibs, ranks 3/4/5
    """
    perc_ugri = (matched[0]+ matched[1])/(targets[0]+ targets[1])
    perc_gri = (matched[0]+ matched[1]+ matched[2])/(targets[0]+ targets[1]+ targets[2])
    
    return '{:.1%} | {:.1%}'.format(perc_ugri, perc_gri)

compute_percentage([350, 374, 60], [398,514,474])


Out[18]:
'79.4% | 56.6%'

NSA129237

The most distant of the new ones

nconfigs ugri completeness gri completeness
1 45.8% 29.8%
2 85.7% 60.2%
3 98.6% 85.9%

This one covers all the rank 3/4/5 region with one config, but needs multiples to get completeness up

NSA21709

Closest of the new ones (29.2 Mpc)

nconfigs ugri completeness gri completeness
1 26.3% 17.7%
2 52.7% 35.3%
3 79.4% 56.6%

This takes 3 fields to cover the area, but even with those 3, the lower percentages here are probably still due to collisions/need to repeat an area at least once

Inspecting ugri cuts


In [19]:
lowzmsk = spectra['SATS']>0
corrmag = {band: spectra[band] - spectra['A'+band]  for band in 'ugri'}


gmr_wunc = corrmag['g']- corrmag['r'] - 2*np.hypot(spectra['g_err'], spectra['r_err'])
rmi_wunc = corrmag['r']- corrmag['i'] - 2*np.hypot(spectra['g_err'], spectra['r_err'])
gmr_accept = gmr_wunc < 0.85
rmi_accept = rmi_wunc < 0.55
ug_cut = corrmag['u'] - corrmag['g'] < (1.5*(corrmag['g'] - corrmag['r']) - 0.25)
cuts = gmr_accept&rmi_accept&~ug_cut

umg = corrmag['u'] - corrmag['g']
gmr = corrmag['g'] - corrmag['r']
rmi = corrmag['r'] - corrmag['i']

fig, (ax1, ax2) = plt.subplots(2,1, figsize=(8, 12))

ax1.scatter(gmr[lowzmsk&cuts], umg[lowzmsk&cuts], alpha=.75, s=3, lw=0, c='b')
ax1.scatter(gmr[~lowzmsk&cuts], umg[~lowzmsk&cuts], alpha=.1, s=2, lw=0, c='k')
ax1.scatter(gmr[lowzmsk&~cuts], umg[lowzmsk&~cuts], alpha=.75, s=3, lw=0, c='c')
ax1.scatter(gmr[~lowzmsk&~cuts], umg[~lowzmsk&~cuts], alpha=.1, s=2, lw=0, c='r')

ax1.set_xlim(-0.2, 2)
ax1.set_ylim(-0.5, 3)
ax1.set_xlabel('g-r')
ax1.set_ylabel('u-g')


ax2.scatter(gmr[lowzmsk&cuts], rmi[lowzmsk&cuts], alpha=.75, s=3, lw=0, c='b')
ax2.scatter(gmr[~lowzmsk&cuts], rmi[~lowzmsk&cuts], alpha=.1, s=2, lw=0, c='k')
ax2.scatter(gmr[lowzmsk&~cuts], rmi[lowzmsk&~cuts], alpha=.75, s=3, lw=0, c='c')
ax2.scatter(gmr[~lowzmsk&~cuts], rmi[~lowzmsk&~cuts], alpha=.1, s=2, lw=0, c='r')
ax2.set_xlim(-0.2, 2)
ax2.set_ylim(-0.5, 1.5)
ax2.set_xlabel('g-r')
ax2.set_ylabel('r-i')


Out[19]:
<matplotlib.text.Text at 0x152d25c90>