Skip to content

Commit

Permalink
test: example of running subarray
Browse files Browse the repository at this point in the history
  • Loading branch information
zonca committed Mar 7, 2020
1 parent 99b243a commit 50c85d7
Showing 1 changed file with 186 additions and 0 deletions.
186 changes: 186 additions & 0 deletions iris_pipeline/tests/run_image2_subarray.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import iris_pipeline"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"iris_pipeline.monkeypatch_jwst_datamodels()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from test_utils import get_data_from_url"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"raw_science_subarray_filename = get_data_from_url(\"21942483\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"raw_science_frame = iris_pipeline.datamodels.IRISImageModel(raw_science_subarray_filename)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"assert raw_science_frame.meta.subarray.name == \"CUSTOM\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"assert raw_science_frame.meta.subarray.xsize == 40"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%file image2_subarray.cfg\n",
"\n",
"\n",
"name = \"Image2Pipeline\"\n",
"class = \"iris_pipeline.pipeline.Image2Pipeline\"\n",
"save_results = True\n",
"\n",
" [steps]\n",
" [[bkg_subtract]]\n",
" [[assign_wcs]]\n",
" skip = True\n",
" [[dark_current]]\n",
" [[flat_field]]\n",
" [[photom]]\n",
" skip = True\n",
" [[resample]]\n",
" skip = True"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"out = iris_pipeline.pipeline.Image2Pipeline.call(raw_science_subarray_filename,\n",
" config_file=\"image2_subarray.cfg\")[0]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"assert int(out.data.min()) == 34"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"assert int(out.data.max()) == 6232"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plt.imshow(out.data)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"out.data.min(), out.data.max()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plt.imshow(out.data - raw_science_frame.data)\n",
"(out.data - raw_science_frame.data).std()"
]
},
{
"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
}

0 comments on commit 50c85d7

Please sign in to comment.