Skip to content

Commit

Permalink
Merge pull request #169 from LSSTDESC/issues/167
Browse files Browse the repository at this point in the history
Issues/167
  • Loading branch information
fjaviersanchez authored Mar 1, 2024
2 parents 33a3a9c + 37a99c5 commit 0fa29ed
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions tutorials/extragalactic_gcr_redshift_dist.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"# Plot N versus z Distributions in the extragalactic catalogs\n",
"\n",
"<br>Owner: **Eve Kovacs** ([@evevkovacs](https://github.com/LSSTDESC/DC2-analysis/issues/new?body=@evevkovacs))\n",
"<br>Last Verified to Run: Nov 30, 2018 by @yymao\n",
"<br>Last Verified to Run: March 1, 2024 by @fjaviersanchez\n",
"\n",
"This notebook demonstrates how to make number-density versus redshift plots from the extragalactic catalog (protoDC2, cosmoDC2).\n",
"\n",
Expand All @@ -26,7 +26,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"from itertools import zip_longest\n",
Expand All @@ -49,7 +51,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"gc = GCRCatalogs.load_catalog('cosmoDC2_v1.1.4_small')"
Expand All @@ -71,7 +75,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"def get_mags_and_redshift(gc, mag_lo, mag_hi, band='r', z='redshift_true', zlo=0., zhi=1.1, \n",
Expand All @@ -86,7 +92,7 @@
" filters = [(lambda z: (z > zlo) & (z < zhi), z)] # Filter on selected redshift range\n",
" \n",
" # Initialize arrays for storing histogram sums\n",
" N_array = np.zeros((nrows, ncolumns, len(zbins)-1), dtype=np.int)\n",
" N_array = np.zeros((nrows, ncolumns, len(zbins)-1), dtype=np.int32)\n",
" sumz_array = np.zeros((nrows, ncolumns, len(zbins)-1))\n",
" # Get catalog data by looping over data iterator (needed for large catalogs) and aggregate histograms\n",
" for catalog_data in gc.get_quantities(required_quantities, filters=filters, return_iterator=True):\n",
Expand Down Expand Up @@ -122,14 +128,16 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# Select some magnitude cuts and fill the histogram arrays for 2-column plots\n",
"mlo = 25\n",
"mhi = 19\n",
"\n",
"mag_lo = 1 + np.arange(mhi, mlo, dtype=np.float)\n",
"mag_lo = 1 + np.arange(mhi, mlo, dtype=np.float64)\n",
"mag_hi = mhi + np.zeros_like(mag_lo)\n",
"\n",
"ncolumns = 2\n",
Expand All @@ -149,7 +157,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"def plot_N_vs_z(mag_lo, mag_hi, N_array, sumz_array, zbins, band='r', normed=True,\n",
Expand Down Expand Up @@ -187,7 +197,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"def decorate_subplot(ax, nplot, nrows, ncolumns, ylabel, xlabel):\n",
Expand All @@ -211,7 +223,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"plot_N_vs_z(mag_lo, mag_hi, N_array, sumz_array, zbins, nrows=nrows, ncolumns=ncolumns, normed=True)"
Expand Down Expand Up @@ -258,9 +272,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.6"
"version": "3.10.13"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}

0 comments on commit 0fa29ed

Please sign in to comment.