Esempio n. 1
0
def table_sncosmo_dupl(data,SN_dupl,nobj,idupl):

    import marshaltools as mt
    from astropy.table import vstack

    ### No duplicates
    if (nobj==1):  

        # Light curves
        classification = data.classification
        z = data.redshift
        ebv_mw = data.mwebv

        lc_data = data.table_sncosmo
       
    ### Duplicates
    elif nobj==2:  

        lcs = mt.ProgramList("Cosmology")
        
        lc1 = lcs.get_lightcurve(SN_dupl[idupl][0])
        lc1_data = lc1.table_sncosmo

        lc2 = lcs.get_lightcurve(SN_dupl[idupl][1])
        lc2_data = lc2.table_sncosmo

        classification = lc1.classification
        z1 = lc1.redshift
        z2 = lc2.redshift
        if z1 == None:
            z = z2
        elif z2 == None:
            z = z1
        else:
            z = 0.5 * (float(z1) + float(z2))

        lc_data = vstack([lc1_data,lc2_data])
        lc_data.meta['z'] = z
        lc_data.meta['mwebv'] = lc1.mwebv   
        
        lc_data.sort('mjd')

        idupl+=1
    else:
        lc_data = None
        classification = None
    
    return lc_data, classification, idupl
Esempio n. 2
0
import datetime
from collections import OrderedDict as odict

##### OUTPUT FILE

save = 1

filename = "runs/fitall_" + datetime.datetime.now().strftime(
    "%y-%m-%d-%H-%M-%S")

mt.filters('./')

alpha = 0.14
beta = 3.14

lcs = mt.ProgramList("Cosmology")
name = lcs.table['name']
ra = lcs.table['ra']
dec = lcs.table['dec']

nSN = len(name)

# Identify duplicates, dtheta = maximum separation (in arcsec)
dtheta = 2
SN_dupl, theta_dupl = mf.duplicate(name, ra, dec, dtheta)

nobj = [1] * nSN
for i in range(0, len(SN_dupl)):
    nobj[np.where(name == SN_dupl[i][0])[0][0]] = 2
    nobj[np.where(name == SN_dupl[i][1])[0][0]] = -1
Esempio n. 3
0
import marshaltools

prog = marshaltools.ProgramList('Cosmology')

# try load sources just for a time range
prog = marshaltools.ProgramList('Cosmology', load_sources=False)
prog.get_saved_sources(trange=('2009-05-18 10:04:09', '2019-05-06 10:04:09'))
Esempio n. 4
0
import marshaltools

# test source and some keys to play with
name, src_id = 'ZTF18abmjvpb', 4066
keys = [
					'classification',
					'redshift',
					'uploaded_spectra.observer',
					'autoannotations.username',
					'redshift'
		]

prog = marshaltools.ProgramList("Cosmology", load_sources=True)

# pass the source name
print ("----------------")
out = prog.retrieve_from_src(name, keys)
print (out)

# if you've looked in the summary (as we are doing in this example), the summary 
# is downloaded at the first call, then it is simlpy used. Now it should be faster:
print ("----------------")
out = prog.retrieve_from_src(name, keys)
print (out)

# try with some missing key and default argument. You should see a warning there.
print ("----------------")
keys2 = keys+['fuffa']
out = prog.retrieve_from_src(name, keys2, default="merci")
print (out)
Esempio n. 5
0
# try to save some candidates

import marshaltools

cand_str = """ZTF18ablrndb 
ZTF18aawlhkh
ZTF18abporae
ZTF17aabihdn
ZTF18aawlhkh
ZTF18absgvqb
ZTF18ablprcf
ZTF18abufaej
ZTF18absrcps
ZTF18abvfecb
ZTF18abwbtco
ZTF18abxdkni
ZTF18abvrzqj"""
candidates = [x.strip() for x in cand_str.split('\n')]

print(candidates)

prog = marshaltools.ProgramList("AMPEL Test")
#prog.save_sources(candidates[0], programidx=42, save_by='name', max_attempts=3, be_anal=True)

failed = prog.save_sources(candidates[1:],
                           save_by='name',
                           max_attempts=3,
                           be_anal=True)
print(failed)
Esempio n. 6
0
# test adding comments to source
import marshaltools

# pick a test source
name = "ZTF19aabfyxn"

# load your program
prog = marshaltools.ProgramList("AMPEL Test",
                                load_sources=True,
                                load_candidates=False)

# try to post a message twice (should fail the second time)
prog.comment(
    name,
    "AMPEL test comment: to be posted twice (but should appear only once)",
    comment_type='comment',
    duplicate_mode='no')
prog.comment(
    name,
    "AMPEL test comment: to be posted twice (but should appear only once)",
    comment_type='comment',
    duplicate_mode='no')
input(
    "go to http://skipper.caltech.edu:8080/cgi-bin/growth/view_source.cgi?name=ZTF19aabfyxn and look at the comments"
)

# now post a message and then delete ot
prog.comment(name, "AMPEL test comment: to be deleted", comment_type='comment')
input("go and refresh your browser: a new comment should be there")
prog.delete_comment(name,
                    comment_text="AMPEL test comment: to be deleted",
Esempio n. 7
0
import marshaltools

prog = marshaltools.ProgramList('Cosmology')

t = prog.table
name = t['name'][1]
print(t)

print(name)
lc = prog.get_lightcurve(name)
Esempio n. 8
0
import time
import marshaltools

prog = marshaltools.ProgramList("AMPEL Test", load_saved=False)
opts = [
    'None', 'selected', 'notSelected', 'onlySelected', 'onlyNotSelected', 'all'
]

for showsaved in opts:

    start = time.time()
    res = prog.query_candidate_page(showsaved, '2018-09-06 09:31.09',
                                    '2018-09-07 09:31.09')
    end = time.time()
    print("showsaved: %s. Fetched %d candidates in %.2e sec" %
          (showsaved, len(res), (end - start)))
Esempio n. 9
0
import time

import marshaltools
prog = marshaltools.ProgramList("Cosmology")

summ = prog.source_summary('ZTF18abmjvpb')
print(summ)

for k, v in summ.items():
    if k != 'uploaded_photometry':
        print(k, ":", v)

# first you download them
start = time.time()
prog.get_summaries()
print("took %.2e sec" % (time.time() - start))

input("press enter to re-read the summaries. This time it will be fast")

## second time, you simply read them
prog.get_summaries()