Skip to content

Commit

Permalink
Merge pull request #91 from aimalz/issue/86/desc_revision
Browse files Browse the repository at this point in the history
Issue/86/desc revision, closes #86
  • Loading branch information
aimalz authored Nov 13, 2017
2 parents bf735df + 099a343 commit 7110e2f
Show file tree
Hide file tree
Showing 43 changed files with 4,737 additions and 1,939 deletions.
6 changes: 3 additions & 3 deletions docs/desc-0000-qp-photo-z_approximation/acknowledgments.tex
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
%
This is the text imported from \code{acknowledgments.tex}, and will be replaced by some standard LSST DESC boilerplate at some point.
%
%
%This is the text imported from \code{acknowledgments.tex}, and will be replaced by some standard LSST DESC boilerplate at some point.
%
8 changes: 4 additions & 4 deletions docs/desc-0000-qp-photo-z_approximation/authors.csv
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
Lastname,Firstname,Authorname,AuthorType,Affiliation,Contribution,Email
Malz,Alex,A.I.~Malz,Contact,"Center for Cosmology and Particle Physics, New York University, 726 Broadway, New York, 10003","Initiated project, led development work.",[email protected]
Marshall,Phil,P.J.~Marshall,Contributor,"SLAC National Accelerator Laboratory, Menlo Park, CA 94025, USA","Advised on statistics, and project design and management.",[email protected]
Schmidt,Samuel,S.J.~Schmidt,Contributor,"Dept. of Physics, University of California, One Shields Ave., Davis, CA, 95616","Provided the lower quality data mock catalog.",[email protected]
Graham,Melissa,M.~Graham,Contributor,"University of Washington","Provided the higher quality data mock catalog.",[email protected]
DeRose,Joe,J.~DeRose,Contributor,"Stanford University","Contributed to the production of the lower quality data mock catalog.",[email protected]
Wechsler,Risa,R.~Wechsler,Contributor,"Stanford University","Contributed to the production of the lower quality data mock catalog.",[email protected]
Schmidt,Samuel,S.J.~Schmidt,Contributor,"Dept. of Physics, University of California, One Shields Ave., Davis, CA, 95616","Produced the PDFs for the fainter mock catalog.",[email protected]
Graham,Melissa,M.L.~Graham,Contributor,"Department of Astronomy, University of Washington, Box 351580 U.W., Seattle, WA 98195-1580","Produced the photometry and PDFs for the brighter mock catalog.",[email protected]
DeRose,Joe,J.~DeRose,Contributor,"Stanford University","Produced the photometry for the fainter mock catalog.",[email protected]
Wechsler,Risa,R.~Wechsler,Contributor,"Stanford University","Produced the photometry for the fainter mock catalog.",[email protected]
4 changes: 2 additions & 2 deletions docs/desc-0000-qp-photo-z_approximation/authors.tex
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
\affiliation{SLAC National Accelerator Laboratory, Menlo Park, CA 94025, USA}
\author{S.J.~Schmidt}
\affiliation{Dept. of Physics, University of California, One Shields Ave., Davis, CA, 95616}
\author{M.~Graham}
\affiliation{University of Washington}
\author{M.L.~Graham}
\affiliation{Department of Astronomy, University of Washington, Box 351580 U.W., Seattle, WA 98195-1580}
\author{J.~DeRose}
\affiliation{Stanford University}
\author{R.~Wechsler}
Expand Down
8 changes: 4 additions & 4 deletions docs/desc-0000-qp-photo-z_approximation/contributions.tex
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Author contributions are listed below. \\
A.I.~Malz: Initiated project, led development work. \\
P.J.~Marshall: Advised on statistics, and project design and management. \\
S.J.~Schmidt: Provided the Optical dataset. \\
M.~Graham: Provided the Optical+IR dataset. \\
J.~DeRose: Contributed to the production of the Optical dataset. \\
R.~Wechsler: Contributed to the production of the Optical dataset. \\
S.J.~Schmidt: Produced the PDFs for the fainter mock catalog. \\
M.L.~Graham: Produced the photometry and PDFs for the brighter mock catalog. \\
J.~DeRose: Produced the photometry for the fainter mock catalog. \\
R.~Wechsler: Produced the photometry for the fainter mock catalog. \\
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
487 changes: 428 additions & 59 deletions docs/desc-0000-qp-photo-z_approximation/main.bib

Large diffs are not rendered by default.

1,392 changes: 876 additions & 516 deletions docs/desc-0000-qp-photo-z_approximation/main.tex

Large diffs are not rendered by default.

1,930 changes: 1,220 additions & 710 deletions docs/desc-0000-qp-photo-z_approximation/research/analysis.html

Large diffs are not rendered by default.

