Skip to content

Instantly share code, notes, and snippets.

@jwise77
Created November 2, 2023 17:28
Show Gist options
  • Save jwise77/3fe7764475556bbe5a7a96eb1048fcc5 to your computer and use it in GitHub Desktop.
Save jwise77/3fe7764475556bbe5a7a96eb1048fcc5 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 5,
"id": "c7ff67c6-adad-40ca-8cd2-6806f4d13bba",
"metadata": {},
"outputs": [],
"source": [
"import unyt as u\n",
"import numpy as np\n",
"from yt.utilities import cosmology as co"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "f0bb8801-2a15-48d3-8075-97f1f33e220f",
"metadata": {},
"outputs": [],
"source": [
"flux = 3e-9 * u.mJy\n",
"zeropoint = 3630.78 * u.Jy"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "2a590da7-9500-4e7a-970b-c9cb8c4c2216",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"37.70719669941819\n"
]
}
],
"source": [
"mag_apparent = -2.5 * np.log10(flux / zeropoint)\n",
"print(mag_apparent)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "d18ebc3d-b890-4e23-8f3b-1320ca31a5af",
"metadata": {},
"outputs": [],
"source": [
"c = co.Cosmology()"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "464a0e35-45f1-41ee-8926-429f4d40b8d0",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"106.30170300070318 Gpc\n"
]
}
],
"source": [
"dL = c.luminosity_distance(0, 10)\n",
"print(dL.to('Gpc'))"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "284ffbe1-6b9f-44a3-a539-5e92e7c3dc56",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"-12.42550441143365\n"
]
}
],
"source": [
"mag_absolute = mag_apparent - 5*np.log10(dL / (10*u.pc))\n",
"print(mag_absolute)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "68ab807c-3ce7-41c3-9443-db0aee837d23",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment