{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "135613bd",
   "metadata": {},
   "source": [
    "# Print out Order Boundaries to Produce Custom Wavemap"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "2811fa76",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1020 1024 42 497\n",
      "1008 1011 41 672\n",
      "995 998 40 837\n",
      "982 986 39 1008\n",
      "969 974 38 1021\n",
      "956 961 37 1021\n",
      "943 948 36 1021\n",
      "930 935 34 1021\n",
      "917 922 33 1021\n",
      "904 909 32 1021\n",
      "891 896 31 1021\n",
      "878 883 30 1021\n",
      "865 870 29 1021\n",
      "852 857 28 1021\n",
      "839 844 26 1021\n",
      "826 831 25 1021\n",
      "813 818 24 1021\n",
      "800 805 23 1021\n",
      "787 792 22 1021\n",
      "774 779 21 1021\n",
      "761 766 20 1021\n",
      "748 753 19 1021\n",
      "735 740 18 1021\n",
      "722 727 17 1021\n",
      "709 714 15 1021\n",
      "696 701 14 1021\n",
      "683 688 13 1021\n",
      "670 675 12 1021\n",
      "657 662 11 1021\n",
      "644 649 10 1021\n",
      "631 636 9 1021\n",
      "618 623 8 1021\n",
      "605 610 7 1021\n",
      "592 597 6 1021\n",
      "579 584 5 1021\n",
      "566 571 3 1021\n",
      "553 558 2 1021\n",
      "540 545 2 1021\n",
      "527 532 2 1021\n",
      "514 519 2 1020\n",
      "501 506 2 1019\n",
      "488 493 2 1018\n",
      "475 480 2 1016\n",
      "462 467 2 1015\n",
      "449 454 2 1014\n",
      "435 441 2 1012\n",
      "421 428 2 1011\n",
      "408 415 2 1010\n",
      "395 402 2 1008\n",
      "382 389 2 1007\n",
      "369 376 2 1006\n",
      "356 363 2 1004\n",
      "343 350 2 1003\n",
      "330 337 2 1002\n",
      "317 324 2 1000\n",
      "304 311 2 999\n",
      "291 298 2 998\n",
      "278 285 2 996\n",
      "265 272 2 995\n",
      "252 259 2 994\n",
      "239 246 2 992\n",
      "225 233 2 991\n",
      "211 220 2 990\n",
      "198 207 2 988\n",
      "185 194 2 987\n",
      "172 181 2 986\n",
      "159 168 2 984\n",
      "146 155 2 983\n",
      "133 142 2 982\n",
      "120 129 2 981\n",
      "106 115 2 979\n",
      "92 101 2 978\n",
      "79 88 2 977\n",
      "66 75 2 976\n",
      "53 62 2 974\n",
      "40 49 72 973\n",
      "27 34 199 972\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/var/folders/ny/wc1343fs1ks1wxbqp7v_x6v40000gq/T/ipykernel_61683/3006118441.py:32: DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`. To silence this warning, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.\n",
      "Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations\n",
      "  print(np.int(hdu[0].header['ORDR_B'].split(',')[k])+4,np.int(hdu[0].header['ORDR_T'].split(',')[k])+1,\n",
      "/var/folders/ny/wc1343fs1ks1wxbqp7v_x6v40000gq/T/ipykernel_61683/3006118441.py:29: DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`. To silence this warning, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.\n",
      "Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations\n",
      "  print(np.int(hdu[0].header['ORDR_B'].split(',')[k])+4,np.int(hdu[0].header['ORDR_T'].split(',')[k])+2,\n",
      "/var/folders/ny/wc1343fs1ks1wxbqp7v_x6v40000gq/T/ipykernel_61683/3006118441.py:26: DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`. To silence this warning, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.\n",
      "Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations\n",
      "  print(np.int(hdu[0].header['ORDR_B'].split(',')[k])+3,np.int(hdu[0].header['ORDR_T'].split(',')[k])+2,\n",
      "/var/folders/ny/wc1343fs1ks1wxbqp7v_x6v40000gq/T/ipykernel_61683/3006118441.py:23: DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`. To silence this warning, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.\n",
      "Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations\n",
      "  print(np.int(hdu[0].header['ORDR_B'].split(',')[k])+2,np.int(hdu[0].header['ORDR_T'].split(',')[k])+2,\n",
      "/var/folders/ny/wc1343fs1ks1wxbqp7v_x6v40000gq/T/ipykernel_61683/3006118441.py:20: DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`. To silence this warning, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.\n",
      "Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations\n",
      "  print(np.int(hdu[0].header['ORDR_B'].split(',')[k])+1,np.int(hdu[0].header['ORDR_T'].split(',')[k])+1,\n",
      "/var/folders/ny/wc1343fs1ks1wxbqp7v_x6v40000gq/T/ipykernel_61683/3006118441.py:17: DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`. To silence this warning, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.\n",
      "Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations\n",
      "  print(np.int(hdu[0].header['ORDR_B'].split(',')[k])+1,np.int(hdu[0].header['ORDR_T'].split(',')[k])-1,\n"
     ]
    }
   ],
   "source": [
    "from astropy.io import fits\n",
    "from astropy.table import Table\n",
    "import numpy as np\n",
    "\n",
    "\n",
    "# import any EXES pipeline produced FITS file after the \n",
    "# make_flat step or later (e.g. FLT to 1D spectral files)\n",
    "file_name = \"F0866_EX_SPE_750106275_EXEELONEXEECHL_COM_80029.fits\"\n",
    "hdu = fits.open(file_name)\n",
    "\n",
    "#For loop over the ORDR_B, ORDR_T, ORDR_S, and ORDR_E keywords\n",
    "#Note the loop has to be built with the reminder that custom wavemap text file goes from the top\n",
    "#to the bottom of the array. However, order 1 is at the bottom of the array, so I've chosen to make the\n",
    "#if statements account for this rather than count downward in the for loop\n",
    "for k in range(hdu[0].header['NORDERS']):\n",
    "    if k == 76:\n",
    "        print(np.int(hdu[0].header['ORDR_B'].split(',')[k])+1,np.int(hdu[0].header['ORDR_T'].split(',')[k])-1,\n",
    "              hdu[0].header['ORDR_S'].split(',')[k],hdu[0].header['ORDR_E'].split(',')[k])\n",
    "    elif k >= 70 and k < 76:\n",
    "        print(np.int(hdu[0].header['ORDR_B'].split(',')[k])+1,np.int(hdu[0].header['ORDR_T'].split(',')[k])+1,\n",
    "              hdu[0].header['ORDR_S'].split(',')[k],hdu[0].header['ORDR_E'].split(',')[k])\n",
    "    elif k >= 61 and k < 70:\n",
    "        print(np.int(hdu[0].header['ORDR_B'].split(',')[k])+2,np.int(hdu[0].header['ORDR_T'].split(',')[k])+2,\n",
    "              hdu[0].header['ORDR_S'].split(',')[k],hdu[0].header['ORDR_E'].split(',')[k])\n",
    "    elif k >= 45 and k < 61:\n",
    "        print(np.int(hdu[0].header['ORDR_B'].split(',')[k])+3,np.int(hdu[0].header['ORDR_T'].split(',')[k])+2,\n",
    "              hdu[0].header['ORDR_S'].split(',')[k],hdu[0].header['ORDR_E'].split(',')[k])      \n",
    "    elif k >= 3 and k < 45:\n",
    "        print(np.int(hdu[0].header['ORDR_B'].split(',')[k])+4,np.int(hdu[0].header['ORDR_T'].split(',')[k])+2,\n",
    "              hdu[0].header['ORDR_S'].split(',')[k],hdu[0].header['ORDR_E'].split(',')[k])\n",
    "    elif k < 3:\n",
    "        print(np.int(hdu[0].header['ORDR_B'].split(',')[k])+4,np.int(hdu[0].header['ORDR_T'].split(',')[k])+1,\n",
    "              hdu[0].header['ORDR_S'].split(',')[k],hdu[0].header['ORDR_E'].split(',')[k])\n",
    "\n",
    "#Above shows an for the IRC +10216 HIGH-LOW 805 cm-1 setting (AOR_ID: 75_0106_275)\n",
    "#Slight shifts from the default values needed to be done for the ORDR_B & ORDR_T values\n",
    "#by location on the detector. Once you're satisified cut and paste the output to a text file"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b7c8e966",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "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.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
