Skip to content

Added checking to see if astroquery returned table has uppercase or l… #15

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changes for swiftbat_python

## v 0.1.5 2025-05-16

- Moved all conditions for the calculation of the exposure to be inside batExposure
- Made all returned values of batExposure be an astropy Quantity object with cm^2 units
- Modified simbadlocation to be able to access table RA/Dec values based on lowercase or uppercase headers, which changes with different versions of astroquery

## v 0.1.4 2023-08-05

- Started CHANGES.md file
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

setup(
name="swiftbat",
version="0.1.4",
version="0.1.5",
packages=["swiftbat"],
package_data={"": ["catalog", "recent_bcttb.fits.gz"]},
url="https://github.com/lanl/swiftbat_python/",
Expand Down
22 changes: 16 additions & 6 deletions swiftbat/swinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,16 @@ def simbadlocation(objectname):
table = Simbad.query_object(objectname)
if len(table) != 1:
raise RuntimeError(f"No unique match for {objectname}")

if "RA" in table.keys():
ra_string="RA"
dec_string="DEC"
else:
ra_string="ra"
dec_string="dec"

co = coordinates.SkyCoord(
table["RA"][0], table["DEC"][0], unit=(u.hour, u.deg), frame="fk5"
table[ra_string][0], table[dec_string][0], unit=(u.hour, u.deg), frame="fk5"
)
return (co.ra.degree, co.dec.degree)
except Exception as e:
Expand Down Expand Up @@ -318,7 +326,6 @@ def updateTLE(self):

# Source, initialized from a data string from the catalog files


def batExposure(theta, phi):
"""
Given theta,phi in radians, returns (open_coded_area_in_cm^2, cosfactor)
Expand All @@ -331,7 +338,11 @@ def batExposure(theta, phi):
phi = apAngle(phi, u.rad)

if np.cos(theta) < 0:
return (0.0, np.cos(theta))
return (0.0*u.cm**2, np.cos(theta))

if theta > apAngle(90, u.deg):
return 0.0*u.cm**2, 0.0

# BAT dimensions
detL = 286 * 4.2e-3 # Amynote: each det element is has length 4.2e-3 m
detW = 173 * 4.2e-3 # Amynote: each det element is has length 4.2e-3 m
Expand Down Expand Up @@ -371,7 +382,7 @@ def batExposure(theta, phi):
area = 0
# if you want to see what the corners do: area = max(0,deltaX * deltaY) - area
# multiply by 1e4 for cm^2, 1/2 for open area
return (area * 1e4 / 2, np.cos(theta))
return (u.cm**2 * area * 1e4 / 2, np.cos(theta))


def detid2xy(detids):
Expand Down Expand Up @@ -569,8 +580,7 @@ def sf_position(self) -> sf_ICRF:
def exposure(self, ra, dec, roll):
# returns (projected_area, cos(theta))
(thetangle, phi) = self.thetangle_phi(ra, dec, roll)
if thetangle > apAngle(90, u.deg):
return 0.0, 0.0

return batExposure(thetangle, phi)

def thetangle_phi(
Expand Down