How to calculate space background X-ray radiation (CXB) with python by specifying the flux range

background

When estimating space background X-ray radiation (CXB), we not only want to know some of the total brightness, but also how much when imaging observations, excluding the bright point sources detected by imaging. Remains without spatial decomposition? Need to be estimated.

Here, I will show you how to calculate soft (1-2 keV) and hard (2-10 keV) with python according to https://iopscience.iop.org/article/10.1086/374335.

Source code

For those who can read the code, see Colab of calc_cxb.

python


#!/bin/evn python 

import matplotlib.pyplot as plt
import numpy as np

# THE RESOLVED FRACTION OF THE COSMIC X-RAY BACKGROUND A. Moretti, 
# The Astrophysical Journal, Volume 588, Number 2 (2003)
# https://iopscience.iop.org/article/10.1086/374335

smax = 1e-1 # maxinum of flux range (erg cm^-2 c^-1)
smin = 1e-17 # minimum of flux range (erg cm^-2 c^-1)
n = int(1e5) # number of grid in flux 
fcut = 5e-14 # user-specified maxinum flux (erg cm^-2 c^-1)

def calc_cxb(s,fcut=5e-14, ftotal_walker=2.18e-11, plot=True, soft=True):

	if soft: # 1-2 keV
		print("..... soft X-ray 1-2 keV is chosen")
		a1=1.82; a2=0.6; s0=1.48e-14; ns=6150
		foutname="soft"
	else: # hard 2-10 keV 
		print("..... hard X-ray 2-10 keV is chosen")
		a1=1.57; a2=0.44; s0=4.5e-15; ns=5300
		foutname="hard"


	n_larger_s = ns * 2.0e-15 ** a1 / (s**a1 + s0**(a1-a2)*s**a2) # Moretti et al. 2013, eq(2)

	if plot:
		F = plt.figure(figsize=(6,6))
		ax = plt.subplot(1,1,1)
		plt.plot(s, n_larger_s, ".", label="test")
		plt.xscale('log')
		plt.ylabel(r"$N(>S)/deg^2$")
		plt.xlabel(r"$S (erg cm^{-2} s^{-1})$")
		plt.yscale('log')
		plt.savefig(foutname + "_ns.png ")
		plt.show()

	diff_n_larger_s = np.abs(np.diff(n_larger_s))
	diff_s = np.diff(s)
	div_ns = np.abs(diff_n_larger_s/diff_s)

	s_lastcut = s[:-1]
	totalflux = np.sum(div_ns*s_lastcut*diff_s) # Moretti et al. 2013, eq(4)

	fluxcut = np.where(s > fcut)[0][:-1]
	particalflux = np.sum(div_ns[fluxcut]*s_lastcut[fluxcut]*diff_s[fluxcut])
	fdiff = totalflux - particalflux 
	fcxb = ftotal_walker - particalflux # Walker et al. 2016, eq(1)

	print("totalflux    = ", "%.4e"%totalflux, " [erg cm^-2 c^-1]", " from ", "%.4e"%smin, " to ",  "%.4e"%smax)
	print("particalflux = ", "%.4e"%particalflux, " [erg cm^-2 c^-1]", " from ", "%.4e"%fcut, " to ",  "%.4e"%smax)
	print("fdiff        = totalflux - particalflux     = ", "%.4e"%fdiff, " [erg cm^-2 c^-1]", " from ", "%.4e"%smin, " to ",  "%.4e"%fcut)	
	print("fcxb(2-10keV)= ftotal_walker - particalflux = ", "%.4e"%fcxb, " [erg cm^-2 c^-1]")

	if plot:
		F = plt.figure(figsize=(6,6))
		ax = plt.subplot(1,1,1)
		plt.plot(s[:-1], div_ns, ".", label="test")
		plt.xscale('log')
		plt.ylabel(r"$dN/dS/deg^2$")
		plt.xlabel(r"$S (erg cm^{-2} s^{-1})$")
		plt.yscale('log')
		plt.savefig(foutname + "_nsdiff.png ")		
		plt.show()

	return s, n_larger_s, diff_n_larger_s, div_ns, diff_s

