Exemplo n.º 1
0
def plot_LvsL_multiple(line1='CIV1548',line2='CIII1908',line1range=[1e3,1e8],line2range=[1e0,1e8],
                       outputdir='./',verbose=True):
    """
    Plotting the model grids for all possible combinations of free and fixed parameters
    for two specific lines

    --- EXAMPLE OF USE ---
    import NEOGALmodels as nm
    nm.plot_LvsL_multiple(outputdir='NEOGALplots_clean1611XX/')

    """
    modeldata = nm.load_model('combined',verbose=verbose)

    if verbose: print ' - Putting together permutations of chosen setups for plotting'
    infodic          = {}
    infodic['Zgas']  = [False,0.0001,0.006,0.040], True
    infodic['logUs'] = [False,-1.0,-2.5,-4.0]    , False
    infodic['xid']   = [False,0.1,0.3,0.5]       , False
    infodic['nh']    = [False,10,100,1000,10000] , False
    infodic['CO']    = [False,0.1,0.38,1.4]      , False
    infodic['Mcut']  = [False,100,300]           , False

    variables = [infodic['Zgas'][0],infodic['logUs'][0],infodic['xid'][0],
                 infodic['nh'][0],infodic['CO'][0],infodic['Mcut'][0]]

    permutations            = list(itertools.product(*variables))
    permutations_with2false = [sublist for sublist in permutations if sublist.count(False) == 2.]
    Nplots                  = len(permutations_with2false)

    if verbose: print ' - With the restriction Nfalse=2 the setup will results in '+str(Nplots)+\
                      ' plots (if model data allows)'
    if verbose: print ' - These will be saved to the output directory: '+outputdir
    for pp, perm in enumerate(permutations_with2false):
        Zval     = perm[0]
        Uval     = perm[1]
        Xival    = perm[2]
        Nhval    = perm[3]
        COval    = perm[4]
        Mval     = perm[5]

        plotname = outputdir+'NEOGALmodelgrid_Zgas'+str(Zval).replace('.','p')+\
                   '_logU'+str(Uval).replace('.','p')+\
                   '_xid'+str(Xival).replace('.','p')+\
                   '_nH'+str(Nhval).replace('.','p')+\
                   '_CO'+str(COval).replace('.','p')+\
                   '_Mcut'+str(Mval).replace('.','p')+'.pdf'

        plotname = plotname.replace('False','Free')

        if verbose:
            plotno    = pp+1
            infostr = ' - Generating plot '+str("%.4d" % plotno)+'/'+str("%.4d" % Nplots)+': '+plotname.split('/')[-1]+'    '
            sys.stdout.write("%s\r" % infostr)
            sys.stdout.flush()

        if not Zval:
            logp1 = True
        else:
            logp1 = False

        nm.plot_LvsL(modeldata,line1=line1,line2=line2,logx=True,logy=True,logp1=logp1,logp2=False,verbose=False,
                     Zgas=Zval,logU=Uval,xid=Xival,nh=Nhval,COratio=COval,Mcutoff=Mval,
                     fixxrange=line1range,fixyrange=line2range,plotname=plotname)

    print '\n   ... done'