コード例 #1
0
ファイル: cycspec.py プロジェクト: gitj/dynISM
def processOne(fn,done,gpus,telescope,outdir,plotdir,redo=False):
    print fn
    info = decodeFilename(fn)
    print info
    pklname = ('ds_%s_%s_%s_%s.pkl' % (info['source'],info['mjd'],
                                      info['scan'],telescope))
    outfn = os.path.join(outdir,'pkls',pklname)
    if (not redo) and (outfn in done):
        return fn,None,pklname
    try:
    #if True:
        ds = loadDynSpecFromCycSpecScan(int(info['scan']), int(info['mjd']), 
                                        gpus=gpus, telescope=telescope)
        print "loaded dynspec"
        dynspec.pickle(outfn, ds)
        print "pickled",outfn
        fig = Figure(figsize=(10,12))
        fig.subplots_adjust(left=0.09,bottom=0.05,top=0.95,right=0.95)
        ds.plot(fig=fig)
        plotname = os.path.join(plotdir,pklname + '.png')
        esc_fname = outfn.replace('_',r'\_')
        fig.suptitle(('%s @ %s %s' % (info['source'],telescope,esc_fname)),size='medium')
        canvas = FigureCanvasAgg(fig)
        canvas.print_figure(plotname)
    except Exception,e:
        print fn,e,pklname
        return fn,e,pklname
コード例 #2
0
ファイル: cycspec.py プロジェクト: gitj/dynISM
def processOne(fn, done, gpus, telescope, outdir, plotdir, redo=False):
    print fn
    info = decodeFilename(fn)
    print info
    pklname = ('ds_%s_%s_%s_%s.pkl' %
               (info['source'], info['mjd'], info['scan'], telescope))
    outfn = os.path.join(outdir, 'pkls', pklname)
    if (not redo) and (outfn in done):
        return fn, None, pklname
    try:
        #if True:
        ds = loadDynSpecFromCycSpecScan(int(info['scan']),
                                        int(info['mjd']),
                                        gpus=gpus,
                                        telescope=telescope)
        print "loaded dynspec"
        dynspec.pickle(outfn, ds)
        print "pickled", outfn
        fig = Figure(figsize=(10, 12))
        fig.subplots_adjust(left=0.09, bottom=0.05, top=0.95, right=0.95)
        ds.plot(fig=fig)
        plotname = os.path.join(plotdir, pklname + '.png')
        esc_fname = outfn.replace('_', r'\_')
        fig.suptitle(('%s @ %s %s' % (info['source'], telescope, esc_fname)),
                     size='medium')
        canvas = FigureCanvasAgg(fig)
        canvas.print_figure(plotname)
    except Exception, e:
        print fn, e, pklname
        return fn, e, pklname
コード例 #3
0
ファイル: replotAllDynspec.py プロジェクト: gitj/dynISM
def pOne(fn):
    try:
        fig = Figure(figsize=(10,12))
        fig.subplots_adjust(left=0.09,bottom=0.05,top=0.95,right=0.95)
        ds = dynspec.unpickle(fn)
        ds = dynspec.DynSpec(ds.source,ds.epochs,ds.telescope,ds.tints,ds.profile,ds.onp,ds.offp,ds.freqs,ds.on,ds.off,ds.guppi,ds.alpha,discard=0.05)
        ds.refit()
        ds.plot(fig=fig)
        outfn = os.path.split(fn)[1]
        plotname = os.path.join(plotdir,outfn + '.png')
        esc_fname = outfn.replace('_',r'\_')
        fig.suptitle(('%s @ %s %s' % (ds.source,ds.telescope,esc_fname)),size='medium')
        canvas = FigureCanvasAgg(fig)
        canvas.print_figure(plotname)
        if repickle:
            dynspec.pickle(fn, ds)
    except Exception, e:
        return fn,e
コード例 #4
0
ファイル: uppispec.py プロジェクト: gitj/dynISM
def processOne(fn, done, telescope, outdir, plotdir, redo=False):
    try:
        info = decodeFilename(os.path.split(fn)[1])
    except:
        print "couldn't decode", fn
        return fn, "couldn't decode"
    print info
    pklname = ('ds_%s_%s_%s_%s_%s.pkl' %
               (info['source'], info['mjd'], info['scan'], telescope,
                info['instrument']))
    outfn = os.path.join(outdir, 'pkls', pklname)
    if (not redo) and (outfn in done):
        return fn, None
    fns = glob.glob(fn[:-9] + '*')

    print fns
    try:
        #    if True:
        ds = loadDynSpecFromGPuppi(fns)
        print "loaded dynspec"
        dynspec.pickle(outfn, ds)
        print "pickled", outfn
        fig = Figure(figsize=(10, 12))
        fig.subplots_adjust(left=0.09, bottom=0.05, top=0.95, right=0.95)
        ds.plot(fig=fig)
        plotname = os.path.join(plotdir, pklname + '.png')
        esc_fname = outfn.replace('_', r'\_')
        fig.suptitle(('%s @ %s %s' % (info['source'], telescope, esc_fname)),
                     size='medium')
        canvas = FigureCanvasAgg(fig)
        canvas.print_figure(plotname)

        fig = Figure(figsize=(10, 12))
        fig.subplots_adjust(left=0.09, bottom=0.05, top=0.95, right=0.95)
        ds.plot(fig=fig, stretch=True)
        plotname = os.path.join(plotdir, 'stretch', pklname + '.png')
        esc_fname = outfn.replace('_', r'\_')
        fig.suptitle(('%s @ %s %s' % (info['source'], telescope, esc_fname)),
                     size='medium')
        canvas = FigureCanvasAgg(fig)
        canvas.print_figure(plotname)
    except Exception, e:
        print fn, e
        return fn, e
