IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 20528


Ignore:
Timestamp:
Nov 4, 2008, 5:03:53 AM (18 years ago)
Author:
Sebastian Jester
Message:

Make 12 plots on one side using sm window command, add plot title too

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/sj_ippTests_branch_20080929/ippTests/compIPPphoto.py

    r20527 r20528  
    6767# (and that's probably quite enough anyway).
    6868
     69# Look at extended flag in PS1 vs. SDSS!!!
    6970
    7071plotcol_1frame_tlist = [
     
    7576    ,(['sky_ps1'],['d_mag'],'scatter')
    7677    ,(['d_sky'],['d_mag'],'scatter')
    77     ,(['x_psf'],['objc_colc'],'histogram')
     78    ,(['d_x'],['d_y'],'histogram')
    7879    ,(['m_rr_cc_psf'],['d_mag'],'scatter')
    7980    ,(['sky_sdss'],['sky_ps1'],'scatter')
     
    100101    outroot = re.sub('(\.[sc]mf|\.fits?)$','',summaryTable)
    101102    for filt in filtlist:
    102         rootstr = "nup_match_%s"%(filt)
     103        rootstr = "win_match_%s"%(filt)
    103104        globstr = "%s_*.eps"%(rootstr)
    104105        filelist = glob(globstr)
     
    203204    return outname
    204205   
    205 def plotStatsOnefile(values_hash,goodrow_hash,matchtable,plotcol_tlist,bandindex,format='eps',bandid=''):
     206def plotStatsOnefile(values_hash,goodrow_hash,matchtable,plotcol_tlist,bandindex,\
     207                         format='epsport',bandid='',expand=0.8):
    206208    """Make diagnostic plots for a single table, based on values in
    207209    values_hash"""
     
    218220    ptype_l = [ 41, 41, 40, 40, 30,30]
    219221    outname_l = []
    220     nplots = 0
     222    nplots = len(plotcol_tlist)
     223    all_outname = "win_" + re.sub('(\.[sc]mf|\.fits?)$','',matchtable) +".eps"
     224    smOpenPlot(all_outname,format=format)
     225    # all the explict sm. and smLib. calls should be wrapped into
     226    # functions that can be called for other plotting packages
     227    sm.window(1,1,1,1)
     228    sm.frelocate(0.5,1.05)
     229    sm.putlabel(5,re.sub('(\.[sc]mf|\.fits?)$','',re.sub('_','\_',matchtable)))
     230    i=0
    221231    for troika in plotcol_tlist:
     232        i+=1
     233        Nx,Ny,winx,winy = setWindow(i,nplots)
     234        smLib.window(Nx,Ny,winx,winy)
    222235        col1name_l = troika[0]
    223236        col2name_l = troika[1]
     
    225238        outname = getOutnameStatsOnefile(matchtable,plottype,col1name_l,col2name_l,format=format,bandid=bandid)
    226239        outname_l.append(outname)
    227         smOpenPlot(outname,format=format)
    228240        firstplot = True
    229         i = 0
    230241        for col1name,col2name in zip(col1name_l,col2name_l):
    231242            values1 = values_hash[col1name.lower()]
     
    255266                        smScatterPlot(values1,values2,logical=goodrows,xlab=col1name,ylab=col2name,\
    256267                                          # xrange=(xmin,xmax),yrange=(ymin,ymax))
    257                                       xrange=None,yrange=None)
     268                                      xrange=None,yrange=None,expand=expand)
    258269                    else:
    259270                        smScatterPlot(values1,values2,logical=goodrows,xlab=col1name,ylab=col2name)
    260271                else:
    261272                    angle(angle_l[i%len(angle_l)])
    262                     smScatterPlot(values1,values2,ptype=ptype_l[i%len(ptype_l)],logical=goodrows,append=True)
     273                    smScatterPlot(values1,values2,ptype=ptype_l[i%len(ptype_l)],\
     274                                      logical=goodrows,append=True,expand=expand)
    263275                    angle(0)
    264276            if plottype == 'histogram':
     
    273285                    minbin=None
    274286                    maxbin=None
    275                 smHistoPlot(values2,ltype=0,nbins=Nbins,minbin=minbin,maxbin=maxbin,xlab=col2name,ylab="N")
     287                smHistoPlot(values2,ltype=0,nbins=Nbins,minbin=minbin,maxbin=maxbin,\
     288                                xlab=col2name,ylab="N",expand=expand)
    276289                smHistoPlot(values1,append=True,minbin=minbin,maxbin=maxbin,nbins=Nbins,\
    277                             ltype=2)
     290                            ltype=2,expand=expand)
    278291            firstplot = False
    279             i+=1
    280         smClosePlot()
    281         nplots += 1
     292    smClosePlot()
    282293    all_outname = "nup_" + re.sub('(\.[sc]mf|\.fits?)$','',matchtable) +".eps"
    283294    tmp_outname = "tmp_" + re.sub('(\.[sc]mf|\.fits?)$','',matchtable) +".eps"
    284     print "creating ", all_outname
    285     mergecmd = "gs -dNOPAUSE -sDEVICE=pswrite -sOutputFile=%s %s -c quit" %(tmp_outname,' '.join(outname_l))
    286     call(mergecmd,shell=True)
    287     psnupcmd = "psnup -pletter -%i %s %s"%(nplots,tmp_outname,all_outname)
    288     print "calling ", psnupcmd
    289     call(psnupcmd,shell=True)
    290     os.remove(tmp_outname)
     295    # print "creating ", all_outname
     296    # mergecmd = "gs -dNOPAUSE -sDEVICE=pswrite -sOutputFile=%s %s -c quit" %(tmp_outname,' '.join(outname_l))
     297    # call(mergecmd,shell=True)
     298    # psnupcmd = "psnup -pletter -%i %s %s"%(nplots,tmp_outname,all_outname)
     299    # print "calling ", psnupcmd
     300    # call(psnupcmd,shell=True)
     301    # os.remove(tmp_outname)
    291302    return all_outname
    292303
    293 def setWindow(i,Nplots):
     304def setWindow(i,Nplots,portrait=True):
    294305    """Set sm window for plotting the i-th out of Nplots. The logic is
    295306    that N_x * N_y >= Nplots and N_y-N_x is 0 or 1. So Ny is the sqrt
     
    318329    if int(i/Nx) == i/float(Nx):
    319330        winy -= 1
     331    if not portrait:
     332        tmp = Nx
     333        Nx = Ny
     334        Ny = tmp
     335        tmp = winx
     336        winx = winy
     337        winy = tmp
    320338    return Nx,Ny,winx,winy
    321339
     
    697715    """Issue sm device command for file of given format:
    698716    eps -> postfile
     717    epsland -> postlandfile
     718    epsport -> postportfile
    699719    else just use given format as 'device'"""
    700720    from sm import device, erase
     
    703723    elif format == 'eps':
    704724        device('postfile '+filename)
     725    elif format == 'epsland':
     726        device('postlandfile '+filename)
     727    elif format == 'epsport':
     728        device('postportfile '+filename)
    705729    else:
    706730        device(format +' '+filename)   
     
    717741                    xlab=None,ylab=None,xrange=None,yrange=None,\
    718742                    box1=None,box2=None,box3=None,box4=None,\
    719                     ltype=0,append=False):
     743                    ltype=0,append=False,expand=1.8):
    720744    """Plot a histogram, intelligently deriving bins from the given
    721745    parameters if they are given intelligently.  Otherwise, silently
     
    735759    bincenters = leftbinedges + 0.5*(leftbinedges[1]-leftbinedges[0])
    736760
     761    sm.expand(expand)
    737762    sm.ltype(ltype)
    738763    if not append:
     
    764789def smScatterPlot(x,y,logical=None,ptype=41,xlab=None,ylab=None,xrange=None,yrange=None,\
    765790                    box1=None,box2=None,box3=None,box4=None,\
    766                     append=False):
     791                    append=False,expand=1.8):
    767792    """Make an sm scatter plot on current device. If append=True,
    768793    overplot with current limits. Otherwise, draw box box1 box2 box3 box4"""
    769794    import sm
    770     sm.expand(1.8)
     795    sm.expand(expand)
    771796    sm.lweight(5)
    772797    # Silently ignore any problems with plot generation
     
    779804        pass
    780805
     806# May need to add erase option here which defaults to True
    781807def smSetup(x,y,logical,xrange,yrange,xlab,ylab,box1,box2,box3,box4):
    782808    import sm,re
Note: See TracChangeset for help on using the changeset viewer.