Skip to content

Commit

Permalink
Merge pull request #73 from mwcraig/add-intro-photometry-notebooks
Browse files Browse the repository at this point in the history
Add intro photometry notebooks
  • Loading branch information
mwcraig authored Oct 18, 2022
2 parents 062e31d + b07107a commit 67f69cf
Show file tree
Hide file tree
Showing 8 changed files with 1,511 additions and 70 deletions.
149 changes: 149 additions & 0 deletions stellarphot/notebooks/calculate_aavso_mags_draft.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "6d973d4c-b1db-4f8b-82a2-e64990c07776",
"metadata": {},
"outputs": [],
"source": [
"from astropy.coordinates import SkyCoord\n",
"from astropy.table import Table\n",
"from astropy.time import Time\n",
"from astropy.timeseries import TimeSeries\n",
"\n",
"from matplotlib import pyplot as plt\n",
"\n",
"from stellarphot.differential_photometry import vsx_mags\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "294fa9a6-5522-414b-ad96-73da98cb3eea",
"metadata": {},
"outputs": [],
"source": [
"your_photometry_file = 'v0553 her-2022-06-03.csv'\n",
"comp_stars_file = 'apass-V0533-Her.csv'\n",
"name_of_variable = 'v0533 her'\n",
"\n",
"# Our filter names vs filter names in comparison star table\n",
"filter_mapping = dict(\n",
" ip='SI',\n",
" B='B'\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "110085f6-4c91-4e55-9ced-fb64936acf69",
"metadata": {},
"outputs": [],
"source": [
"var_coord = SkyCoord.from_name(name_of_variable)\n",
"\n",
"vc = dict(coords=var_coord)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7cd3031f-59ef-4b21-bad9-0075fc9b679a",
"metadata": {},
"outputs": [],
"source": [
"your_photometry = Table.read(your_photometry_file)\n",
"your_photometry['RA'].unit = 'degree'\n",
"your_photometry['Dec'].unit = 'degree'\n",
"\n",
"your_photometry['band'] = your_photometry['filter']\n",
"\n",
"comp_stars = Table.read(comp_stars_file)\n",
"comp_stars['RAJ2000'].unit = 'degree'\n",
"comp_stars['DEJ2000'].unit = 'degree'\n",
"\n"
]
},
{
"cell_type": "markdown",
"id": "23411fe8-7cd2-455d-ac74-058ec5df9c37",
"metadata": {},
"source": [
"## The cell below does just one filter..."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "77fd8792-f47b-41ef-a489-f82f05b4d68f",
"metadata": {},
"outputs": [],
"source": [
"this_filter = 'ip'\n",
"\n",
"this_phot = your_photometry[your_photometry['band'] == this_filter]\n",
"\n",
"this_phot_grp = this_phot.group_by('BJD')\n",
"\n",
"times = []\n",
"cal_mag = []\n",
"cal_mag_err = []\n",
"for time, rows in zip(this_phot_grp.groups.keys, this_phot_grp.groups):\n",
" mag, err = vsx_mags.calc_vmag(vc, rows, comp_stars, band=filter_mapping[this_filter], star_data_mag_column=f'mag_inst_{this_filter}')\n",
" cal_mag.append(mag)\n",
" cal_mag_err.append(err)\n",
" times.append(time[0])"
]
},
{
"cell_type": "markdown",
"id": "5ec0ee07-89f5-495a-b1ed-549e61fdf73f",
"metadata": {},
"source": [
"## Sample plot...."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ed95a387-bcbb-41f8-9aca-d872ba53baa9",
"metadata": {},
"outputs": [],
"source": [
"plt.errorbar(times, cal_mag, yerr=cal_mag_err, fmt='s')\n",
"plt.grid()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d88f4d8a-8fb4-46dd-838d-709adc75d3d2",
"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.10.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading

0 comments on commit 67f69cf

Please sign in to comment.