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

Allow for passing the target coordinates to extrat_source_position #1321

Open
morcuended opened this issue Nov 27, 2024 · 0 comments
Open

Allow for passing the target coordinates to extrat_source_position #1321

morcuended opened this issue Nov 27, 2024 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@morcuended
Copy link
Member

morcuended commented Nov 27, 2024

def extract_source_position(
data, observed_source_name, equivalent_focal_length=28 * u.m
):
"""
Extract source position from data
Parameters
----------
pandas.DataFrame data: input data
str observed_source_name: Name of the observed source
astropy.units.m equivalent_focal_length: Equivalent focal length of a telescope
Returns
-------
2D array of coordinates of the source in form [(x),(y)] in astropy.units.m
"""
observed_source = SkyCoord.from_name(observed_source_name)
obstime = pd.to_datetime(data["dragon_time"], unit="s")
pointing_alt = u.Quantity(data["alt_tel"], u.rad, copy=False)
pointing_az = u.Quantity(data["az_tel"], u.rad, copy=False)
source_pos_camera = radec_to_camera(
observed_source,
obstime,
pointing_alt,
pointing_az,
focal=equivalent_focal_length,
)
source_position = [source_pos_camera.x, source_pos_camera.y]
return source_position

For cases in which the name solver of astropy does not work (e.g. GRBs, GW, neutrino alerts) one needs to pass the coordinates directly to make this function work. Used in the explore DL2 notebook (theta2 distribution calculation)

@morcuended morcuended added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant