Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MDM OSMOS R4K #293

Merged
merged 7 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
244 changes: 244 additions & 0 deletions dev_algorithms/osmos/CutImage.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "7de93a74-b81a-4a7d-953f-52704037550d",
"metadata": {},
"source": [
"# Cut image"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "fc02bde1-d1c6-4506-bafe-9f87d72e9692",
"metadata": {},
"outputs": [],
"source": [
"# imports\n",
"import os\n",
"from astropy.io import fits"
]
},
{
"cell_type": "markdown",
"id": "3c71840a-b2cb-4dc0-a7c3-6917c8b50476",
"metadata": {},
"source": [
"# Test one"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "bcf4dc8d-0bcc-4ad1-a114-c083004158e3",
"metadata": {},
"outputs": [],
"source": [
"dpath = os.path.join(os.getenv('PYPEIT_DEV'), 'RAW_DATA', 'mdm_osmos', 'R4K')"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "01f7e559-04c6-41ee-af7f-69b20ce77416",
"metadata": {},
"outputs": [],
"source": [
"#root = 'cscu.0002.fits'\n",
"root = 'cscu.0021.fits'\n",
"dfile = os.path.join(dpath, root)"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "a2985587-0336-4fad-ab99-01e4d47d4092",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING: The following header keyword is invalid or follows an unrecognized non-standard convention:\n",
"MISFILT / MIS Filter Number [astropy.io.fits.card]\n",
"WARNING: The following header keyword is invalid or follows an unrecognized non-standard convention:\n",
"MISFLTID / MIS Filter ID [astropy.io.fits.card]\n"
]
}
],
"source": [
"hdul = fits.open(dfile)"
]
},
{
"cell_type": "markdown",
"id": "ca436ce2-cf04-403e-997b-125709c10a80",
"metadata": {},
"source": [
"## Cut image"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "30ee203f-92ee-46f7-a0f7-5229ed52dbb2",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(1048, 4160)"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cut_img = hdul[0].data[1524:1524+1048,:]\n",
"cut_img.shape"
]
},
{
"cell_type": "markdown",
"id": "14c2a11e-b8aa-4642-833d-e5d59e052f45",
"metadata": {},
"source": [
"## Header"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "d14a991f-1183-4554-a08d-3e539f160f9a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"SIMPLE = T / conforms to FITS standard \n",
"BITPIX = 16 / array data type \n",
"NAXIS = 2 / number of array dimensions \n",
"NAXIS1 = 4160 \n",
"NAXIS2 = 1048 \n",
"EXTEND = T \n",
"BSCALE = 1 \n",
"BZERO = 32768 "
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"phdu = fits.PrimaryHDU(cut_img)\n",
"phdu.header"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "91a0bca6-44d5-4bb3-9ed9-3231d1e2a600",
"metadata": {},
"outputs": [],
"source": [
"for key in hdul[0].header.keys():\n",
" if key in phdu.header.keys():\n",
" continue\n",
" if key == 'COMMENT':\n",
" continue\n",
" #print(key)\n",
" phdu.header[key] = hdul[0].header[key]"
]
},
{
"cell_type": "markdown",
"id": "e8435a77-70ba-4a26-a449-c84e5651b3e8",
"metadata": {},
"source": [
"## Write"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "40aa62cf-bfe8-41b7-8d99-458db93302d8",
"metadata": {},
"outputs": [],
"source": [
"new_hdul = fits.HDUList([phdu])"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "ee928bd9-6b15-4945-aa06-bd91e05c9d84",
"metadata": {},
"outputs": [],
"source": [
"new_hdul.writeto(root.replace('.fits', '.cut.fits'))"
]
},
{
"cell_type": "markdown",
"id": "500bd534-90a2-4b16-877c-a34ff9f5a2a7",
"metadata": {},
"source": [
"----"
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "d3398a65-cd1f-4ba0-8b3c-24a89ac2de8c",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Ne Hg'"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"hdul[0].header['LAMPS']"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "dfc22282-f898-4b7b-8446-85086c994eef",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"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.9.15"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
24 changes: 24 additions & 0 deletions dev_algorithms/osmos/HgNeAr_arclines_pixvswav
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# lines used ...
# column 1: pixel number
# column 2: catalog wavelength (Angstroms)
572.63 0139.787
828.11 9784.503
918.40 9657.786
1300.66 9122.966
1730.84 521.4422
1915.23 264.5225
2143.37 948.1764
2370.18 7635.106
2513.32 7438.899
2553.65 383.9805
2655.85 7245.167
2728.19 147.0416
2889.96 6929.468
3049.32 6717.048
3078.65 6678.277
3289.11 6402.246
3341.35 6334.428
3393.85 6266.495
3432.12 6217.281
3490.02 6143.063
4041.10 5460.74
Loading