Beispiel #1
0
def find_TSdc(name, pwndata):
    print "Calculating TSdc"
    roi = setup_pwn(name, pwndata, phase=PhaseRange(0, 1))

    # start with a grid search, for convergence help
    f = roi.get_model(name).i_flux(1e2, 1e5)

    best_ts = -np.inf
    for index in [0.01, 0.5, 1, 1.5, 2]:
        for cutoff in [3e2, 1e3, 3e3, 1e4, 3e4]:
            m = ExpCutoff(index=index, cutoff=cutoff)
            m.set_flux(f, 1e2, 1e5)
            roi.modify(which=name, model=m, keep_old_flux=False)
            roi.fit(use_gradient=False, estimate_errors=False)
            ts = roi.TS(which=name)
            print cutoff, index, ts
            if ts > best_ts:
                best_ts, best_index, best_cutoff = ts, index, cutoff

    roi.print_summary()

    TSdc = best_ts

    roi.plot_sed(which=name, filename="sed_%s.pdf" % name)
    roi.print_summary()

    print "TSdc=%.1f" % TSdc

    return TSdc
Beispiel #2
0
parser.add_argument("-emax", "--emax",  default=1.0e5, type=float)
parser.add_argument("-model", "--model")

args=parser.parse_args()
  
name=args.name

phase=yaml.load(open(args.pwnphase))[name]['phase']

#####setup the roi testing if we want to use a model or a catalog


if args.model != "None":
    #Include an existing sourcemodel
    modelloc=args.model+"/%s/srcmodel_%s.xml"
    roi=setup_pwn(name,args.pwndata,phase,emin=args.emin,emax=args.emax,model=modelloc,maxroi=maxroi)
else :
    #Create a source model such as less than 20 parameters still free
    maxroi=10.0
    free_radius=5.0
    roi=setup_pwn(name,args.pwndata,phase,emin=args.emin,emax=args.emax,free_radius=free_radius,maxroi=maxroi)

    while len(roi.parameters())>19 and free_radius>0.5:
        free_radius*=0.9
        roi=setup_pwn(name,args.pwndata,phase,emin=args.emin,emax=args.emax,free_radius=free_radius,maxroi=maxroi)
        
def get_spec_par(like,srcname):
    """Function to obtain the spectral parameters of a source using the like object"""
    #Call the function
    funcs = like[srcname].src.getSrcFuncs()
    
Beispiel #3
0
from uw.like.roi_tsmap import TSCalc,TSCalcPySkyFunction
from argparse import ArgumentParser
from skymaps import SkyImage,SkyDir
import yaml

from uw.like.sed_plotter import plot_sed
    

parser = ArgumentParser()
parser.add_argument("-l", "--list", required=True, help="List of all yaml sources")
parser.add_argument("-n", "--name", required=True, help="Name of the pulsar")
args=parser.parse_args()
  
name=args.name

roi=setup_pwn(name,args.list)


results=r={}



source=roi.get_source(which=name)
pulsar_position=source.skydir
    
roi.fit(use_gradient=False)

roi.print_summary()

r['ts_at_pulsar'] = roi.TS(which=name,quick=False,quiet=True)
r['flux_at_pulsar'],r['flux_at_pulsar_err']=source.model.i_flux(100,100000,error=True)
Beispiel #4
0

parser = ArgumentParser()
parser.add_argument("--pwndata", required=True)
parser.add_argument("-p", "--pwnphase", required=True)
parser.add_argument("-n", "--name", required=True, help="Name of the pulsar")
parser.add_argument("--emin", default=1e2, type=float)
parser.add_argument("--emax", default=3e5, type=float)
args=parser.parse_args()
  
name=args.name
emin=args.emin
emax=args.emax

phase=yaml.load(open(args.pwnphase))[name]['phase']
roi=setup_pwn(name,args.pwndata,phase)


def customize_roi(name,roi):
    """ For each modification, add some justifcaiton for why
        this needs to be done + where you did the analysis
        which convinced you we need to do this to the region. """

    # first, modify known pulsars to their fit values from PWNCat1
    for psr,flux,index in [
        ['PSRJ0034-0534',   17.26e-9, 2.27, ],
        ['PSRJ0534+2200',  980.00e-9, 2.15, ],
        ['PSRJ0633+1746', 1115.54e-9, 2.24, ],
        ['PSRJ0835-4510',  405.44e-9, 2.30, ],
        ['PSRJ1023-5746',    1.33e-9, 1.05, ],
        ['PSRJ1813-1246',  295.55e-9, 2.65, ],
Beispiel #5
0
do_point = not args.no_point
do_extended = not args.no_extended
do_gtlike = not args.no_gtlike
do_plots = not args.no_plots
do_cutoff = not args.no_cutoff
do_extension_upper_limit = not args.no_extension_upper_limit


name = args.name
emin = args.emin
emax = args.emax

phase = yaml.load(open(args.pwnphase))[name]["phase"]

free_radius = 2
roi = setup_pwn(name, args.pwndata, phase, free_radius=free_radius)
while len(roi.parameters()) > 19 and free_radius > 0.5:
    free_radius *= 0.9
    roi = setup_pwn(name, args.pwndata, phase, xml=None, free_radius=free_radius)


from modify import modify_roi

modify_roi(name, roi)

results = r = defaultdict(lambda: defaultdict(dict))


def plots(roi, hypothesis, size=5):
    print "Making plots for hypothesis %s" % hypothesis
    roi.plot_tsmap(filename="residual_tsmap_%s_%s.png" % (hypothesis, name), size=size, pixelsize=0.1)