コード例 #5
0
ファイル: uppispec.py プロジェクト: gitj/dynISM
def processOne(fn,done,telescope,outdir,plotdir,redo=False):
    try:
        info = decodeFilename(os.path.split(fn)[1])
    except:
        print "couldn't decode",fn
        return fn,"couldn't decode"
    print info
    pklname = ('ds_%s_%s_%s_%s_%s.pkl' % (info['source'],info['mjd'],
                                      info['scan'],telescope,info['instrument']))
    outfn = os.path.join(outdir,'pkls',pklname)
    if (not redo) and (outfn in done):
        return fn,None
    fns = glob.glob(fn[:-9]+'*')
    
    print fns
    try:
#    if True:
        ds = loadDynSpecFromGPuppi(fns)
        print "loaded dynspec"
        dynspec.pickle(outfn, ds)
        print "pickled",outfn
        fig = Figure(figsize=(10,12))
        fig.subplots_adjust(left=0.09,bottom=0.05,top=0.95,right=0.95)
        ds.plot(fig=fig)
        plotname = os.path.join(plotdir,pklname + '.png')
        esc_fname = outfn.replace('_',r'\_')
        fig.suptitle(('%s @ %s %s' % (info['source'],telescope,esc_fname)),size='medium')
        canvas = FigureCanvasAgg(fig)
        canvas.print_figure(plotname)

        fig = Figure(figsize=(10,12))
        fig.subplots_adjust(left=0.09,bottom=0.05,top=0.95,right=0.95)
        ds.plot(fig=fig,stretch=True)
        plotname = os.path.join(plotdir,'stretch',pklname + '.png')
        esc_fname = outfn.replace('_',r'\_')
        fig.suptitle(('%s @ %s %s' % (info['source'],telescope,esc_fname)),size='medium')
        canvas = FigureCanvasAgg(fig)
        canvas.print_figure(plotname)
    except Exception,e:
        print fn,e
        return fn,e
コード例 #6
0
import matplotlib
matplotlib.use('agg')
import uppispec
import dynspec
import multiprocessing
import functools
import glob
import os
from matplotlib.figure import Figure                         
from matplotlib.backends.backend_agg import FigureCanvasAgg 

telescope='gbt'
gpus=None#[1,2,3,4,6]
redo=False
outdir = '/lakitu/data/scratch/nanograv/uppi/analysis/dynspec'
plotdir= '/home/gjones/uppi/analysis/dynspec/plots'
#todo = glob.glob('/lakitu/data/scratch/nanograv/puppi/*/*uppi_?????_*_*_0001.fits')
todo = glob.glob('/lakitu/data/scratch/nanograv/guppi/*/*uppi_?????_*_*_0001.fits')
todo = [x for x in todo if x.find('cal') < 0]
todo.sort()
#todo = todo[:2]
done = set(glob.glob(os.path.join(outdir,('pkls/ds_*_%s_*.pkl' % telescope))))
errors = {}
def pOne(fn):
    return uppispec.processOne(fn,done,telescope,outdir,plotdir,redo)
p = multiprocessing.Pool(12)
errors = dict(p.map(pOne,todo))
dynspec.pickle('uppierrors.pkl', errors)
print errors
コード例 #7
0
import dynspec
import multiprocessing
import functools
import glob
import os
from matplotlib.figure import Figure
from matplotlib.backends.backend_agg import FigureCanvasAgg

telescope = 'gbt'
gpus = None  #[1,2,3,4,6]
redo = False
outdir = '/lakitu/data/scratch/nanograv/uppi/analysis/dynspec'
plotdir = '/home/gjones/uppi/analysis/dynspec/plots'
#todo = glob.glob('/lakitu/data/scratch/nanograv/puppi/*/*uppi_?????_*_*_0001.fits')
todo = glob.glob(
    '/lakitu/data/scratch/nanograv/guppi/*/*uppi_?????_*_*_0001.fits')
todo = [x for x in todo if x.find('cal') < 0]
todo.sort()
#todo = todo[:2]
done = set(glob.glob(os.path.join(outdir, ('pkls/ds_*_%s_*.pkl' % telescope))))
errors = {}


def pOne(fn):
    return uppispec.processOne(fn, done, telescope, outdir, plotdir, redo)


p = multiprocessing.Pool(12)
errors = dict(p.map(pOne, todo))
dynspec.pickle('uppierrors.pkl', errors)
print errors