Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
bastiencarreres committed Jul 31, 2024
1 parent 376a31f commit 51aedcb
Show file tree
Hide file tree
Showing 6 changed files with 745 additions and 587 deletions.
685 changes: 409 additions & 276 deletions Examples/SNSim_one_SN_LC_simulation.ipynb

Large diffs are not rendered by default.

474 changes: 264 additions & 210 deletions Examples/SN_simulation.ipynb

Large diffs are not rendered by default.

86 changes: 43 additions & 43 deletions Examples/SN_simulation_SNIA_peculiar.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@
"id": "3f7c6f0f",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING: AstropyDeprecationWarning: The update_default_config function is deprecated and may be removed in a future version. [sncosmo]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
Expand Down Expand Up @@ -73,7 +66,7 @@
" <div style=\"width: 24px; height: 24px; background-color: #e1e1e1; border: 3px solid #9D9D9D; border-radius: 5px; position: absolute;\"> </div>\n",
" <div style=\"margin-left: 48px;\">\n",
" <h3 style=\"margin-bottom: 0px;\">Client</h3>\n",
" <p style=\"color: #9D9D9D; margin-bottom: 0px;\">Client-075c87a2-f7df-11ee-a787-3ffa743c1225</p>\n",
" <p style=\"color: #9D9D9D; margin-bottom: 0px;\">Client-5bf62a68-4f6c-11ef-86a4-58ef68e79040</p>\n",
" <table style=\"width: 100%; text-align: left;\">\n",
"\n",
" <tr>\n",
Expand Down Expand Up @@ -104,7 +97,7 @@
" </div>\n",
" <div style=\"margin-left: 48px;\">\n",
" <h3 style=\"margin-bottom: 0px; margin-top: 0px;\">LocalCluster</h3>\n",
" <p style=\"color: #9D9D9D; margin-bottom: 0px;\">47ab588d</p>\n",
" <p style=\"color: #9D9D9D; margin-bottom: 0px;\">8c24c396</p>\n",
" <table style=\"width: 100%; text-align: left;\">\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
Expand All @@ -116,10 +109,10 @@
" </tr>\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Total threads:</strong> 8\n",
" <strong>Total threads:</strong> 16\n",
" </td>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Total memory:</strong> 15.30 GiB\n",
" <strong>Total memory:</strong> 15.32 GiB\n",
" </td>\n",
" </tr>\n",
" \n",
Expand All @@ -141,11 +134,11 @@
" <div style=\"width: 24px; height: 24px; background-color: #FFF7E5; border: 3px solid #FF6132; border-radius: 5px; position: absolute;\"> </div>\n",
" <div style=\"margin-left: 48px;\">\n",
" <h3 style=\"margin-bottom: 0px;\">Scheduler</h3>\n",
" <p style=\"color: #9D9D9D; margin-bottom: 0px;\">Scheduler-5c509616-e0a1-46b2-9903-abfb06c32732</p>\n",
" <p style=\"color: #9D9D9D; margin-bottom: 0px;\">Scheduler-1c46d428-325e-4a6a-8e13-d9e91c34cf4f</p>\n",
" <table style=\"width: 100%; text-align: left;\">\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Comm:</strong> tcp://127.0.0.1:34489\n",
" <strong>Comm:</strong> tcp://127.0.0.1:45893\n",
" </td>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Workers:</strong> 4\n",
Expand All @@ -156,15 +149,15 @@
" <strong>Dashboard:</strong> <a href=\"http://127.0.0.1:8787/status\" target=\"_blank\">http://127.0.0.1:8787/status</a>\n",
" </td>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Total threads:</strong> 8\n",
" <strong>Total threads:</strong> 16\n",
" </td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Started:</strong> Just now\n",
" </td>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Total memory:</strong> 15.30 GiB\n",
" <strong>Total memory:</strong> 15.32 GiB\n",
" </td>\n",
" </tr>\n",
" </table>\n",
Expand All @@ -187,29 +180,29 @@
" <table style=\"width: 100%; text-align: left;\">\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Comm: </strong> tcp://127.0.0.1:41781\n",
" <strong>Comm: </strong> tcp://127.0.0.1:35077\n",
" </td>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Total threads: </strong> 2\n",
" <strong>Total threads: </strong> 4\n",
" </td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Dashboard: </strong> <a href=\"http://127.0.0.1:43113/status\" target=\"_blank\">http://127.0.0.1:43113/status</a>\n",
" <strong>Dashboard: </strong> <a href=\"http://127.0.0.1:46331/status\" target=\"_blank\">http://127.0.0.1:46331/status</a>\n",
" </td>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Memory: </strong> 3.83 GiB\n",
" </td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Nanny: </strong> tcp://127.0.0.1:40007\n",
" <strong>Nanny: </strong> tcp://127.0.0.1:39327\n",
" </td>\n",
" <td style=\"text-align: left;\"></td>\n",
" </tr>\n",
" <tr>\n",
" <td colspan=\"2\" style=\"text-align: left;\">\n",
" <strong>Local directory: </strong> /tmp/dask-worker-space/worker-alcx9x41\n",
" <strong>Local directory: </strong> /tmp/dask-scratch-space/worker-qujemltk\n",
" </td>\n",
" </tr>\n",
"\n",
Expand All @@ -232,29 +225,29 @@
" <table style=\"width: 100%; text-align: left;\">\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Comm: </strong> tcp://127.0.0.1:33603\n",
" <strong>Comm: </strong> tcp://127.0.0.1:45289\n",
" </td>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Total threads: </strong> 2\n",
" <strong>Total threads: </strong> 4\n",
" </td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Dashboard: </strong> <a href=\"http://127.0.0.1:37153/status\" target=\"_blank\">http://127.0.0.1:37153/status</a>\n",
" <strong>Dashboard: </strong> <a href=\"http://127.0.0.1:33325/status\" target=\"_blank\">http://127.0.0.1:33325/status</a>\n",
" </td>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Memory: </strong> 3.83 GiB\n",
" </td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Nanny: </strong> tcp://127.0.0.1:42469\n",
" <strong>Nanny: </strong> tcp://127.0.0.1:35329\n",
" </td>\n",
" <td style=\"text-align: left;\"></td>\n",
" </tr>\n",
" <tr>\n",
" <td colspan=\"2\" style=\"text-align: left;\">\n",
" <strong>Local directory: </strong> /tmp/dask-worker-space/worker-6tkfcnpi\n",
" <strong>Local directory: </strong> /tmp/dask-scratch-space/worker-xb69kypp\n",
" </td>\n",
" </tr>\n",
"\n",
Expand All @@ -277,29 +270,29 @@
" <table style=\"width: 100%; text-align: left;\">\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Comm: </strong> tcp://127.0.0.1:44495\n",
" <strong>Comm: </strong> tcp://127.0.0.1:39647\n",
" </td>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Total threads: </strong> 2\n",
" <strong>Total threads: </strong> 4\n",
" </td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Dashboard: </strong> <a href=\"http://127.0.0.1:43725/status\" target=\"_blank\">http://127.0.0.1:43725/status</a>\n",
" <strong>Dashboard: </strong> <a href=\"http://127.0.0.1:34249/status\" target=\"_blank\">http://127.0.0.1:34249/status</a>\n",
" </td>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Memory: </strong> 3.83 GiB\n",
" </td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Nanny: </strong> tcp://127.0.0.1:41669\n",
" <strong>Nanny: </strong> tcp://127.0.0.1:35633\n",
" </td>\n",
" <td style=\"text-align: left;\"></td>\n",
" </tr>\n",
" <tr>\n",
" <td colspan=\"2\" style=\"text-align: left;\">\n",
" <strong>Local directory: </strong> /tmp/dask-worker-space/worker-_4k9s2ql\n",
" <strong>Local directory: </strong> /tmp/dask-scratch-space/worker-yx6u12us\n",
" </td>\n",
" </tr>\n",
"\n",
Expand All @@ -322,29 +315,29 @@
" <table style=\"width: 100%; text-align: left;\">\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Comm: </strong> tcp://127.0.0.1:42287\n",
" <strong>Comm: </strong> tcp://127.0.0.1:36421\n",
" </td>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Total threads: </strong> 2\n",
" <strong>Total threads: </strong> 4\n",
" </td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Dashboard: </strong> <a href=\"http://127.0.0.1:43669/status\" target=\"_blank\">http://127.0.0.1:43669/status</a>\n",
" <strong>Dashboard: </strong> <a href=\"http://127.0.0.1:35797/status\" target=\"_blank\">http://127.0.0.1:35797/status</a>\n",
" </td>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Memory: </strong> 3.83 GiB\n",
" </td>\n",
" </tr>\n",
" <tr>\n",
" <td style=\"text-align: left;\">\n",
" <strong>Nanny: </strong> tcp://127.0.0.1:33895\n",
" <strong>Nanny: </strong> tcp://127.0.0.1:35849\n",
" </td>\n",
" <td style=\"text-align: left;\"></td>\n",
" </tr>\n",
" <tr>\n",
" <td colspan=\"2\" style=\"text-align: left;\">\n",
" <strong>Local directory: </strong> /tmp/dask-worker-space/worker-50hb8mgv\n",
" <strong>Local directory: </strong> /tmp/dask-scratch-space/worker-5xynkei1\n",
" </td>\n",
" </tr>\n",
"\n",
Expand All @@ -371,7 +364,7 @@
"</div>"
],
"text/plain": [
"<Client: 'tcp://127.0.0.1:34489' processes=4 threads=8, memory=15.30 GiB>"
"<Client: 'tcp://127.0.0.1:45893' processes=4 threads=16, memory=15.32 GiB>"
]
},
"execution_count": 2,
Expand Down Expand Up @@ -403,7 +396,7 @@
"source": [
"survey_conf = {\n",
" 'survey_file': './survey_file_example.csv',\n",
" 'sig_psf': 0.0,\n",
" 'fwhm_psf': 0.0,\n",
" 'sig_zp': 0.01,\n",
" 'zp': 25,\n",
" 'gain': 1,\n",
Expand Down Expand Up @@ -517,11 +510,18 @@
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"CPU times: user 3min 47s, sys: 3.47 s, total: 3min 50s\n",
"Wall time: 3min 45s\n"
"ename": "KeyError",
"evalue": "'fwhm_psf is needed in obs file'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)",
"File \u001b[0;32m<timed exec>:3\u001b[0m\n",
"File \u001b[0;32m~/Documents/Soft/snsim/snsim/simu.py:126\u001b[0m, in \u001b[0;36mSimulator.__init__\u001b[0;34m(self, param_dic, print_config)\u001b[0m\n\u001b[1;32m 123\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_cosmology \u001b[38;5;241m=\u001b[39m ut\u001b[38;5;241m.\u001b[39mset_cosmo(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mconfig[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcosmology\u001b[39m\u001b[38;5;124m\"\u001b[39m])\n\u001b[1;32m 125\u001b[0m \u001b[38;5;66;03m# -- Init SurveyObs object\u001b[39;00m\n\u001b[0;32m--> 126\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_survey \u001b[38;5;241m=\u001b[39m \u001b[43msh\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mSurveyObs\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mconfig\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43msurvey_config\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 128\u001b[0m \u001b[38;5;66;03m# -- Init vpec_dist\u001b[39;00m\n\u001b[1;32m 129\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mvpec_dist\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mconfig:\n",
"File \u001b[0;32m~/Documents/Soft/snsim/snsim/survey_host.py:53\u001b[0m, in \u001b[0;36mSurveyObs.__init__\u001b[0;34m(self, survey_config)\u001b[0m\n\u001b[1;32m 50\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_config \u001b[38;5;241m=\u001b[39m survey_config\n\u001b[1;32m 52\u001b[0m \u001b[38;5;66;03m# -- Init obs table\u001b[39;00m\n\u001b[0;32m---> 53\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_obs_table, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_start_end_days \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_init_data\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 55\u001b[0m \u001b[38;5;66;03m# -- Init fields\u001b[39;00m\n\u001b[1;32m 56\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mfield_map\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mconfig:\n",
"File \u001b[0;32m~/Documents/Soft/snsim/snsim/survey_host.py:262\u001b[0m, in \u001b[0;36mSurveyObs._init_data\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 259\u001b[0m keys \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_check_keys()\n\u001b[1;32m 261\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m ext \u001b[38;5;129;01min\u001b[39;00m [\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m.csv\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m.parquet\u001b[39m\u001b[38;5;124m\"\u001b[39m]:\n\u001b[0;32m--> 262\u001b[0m obs_dic \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_extract_from_file\u001b[49m\u001b[43m(\u001b[49m\u001b[43mext\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkeys\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 263\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 264\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mAccepted formats are .csv or .parquet\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
"File \u001b[0;32m~/Documents/Soft/snsim/snsim/survey_host.py:234\u001b[0m, in \u001b[0;36mSurveyObs._extract_from_file\u001b[0;34m(self, ext, keys)\u001b[0m\n\u001b[1;32m 232\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m k \u001b[38;5;129;01min\u001b[39;00m keys:\n\u001b[1;32m 233\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m k \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m obs_dic\u001b[38;5;241m.\u001b[39mkeys()\u001b[38;5;241m.\u001b[39mto_list():\n\u001b[0;32m--> 234\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mk\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m is needed in obs file\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 236\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msurvey_cut\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mconfig:\n\u001b[1;32m 237\u001b[0m query \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m\"\u001b[39m\n",
"\u001b[0;31mKeyError\u001b[0m: 'fwhm_psf is needed in obs file'"
]
}
],
Expand Down Expand Up @@ -4191,7 +4191,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
"version": "3.11.9"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 51aedcb

Please sign in to comment.