Skip to content

Commit

Permalink
add dtype on boolean arrays
Browse files Browse the repository at this point in the history
Notebooks ran on mac but not vulcain due to numpy defaults #4
  • Loading branch information
raphaelshirley committed Jan 10, 2018
1 parent f323b3a commit 46460e3
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 13 deletions.
51 changes: 43 additions & 8 deletions dmu1/dmu1_ml_Herschel-Stripe-82/1.2_VISTA-VHS.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"OUT_DIR = os.environ.get('TMP_DIR', \"./data_tmp\")\n",
Expand All @@ -99,7 +101,9 @@
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# Bands: Y,J,H,K\n",
Expand Down Expand Up @@ -137,10 +141,31 @@
"catalogue.meta = None"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# Conversion from Vega magnitudes to AB is done using values from \n",
"# http://casu.ast.cam.ac.uk/surveys-projects/vista/technical/filter-set\n",
"vega_to_ab = {\n",
" \"z\": 0.521,\n",
" \"y\": 0.618,\n",
" \"j\": 0.937,\n",
" \"h\": 1.384,\n",
" \"k\": 1.839\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# Adding flux and band-flag columns\n",
Expand All @@ -153,7 +178,9 @@
" catalogue[col][catalogue[col] <= 0] = np.nan\n",
" catalogue[errcol][catalogue[errcol] <= 0] = np.nan \n",
" \n",
"\n",
" # Convert magnitude from Vega to AB\n",
" catalogue[col] += vega_to_ab[col[-1]]\n",
" \n",
" flux, error = mag_to_flux(np.array(catalogue[col]), np.array(catalogue[errcol]))\n",
" \n",
" # Fluxes are added in µJy\n",
Expand Down Expand Up @@ -298,7 +325,9 @@
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"gaia = Table.read(\"../../dmu0/dmu0_GAIA/data/GAIA_Herschel-Stripe-82.fits\")\n",
Expand Down Expand Up @@ -363,7 +392,9 @@
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"catalogue[RA_COL] += delta_ra.to(u.deg)\n",
Expand Down Expand Up @@ -411,7 +442,9 @@
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"catalogue.add_column(\n",
Expand Down Expand Up @@ -456,7 +489,9 @@
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"catalogue.write(\"{}/VISTA-VHS.fits\".format(OUT_DIR), overwrite=True)"
Expand Down
4 changes: 2 additions & 2 deletions dmu1/dmu1_ml_XMM-LSS/2.1_Megacam_merge.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -462,11 +462,11 @@
" # Megacam total flux \n",
" has_cfhtls_deep = ~np.isnan(master_catalogue['f_cfhtls-deep_' + band])\n",
" if band == 'y':\n",
" has_cfhtls_wide = np.full(len(master_catalogue), False)\n",
" has_cfhtls_wide = np.full(len(master_catalogue), False, dtype=bool)\n",
" else:\n",
" has_cfhtls_wide = ~np.isnan(master_catalogue['f_cfhtls-wide_' + band])\n",
" if band == 'i':\n",
" has_sparcs = np.full(len(master_catalogue), False)\n",
" has_sparcs = np.full(len(master_catalogue), False, dtype=bool)\n",
" else:\n",
" has_sparcs = ~np.isnan(master_catalogue['f_sparcs_' + band])\n",
" \n",
Expand Down
8 changes: 5 additions & 3 deletions dmu1/dmu1_ml_XMM-LSS/2.4_VIRCAM_merge.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@
" has_video = ~np.isnan(master_catalogue['f_video_' + band])\n",
" has_viking = ~np.isnan(master_catalogue['f_viking_' + band])\n",
" if band == 'z':\n",
" has_vhs = np.full(len(master_catalogue), False)\n",
" has_vhs = np.full(len(master_catalogue), False, dtype=bool)\n",
" else:\n",
" has_vhs = ~np.isnan(master_catalogue['f_vhs_' + band])\n",
" \n",
Expand Down Expand Up @@ -563,7 +563,7 @@
" has_ap_video = ~np.isnan(master_catalogue['f_ap_video_' + band])\n",
" has_ap_viking = ~np.isnan(master_catalogue['f_ap_viking_' + band])\n",
" if (band == 'z'):\n",
" has_ap_vhs = np.full(len(master_catalogue), False)\n",
" has_ap_vhs = np.full(len(master_catalogue), False, dtype=bool)\n",
" else:\n",
" has_ap_vhs = ~np.isnan(master_catalogue['f_ap_vhs_' + band])\n",
"\n",
Expand Down Expand Up @@ -744,7 +744,9 @@
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"vista_origin.write(\"{}/xmm-lss_vista_fluxes_origins{}.fits\".format(OUT_DIR, SUFFIX), overwrite=True)"
Expand Down

0 comments on commit 46460e3

Please sign in to comment.