Skip to content

Commit

Permalink
correct gaia resolution, add example notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
ndrory committed Oct 2, 2024
1 parent 92a777e commit 4cd0a83
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 1 deletion.
89 changes: 89 additions & 0 deletions examples/lco_com/gaia_conv.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import lvmdrp.core.fluxcal as fluxcal\n",
"from lvmdrp.functions.fluxCalMethod import get_bprp_convolution_matrix\n",
"from astropy.io import fits\n",
"from astropy.table import Table\n",
"\n",
"with fits.open('/Users/droryn/work/LVM/data/sas/sdsswork/lvm/spectro/redux/1.1.0dev/1039XX/1039949/60356/lvmCFrame-00012618.fits') as hdu:\n",
" d = hdu['FLUX'].data\n",
" w = hdu['WAVE'].data\n",
" slitmap = Table(hdu['SLITMAP'].data)\n",
"\n",
"gw, gf = fluxcal.retrive_gaia_star('5611678276101933056', GAIA_CACHE_DIR='/Users/droryn/work/LVM/data/sas/sdsswork/lvm/sandbox/calib/gaia_cache')\n",
"stdflux = np.interp(w, gw, gf) # interpolate to our wavelength grid\n",
"f = d[1297,:]\n",
"plt.plot(w,f, color='blue', linewidth=1)\n",
"plt.plot(gw,gf, color='red', linewidth=1)\n",
"\n",
"bprp_conv = get_bprp_convolution_matrix(w)\n",
"spec_c = bprp_conv@f\n",
"\n",
"plt.plot(w,spec_c, color='green')\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"slitmap[slitmap['orig_ifulabel']=='P1-2']"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"s = '/Users/droryn/prog/lvm/lvmcore/etc/Gaia_BPRP_resolution.txt'\n",
"txt = np.genfromtxt(s)\n",
"l_bprp, r_bprp = txt[:, 0], txt[:, 1]\n",
"sigmas = l_bprp/r_bprp/2.35\n",
"plt.plot(l_bprp, sigmas)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "lvmdrp",
"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.12.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
2 changes: 1 addition & 1 deletion python/lvmdrp/functions/fluxCalMethod.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ def get_bprp_convolution_matrix(w):
Input: w numpy.ndarray of wavelengths for target spectrum
'''
s = os.getenv('LVMCORE_DIR')+'/etc/Gaia1'
s = os.getenv('LVMCORE_DIR')+'/etc/Gaia_BPRP_resolution.txt'
log.info(f"Reading GAIA PB-RP resolution {s}")
txt = np.genfromtxt(s)
l_bprp, r_bprp = txt[:, 0], txt[:, 1]
Expand Down

0 comments on commit 4cd0a83

Please sign in to comment.