Skip to content

Instantly share code, notes, and snippets.

@zonca
Last active May 27, 2021 23:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zonca/2397b395d26872d45e9ad1192d6625dd to your computer and use it in GitHub Desktop.
Save zonca/2397b395d26872d45e9ad1192d6625dd to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "a326d0ce-9245-4043-96d8-72273140c7e8",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"os.environ[\"OMP_NUM_THREADS\"] = \"16\""
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "32931c49-97d5-4b0f-8996-e5a17b323cc2",
"metadata": {},
"outputs": [],
"source": [
"import healpy as hp\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "f3bd0483-1711-425e-a67b-9962ed1bc30c",
"metadata": {},
"outputs": [],
"source": [
"lmax = 10000\n",
"nside = 8192\n",
"high_lmax = 2 * nside"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "b3b59904-ae32-41cb-9570-c91de281086a",
"metadata": {},
"outputs": [],
"source": [
"folder = \"/global/cfs/cdirs/cmb/data/generic/mmDL/healpix/00000\""
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "8a80f2fb-ac16-4bd0-afb3-7bb4c548f52f",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Warning: Python module not loaded, you already have Python loaded via conda init\n",
"ls: cannot access '/global/cfs/cdirs/cmb/data/generic/mmDL/healpix/00000/healpix/00030': No such file or directory\n"
]
}
],
"source": [
"%ls $folder/healpix/00030"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "ff03535a-fbdd-4644-b10f-82755f17ba83",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Warning: Python module not loaded, you already have Python loaded via conda init\n",
"-rw-r--r-- 1 cmb cmb 3.1G May 9 08:19 /global/cfs/cdirs/cmb/data/generic/mmDL/healpix/00000/lensed_cmb_Q_00000.fits\n",
"-rw-r--r-- 1 cmb cmb 3.1G May 9 08:17 /global/cfs/cdirs/cmb/data/generic/mmDL/healpix/00000/lensed_cmb_T_00000.fits\n",
"-rw-r--r-- 1 cmb cmb 3.1G May 9 08:20 /global/cfs/cdirs/cmb/data/generic/mmDL/healpix/00000/lensed_cmb_U_00000.fits\n"
]
}
],
"source": [
"%ls -lh /global/cfs/cdirs/cmb/data/generic/mmDL/healpix/00000/*cmb*"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "7fda9701-ec51-4474-af57-727e7ad5e107",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/global/homes/z/zonca/condajupynersc/lib/python3.7/site-packages/healpy/fitsfunc.py:369: UserWarning: If you are not specifying the input dtype and using the default np.float64 dtype of read_map(), please consider that it will change in a future version to None as to keep the same dtype of the input file: please explicitly set the dtype if it is important to you.\n",
" \"If you are not specifying the input dtype and using the default \"\n",
"/global/homes/z/zonca/condajupynersc/lib/python3.7/site-packages/healpy/fitsfunc.py:391: UserWarning: NSIDE = 8192\n",
" warnings.warn(\"NSIDE = {0:d}\".format(nside))\n",
"/global/homes/z/zonca/condajupynersc/lib/python3.7/site-packages/healpy/fitsfunc.py:400: UserWarning: ORDERING = RING in fits file\n",
" warnings.warn(\"ORDERING = {0:s} in fits file\".format(ordering))\n",
"/global/homes/z/zonca/condajupynersc/lib/python3.7/site-packages/healpy/fitsfunc.py:428: UserWarning: INDXSCHM = IMPLICIT\n",
" warnings.warn(\"INDXSCHM = {0:s}\".format(schm))\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"CPU times: user 5.67 s, sys: 10.8 s, total: 16.4 s\n",
"Wall time: 16.6 s\n"
]
}
],
"source": [
"%time m = hp.read_map(\"/global/cfs/cdirs/cmb/data/generic/mmDL/healpix/00000/lensed_cmb_T_00000.fits\")"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "7571b10d-bc34-40d3-835c-4454fb5c7960",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"CPU times: user 1h 20min 57s, sys: 49.6 s, total: 1h 21min 46s\n",
"Wall time: 6min 1s\n"
]
}
],
"source": [
"%time alm = hp.map2alm(m, lmax=lmax)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "258a108c-c01f-49e8-ada5-11af690034ee",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"CPU times: user 3h 27min 1s, sys: 1min 18s, total: 3h 28min 19s\n",
"Wall time: 14min 19s\n"
]
}
],
"source": [
"%time alm_high_lmax = hp.map2alm(m, lmax=high_lmax)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "08f7323a-9cf4-4e5b-b500-9f26bc1a07ad",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"CPU times: user 7.04 s, sys: 35.6 s, total: 42.6 s\n",
"Wall time: 42.7 s\n"
]
}
],
"source": [
"%time hp.write_alm(\"s/alm.fits\", alm, overwrite=True)"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "cb0f7d63-382d-4e4e-9523-e1b58cb5c7c0",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"CPU times: user 18.7 s, sys: 43.7 s, total: 1min 2s\n",
"Wall time: 1min 2s\n"
]
}
],
"source": [
"%time hp.write_alm(\"s/alm_high_lmax.fits\", alm_high_lmax, overwrite=True)"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "a3413347-f654-4964-be6f-df76be8f8ca6",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"CPU times: user 9.64 s, sys: 4.68 s, total: 14.3 s\n",
"Wall time: 14.3 s\n"
]
}
],
"source": [
"%time alm_high_lmax_read = hp.read_alm(\"s/alm_high_lmax.fits\")"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "47f7baa2-fa2d-4777-8b3d-d458ba71775f",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"CPU times: user 3.76 s, sys: 1.91 s, total: 5.68 s\n",
"Wall time: 5.72 s\n"
]
}
],
"source": [
"%time alm_read = hp.read_alm(\"s/alm.fits\")"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "a7e1aec5-52d8-49f9-b7bf-fd43f456f26d",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Warning: Python module not loaded, you already have Python loaded via conda init\n",
"-rw-rw---- 1 zonca zonca 954M May 27 15:35 s/alm.fits\n",
"-rw-rw---- 1 zonca zonca 2.6G May 27 15:56 s/alm_high_lmax.fits\n"
]
}
],
"source": [
"%ls -lh s/alm*.fits"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "28726e77-2f9e-49b8-bf56-5b084a49cb38",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"CPU times: user 12min 31s, sys: 9.43 s, total: 12min 40s\n",
"Wall time: 59 s\n"
]
}
],
"source": [
"%time m_read = hp.alm2map(alm_read, nside)"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "7b3b997c-ac40-47d2-a30e-c3c5f94b51e0",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"CPU times: user 31min 50s, sys: 17.7 s, total: 32min 7s\n",
"Wall time: 2min 19s\n"
]
}
],
"source": [
"%time m_high_lmax_read = hp.alm2map(alm_high_lmax_read, nside)"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "1d09550f-0994-45e3-8dc9-eea64cedc0c4",
"metadata": {},
"outputs": [],
"source": [
"np.testing.assert_almost_equal(alm, alm_read)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "eaa883b5-6b8c-466f-b87c-7b16910868b2",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "condajupynersc",
"language": "python",
"name": "condajupynersc"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.0"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment