Created
December 18, 2019 06:35
-
-
Save zonca/1dca26dea35c9079a2df8ebb5dfb32f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import iris_pipeline" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"%run ~/p/software/iris_pipeline/setup_local_crds.py" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"iris_pipeline.monkeypatch_jwst_datamodels()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"r2019-03-18_i_001_001_0.fits r2019-03-18_i_001_001_3.fits\n", | |
"r2019-03-18_i_001_001_1.fits r2019-03-18_i_001_001_4.fits\n", | |
"r2019-03-18_i_001_001_2.fits raw_science_frame_subarray.fits\n" | |
] | |
} | |
], | |
"source": [ | |
"ls readouts/" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 16, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"raw_science_frame = iris_pipeline.datamodels.IRISImageModel(\"/home/azonca/p/software/iris_pipeline/iris_pipeline/tests/data/raw_science_frame_sci.fits\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 18, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import jwst" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 26, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"2019-12-17 22:06:28,100 - stpipe.Step - INFO - Step instance created.\n" | |
] | |
} | |
], | |
"source": [ | |
"full_dark_filename = jwst.stpipe.Step().get_reference_file(raw_science_frame, \"dark\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 31, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"'/home/azonca/crds_cache/references/tmt/iris/tmt_iris_dark_0001.fits'" | |
] | |
}, | |
"execution_count": 31, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"full_dark_filename" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 66, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"full_dark = iris_pipeline.datamodels.IRISImageModel(full_dark_filename)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 67, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"subarray = jwst.datamodels.open(\"readouts/raw_science_frame_subarray.fits\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 68, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"980" | |
] | |
}, | |
"execution_count": 68, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"subarray.meta.subarray.xstart" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 69, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"full_dark.data = full_dark.data[subarray.meta.subarray.xstart:subarray.meta.subarray.xstart+subarray.meta.subarray.xsize,\n", | |
" subarray.meta.subarray.ystart:subarray.meta.subarray.ystart+subarray.meta.subarray.ysize]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 70, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"full_dark.write(\"subarray_dark.fits\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 71, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"array([[14.545454 , 7.272727 , 13.181818 , ..., 9.545454 , 10.454545 ,\n", | |
" 9.545454 ],\n", | |
" [ 9.090909 , 11.818182 , 12.727272 , ..., 11.818182 , 11.363636 ,\n", | |
" 10. ],\n", | |
" [13.636363 , 12.727272 , 15.909091 , ..., 14.545454 , 12.272727 ,\n", | |
" 12.272727 ],\n", | |
" ...,\n", | |
" [10.909091 , 9.545454 , 11.363636 , ..., 10.909091 , 15. ,\n", | |
" 9.545454 ],\n", | |
" [13.181818 , 13.636363 , 6.8181815, ..., 11.363636 , 10.454545 ,\n", | |
" 11.363636 ],\n", | |
" [10. , 13.636363 , 8.636363 , ..., 9.545454 , 16.363636 ,\n", | |
" 7.7272725]], dtype=float32)" | |
] | |
}, | |
"execution_count": 71, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"full_dark.data" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 72, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Overwriting dark.cfg\n" | |
] | |
} | |
], | |
"source": [ | |
"%%file dark.cfg\n", | |
"\n", | |
"override_dark = subarray_dark.fits" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 73, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"\n", | |
"override_dark = subarray_dark.fits\n" | |
] | |
} | |
], | |
"source": [ | |
"cat dark.cfg" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 74, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"2019-12-17 22:32:51,963 - stpipe.DarkCurrentStep - INFO - DarkCurrentStep instance created.\n", | |
"2019-12-17 22:32:52,210 - stpipe.DarkCurrentStep - INFO - Step DarkCurrentStep running with args ('readouts/raw_science_frame_subarray.fits',).\n", | |
"2019-12-17 22:32:52,386 - stpipe.DarkCurrentStep - INFO - Using DARK reference file /home/azonca/p/issues/201912_subarrays/subarray_dark.fits\n", | |
"2019-12-17 22:32:52,674 - stpipe.DarkCurrentStep - INFO - Step DarkCurrentStep done\n" | |
] | |
} | |
], | |
"source": [ | |
"out = iris_pipeline.dark_current.DarkCurrentStep.call(\"readouts/raw_science_frame_subarray.fits\", config_file=\"dark.cfg\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 75, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"array([[ 86.454544, 106.72727 , 90.818184, ..., 72.454544, 78.545456,\n", | |
" 80.454544],\n", | |
" [ 79.90909 , 85.181816, 69.27273 , ..., 80.181816, 103.63637 ,\n", | |
" 91. ],\n", | |
" [ 81.36364 , 82.27273 , 59.090908, ..., 76.454544, 91.72727 ,\n", | |
" 84.72727 ],\n", | |
" ...,\n", | |
" [ 83.09091 , 75.454544, 79.63637 , ..., 65.09091 , 52. ,\n", | |
" 69.454544],\n", | |
" [ 57.818184, 72.36364 , 59.18182 , ..., 80.63637 , 74.545456,\n", | |
" 69.63637 ],\n", | |
" [ 69. , 55.363636, 68.36364 , ..., 72.454544, 59.636364,\n", | |
" 73.27273 ]], dtype=float32)" | |
] | |
}, | |
"execution_count": 75, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"out.data" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 76, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import numpy as np\n", | |
"np.testing.assert_allclose(out.data, subarray.data - full_dark.data)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "jwst", | |
"language": "python", | |
"name": "jwst" | |
}, | |
"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.6.9" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 4 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment