예제 #1
0
def gen_conf(wdir, tar, est):

    print('Modifying config with new experimental data file...')

    load_config('%s/input.py' % wdir)
    istep = core.get_istep()
    conf['steps'][istep]['datasets'] = {}
    conf['steps'][istep]['datasets']['pidis'] = []
    conf['datasets']['pidis']['filters'] = []

    #--placeholder index
    idx = 80000
    conf['datasets']['pidis']['xlsx'][idx] = './%s/sim/all-%s-%s.xlsx' % (
        wdir, tar, est)
    conf['steps'][istep]['datasets']['pidis'].append(idx)

    fdir = os.environ['FITPACK']
    fn = [fdir + '/database/EIC/expdata/1000.xlsx']

    conf['pidis grid'] = {}
    if tar == 'p': conf['pidis grid']['overwrite'] = True
    if tar == 'd': conf['pidis grid']['overwrite'] = False
    conf['pidis grid']['xlsx'] = fn
    conf['idis grid'] = {}
    if tar == 'p': conf['idis grid']['overwrite'] = True
    if tar == 'd': conf['idis grid']['overwrite'] = False
    conf['idis grid']['xlsx'] = fn

    return conf
예제 #2
0
    def histogram_figure(self, wdir, Q2, dpi):
        ## plot histogram for parameters of all flavors
        load_config('%s/input.py' % wdir)
        istep = core.get_istep()
        # jar = load('%s/data/jar-%d.dat' % (wdir, istep))
        labels = load('%s/data/labels-%d.dat' % (wdir, istep))
        self.cluster = labels['cluster']
        self.best_cluster = np.argmin(labels['cluster_average_chi2'])

        if Q2 == None: Q2 = conf['Q20']
        if Q2 == conf['Q20']:
            self.ppdf_parameter_data = load('%s/data/ppdf-parameters-%d.dat' % (wdir, istep))
        else:
            self.ppdf_parameter_data = load('%s/data/ppdf-parameters-%d-%f.dat' % (wdir, istep, Q2))

        shapes = self.ppdf_parameter_data.keys()
        flavors = self.ppdf_parameter_data[shapes[0]].keys()

        for _ in sorted(self.ppdf_parameter_data[shapes[0]][flavors[0]]):
            print '\nplotting PPDF parameter %s histograms from %s' % (_, wdir)
            if len(flavors) == 8:
                n_rows, n_columns = 4, 2
                figure = py.figure(figsize = (n_columns * 5.0, n_rows * 3.0))
                axs = [py.subplot(n_rows, n_columns, count + 1) for count in range(8)]
                sys.exit('please make a subplot configuration for your flavors')
            elif len(flavors) == 7:
                n_rows, n_columns = 4, 2
                figure = py.figure(figsize = (n_columns * 5.0, n_rows * 3.0))
                axs = [py.subplot(n_rows, n_columns, count + 1) for count in range(8) if count != 7]
            else:
                sys.exit('please make a subplot configuration for your flavors')

            if sorted(flavors) == sorted(['g', 'up', 'ub', 'dp', 'db', 'sp', 'sb']):
                self.ppdf_histogram(axs[0], 'up', _, r'\boldmath$u_+$')
                self.ppdf_histogram(axs[1], 'ub', _, r'\boldmath$\overline{u}$')
                self.ppdf_histogram(axs[2], 'dp', _, r'\boldmath$d_+$')
                self.ppdf_histogram(axs[3], 'db', _, r'\boldmath$\overline{d}$')
                self.ppdf_histogram(axs[4], 'sp', _, r'\boldmath$s_+$')
                self.ppdf_histogram(axs[5], 'sb', _, r'\boldmath$\overline{s}$')
                self.ppdf_histogram(axs[6], 'g', _, r'\boldmath$g$')

            for ax in axs:
                # ax.semilogx()
                # ax.tick_params(axis = 'both', which = 'both', right = True, top = True, direction = 'in', labelsize = 20)
                # ax.set_xticklabels([r'', r''])
                ax.legend(frameon = 0, loc = 'best', fontsize = 17)

            axs[0].title.set_text(r'$\mathrm{parameter}~%s~\mathrm{at}~Q^2 = %.2f~\mathrm{GeV^2}$' % (_, Q2))
            axs[1].title.set_text(r'$\mathrm{parameter}~%s~\mathrm{at}~Q^2 = %.2f~\mathrm{GeV^2}$' % (_, Q2))

            py.tight_layout()
            if Q2 == conf['Q20']:
                py.savefig('%s/gallery/ppdf-histogram-pjet-%s-%d.png' % (wdir, _, istep), dpi = dpi)
            else:
                py.savefig('%s/gallery/ppdf-histogram-pjet-%s-%d-%f.png' % (wdir, _, istep, Q2), dpi = dpi)
예제 #3
0
    def line_figure(self, wdir, Q2, dpi):
        ## this block may contain something not useful
        load_config('%s/input.py' % wdir)
        istep = core.get_istep()
        # jar = load('%s/data/jar-%d.dat' % (wdir, istep))
        labels = load('%s/data/labels-%d.dat' % (wdir, istep))
        self.cluster = labels['cluster']
        self.cluster_average_chi2 = labels['cluster_average_chi2']
        self.best_cluster = np.argmin(self.cluster_average_chi2)

        nrows, ncols = 1, 1
        fig = py.figure(figsize = (ncols * 5.0, nrows * 3.0))
        ax = py.subplot(nrows, ncols, 1)

        ## polarized PDF
        if Q2 == None: Q2 = conf['Q20']
        if Q2 == conf['Q20']:
            self.xf_data = load('%s/data/ppdf-%d.dat' % (wdir, istep))
        else:
            self.xf_data = load('%s/data/ppdf-%d-%f.dat' % (wdir, istep, Q2))

        print '\nplotting polarized PDF line figure from %s at Q2 = %.2f' % (wdir, Q2)
        self.plot_lines(ax, 'g', 'r', all_cluster = 2)

        ax.set_ylim(-0.11, 0.3)
        ax.set_yticks([-0.1, 0.0, 0.1, 0.2])
        ax.set_yticklabels([r'$-0.1$', r'$0.0$', r'$0.1$', r'$0.2$'])
        # ax.text(0.7, 0.8, r'\boldmath$x\Delta g$', color = 'k', transform = axs[3].transAxes, size = 28)
        ax.title.set_text(r'\boldmath$x\Delta g~\mathrm{at}~Q^2 = %.2f~\mathrm{GeV}^2$' % Q2)

        legends = ax.legend(frameon = 0, loc = 'best')
        for line in legends.get_lines():
            line.set_linewidth(1.0)

        ax.semilogx()
        ax.set_xlim(8e-3, 9e-1)
        ax.set_xticks([1e-2, 1e-1])
        ax.tick_params(axis = 'both', which = 'both', right = True, top = True, direction = 'in', labelsize = 20)
        ax.set_xticklabels([r'', r''])

        ax.axhline(0.0, color = 'k', linestyle = 'dashdot', linewidth = 0.5)
        ax.set_xticks([0.01, 0.1, 0.5, 0.8])
        ax.set_xticklabels([r'$0.01$', r'$0.1$', r'$0.5$', r'$0.8$'])

        # py.subplots_adjust(left = 0.12, bottom = 0.08, right = 0.99, top = 0.97, wspace = None, hspace = 0.2)
        py.tight_layout()
        if Q2 == conf['Q20']:
            py.savefig('%s/gallery/ppdf-lines-pjet-%d.png' % (wdir, istep), dpi = dpi)
        else:
            py.savefig('%s/gallery/ppdf-lines-pjet-%d-%f.png' % (wdir, istep, Q2), dpi = dpi)
