def rwa_guys():
    """
    Creates JJH plots for RWA sources.

    """
    
    print "Now for RWA sources:"

    for s, n in zip(rwa_sources, rwa_names):
        fig = plot3.jjh(rwa_data, s, name=str(n), color_slope=True, 
                        date_offset=54579,
                        outfile=path2+'RWA_sources/'+str(n), png_too=True)

        if fig == None:
            print "dude %s failed to plot right" % str(s)
def wise_guys():
    """
    Creates JJH plots for WISE and Aspin sources.
    
    """

    # wise disks
    for s, n in zip(wise_disks[rwd], wise_disks_names[rwd]):
        fig = plot3.jjh(watso, s, name=str(n), color_slope=True, 
                        date_offset=54579,
                        outfile=path2+'Wise/'+str(n), png_too=True)

        if fig == None:
            print "dude %s failed to plot right" % str(s)

    # wise special case
    for s, n in zip(wise_v, wise_v_names):
        fig = plot3.jjh(data, s, name=str(n), color_slope=True, 
                        date_offset=54579,
                        outfile=path2+'Wise/'+str(n), png_too=True)


    # aspins
    for s, n in zip(aspin_sources[ras], aspin_sources_names[ras]):
        fig = plot3.jjh(watso, s, name=str(n), color_slope=True, 
                        date_offset=54579,
                        outfile=path2+'Aspin/'+str(n), png_too=True)

        if fig == None:
            print "dude %s failed to plot right" % str(s)


    # wise trans
    for s, n in zip(wise_trans[rwt], wise_trans_names[rwt]):
        fig = plot3.jjh(watso, s, name=str(n), color_slope=True, 
                        date_offset=54579,
                        outfile=path2+'transition/'+str(n), png_too=True)

        if fig == None:
            print "dude %s failed to plot right" % str(s)

    # wise extras
    for s, n in zip(wise_extras[rwe], wise_extras_names[rwe]):
        fig = plot3.jjh(data, s, name=str(n), color_slope=True, 
                        date_offset=54579,
                        outfile=path2+'Wise_extras/'+str(n), png_too=True)

        if fig == None:
            fig2 = plot3.jjh(welo, s, name=str(n), color_slope=True, 
                             date_offset=54579,
                             outfile=path2+'Wise_extras/'+str(n), png_too=True)
            if fig2 == None:
                print "dude %s failed to plot right" % str(s)

    print "did that."
def gen_ukvar_all_jjh(start=0, stop=len(ukvar)):
    """ 
    Creates all the UKvar JJH plots in one shot.

    Uses the UKvar ID as the primary identifier; lists info
    in the filename distinguishing auto/strict/subj, plus per/nonper
    I'm thinking: 'a' for autovar, 't' for strict, 'j' for subj,
    'p' for periodic, 'n' for nonperiodic. Each dude gets two letters.

    The glued plots only consist of (a) colored-by-time and 
    (b) colored-by-phase. No periodograms here, go see the lightcurves
    for that.
    
    if periodic:
        do the gluedvars stuff
    else:
        just a normal lightcurve!

    """

    for s, id, i in zip(ukvar.SOURCEID, ukvar.UKvar_ID, 
                        range(len(ukvar)))[start:stop]:

        # Each plot gets a suffix: ('a'|'t'|'j')+('p'|'n')
        
        suffix = suffix_generator(ukvar, i)

        # Periodics first

        #        if ukvar.periodic[i] == 1:
        if False: # uncomment the above line when jjh_phase is functional.
            
            # Dig up the best period for this dude! 3 main cases.

            if ukvar.autovar[i] == 1:
                if s in autovars_true_periods.SOURCEID:
                    t = autovars_true_periods
                elif s in autovars_true_periods_s1.SOURCEID:
                    t = autovars_true_periods_s1
                else:
                    raise Exception("Something weird happened!")
            else:
                t = conf_subj_periodics
                
            best_period = t.best_period[t.SOURCEID == s][0]

            # Let's make 2 plots. LC and folded. Save em into a place.
            # print out the names as ID_fs_lc.png
            plot3.jjh(data, s, color_slope=True, 
                      date_offset=54034,
            #                      timecolor=True,
                      name = "%s:  UKvar %s (%s)" %
                      (str(s), str(id), suffix),
                      outfile=jjh_path+"%s_%s_lc.png" %
                      (str(id), suffix))

            # ID_fs_phase.png
            plot3.jjh_phase(data, s, timecolor='time', color_slope=True,
                            date_offset=54034,
                            period=best_period, 
                            name = "%s:  UKvar %s (%s)" %
                            (str(s), str(id), suffix),
                            outfile=jjh_path+"%s_%s_phase.png" % 
                            (str(id), suffix))


# now glue em together!
                
            try:
                call(["montage","-mode", "concatenate", "-tile", "2x", 
                      jjh_path+"%s_%s*.png" % (str(id), suffix), 
                      jjh_path_g+"%s_%s.png" % (str(id), suffix) ])
            except Exception, e:
                print "Why did montage fail?"
                raise e
                
        else:
            # Just make the lightcurve.
            
            plot3.jjh(data, s, color_slope=True, 
                      date_offset=54034,
            #                      timecolor=True, 
                      name = "%s:  UKvar %s (%s)" %
                      (str(s), str(id), suffix),
                      outfile=jjh_path_g+"%s_%s.png" % 
                      (str(id), suffix))

        print "Completed jjh: UKvar %s" % str(id)