Skip to content

Commit

Permalink
Merge pull request #25 from scarrazza/obscorr_title
Browse files Browse the repository at this point in the history
fixing obscorr title with pdf label instead of name
  • Loading branch information
Zaharid committed May 26, 2016
2 parents 91f5954 + 038fee4 commit f74efb7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/smpdflib/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def export_obscorrs(data_table, output_dir, prefix, base_pdf=None):

from smpdflib.corrutils import observable_correlations

for title, corrmat, labels in observable_correlations(data_table, base_pdf):
for title, corrmat, labels, filename in observable_correlations(data_table, base_pdf):
name = prefix + "_" + normalize_name(title)
filename = osp.join(output_dir, name + ".csv")
pd.DataFrame(corrmat, index=labels, columns=labels).to_csv(filename, sep='\t')
Expand Down
8 changes: 5 additions & 3 deletions src/smpdflib/corrutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,12 @@ def observable_correlations(results_table, base_pdf=None):
M = np.concatenate([result._all_vals.as_matrix() for result in results])
#Without atleast_2d would return a scalar if M has only one element.
corrmat = np.atleast_2d(np.corrcoef(M))
title = "Observables correlation\n%s" % pdf
title = "Observables correlation\n%s" % pdf.label
filename = "%s" % pdf
if base_pdf:
corrmat -= base_corr
title += "-%s" % base_pdf
title += "-%s" % base_pdf.label
filename += "-%s" % base_pdf


def make_labels(results):
Expand All @@ -83,4 +85,4 @@ def make_labels(results):
yield "%s (Bin %d)" % (obslabel, b+1)

labels = list(make_labels(results))
yield title, corrmat, labels
yield title, corrmat, labels, filename
4 changes: 2 additions & 2 deletions src/smpdflib/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ def plot_correlations(results):

def plot_observable_correlations(results_table, base_pdf=None):

for title, corrmat, labels in observable_correlations(results_table, base_pdf):
for title, corrmat, labels, filename in observable_correlations(results_table, base_pdf):
if base_pdf is not None:
rlim = np.max(np.abs(corrmat))
else:
Expand Down Expand Up @@ -507,4 +507,4 @@ def plot_observable_correlations(results_table, base_pdf=None):
plt.tight_layout()
plt.colorbar()

yield (title.split()[-1],) , fig
yield (filename,) , fig
8 changes: 5 additions & 3 deletions src/smpdflib/reducedset.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def get_smpdf_lincomb(pdf, pdf_results,
)

def complete_smpdf_description(desc, pdf ,pdf_results, full_grid,
target_error ):
target_error, total_neig ):

input_hash = smpdf_input_hash(pdf, pdf_results, full_grid,
target_error)
Expand All @@ -289,6 +289,7 @@ def complete_smpdf_description(desc, pdf ,pdf_results, full_grid,
'full_grid' : full_grid,
'input_hash' : input_hash,
'input_set' : str(pdf),
'total_neig': total_neig,
}

return desc
Expand Down Expand Up @@ -430,7 +431,8 @@ def create_smpdf(pdf, pdf_results, output_dir, name,

description = complete_smpdf_description(description, pdf, pdf_results,
full_grid=full_grid,
target_error=smpdf_tolerance)
target_error=smpdf_tolerance,
total_neig=lincomb.shape[1])
#We have do do this because LHAPDF seems to not parse complex structures
parsed_desc = {'smpdf_description':yaml.dump(description,
default_flow_style=False)}
Expand All @@ -446,4 +448,4 @@ def create_smpdf(pdf, pdf_results, output_dir, name,


return hessian_from_lincomb(pdf, vec, folder=output_dir,
set_name= name, db=db, extra_fields=parsed_desc)
set_name= name, db=db, extra_fields=parsed_desc)

0 comments on commit f74efb7

Please sign in to comment.