예제 #4
0
def update_tabs(wdir, tar, est, lum):

    istep = core.get_istep()
    data = load('%s/data/predictions-%d-all-%s-%s.dat' %
                (wdir, istep, tar, est))

    blist = []
    blist.append('thy')
    blist.append('shift')
    blist.append('residuals')
    blist.append('prediction')
    blist.append('N')
    blist.append('Shift')
    blist.append('W2')
    blist.append('alpha')
    blist.append('residuals-rep')
    blist.append('r-residuals')
    blist.append('L')
    blist.append('H')

    #--placeholder index
    idx = 80000
    tab = data['reactions']['pidis'][idx]

    #--delete unnecessary data
    for k in blist:
        try:
            del tab[k]
        except:
            continue

    #--save mean value
    tab['value'] = np.mean(tab['prediction-rep'], axis=0)

    #--save individual values
    for i in range(len(tab['prediction-rep'])):
        tab['value%s' % (i + 1)] = tab['prediction-rep'][i]

    del tab['prediction-rep']

    tab['stat_u'], tab['pole_u'], tab['polh_u'], tab['lum_u'], tab[
        'syst_u'] = all_errors(wdir, tar, est, tab['value'], lum)

    df = pd.DataFrame(tab)
    filename = '%s/sim/all-%s-%s.xlsx' % (wdir, tar, est)
    df.to_excel(filename, index=False)
    print('Updating xlsx file and saving to %s' % filename)
예제 #5
0
def make_figure(wdir, task, only_best_cluster=True, dpi=200):

    if task == 1:
        print('\nplotting PIDIS data from %s' % (wdir))
    elif task == 2:
        print('\nplotting PIDIS data over theory from %s' % (wdir))

    load_config('%s/input.py' % wdir)
    istep = core.get_istep()
    replicas = core.get_replicas(wdir)
    core.mod_conf(istep, replicas[0])  #--set conf as specified in istep

    predictions = load('%s/data/predictions-%d.dat' % (wdir, istep))
    if 'pidis' not in predictions['reactions']:
        print('PIDIS is not in data file')
        return
    labels = load('%s/data/labels-%d.dat' % (wdir, istep))
    cluster = labels['cluster']
    cluster_average_chi2 = labels['cluster_average_chi2']
    best_cluster = np.argmin(cluster_average_chi2)

    data = predictions['reactions']['pidis']

    for idx in data:
        predictions = copy.copy(data[idx]['prediction-rep'])
        del data[idx]['prediction-rep']
        del data[idx]['residuals-rep']
        if only_best_cluster:
            best_predictions = [
                predictions[i] for i in range(len(predictions))
                if cluster[i] == best_cluster
            ]
            data[idx]['thy'] = np.mean(best_predictions, axis=0)
            data[idx]['dthy'] = np.std(best_predictions, axis=0)
        else:
            all_predictions = [predictions[i] for i in range(len(predictions))]
            data[idx]['thy'] = np.mean(all_predictions, axis=0)
            data[idx]['dthy'] = np.std(all_predictions, axis=0)

    maps = generate_maps()
    subset_bins = pick_subsets(data)
    # log_list = []

    if task == 1:
        indices = {}
        for idx in data:
            observable = data[idx]['obs'][0]
            target = data[idx]['target'][0]
            collaboration = data[idx]['col'][0]
            if (observable == 'A1') or (observable == 'Apa'):
                if target == 'p':
                    if collaboration.startswith('JLab') != True:
                        if 'Apa_proton' not in indices:
                            indices['Apa_proton'] = []
                        indices['Apa_proton'].append(idx)
                    elif collaboration.startswith('JLabHB(EG1DVCS)') == True:
                        if 'Apa_proton_DVCS' not in indices:
                            indices['Apa_proton_DVCS'] = []
                        indices['Apa_proton_DVCS'].append(idx)
                    elif collaboration.startswith('JLabHB(EG1b)') == True:
                        if 'Apa_proton_EG1b' not in indices:
                            indices['Apa_proton_EG1b'] = []
                        indices['Apa_proton_EG1b'].append(idx)
                elif target == 'd':
                    if collaboration.startswith('JLab') != True:
                        if 'Apa_deuteron' not in indices:
                            indices['Apa_deuteron'] = []
                        indices['Apa_deuteron'].append(idx)
                    elif collaboration.startswith('JLabHB(EG1DVCS)') == True:
                        if 'Apa_deuteron_DVCS' not in indices:
                            indices['Apa_deuteron_DVCS'] = []
                        indices['Apa_deuteron_DVCS'].append(idx)
                    elif collaboration.startswith('JLabHB(EG1b)') == True:
                        if 'Apa_deuteron_EG1b' not in indices:
                            indices['Apa_deuteron_EG1b'] = []
                        indices['Apa_deuteron_EG1b'].append(idx)
            elif (observable == 'A2') or (observable == 'Ape') or (observable
                                                                   == 'Atpe'):
                if target == 'p':
                    if collaboration.startswith('JLab') != True:
                        if 'Ape_proton' not in indices:
                            indices['Ape_proton'] = []
                        indices['Ape_proton'].append(idx)
                elif target == 'd':
                    if collaboration.startswith('JLab') != True:
                        if 'Ape_deuteron' not in indices:
                            indices['Ape_deuteron'] = []
                        indices['Ape_deuteron'].append(idx)

            if target == 'h':
                if 'helium' not in indices:
                    indices['helium'] = []
                indices['helium'].append(idx)

        for key in indices:
            print(key)
            if key == 'Apa_proton':
                data_Apa_proton(wdir, data, indices[key], subset_bins, maps,
                                istep, dpi)
            elif key == 'Apa_proton_DVCS':
                data_Apa_proton_DVCS(wdir, data, indices[key], subset_bins,
                                     maps, istep, dpi)
            elif key == 'Apa_proton_EG1b':
                data_Apa_proton_EG1b(wdir, data, indices[key], subset_bins,
                                     maps, istep, dpi)
            elif key == 'Apa_deuteron':
                data_Apa_deuteron(wdir, data, indices[key], subset_bins, maps,
                                  istep, dpi)
            elif key == 'Apa_deuteron_DVCS':
                data_Apa_deuteron_DVCS(wdir, data, indices[key], subset_bins,
                                       maps, istep, dpi)
            elif key == 'Apa_deuteron_EG1b':
                data_Apa_deuteron_EG1b(wdir, data, indices[key], subset_bins,
                                       maps, istep, dpi)
            elif key == 'Ape_proton':
                data_Ape_proton(wdir, data, indices[key], subset_bins, maps,
                                istep, dpi)
            elif key == 'Ape_deuteron':
                data_Ape_deuteron(wdir, data, indices[key], subset_bins, maps,
                                  istep, dpi)
            elif key == 'helium':
                data_helium(wdir, data, indices[key], subset_bins, maps, istep,
                            dpi)

    elif task == 2:
        plot_data_on_theory(wdir, data, istep, dpi)

    return