#s = np.linspace(sexcl,smax,n)
s = np.logspace(np.log10(smin),np.log10(smax),n)

# plot soft band
s, n_larger_s, diff_n_larger_s, div_ns, diff_s = calc_cxb(s,fcut=fcut)
# plot hard band
s, n_larger_s, diff_n_larger_s, div_ns, diff_s = calc_cxb(s,fcut=fcut,soft=False)

Execution result

1-2 keV

スクリーンショット 2020-11-04 11.23.26.png

2-10 keV

スクリーンショット 2020-11-04 11.23.34.png

Method of calculation

As expected, if it is linear, the memory is insufficient and it cannot be calculated, so in the log of the s (erg cm ^ -2 s ^ -1) space, the integral used a simple rectangular approximation.

スクリーンショット 2020-11-04 11.29.23.png

This function is calculated by n_larger_s = ns * 2.0e-15 ** a1 / (s ** a1 + s0 ** (a1-a2) * s ** a2).

スクリーンショット 2020-11-04 11.29.31.png

This integral is calculated by totalflux = np.sum (div_ns * s_lastcut * diff_s).

fcxb = ftotal_walker --particalflux # Walker et al. 2016, eq (1) is a bonus, and the CXB of 2-10 keV in this paper is estimated, and the calculation is based on it.

Recommended Posts

How to calculate space background X-ray radiation (CXB) with python by specifying the flux range
How to calculate date with python
[Python] How to use the for statement. A method of extracting by specifying a range or conditions.
[Python] Explains how to use the range function with a concrete example
How to sort by specifying a column in the Python Numpy array.
How to erase the characters output by Python
[Python] How to specify the download location with youtube-dl
[Python] How to rewrite the table style with python-pptx [python-pptx]
How to execute a schedule by specifying the Python time zone and execution frequency
I tried to simulate how the infection spreads with Python
How to switch the configuration file to be read by Python
How to get into the python development environment with Vagrant
How to start Apache by specifying httpd.conf with systemd (CentOS7, CentOS8)
[Introduction to Python] How to get data with the listdir function
[Introduction to Python] How to split a character string with the split function
[Python] Explains how to use the format function with an example
How to send a request to the DMM (FANZA) API with python
How to calculate "xx time" in one shot with Python timedelta
How to calculate the autocorrelation coefficient
Python: How to use async with
How to get the Python version
How to get started with Python
[Python] How to import the library
How to use FTP with Python
The 16th offline real-time how to write problem was solved with Python
[Python Kivy] How to get the file path by dragging and dropping
How to crop the lower right part of the image with Python OpenCV
The 16th offline real-time how to write reference problem to solve with Python
How to get the date and time difference in seconds with python
[Introduction to Python] How to sort the contents of a list efficiently with list sort
[Python] How to set the (client) window size inside the browser with Selenium
[Introduction to Python] How to write a character string with the format function
The 19th offline real-time how to write reference problem to solve with Python
The 15th offline real-time how to write problem was solved with python
How to automatically notify by phone when the python system is down
How to deal with old Python versions in Cloud9 made by others
[Python] Set the graph range with matplotlib
How to work with BigQuery in Python
Install by specifying the version with pip
How to do portmanteau test with python
How to display python Japanese with lolipop
How to enter Japanese with Python curses
[Python] How to calculate MAE and RMSE
[Python] How to deal with module errors
The road to compiling to Python 3 with Thrift
How to install python3 with docker centos
How to get started with the 2020 Python project (windows wsl and mac standardization)
[Python] Created a class to play sin waves in the background with pyaudio
[python] How to sort by the Nth Mth element of a multidimensional array
[Python] How to save images on the Web at once with Beautiful Soup
How to display in the entire window when setting the background image with tkinter
Note: How to get the last day of the month with python (added the first day of the month)
[Python Tips] How to retrieve multiple keys with the maximum value from the dictionary
How to get a list of files in the same directory with python
[Introduction to Python] How to get the index of data with a for statement
How to upload with Heroku, Flask, Python, Git (4)
[python] How to display list elements side by side
How to use the C library in Python
How to read a CSV file with Python 2/3
How to enjoy programming with Minecraft (Ruby, Python)
[REAPER] How to play with Reascript in Python