IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 20472


Ignore:
Timestamp:
Oct 30, 2008, 5:07:04 AM (18 years ago)
Author:
Sebastian Jester
Message:

new plotting using psnup; mergePlots is out of synch with new plotting...

File:
1 edited

Legend:

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

    r20459 r20472  
    6464
    6565plotcol_1frame_tlist = [
    66     (['d_sky'],['d_mag'],'scatter')
     66    (['x_psf','objc_colc'],['y_psf','objc_rowc'],'scatter')
     67    ,(['psfinstmag_sdss'],['d_mag'],'scatter')
     68    ,(['psfinstmag_sdss'],['d_sky'],'scatter')
    6769    ,(['d_x'],['d_y'],'scatter')
    6870    ,(['sky_ps1'],['d_mag'],'scatter')
    69     ,(['psfinstmag_sdss'],['d_mag'],'scatter')
    70     ,(['psfinstmag_sdss'],['d_sky'],'scatter')
     71    ,(['d_sky'],['d_mag'],'scatter')
     72    ,(['x_psf'],['objc_colc'],'histogram')
    7173    ,(['m_rr_cc_psf'],['d_mag'],'scatter')
    7274    ,(['sky_sdss'],['sky_ps1'],'scatter')
     75    ,(['y_psf'],['objc_rowc'],'histogram')
     76    ,(['sky_sdss'],['sky_ps1'],'histogram')
    7377    ,(['psfinstmag_sdss'],['psf_inst_mag'],'histogram')
    74     ,(['sky_sdss'],['sky_ps1'],'histogram')
    75     ,(['x_psf'],['objc_colc'],'histogram')
    76     ,(['y_psf'],['objc_rowc'],'histogram')
    77     ,(['x_psf','objc_colc'],['y_psf','objc_rowc'],'scatter')
    7878    ]
    7979
     
    8181    (['d_mag_median'],['d_sky_median'],'scatter')
    8282    ,(['d_x_median'],['d_y_median'],'scatter')
     83    ,(['d_x_median'],['d_y_median'],'histogram')
    8384    ,(['d_mag_median'],['N_SDSS'],'scatter')
     85    ,(['N_PS1'],['N_SDSS'],'scatter')
    8486    ,(['field','field'],['d_mag_median','d_mag_mean'],'scatter')
    8587    ]
    8688
    87 def mergePlots(plotcol_1frame_tlist=plotcol_1frame_tlist,filtlist=['u','g','r','i','z'],workdir='/IPP/data/SDSS/stripe82/coadd/compare'):
     89def mergePlots(summaryTable,plotcol_1frame_tlist=plotcol_1frame_tlist,filtlist=['u','g','r','i','z'],workdir='/IPP/data/SDSS/stripe82/coadd/compare'):
    8890    from subprocess import call
    8991    from glob import glob
     92    import re
    9093    import os
    9194    os.chdir(workdir)
     95    outroot = re.sub('(\.[sc]mf|\.fits?)$','',summaryTable)
    9296    for tup in plotcol_1frame_tlist:
    9397        t1,t2,t3=tup
     
    9599            globstr = getOutnameStatsOnefile("match_%s_*"%(filt),t3,t1,t2)
    96100            filelist = glob(globstr)
    97             outname = getOutnameStatsOnefile("merged_%s" %(filt),t3,t1,t2)
     101            outname = getOutnameStatsOnefile("merged_%s_%s" %(outroot,filt),t3,t1,t2)
    98102            cmdstr = "gs -dNOPAUSE -sDEVICE=pswrite -sOutputFile=%s %s -c quit" %(outname,' '.join(filelist))
    99103            print "Making %s" %(outname)
    100104            call(cmdstr,shell=True)
    101             call("gzip %s" %(outname),shell=True)
     105            print "gzipping %s" %(outname)
     106            call("gzip -f %s" %(outname),shell=True)
    102107
    103108def compIPPphoto(summaryTable,mode,plotcol_1frame_tlist=plotcol_1frame_tlist,\
     
    144149        vallist,keylist = valuesKeysSortedByKeys(stats_hash)
    145150        rowtuple_list.append(vallist)
    146         plotStatsOnefile(column_hash,goodrow_hash,matchtable,plotcol_1frame_tlist,bandindex)
     151        plotStatsOnefile(column_hash,goodrow_hash,matchtable,plotcol_1frame_tlist,bandindex,bandid=filter_name)
    147152        # return column_hash,goodrow_hash
    148153    newrows = numpy.rec.array(rowtuple_list,names=keylist)
     
    159164    sumgoodrows_hash = summaryhash.fromkeys(summaryhash.keys(),numpy.ones((nrows,),bool))
    160165    for filt in filters:
     166        print bandindex_hash[filt], filt
    161167        plotStatsOnefile(summaryhash,sumgoodrows_hash,summaryTable,plotcol_summary_tlist,bandindex_hash[filt],bandid=filt)
    162     mergePlots(plotcol_1frame_tlist=plotcol_1frame_tlist,filtlist=filters)
     168    mergePlots(summaryTable,plotcol_1frame_tlist=plotcol_1frame_tlist,filtlist=filters)
    163169    return column_hash,goodrow_hash
    164170
     
    175181    return outhash
    176182
    177 def getOutnameStatsOnefile(matchtable,kind,col1_l,col2_l=None,format='eps',bandid=''):
     183def getOutnameStatsOnefile(matchtable,kind,col1_l,col2_l=None,format='eps',bandid='',useBandid=False):
    178184    import re
    179185    # Construct output filename
    180186    root = re.sub('(\.[sc]mf|\.fits?)$','',matchtable)
    181     if bandid != '':
     187    if useBandid and bandid != '':
    182188        root = "%s_%s" %(root,bandid)
    183189    if isNone(col2_l):
     
    191197   
    192198def plotStatsOnefile(values_hash,goodrow_hash,matchtable,plotcol_tlist,bandindex,format='eps',bandid=''):
    193     """Make diagnostic plots for a single table, based on values
    194     in values_hash"""
     199    """Make diagnostic plots for a single table, based on values in
     200    values_hash"""
     201    from subprocess import call
    195202    from numpy import concatenate
    196203    from sm import cvar,angle
     
    201208    angle_l = [0,45,0,45,0,90]
    202209    ptype_l = [ 41, 41, 40, 40, 30,30]
     210    outname_l = []
     211    nplots = 0
    203212    for troika in plotcol_tlist:
    204213        col1name_l = troika[0]
     
    206215        plottype = troika[2]
    207216        outname = getOutnameStatsOnefile(matchtable,plottype,col1name_l,col2name_l,format=format,bandid=bandid)
     217        outname_l.append(outname)
    208218        smOpenPlot(outname,format=format)
    209219        firstplot = True
     
    259269            firstplot = False
    260270            i+=1
    261     smClosePlot()
     271        smClosePlot()
     272        nplots += 1
     273    all_outname = "nup_" + re.sub('(\.[sc]mf|\.fits?)$','',matchtable) +".eps"
     274    tmp_outname = "tmp_" + re.sub('(\.[sc]mf|\.fits?)$','',matchtable) +".eps"
     275    print "creating ", all_outname
     276    mergecmd = "gs -dNOPAUSE -sDEVICE=pswrite -sOutputFile=%s %s -c quit" %(tmp_outname,' '.join(outname_l))
     277    call(mergecmd,shell=True)
     278    psnupcmd = "psnup -pletter -%i %s %s"%(nplots,tmp_outname,all_outname)
     279    print "calling ", psnupcmd
     280    call(psnupcmd,shell=True)
     281    os.remove(tmp_outname)
     282    return all_outname
     283       
    262284
    263285def valuesKeysSortedByKeys(hash):
     
    513535    return array(good1_l),array(good2_l),array(good3_l)
    514536   
    515 def makePlan(lastcamcol=6):
     537def makePlan(lastcamcol=1):
    516538    """Make paired list of which fpObjc file to compare to which IPP
    517539    .cmf file. Could also think about constructing the fpObjc filename
     
    598620    # Filtering out objects that can't be primary, i.e.
    599621    # !BRIGHT && (!BLENDED || NODEBLEND || nchild == 0)
    600     sdssfilt += ';select !((flags[%s]&1<<1)!=0)&&(!((flags[%s]&1<<3)!=0)||((flags[%s]&1<<6)!=0)||nchild==0)' % \
    601         (bandindex,bandindex,bandindex)
    602     # add check for BINNED1 !!! bit28 in flags1
    603    
     622    # Get flag values by left-shifting a 1 by the correct number of bits. Bit N needs to be left-shifted N times.
     623    bright = 1<<1
     624    blended = 1<<3
     625    nodeblend = 1<<6
     626    binned1 = 1<<28
     627    sdssfilt += ';select ((flags[%s]&%s)==0)&&(!((flags[%s]&%s)!=0)||((flags[%s]&%s)!=0)||nchild==0)&&((flags[%s]&%s)!=0)' % \
     628        (bandindex,bright,bandindex,blended,bandindex,nodeblend,bandindex,binned1)
    604629    # Check flag 0x4000 (extended) to compare against prob_psf in SDSS
    605630    # - for some reason, 'flags' and the other integer columns get
Note: See TracChangeset for help on using the changeset viewer.