예제 #6
0
def get_moments(wdir, flavors, x_1, x_2, Q2=None):
    load_config('%s/input.py' % wdir)
    istep = core.get_istep()

    replicas = core.get_replicas(wdir)
    ## 'conf' will be modified for each replica individually later in the loop over 'replicas'
    ## the reason for doing this is that 'fix parameters' has to be set correctly for each replica

    if 'ppdf_smx' not in conf['steps'][istep]['active distributions']:
        print('ppdf-smx-proton not in active distribution')
        return

    resman = RESMAN(nworkers=1, parallel=False, datasets=False)
    parman = resman.parman
    parman.order = replicas[0]['order'][istep]
    ## make sure 'parman' uses the same order for active distributions as all the replicas do
    # print parman.order

    ppdf = conf['ppdf_smx']

    ## setup kinematics
    # X = 10.0 ** np.linspace(-3, -1, 100)
    # X = np.append(X, np.linspace(0.1, 0.99, 100))
    if Q2 == None: Q2 = conf['Q20']
    print(
        '\ngenerating momentus for polarized pdf_smx-proton from %s at Q2 = %f'
        % (wdir, Q2))

    ## compute moments for all replicas
    moments = {}
    statistics = {}
    n_replicas = len(replicas)
    for i in range(n_replicas):
        lprint('%d/%d' % (i + 1, n_replicas))

        parman.order = copy.copy(replicas[i]['order'][istep])
        core.mod_conf(istep, replicas[i])
        parman.set_new_params(replicas[i]['params'][istep], initial=True)

        for flavor in flavors:
            if flavor not in moments: moments[flavor] = []
            if flavor not in statistics: statistics[flavor] = {}
            if flavor == 'up':
                func = lambda x: (ppdf.get_xF(x, Q2, 'u') + ppdf.get_xF(
                    x, Q2, 'ub')) / x
            elif flavor == 'dp':
                func = lambda x: (ppdf.get_xF(x, Q2, 'd') + ppdf.get_xF(
                    x, Q2, 'sb')) / x
            elif flavor == 'sp':
                func = lambda x: (ppdf.get_xF(x, Q2, 's') + ppdf.get_xF(
                    x, Q2, 'sb')) / x
            else:
                func = lambda x: ppdf.get_xF(x, Q2, flavor) / x

            moments[flavor].append(quad(func, x_1, x_2)[0])

    for flavor in flavors:
        statistics[flavor]['mean'] = np.mean(moments[flavor])
        statistics[flavor]['standard_deviation'] = np.std(moments[flavor])

    print
    for flavor in flavors:
        print flavor, ': ', statistics[flavor]

    checkdir('%s/data' % wdir)
    if Q2 == conf['Q20']:
        save({
            'Q2': Q2,
            'moments': moments,
            'statistics': statistics
        }, '%s/data/ppdf_smx-moments-%s-to-%s-%d.dat' %
             (wdir, x_1, x_2, istep))
    else:
        save({
            'Q2': Q2,
            'moments': moments,
            'statistics': statistics
        }, '%s/data/ppdf_smx-moments-%s-to-%s-%d-%f.dat' %
             (wdir, x_1, x_2, istep, Q2))
