Skip to content

Commit

Permalink
Merge pull request #46 from PWhiddy/master
Browse files Browse the repository at this point in the history
Refining new features
  • Loading branch information
PWhiddy authored Aug 9, 2017
2 parents 3ad8924 + c5eb01c commit 1941bb3
Show file tree
Hide file tree
Showing 24 changed files with 1,340 additions and 136 deletions.
3 changes: 0 additions & 3 deletions #setup.bash#

This file was deleted.

343 changes: 343 additions & 0 deletions notebooks/.ipynb_checkpoints/HITS_Main_Belt_Example-checkpoint.ipynb

Large diffs are not rendered by default.

136 changes: 96 additions & 40 deletions notebooks/.ipynb_checkpoints/Kbmod_Documentation-checkpoint.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
},
"outputs": [],
"source": [
"from kbmod import *\n",
"from kbmodpy import kbmod as kb\n",
"import numpy\n",
"path = \"../data/demo/\""
]
},
Expand Down Expand Up @@ -62,7 +63,7 @@
},
"outputs": [],
"source": [
"p = psf(1.0)"
"p = kb.psf(1.0)"
]
},
{
Expand Down Expand Up @@ -150,13 +151,13 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"im = layered_image(\"image2\", 100, 100, 20.0, 20.0, 0.0)\n",
"im = kb.layered_image(\"image2\", 100, 100, 5.0, 25.0, 0.0)\n",
"# name, width, height, background_noise_sigma, variance, capture_time"
]
},
Expand All @@ -169,13 +170,13 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"im = layered_image(path+\"CORR40535777.fits\")"
"im = kb.layered_image(path+\"CORR40535777.fits\")"
]
},
{
Expand All @@ -187,16 +188,58 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 8,
"metadata": {
"collapsed": true
"collapsed": false
},
"outputs": [],
"source": [
"im.add_object(20.0, 35.0, 2500.0, p)\n",
"# x, y, flux, psf"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The image pixels can be retrieved as a 2D numpy array"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"array([[ 2.28166199e+01, 6.30420532e+01, 1.63110748e+02, ...,\n",
" 7.00930725e+02, 7.09400024e+02, 7.12992859e+02],\n",
" [ 5.68100052e+01, 5.66378860e+01, 5.64662590e+01, ...,\n",
" 4.21070099e+01, 4.24052353e+01, 4.27034683e+01],\n",
" [ 7.16959906e+00, 5.70686722e+00, -7.47076273e-01, ...,\n",
" 4.78974731e+02, 4.69988556e+02, 4.66543457e+02],\n",
" ..., \n",
" [ 2.35906372e+03, 2.31805493e+03, 2.26477246e+03, ...,\n",
" 2.29155615e+03, 2.36493823e+03, 2.33169312e+03],\n",
" [ 2.37056982e+03, 2.30898706e+03, 2.28240771e+03, ...,\n",
" 2.34917578e+03, 2.27273486e+03, 2.30295142e+03],\n",
" [ 2.31421606e+03, 2.29851660e+03, 2.37822192e+03, ...,\n",
" 2.27155884e+03, 2.27939673e+03, 2.27193042e+03]], dtype=float32)"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pixels = im.science()\n",
"pixels"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -206,15 +249,16 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 3,
"metadata": {
"collapsed": true
"collapsed": false
},
"outputs": [],
"source": [
"flags = int('11001', 2)\n",
"# this selects pixels with the first, fourth, and fifth flags (bits read right to left)\n",
"im.apply_mask_flags( flags ) "
"flags = ~0\n",
"flag_exceptions = [32,39]\n",
"# mask all of pixels with flags except those with specifed combiniations\n",
"im.apply_mask_flags( flags, flag_exceptions ) "
]
},
{
Expand All @@ -226,7 +270,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 26,
"metadata": {
"collapsed": true
},
Expand All @@ -247,7 +291,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 27,
"metadata": {
"collapsed": false
},
Expand All @@ -265,7 +309,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 28,
"metadata": {
"collapsed": false
},
Expand All @@ -276,7 +320,7 @@
"8388608"
]
},
"execution_count": 11,
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -298,15 +342,15 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 13,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"count = 10\n",
"imlist = [ layered_image(\"img\"+str(n), 50, 50, 10.0, 5.0, n/count) for n in range(count) ]\n",
"stack = image_stack( imlist )\n",
"imlist = [ kb.layered_image(\"img\"+str(n), 50, 50, 10.0, 5.0, n/count) for n in range(count) ]\n",
"stack = kb.image_stack( imlist )\n",
"# this creates a stack with 10 50x50 images, and times ranging from 0 to 1"
]
},
Expand All @@ -319,7 +363,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 30,
"metadata": {
"collapsed": false
},
Expand All @@ -334,7 +378,7 @@
" '../data/demo/CORR40535817.fits']"
]
},
"execution_count": 13,
"execution_count": 30,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -349,13 +393,13 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 31,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"stack = image_stack(files)"
"stack = kb.image_stack(files)"
]
},
{
Expand All @@ -367,16 +411,34 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 32,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"stack.apply_master_mask( flags, 2 ) # flags, threshold\n",
"stack.apply_master_mask( int('100111', 2), 2 ) # flags, threshold\n",
"stack.save_master_mask(\"mask.fits\") "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Manually set the times the images in the stack were taken "
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"stack.set_times( [0,2,3,4.5,5,6,7,10,11,14] )"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -394,11 +456,7 @@
{
"data": {
"text/plain": [
"[0.0,\n",
" 0.0030539999715983868,\n",
" 0.006087000016123056,\n",
" 0.00913199968636036,\n",
" 0.012175999581813812]"
"[0.0, 2.0, 3.0, 4.5, 5.0, 6.0, 7.0, 10.0, 11.0, 14.0]"
]
},
"execution_count": 16,
Expand All @@ -407,7 +465,7 @@
}
],
"source": [
"stack.apply_mask_flags(flags)\n",
"stack.apply_mask_flags(flags, flag_exceptions)\n",
"stack.convolve(p)\n",
"stack.get_width()\n",
"stack.get_height()\n",
Expand All @@ -426,33 +484,31 @@
},
{
"cell_type": "code",
"execution_count": 67,
"execution_count": 11,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"search = stack_search( stack, p )"
"search = kb.stack_search( stack, p )"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To save psi and images, a directory with \"psi\" and \"phi\" folders must be specified. \n",
"To search without saving images, simply skip this step"
"To save psi and images, a directory with \"psi\" and \"phi\" folders must be specified."
]
},
{
"cell_type": "code",
"execution_count": 68,
"execution_count": 12,
"metadata": {
"collapsed": true
"collapsed": false
},
"outputs": [],
"source": [
"search.image_save_location(\"/home/kbmod-usr/cuda-workspace/kbmod/search/output\")\n",
"#search.image_save_location(\"\") # <- this will cancel saving"
"search.save_psi_phi(\"/home/kbmod-usr/cuda-workspace/kbmod/search/output\")"
]
},
{
Expand Down
Loading

0 comments on commit 1941bb3

Please sign in to comment.