1,838 changes: 1,489 additions & 349 deletions docs/desc-0000-qp-photo-z_approximation/research/analysis.ipynb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@
"outputs": [],
"source": [
"# choose one of these:\n",
"dataset_key = 'Euclid'# Melissa Graham's data\n",
"# dataset_key = 'LSST'# Sam Schmidt's data\n",
"# dataset_key = 'Euclid'# Melissa Graham's data\n",
"dataset_key = 'LSST'# Sam Schmidt's data\n",
"dataname = dataset_key\n",
"\n",
"dataset_info = {}\n",
Expand Down Expand Up @@ -192,24 +192,24 @@
},
"outputs": [],
"source": [
"colors = ['red','green','blue','cyan','magenta','yellow']\n",
"n_plot = len(colors)\n",
"\n",
"# if dataset_key == 'mg':\n",
"# indices = [1, 3, 14, 16, 19, 21]\n",
"# elif dataset_key == 'ss':\n",
"n_gals_tot = len(pdfs)\n",
"full_gal_range = range(n_gals_tot)\n",
"indices = np.random.choice(full_gal_range, n_plot)\n",
"\n",
"for i in range(n_plot):\n",
" plt.plot(dataset_info[dataset_key]['z_grid'], pdfs[indices[i]], \n",
" color=colors[i], label=dataset_key+'#'+str(indices[i]))\n",
"plt.xlabel(r'$z$', fontsize=16)\n",
"plt.ylabel(r'$p(z)$', fontsize=16)\n",
"plt.title(dataset_key+' mock catalog')\n",
"plt.legend()\n",
"plt.savefig('pz_placeholder_'+dataset_key+'.png', dpi=250)"
"# colors = ['red','green','blue','cyan','magenta','yellow']\n",
"# n_plot = len(colors)\n",
"\n",
"# # if dataset_key == 'mg':\n",
"# # indices = [1, 3, 14, 16, 19, 21]\n",
"# # elif dataset_key == 'ss':\n",
"# n_gals_tot = len(pdfs)\n",
"# full_gal_range = range(n_gals_tot)\n",
"# indices = np.random.choice(full_gal_range, n_plot)\n",
"\n",
"# for i in range(n_plot):\n",
"# plt.plot(dataset_info[dataset_key]['z_grid'], pdfs[indices[i]], \n",
"# color=colors[i], label=dataset_key+' #'+str(indices[i]))\n",
"# plt.xlabel(r'$z$', fontsize=16)\n",
"# plt.ylabel(r'$p(z)$', fontsize=16)\n",
"# plt.title(dataset_key+' mock catalog')\n",
"# plt.legend()\n",
"# plt.savefig('pz_placeholder_'+dataset_key+'.pdf', dpi=250)"
]
},
{
Expand Down Expand Up @@ -246,8 +246,10 @@
"if dataset_key == 'Euclid':\n",
" chosen = 5390\n",
"elif dataset_key == 'LSST':\n",
" chosen = 108019\n",
"\n",
"# chosen = 108019 \n",
" indices = [ 12543, 52661, 46216, 53296, 95524, 84574 , 2607 ,56017 , 64794, 7600]\n",
" chosen = indices[9]\n",
" \n",
"start_time = timeit.default_timer()\n",
"G = qp.PDF(gridded=(dataset_info[dataset_key]['z_grid'], pdfs[chosen]))\n",
"print(timeit.default_timer() - start_time)\n",
Expand All @@ -265,13 +267,13 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
"collapsed": false
},
"outputs": [],
"source": [
"if dataset_key == 'Euclid':\n",
" nc_needed = 3\n",
"elif datanset_key == 'LSST':\n",
"elif dataset_key == 'LSST':\n",
" nc_needed = 5\n",
" \n",
"dataset_info[dataset_key]['N_GMM'] = nc_needed"
Expand Down Expand Up @@ -312,7 +314,8 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": false,
"scrolled": true
},
"outputs": [],
"source": [
Expand All @@ -332,24 +335,24 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The `qp.composite` object can be used as the `qp.PDF.truth` to initialize a new `qp.PDF` object that doesn't have any information about the gridded or sample approximations but has a qualitatively similar shape and is thus \"realistically complex\" enough to draw conclusions about real data. Now we can approximate it any way we like! Consider this example for $N_f=20$ parameters."
"The `qp.composite` object can be used as the `qp.PDF.truth` to initialize a new `qp.PDF` object that doesn't have any information about the gridded or sample approximations but has a qualitatively similar shape and is thus \"realistically complex\" enough to draw conclusions about real data. Now we can approximate it any way we like! Consider this example for $N_f=7$ parameters."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"scrolled": false
"scrolled": true
},
"outputs": [],
"source": [
"N_f = 20\n",
"N_f = 7\n",
"M = qp.PDF(truth=G.mix_mod, limits=dataset_info[dataset_key]['z_lim'])\n",
"M.quantize(N=N_f, vb=False)\n",
"M.histogramize(N=N_f, binrange=dataset_info[dataset_key]['z_lim'], vb=False)\n",
"M.sample(N=N_f, using='truth', vb=False)\n",
"M.plot(loc=dataset_key+'_example_pz.png', vb=True)"
"M.plot(loc=dataset_key+'_example_pz.pdf', vb=True)"
]
},
{
Expand Down Expand Up @@ -407,7 +410,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
"collapsed": false
},
"outputs": [],
"source": [
Expand All @@ -424,7 +427,7 @@
"\n",
"if dataset_key == 'Euclid':\n",
" dataset_info[dataset_key]['N_GMM'] = 3\n",
"elif datanset_key == 'LSST':\n",
"elif dataset_key == 'LSST':\n",
" dataset_info[dataset_key]['N_GMM'] = 5\n",
"fit_components = dataset_info[dataset_key]['N_GMM']\n",
"\n",
Expand Down Expand Up @@ -485,7 +488,7 @@
" N_pdfs =len(pdfs)\n",
" randos = np.random.choice(range(N_pdfs), n_plot)\n",
" for i in range(n_plot):\n",
" plt.plot(z_grid, pdfs[randos[i]], label=dataset_key+'#'+str(randos[i]))\n",
" plt.plot(z_grid, pdfs[randos[i]], label=dataset_key+r'\\#'+str(randos[i]))\n",
" plt.xlabel(r'$z$', fontsize=16)\n",
" plt.ylabel(r'$p(z)$', fontsize=16)\n",
" plt.title(dataset_key+' mock catalog')\n",
Expand Down Expand Up @@ -1657,14 +1660,14 @@
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.13"
"pygments_lexer": "ipython3",
"version": "3.6.3"
}
},
"nbformat": 4,
Expand Down
34 changes: 20 additions & 14 deletions docs/notebooks/demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
},
"outputs": [],
"source": [
"print P.approximate([0.314], using='quantiles')"
"print P.approximate(np.array([0.314]), using='quantiles')"
]
},
{
Expand Down Expand Up @@ -227,7 +227,7 @@
"outputs": [],
"source": [
"print P.scheme\n",
"print P.approximate([0.314], using='quantiles', scheme='nearest')\n",
"print P.approximate(np.array([0.314]), using='quantiles', scheme='nearest')\n",
"print P.scheme"
]
},
Expand Down Expand Up @@ -373,23 +373,29 @@
},
"outputs": [],
"source": [
"qD1 = qp.utils.calculate_kl_divergence(P, Q, limits=(-5.,5.), vb=True)\n",
"qD1 = qp.utils.calculate_kl_divergence(P, Q, limits=(-1.,1.), vb=True)\n",
"qD2 = qp.utils.calculate_kl_divergence(P, Q, limits=(-2.,2.), vb=True)\n",
"qD3 = qp.utils.calculate_kl_divergence(P, Q, limits=(-3.,3.), vb=True)\n",
"\n",
"hD1 = qp.utils.calculate_kl_divergence(P, H, limits=(-5.,5.), vb=True)\n",
"print 'Quantile approximation: KLD over 1,2,3 sigma ranges = ', qD1, qD2, qD3\n",
"hD1 = qp.utils.calculate_kl_divergence(P, H, limits=(-1.,1.), vb=True)\n",
"hD2 = qp.utils.calculate_kl_divergence(P, H, limits=(-2.,2.), vb=True)\n",
"hD3 = qp.utils.calculate_kl_divergence(P, H, limits=(-3.,3.), vb=True)\n",
"\n",
"sD1 = qp.utils.calculate_kl_divergence(P, S, limits=(-5.,5.), vb=True)\n",
"print 'Histogram approximation: KLD over 1,2,3 sigma ranges = ', hD1, hD2, hD3\n",
"sD1 = qp.utils.calculate_kl_divergence(P, S, limits=(-1.,1.), vb=True)\n",
"sD2 = qp.utils.calculate_kl_divergence(P, S, limits=(-2.,2.), vb=True)\n",
"sD3 = qp.utils.calculate_kl_divergence(P, S, limits=(-3.,3.), vb=True)\n",
"\n",
"print 'Quantile approximation: KLD over 1,2,3 sigma ranges = ', qD1, qD2, qD3\n",
"print 'Histogram approximation: KLD over 1,2,3 sigma ranges = ', hD1, hD2, hD3\n",
"print 'Sampled approximation: KLD over 1,2,3 sigma ranges = ', sD1, sD2, sD3"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true
},
"source": [
"Holy smokes, does the quantile approximation blow everything else out of the water, thanks to using spline interpolation."
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -563,7 +569,7 @@
"outputs": [],
"source": [
"Cs = qp.PDF(truth=C_dist, limits = composite_lims)\n",
"Cs.sample(N=20, vb=False)\n",
"Cs.sample(N=20, using='truth', vb=False)\n",
"Cs.plot()"
]
},
Expand Down Expand Up @@ -609,14 +615,14 @@
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.13"
"pygments_lexer": "ipython3",
"version": "3.6.3"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 7110e2f

Please sign in to comment.