From 547743bafcd98c4f4b25d17ab10e7cb8218adb36 Mon Sep 17 00:00:00 2001 From: Robert Stein Date: Thu, 17 Aug 2023 12:21:21 -0700 Subject: [PATCH] Fix query for fields (#28) --- tests/test_fields.py | 8 ++++---- wintertoo/fields.py | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/test_fields.py b/tests/test_fields.py index 4e0bacb..8750fd4 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -32,13 +32,13 @@ def test_get_fields_in_box(self): fields = get_fields_in_box(ra_lim, dec_lim, summer=True) - assert len(fields) == 17, "Wrong number of fields" - assert fields["ID"].iloc[0] == 55286, "Wrong field" + assert len(fields) == 28, f"Wrong number of fields ({len(fields)})" + assert fields["ID"].iloc[0] == 54494, f"Wrong field {fields['ID'].iloc[0]}" fields = get_fields_in_box(ra_lim, dec_lim, summer=False) - assert len(fields) == 2, "Wrong number of fields" - assert fields["ID"].iloc[0] == 3735, "Wrong field" + assert len(fields) == 3, f"Wrong number of fields ({len(fields)})" + assert fields["ID"].iloc[0] == 3735, f"Wrong field {fields['ID'].iloc[0]}" def test_get_field_info(self): """ diff --git a/wintertoo/fields.py b/wintertoo/fields.py index 05fca5e..0a8f699 100644 --- a/wintertoo/fields.py +++ b/wintertoo/fields.py @@ -74,10 +74,11 @@ def get_fields_in_box( """ field_df = get_fields(summer=summer) + base_width = 0.5 * get_base_width(summer=summer) res = field_df.query( - f"(RA > {ra_lim[0]}) and (RA < {ra_lim[1]}) " - f"and (Dec > {dec_lim[0]}) and (Dec < {dec_lim[1]})" + f"(RA > {ra_lim[0] - base_width}) and (RA < {ra_lim[1] + base_width}) " + f"and (Dec > {dec_lim[0] - base_width}) and (Dec < {dec_lim[1] + base_width})" ) return res