예제 #7
0
def gen_xf(wdir, flavors, Q2=None):
    load_config('%s/input.py' % wdir)
    istep = core.get_istep()

    replicas = core.get_replicas(wdir)
    ## 'conf' will be modified for each replica individually later in the loop over 'replicas'
    ## the reason for doing this is that 'fix parameters' has to be set correctly for each replica

    if 'ppdf_smx' not in conf['steps'][istep]['active distributions']:
        print('ppdf_smx-proton not in active distribution')
        return

    resman = RESMAN(nworkers=1, parallel=False, datasets=False)
    parman = resman.parman
    parman.order = replicas[0]['order'][istep]
    ## make sure 'parman' uses the same order for active distributions as all the replicas do
    # print parman.order

    ppdf = conf['ppdf_smx']
    ppdfJAM = conf['ppdf']

    ## setup kinematics
    xs = 10.0**np.linspace(-5, -1, 100)
    xs = np.append(xs, np.linspace(0.1, 0.3, 100))
    #xs = np.append(xs, np.linspace(0.1, 0.99, 100))
    if Q2 == None: Q2 = conf['Q20']
    print('\ngenerating polarized pdf-proton from %s at Q2 = %f' % (wdir, Q2))

    ## compute xf for all replicas
    xfs = {}
    n_replicas = len(replicas)
    for i in range(n_replicas):
        lprint('%d/%d' % (i + 1, n_replicas))

        ## filter
        #flag=False
        #params=replica['params'][istep]
        #order=replica['order'][istep]
        #for i in range(len(order)):
        #    if order[i][0]!=1:continue
        #    if order[i][1]!='ppdf':continue
        #    #if order[i][2]=='s1 a':
        #    #   if params[i]<-0.9: flag=True
        #if flag: continue

        parman.order = copy.copy(replicas[i]['order'][istep])
        core.mod_conf(istep, replicas[i])
        parman.set_new_params(replicas[i]['params'][istep], initial=True)

        x0 = conf['smx']['x0']
        xsep = conf['smx']['xsep']

        for flavor in flavors:
            if flavor not in xfs: xfs[flavor] = []
            if flavor == 'up':
                #func = lambda x: x*ppdf.get_C(x, Q2)[1]
                #func = lambda x: np.heaviside(xsep-x,1)*(x*ppdf.get_C(x, Q2)[1] + ppdfJAM.get_xF(xsep,xsep*Q2/x,flavor)) + np.heaviside(x-xsep,0)*ppdfJAM.get_xF(x,Q2,flavor)
                func = lambda x: np.heaviside(xsep - x, 1) * (x * ppdf.get_C(
                    x, Q2)[1] + x * ppdf.get_C_NOevo(xsep, xsep * Q2 / x)[
                        1]) + np.heaviside(x - xsep, 0) * x * ppdf.get_C_NOevo(
                            x, Q2)[1]
            elif flavor == 'dp':
                #func = lambda x: x*ppdf.get_C(x, Q2)[2]
                #func = lambda x: np.heaviside(xsep-x,1)*(x*ppdf.get_C(x, Q2)[2] + ppdfJAM.get_xF(xsep,xsep*Q2/x,flavor)) + np.heaviside(x-xsep,0)*ppdfJAM.get_xF(x,Q2,flavor)
                func = lambda x: np.heaviside(xsep - x, 1) * (x * ppdf.get_C(
                    x, Q2)[2] + x * ppdf.get_C_NOevo(xsep, xsep * Q2 / x)[
                        2]) + np.heaviside(x - xsep, 0) * x * ppdf.get_C_NOevo(
                            x, Q2)[2]
            elif flavor == 'sp':
                #func = lambda x: x*ppdf.get_C(x, Q2)[3]
                #func = lambda x: np.heaviside(xsep-x,1)*(x*ppdf.get_C(x, Q2)[3] + ppdfJAM.get_xF(xsep,xsep*Q2/x,flavor)) + np.heaviside(x-xsep,0)*ppdfJAM.get_xF(x,Q2,flavor)
                func = lambda x: np.heaviside(xsep - x, 1) * (x * ppdf.get_C(
                    x, Q2)[3] + x * ppdf.get_C_NOevo(xsep, xsep * Q2 / x)[
                        3]) + np.heaviside(x - xsep, 0) * x * ppdf.get_C_NOevo(
                            x, Q2)[3]
            elif flavor == 'g':
                #func = lambda x: x*ppdf.get_C(x, Q2)[0]
                #func = lambda x: np.heaviside(xsep-x,1)*(x*ppdf.get_C(x, Q2)[0] + ppdfJAM.get_xF(xsep,xsep*Q2/x,flavor)) + np.heaviside(x-xsep,0)*ppdfJAM.get_xF(x,Q2,flavor)
                func = lambda x: np.heaviside(xsep - x, 1) * (x * ppdf.get_C(
                    x, Q2)[0] + x * ppdf.get_C_NOevo(xsep, xsep * Q2 / x)[
                        0]) + np.heaviside(x - xsep, 0) * x * ppdf.get_C_NOevo(
                            x, Q2)[0]
            xfs[flavor].append([func(x) for x in xs])
    print
    checkdir('%s/data' % wdir)
    if Q2 == conf['Q20']:
        save({
            'X': xs,
            'Q2': Q2,
            'XF': xfs
        }, '%s/data/ppdf_smx-%d.dat' % (wdir, istep))
    else:
        save({
            'X': xs,
            'Q2': Q2,
            'XF': xfs
        }, '%s/data/ppdf_smx-%d-%f.dat' % (wdir, istep, Q2))
예제 #8
0
def get_parameters(wdir, Q2=None):
    load_config('%s/input.py' % wdir)
    istep = core.get_istep()

    replicas = core.get_replicas(wdir)
    ## 'conf' will be modified for each replica individually later in the loop over 'replicas'
    ## the reason for doing this is that 'fix parameters' has to be set correctly for each replica

    if 'ppdf_smx' not in conf['steps'][istep]['active distributions']:
        print('ppdf_smx-proton not in active distribution')
        return

    resman = RESMAN(nworkers=1, parallel=False, datasets=False)
    parman = resman.parman
    parman.order = replicas[0]['order'][
        istep]  ## make sure 'parman' uses the same order as all the replicas do
    # print parman.order

    ppdf = conf['ppdf_smx']

    ## setup kinematics
    if Q2 == None: Q2 = conf['Q20']
    ## get parameters for all flavors of PDF
    print('\ngetting ppdf_smx-parameters from %s at Q2 = %.2f' % (wdir, Q2))

    ## check if any of the shapes are fixed
    shape_1 = []
    shape_2 = []
    shape_3 = []
    for parameter in conf['params']['ppdf_smx']:
        if '1' in parameter:
            shape_1.append(conf['params']['ppdf_smx'][parameter]['fixed'])
        elif '2' in parameter:
            shape_2.append(conf['params']['ppdf_smx'][parameter]['fixed'])
        elif '3' in parameter:
            shape_3.append(conf['params']['ppdf_smx'][parameter]['fixed'])
        else:
            print('there seems to be more than three shapes')
            print(parameter)
            sys.exit('please update script %s' % __file__)

    fixed_shape_1 = False
    fixed_shape_2 = False
    fixed_shape_3 = False
    if (len(shape_1) != 0) and all([_ == True for _ in shape_1]):
        fixed_shape_1 = True
    elif len(shape_1) == 0:
        fixed_shape_1 = True
    if (len(shape_2) != 0) and all([_ == True for _ in shape_2]):
        fixed_shape_2 = True
    elif len(shape_2) == 0:
        fixed_shape_2 = True
    if (len(shape_3) != 0) and all([_ == True for _ in shape_3]):
        fixed_shape_3 = True
    elif len(shape_3) == 0:
        fixed_shape_3 = True

    parameters = {}
    if not fixed_shape_1: parameters[1] = {}
    if not fixed_shape_2: parameters[2] = {}
    if not fixed_shape_3: parameters[3] = {}

    n_replicas = len(replicas)
    for i in range(n_replicas):
        lprint('%d/%d' % (i + 1, n_replicas))

        parman.order = copy.copy(replicas[i]['order'][istep])
        core.mod_conf(istep, replicas[i])
        parman.set_new_params(replicas[i]['params'][istep], initial=True)

        for flavor, value in ppdf.params.iteritems():
            for j in parameters:
                if str(j) in flavor:
                    flavor_key = flavor.replace(str(j), '')
                    if flavor_key not in parameters[j]:
                        parameters[j][flavor_key] = {
                            'n': [],
                            'a': [],
                            'b': [],
                            'c': [],
                            'd': []
                        }

                    parameters[j][flavor_key]['n'].append(value[0])
                    parameters[j][flavor_key]['a'].append(value[1])
                    parameters[j][flavor_key]['b'].append(value[2])
                    parameters[j][flavor_key]['c'].append(value[3])
                    parameters[j][flavor_key]['d'].append(value[4])
                else:
                    pass

    ## remove c or d parameters if fixed in all flavors and shapes
    ## this is to avoid producing empty figures
    shapes_fixed_c = []
    shapes_fixed_d = []
    for shape in parameters:
        flavors_fixed_c = []
        flavors_fixed_d = []
        for flavor in parameters[shape]:
            cs = parameters[shape][flavor]['c']
            ds = parameters[shape][flavor]['d']
            if all([_ == cs[0] for _ in cs]):
                flavors_fixed_c.append(True)
            else:
                flavors_fixed_c.append(False)
            if all([_ == ds[0] for _ in ds]):
                flavors_fixed_d.append(True)
            else:
                flavors_fixed_d.append(False)

        if all(flavors_fixed_c):
            shapes_fixed_c.append(True)
        else:
            shapes_fixed_c.append(False)
        if all(flavors_fixed_d):
            shapes_fixed_d.append(True)
        else:
            shapes_fixed_d.append(False)

    if all(shapes_fixed_c):
        for shape in parameters:
            for flavor in parameters[shape]:
                del parameters[shape][flavor]['c']
        print('parameter c is fixed for shape %s' % shape)
    if all(shapes_fixed_d):
        for shape in parameters:
            for flavor in parameters[shape]:
                del parameters[shape][flavor]['d']
        print('parameter d is fixed for shape %s' % shape)

    print
    checkdir('%s/data' % wdir)
    if Q2 == conf['Q20']:
        save(parameters, '%s/data/ppdf_smx-parameters-%d.dat' % (wdir, istep))
    else:
        save(parameters,
             '%s/data/ppdf_smx-parameters-%d-%f.dat' % (wdir, istep, Q2))
