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

Remove redundant function get_cat #230

Merged
merged 1 commit into from
Dec 21, 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
16 changes: 8 additions & 8 deletions stellarphot/notebooks/photometry/04-transform-pared-back.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"%matplotlib inline\n",
"import matplotlib.pyplot as plt\n",
"\n",
"from stellarphot.utils.magnitude_transforms import get_cat, f, opts_to_str, calc_residual, transform_to_catalog"
"from stellarphot.utils.magnitude_transforms import f, opts_to_str, calc_residual, transform_to_catalog"
]
},
{
Expand Down Expand Up @@ -72,7 +72,7 @@
"our_filters = ['SI']\n",
"\n",
"aavso_band_names = dict(\n",
" B='B', \n",
" B='B',\n",
" V='V',\n",
" gp='SG',\n",
" rp='SR',\n",
Expand All @@ -90,7 +90,7 @@
")\n",
"\n",
"cat_filter = dict(\n",
" B='Bmag', \n",
" B='Bmag',\n",
" V='Vmag',\n",
" gp='g_mag',\n",
" rp='r_mag',\n",
Expand Down Expand Up @@ -154,16 +154,16 @@
},
"outputs": [],
"source": [
"output_table = [] \n",
"output_table = []\n",
"\n",
"for k, group in zip(our_filters, filter_groups.groups):\n",
" print(f'Transforming band {k}')\n",
" by_bjd = group.group_by('bjd')\n",
" \n",
" transform_to_catalog(by_bjd, f'mag_inst', aavso_band_names[k], \n",
" obs_error_column='mag_error', \n",
"\n",
" transform_to_catalog(by_bjd, f'mag_inst', aavso_band_names[k],\n",
" obs_error_column='mag_error',\n",
" zero_point_range=[12, 25],\n",
" c_delta=0.5, # b_delta=0.1, \n",
" c_delta=0.5, # b_delta=0.1,\n",
" cat_filter=cat_filter[k], cat_color=cat_color_colums[k],\n",
" in_place=True);\n",
" output_table.append(by_bjd.copy())\n",
Expand Down
39 changes: 5 additions & 34 deletions stellarphot/utils/magnitude_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
from astropy.coordinates import SkyCoord, match_coordinates_sky
from astropy import units as u

from astroquery.vizier import Vizier
from ..core import apass_dr9


__all__ = [
"f",
"get_cat",
"opts_to_str",
"calc_residual",
"filter_transform",
Expand Down Expand Up @@ -48,37 +47,6 @@ def f(X, a, b, c, d, z):
return a * mag_inst + b * mag_inst**2 + c * color + d * color**2 + z


def get_cat(image):
"""
Get the APASS catalog entries within 1 degree of first object in
Astropy table 'image'.

Parameters
----------

image : `astropy.table.Table`
Table containing the image information. Must have columns
``RA`` and ``Dec``.

Returns
-------

`astropy.table.Table`
Table containing the APASS catalog entries within 1 degree of
first object in Astropy table.
"""
our_coords = SkyCoord(image["RA"], image["Dec"], unit="degree")
# Get catalog via cone search
Vizier.ROW_LIMIT = -1 # Set row_limit to have no limit
desired_catalog = "II/336/apass9"
a_star = our_coords[0]
rad = 1 * u.degree
cat = Vizier.query_region(a_star, radius=rad, catalog=desired_catalog)
cat = cat[0]
cat_coords = SkyCoord(cat["RAJ2000"], cat["DEJ2000"])
return cat, cat_coords


def opts_to_str(opts):
"""
Convert the options from a fit to a string.
Expand Down Expand Up @@ -632,7 +600,10 @@ def transform_to_catalog(
):
our_coords = SkyCoord(one_image["RA"], one_image["Dec"], unit="degree")
if cat is None or cat_coords is None:
cat, cat_coords = get_cat(one_image)
cat = apass_dr9(
our_coords[0], radius=1 * u.degree, clip_by_frame=False, padding=0
)
cat_coords = SkyCoord(cat["ra"], cat["dec"])
cat["color"] = cat[cat_color[0]] - cat[cat_color[1]]

cat_idx, d2d, _ = our_coords.match_to_catalog_sky(cat_coords)
Expand Down