Skip to content

Commit

Permalink
Merge pull request #9 from radionets-project/beam2jansky
Browse files Browse the repository at this point in the history
Beam2jansky
  • Loading branch information
aknierim authored Oct 24, 2024
2 parents 180195c + 9fd7ded commit b95ad45
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/changes/9.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Add utility function `radiotools.utils.img2jansky` that converts an image in Jy/beam to Jy/px
4 changes: 2 additions & 2 deletions radiotools/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .utils import get_array_names
from .utils import get_array_names, img2jansky

__all__ = ["get_array_names"]
__all__ = ["get_array_names", "img2jansky"]
27 changes: 27 additions & 0 deletions radiotools/utils/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import numpy as np
import requests
from astropy.io import fits
from bs4 import BeautifulSoup
from numpy.typing import ArrayLike


def get_array_names(url: str) -> list[str]:
Expand Down Expand Up @@ -30,3 +33,27 @@ def get_array_names(url: str) -> list[str]:
layouts = list(set(layouts))

return layouts


def img2jansky(image: ArrayLike, header: fits.Header):
"""Converts an image from Jy/beam to Jy/px.
Parameters
----------
image : array_like
Input image that is to be converted.
header : :class:`astropy.io.fits.header.Header`
FITS file header belonging to the respective image.
Returns
-------
array_like
Converted image in units of Jy/px.
"""
return (
4
* image
* np.log(2)
* np.power(header["CDELT1"], 2)
/ (np.pi * header["BMIN"] * header["BMAJ"])
)

0 comments on commit b95ad45

Please sign in to comment.