예제 #9
0
    def steps_comparison_figure(self, wdirs, Q2, dpi):
        step_keys = sorted(wdirs.keys())
        load_config('%s/input.py' % wdirs[step_keys[-1]])
        istep = core.get_istep()

        nrows, ncols = 1, 1
        fig = py.figure(figsize = (ncols * 5.0, nrows * 3.0))
        ax = py.subplot(nrows, ncols, 1)
        colors = ['y', 'r', 'b', 'g', 'm']

        ## PPDF
        self.xf_data = {}
        self.cluster = {}
        self.best_cluster = {}
        labels = {}
        if Q2 == None: Q2 = conf['Q20']
        if Q2 == conf['Q20']:
            for step_key in step_keys:
                self.xf_data[step_key] = load('%s/data/ppdf-%d.dat' % (wdirs[step_key], step_key))
                labels[step_key] = load('%s/data/labels-%d.dat' % (wdirs[step_key], step_key))
                self.cluster[step_key] = labels[step_key]['cluster']
                self.best_cluster[step_key] = np.argmin(labels[step_key]['cluster_average_chi2'])
        else:
            for step_key in step_keys:
                self.xf_data[step_key] = load('%s/data/ppdf-%d-%f.dat' % (wdirs[step_key], step_key, Q2))
                labels[step_key] = load('%s/data/labels-%d.dat' % (wdirs[step_key], step_key))
                self.cluster[step_key] = labels[step_key]['cluster']
                self.best_cluster[step_key] = np.argmin(labels[step_key]['cluster_average_chi2'])

        print '\nplotting PPDF band figure with following steps at Q2 = %.2f' % Q2
        print [wdirs[_] for _ in wdirs]

        for i in range(len(step_keys)):
            step = step_keys[i]
            # alpha = (1.0 / len(step_keys)) * (len(step_keys) - i)
            alpha = 0.5
            color = colors[i]
            label = r'$\mathrm{step~%02d}$' % step
            self.plot_band_steps(ax, step, 'g', color, alpha, label)
        ax.set_ylim(-0.11, 0.3)
        ax.set_yticks([-0.1, 0.0, 0.1, 0.2])
        ax.set_yticklabels([r'$-0.1$', r'$0.0$', r'$0.1$', r'$0.2$'])
        # ax.text(0.1, 0.1, r'\boldmath$x\Delta g$', color = 'k', transform = ax.transAxes, size = 28)
        ax.legend(frameon = 0, loc = 'lower left', fontsize = 7)

        ax.semilogx()
        ax.set_xlim(8e-3, 9e-1)
        ax.set_xticks([1e-2, 1e-1])
        ax.tick_params(axis = 'both', which = 'both', right = True, top = True, direction = 'in', labelsize = 20)
        ax.set_xticklabels([r'', r''])

        ax.axhline(0.0, color = 'k', linestyle = 'dashdot', linewidth = 0.5)
        ax.set_xticks([0.01, 0.1, 0.5])
        ax.set_xticklabels([r'$0.01$', r'$0.1$', r'$0.5$'])
        ax.set_ylabel(r'$x \Delta g$', size = 15)
        ax.set_xlabel(r'\boldmath$x$', size = 15)
        ax.xaxis.set_label_coords(1.05, 0.0)

        py.tight_layout()
        # py.subplots_adjust(left=0.05, bottom=0.04, right=0.99, top=0.99, wspace=0.17, hspace=0.04)
        if Q2 == conf['Q20']:
            py.savefig('%s/gallery/ppdf-steps-pjet-%d.png' % (wdirs[step_keys[-1]], istep), dpi = dpi)
        else:
            py.savefig('%s/gallery/ppdf-steps-pjet-%d-%f.png' % (wdirs[step_keys[-1]], istep, Q2), dpi = dpi)
예제 #10
0
    def steps_comparison_figure(self, wdirs, Q2, dpi):
        step_keys = sorted(wdirs.keys())
        load_config('%s/input.py' % wdirs[step_keys[-1]])
        istep = core.get_istep()

        nrows, ncols = 2, 2
        fig = py.figure(figsize = (ncols * 5.0, nrows * 3.0))
        axs = [py.subplot(nrows, ncols, cnt + 1) for cnt in range(4)]
        colors = ['k', 'r', 'g', 'Yellow', 'b']

        ## PPDF
        self.xf_data = {}
        self.cluster = {}
        self.best_cluster = {}
        labels = {}
        if Q2 == None: Q2 = conf['Q20']
        if Q2 == conf['Q20']:
            for step_key in step_keys:
                self.xf_data[step_key] = load('%s/data/ppdf_smx-%d.dat' % (wdirs[step_key], step_key))
                labels[step_key] = load('%s/data/labels-%d.dat' % (wdirs[step_key], step_key))
                self.cluster[step_key] = labels[step_key]['cluster']
                self.best_cluster[step_key] = np.argmin(labels[step_key]['cluster_average_chi2'])
        else:
            for step_key in step_keys:
                self.xf_data[step_key] = load('%s/data/ppdf_smx-%d-%f.dat' % (wdirs[step_key], step_key, Q2))
                labels[step_key] = load('%s/data/labels-%d.dat' % (wdirs[step_key], step_key))
                self.cluster[step_key] = labels[step_key]['cluster']
                self.best_cluster[step_key] = np.argmin(labels[step_key]['cluster_average_chi2'])

        print '\nplotting PPDF band figure with following steps at Q2 = %.2f' % Q2
        print [wdirs[_] for _ in wdirs]

        ax = axs[0]
        for i in range(len(step_keys)):
            step = step_keys[i]
            # alpha = (1.0 / len(step_keys)) * (len(step_keys) - i)
            alpha = 0.5
            color = colors[i]
            self.plot_band_steps(ax, step, 'uv', color, alpha)
            self.plot_band_steps(ax, step, 'dv', color, alpha)
        ax.set_ylim(0.0, 0.5)
        ax.set_yticks([0.0, 0.1, 0.2, 0.3, 0.4, 0.5])
        ax.set_yticklabels([r'$0.1$', r'$0.2$', r'$0.3$', r'$0.4$', r'$0.5$'])
        ax.text(0.6, 0.3, r'\boldmath$x\Delta u^+$', color = 'k', transform = axs[0].transAxes, size = 28)

        ax = axs[1]
        for i in range(len(step_keys)):
            step = step_keys[i]
            # alpha = (1.0 / len(step_keys)) * (len(step_keys) - i)
            alpha = 0.5
            color = colors[i]
            self.plot_band_steps(ax, step, 'd/u', color, alpha)
        ax.set_ylim(-0.2, 0.0)
        ax.set_yticks([-0.05, -0.1, -0.15])
        ax.set_yticklabels([r'$-0.05$', r'$-0.10$', r'$-0.15$'])
        ax.text(0.05, 0.15, r'\boldmath$x\Delta d^+$', color = 'k', transform = axs[1].transAxes, size = 28)

        ax = axs[2]
        for i in range(len(step_keys)):
            step = step_keys[i]
            # alpha = (1.0 / len(step_keys)) * (len(step_keys) - i)
            alpha = 0.5
            color = colors[i]
            self.plot_band_steps(ax, step, 'db+ub', color, alpha)
        ax.set_ylim(-0.1, 0.05)
        ax.set_yticks([-0.08, -0.04, 0.0, 0.04])
        ax.set_yticklabels([r'$-0.08$', r'$-0.04$', r'$0.00$', r'$0.04$'])
        ax.text(0.1, 0.7, r'\boldmath$x\Delta s^+$', color = 'k', transform = axs[2].transAxes, size = 28)

        ax = axs[3]
        for i in range(len(step_keys)):
            step = step_keys[i]
            # alpha = (1.0 / len(step_keys)) * (len(step_keys) - i)
            alpha = 0.5
            color = colors[i]
            self.plot_band_steps(ax, step, 'db-ub', color, alpha)
        ax.set_ylim(-0.11, 0.3)
        ax.set_yticks([-0.1, 0.0, 0.1, 0.2])
        ax.set_yticklabels([r'$-0.1$', r'$0.0$', r'$0.1$', r'$0.2$'])
        ax.text(0.7, 0.8, r'\boldmath$x\Delta g$', color = 'k', transform = axs[3].transAxes, size = 28)

        ax = axs[4]
        for i in range(len(step_keys)):
            step = step_keys[i]
            # alpha = (1.0 / len(step_keys)) * (len(step_keys) - i)
            alpha = 0.5
            color = colors[i]
            self.plot_band_steps(ax, step, 's+sb', color, alpha)
        ax.text(0.6, 0.8, r'\boldmath$x(s\!+\!\overline{s})$', color = 'k', transform = ax.transAxes, size = 28)
        ax.set_ylim(0.0, 0.48)
        ax.set_yticks([0.0, 0.1, 0.2, 0.3, 0.4])
        ax.set_yticklabels([r'$0$', r'', r'$0.2$', r'', r'$0.4$'])

        ax = axs[5]
        for i in range(len(step_keys)):
            step = step_keys[i]
            # alpha = (1.0 / len(step_keys)) * (len(step_keys) - i)
            alpha = 0.5
            color = colors[i]
            self.plot_band_steps(ax, step, 'rs', color, alpha)
        ax.text(0.05, 0.78, r'\boldmath$R_s$', color = 'k', transform = ax.transAxes, size = 30)
        ax.set_ylim(0.0, 1.6)
        ax.set_yticks([0.0, 0.5, 1.0, 1.5])
        ax.set_yticklabels([r'$0$', r'$0.5$', r'$1$', r'$1.5$'])

        ax = axs[6]
        for i in range(len(step_keys)):
            step = step_keys[i]
            # alpha = (1.0 / len(step_keys)) * (len(step_keys) - i)
            alpha = 0.5
            color = colors[i]
            label = r'$\mathrm{step~%02d}$' % step
            self.plot_band_steps(ax, step, 'g', color, alpha, label)
        ax.text(0.8, 0.8, r'\boldmath$xg$', color = 'k', transform = ax.transAxes, size = 31)
        ax.set_ylim(0.0, 2.5)
        ax.set_yticks([0.0, 0.5, 1.0, 1.5, 2.0])
        ax.legend(frameon = 0, loc = 'best', bbox_to_anchor = [1.87, 0.9], fontsize = 20)

        for ax in axs:
            ax.semilogx()
            ax.set_xlim(8e-3, 9e-1)
            ax.set_xticks([1e-2, 1e-1])
            # ax.xaxis.set_label_coords(0.95, -0.05)
            ax.tick_params(axis = 'both', which = 'both', right = True, top = True, direction = 'in', labelsize = 20)
            ax.set_xticklabels([r'', r''])
            ax.xaxis.set_label_coords(0.7, -0.05)
            ax.legend(frameon = 0, loc = 'best')

        axs[2].axhline(0.0, color = 'k', linestyle = 'dashdot', linewidth = 0.5)
        axs[3].axhline(0.0, color = 'k', linestyle = 'dashdot', linewidth = 0.5)
        for i in range(len(axs) - 1, len(axs) - 1 - ncols, -1):
            axs[i].set_xlabel(r'\boldmath$x$', size = 30)
            # axs[i].text(0.84, -0.095, r'$0.5$', color = 'k', transform = ax.transAxes, size = 20)
            axs[i].set_xticks([0.01, 0.1, 0.5, 0.8])
            axs[i].set_xticklabels([r'$0.01$', r'$0.1$', r'$0.5$', r'$0.8$'])

        py.tight_layout()
        py.subplots_adjust(left=0.05, bottom=0.04, right=0.99, top=0.99, wspace=0.17, hspace=0.04)
        if Q2 == conf['Q20']:
            py.savefig('%s/gallery/ppdf_smx-steps-%d.png' % (wdirs[step_keys[-1]], istep), dpi = dpi)
        else:
            py.savefig('%s/gallery/ppdf_smx-steps-%d-%f.png' % (wdirs[step_keys[-1]], istep, Q2), dpi = dpi)
예제 #11
0
    def g1_band_figure(self, wdir, Q2, dpi):
        ## this block may contain something not useful
        load_config('%s/input.py' % wdir)
        istep = core.get_istep()
        # jar = load('%s/data/jar-%d.dat' % (wdir, istep))
        labels = load('%s/data/labels-%d.dat' % (wdir, istep))
        self.cluster = labels['cluster']
        self.cluster_average_chi2 = labels['cluster_average_chi2']
        self.best_cluster = np.argmin(self.cluster_average_chi2)
        nrows, ncols = 1, 1
        fig = py.figure(figsize = (ncols * 5.0, nrows * 3.0))
        ax=py.subplot(nrows,ncols,1)
        ax1=py.subplot(nrows,ncols,1)

        ## polarized PDF
        if Q2 == None: Q2 = conf['Q20']
        if Q2 == conf['Q20']:
            self.xf_data = load('%s/data/ppdf_smx-%d.dat' % (wdir, istep))
        else:
            self.xf_data = load('%s/data/ppdf_smx-%d-%f.dat' % (wdir, istep, Q2))

        print '\nplotting g1 band figure from %s at Q2 = %.2f' % (wdir, Q2)
        self.plot_g1_band(ax, 'b',alpha=1.)
        p3=self.plot_g1_band(ax, 'r',central=True)
        
        if Q2 == conf['Q20']:
            self.xf_data = load('results/step_test1_smx_cut_0.1/data/ppdf_smx-%d.dat' % (istep))
        else:
            self.xf_data = load('results/step_test1_smx_cut_0.1/data/ppdf_smx-%d-%f.dat' % (istep, Q2))

        print '\nplotting g1 band figure from %s at Q2 = %.2f' % (wdir, Q2)
        self.plot_g1_band(ax1, 'b')
        #self.plot_g1_band(ax1, 'b',central=True)

        ax.set_ylim(-100, 10)
        #axs[0].set_yticks([0.0, 0.1, 0.2, 0.3, 0.4, 0.5])
        #axs[0].set_yticklabels([r'$0.1$', r'$0.2$', r'$0.3$', r'$0.4$', r'$0.5$'])
        # axs[0].text(0.6, 0.3, r'\boldmath$x\Delta u^+$', color = 'k', transform = axs[0].transAxes, size = 28)
        ax.title.set_text(r'\boldmath$g_1(x)~\mathrm{at}~Q^2 = %.2f~\mathrm{GeV}^2$' % Q2)

        ax.semilogx()
        ax1.semilogx()
        ax.set_xlim(1e-5, 1e-1) #ax.set_xlim(1e-3, 9e-1)
        #ax.set_xticks([1e-6,1e-5,1e-4,1e-3,1e-2, 1e-1])
        #ax.xaxis.set_label_coords(0.95, -0.05)
        ax.set_xlabel(r'\boldmath$x$',fontsize=18)
        #ax.set_xticklabels([r'$10^{-6}$',r'$10^{-5}$',r'$10^{-4}$',r'$0.001$', r'$0.01$', r'$0.1$']) #ax.set_xticklabels([r'$0.01$', r'$0.1$', r'$0.5$', r'$0.8$'])
        ax.tick_params(axis = 'both', which = 'both', right = True, top = True, direction = 'in')
        #ax.set_xticklabels([r'', r''])

        ax.axhline(0.0, color = 'k', linestyle = 'dashdot', linewidth = 0.5)
        #axs3.axhline(0.0, color = 'k', linestyle = 'dashdot', linewidth = 0.5)
        #for i in range(len(axs)):
        #     if (i % ncols) == 0: axs[i].set_ylabel(r'$xf(x)$', size = 20)
        #for i in range(len(axs) - 1, len(axs) - 1 - ncols, -1):
        #    axs[i].set_xlabel(r'\boldmath$x$', size = 30)
        #    # axs[i].text(0.84, -0.095, r'$0.5$', color = 'k', transform = ax.transAxes, size = 20)
        #    axs[i].set_xticks([0.01, 0.1, 0.5, 0.8])
        #    axs[i].set_xticklabels([r'$0.01$', r'$0.1$', r'$0.5$', r'$0.8$'])

        #for line in legends.get_lines():
        #    line.set_linewidth(1.0)

        p1 = ax1.fill(np.NaN, np.NaN, 'b', alpha=0.3)
        p2 = ax.fill(np.NaN, np.NaN, 'b', alpha=1.)
        ax1.legend([p1[0],(p2[0],p3[0]),], [r'JAM-small$x$',r'JAM-small$x$+EIC'])

        py.subplots_adjust(left = 0.12, bottom = 0.08, right = 0.99, top = 0.97, wspace = None, hspace = 0.2)
        py.tight_layout()
        if Q2 == conf['Q20']:
            py.savefig('%s/gallery/g1_smx-band-%d.png' % (wdir, istep), dpi = dpi)
        else:
            py.savefig('%s/gallery/g1_smx-band-%d-%f.png' % (wdir, istep, Q2), dpi = dpi)
예제 #12
0
    def band_figure(self, wdir, Q2, dpi):
        ## this block may contain something not useful
        load_config('%s/input.py' % wdir)
        istep = core.get_istep()
        # jar = load('%s/data/jar-%d.dat' % (wdir, istep))
        labels = load('%s/data/labels-%d.dat' % (wdir, istep))
        self.cluster = labels['cluster']
        self.cluster_average_chi2 = labels['cluster_average_chi2']
        self.best_cluster = np.argmin(self.cluster_average_chi2)

        nrows, ncols = 2, 2
        fig = py.figure(figsize = (ncols * 5.0, nrows * 3.0))
        axs0 = py.subplot(nrows, ncols, 1)
        axs1 = py.subplot(nrows, ncols, 2)
        axs2 = py.subplot(nrows, ncols, 3)
        axs3 = py.subplot(nrows, ncols, 4)
        ## polarized PDF
        if Q2 == None: Q2 = conf['Q20']
        if Q2 == conf['Q20']:
            self.xf_data = load('%s/data/ppdf_smx-%d.dat' % (wdir, istep))
        else:
            self.xf_data = load('%s/data/ppdf_smx-%d-%f.dat' % (wdir, istep, Q2))

        print '\nplotting polarized PDF band figure from %s at Q2 = %.2f' % (wdir, Q2)
        self.plot_band(axs0, 'up', 'r')
        self.plot_band(axs1, 'dp', 'r')
        self.plot_band(axs2, 'sp', 'r')
        self.plot_band(axs3, 'g', 'r')
    
        self.plot_band(axs0, 'up', 'r',central=True)
        self.plot_band(axs1, 'dp', 'r',central=True)
        self.plot_band(axs2, 'sp', 'r',central=True)
        self.plot_band(axs3, 'g', 'r',central=True)

        axs0.set_ylim(-0.5, 0.5)
        #axs[0].set_yticks([0.0, 0.1, 0.2, 0.3, 0.4, 0.5])
        #axs[0].set_yticklabels([r'$0.1$', r'$0.2$', r'$0.3$', r'$0.4$', r'$0.5$'])
        # axs[0].text(0.6, 0.3, r'\boldmath$x\Delta u^+$', color = 'k', transform = axs[0].transAxes, size = 28)
        axs0.title.set_text(r'\boldmath$x\Delta u^+(x)~\mathrm{at}~Q^2 = %.2f~\mathrm{GeV}^2$' % Q2)
        #axs[1].set_ylim(-0.2, 0.2)
        #axs[1].set_yticks([-0.05, -0.1, -0.15])
        #axs[1].set_yticklabels([r'$-0.05$', r'$-0.10$', r'$-0.15$'])
        # axs[1].text(0.05, 0.15, r'\boldmath$x\Delta d^+$', color = 'k', transform = axs[1].transAxes, size = 28)
        axs1.title.set_text(r'\boldmath$x\Delta d^+(x)~\mathrm{at}~Q^2 = %.2f~\mathrm{GeV}^2$' % Q2)
        #axs[2].set_ylim(-0.1, 0.5)
        #axs[2].set_yticks([-0.08, -0.04, 0.0, 0.04])
        #axs[2].set_yticklabels([r'$-0.08$', r'$-0.04$', r'$0.00$', r'$0.04$'])
        # axs[2].text(0.1, 0.7, r'\boldmath$x\Delta s^+$', color = 'k', transform = axs[2].transAxes, size = 28)
        axs2.title.set_text(r'\boldmath$x\Delta s^+(x)~\mathrm{at}~Q^2 = %.2f~\mathrm{GeV}^2$' % Q2)
        #axs[3].set_ylim(-0.11, 0.3)
        #axs[3].set_yticks([-0.1, 0.0, 0.1, 0.2])
        #axs[3].set_yticklabels([r'$-0.1$', r'$0.0$', r'$0.1$', r'$0.2$'])
        # axs[3].text(0.7, 0.8, r'\boldmath$x\Delta g$', color = 'k', transform = axs[3].transAxes, size = 28)
        axs3.title.set_text(r'\boldmath$x\Delta g(x)~\mathrm{at}~Q^2 = %.2f~\mathrm{GeV}^2$' % Q2)

        for ax in [axs0,axs1,axs2,axs3]:
            ax.semilogx()
            ax.set_xlim(1e-5, 0.3) #ax.set_xlim(1e-3, 9e-1)
            #ax.set_xticks([1e-6,1e-5,1e-4,1e-3,1e-2, 1e-1])
            #ax.xaxis.set_label_coords(0.95, -0.05)
            ax.set_xlabel(r'\boldmath$x$',fontsize=18)
            #ax.set_xticklabels([r'$10^{-6}$',r'$10^{-5}$',r'$10^{-4}$',r'$0.001$', r'$0.01$', r'$0.1$']) #ax.set_xticklabels([r'$0.01$', r'$0.1$', r'$0.5$', r'$0.8$'])
            ax.tick_params(axis = 'both', which = 'both', right = True, top = True, direction = 'in')
            #ax.set_xticklabels([r'', r''])

        axs0.axhline(0.0, color = 'k', linestyle = 'dashdot', linewidth = 0.5)
        axs1.axhline(0.0, color = 'k', linestyle = 'dashdot', linewidth = 0.5)
        axs2.axhline(0.0, color = 'k', linestyle = 'dashdot', linewidth = 0.5)
        axs3.axhline(0.0, color = 'k', linestyle = 'dashdot', linewidth = 0.5)
        #for i in range(len(axs)):
        #     if (i % ncols) == 0: axs[i].set_ylabel(r'$xf(x)$', size = 20)
        #for i in range(len(axs) - 1, len(axs) - 1 - ncols, -1):
        #    axs[i].set_xlabel(r'\boldmath$x$', size = 30)
        #    # axs[i].text(0.84, -0.095, r'$0.5$', color = 'k', transform = ax.transAxes, size = 20)
        #    axs[i].set_xticks([0.01, 0.1, 0.5, 0.8])
        #    axs[i].set_xticklabels([r'$0.01$', r'$0.1$', r'$0.5$', r'$0.8$'])

        legends = axs0.legend(frameon = 0, loc = 'best')
        for line in legends.get_lines():
            line.set_linewidth(1.0)

        py.subplots_adjust(left = 0.12, bottom = 0.08, right = 0.99, top = 0.97, wspace = None, hspace = 0.2)
        py.tight_layout()
        if Q2 == conf['Q20']:
            py.savefig('%s/gallery/ppdf_smx-band-%d.png' % (wdir, istep), dpi = dpi)
        else:
            py.savefig('%s/gallery/ppdf_smx-band-%d-%f.png' % (wdir, istep, Q2), dpi = dpi)