SkillAgentSearch skills...

Lumfunc

Galaxian Luminosity Function Constructor package using the 1/Vmax estimator and Schechter model.

Install / Use

/learn @manasveesaraf/Lumfunc
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Luminosity Function Constructor and Modeller

This package allows the user to construct and model Galaxian Luminosity Functions using the 1/Vmax estimator and Schechter function.

PyPI PyPI - Python Version Downloads PyPI - Downloads GitHub issues GitHub stars GitHub forks GitHub license

Installation

Use the package manager pip to install lumfunc.

pip install lumfunc

Keep the package up to date to access all commands.

pip install --upgrade lumfunc

Usage

Import the module in your Python code.

import lumfunc as lf

Load the catalogued data from survey. Usually stored in .fits or .csv files.

import numpy as np
import pandas as pd

# test data (photometric galaxian survey)
data_table = pd.read_csv('catalogue_test.csv')

ID_list = np.array(data_table['ID'])

RA_list = np.array(data_table['RA'])
Dec_list = np.array(data_table['Dec'])

u_app_mag_list = np.array(data_table['u_mag'])
u_app_mag_err_list = np.array(data_table['u_mag_err'])
g_app_mag_list = np.array(data_table['g_mag'])
g_app_mag_err_list = np.array(data_table['g_mag_err'])
r_app_mag_list = np.array(data_table['r_mag'])
r_app_mag_err_list = np.array(data_table['r_mag_err'])
i_app_mag_list = np.array(data_table['i_mag'])
i_app_mag_err_list = np.array(data_table['i_mag_err'])
Z_app_mag_list = np.array(data_table['Z_mag'])
Z_app_mag_err_list = np.array(data_table['Z_mag_err'])
Y_app_mag_list = np.array(data_table['Y_mag'])
Y_app_mag_err_list = np.array(data_table['Y_mag_err'])
J_app_mag_list = np.array(data_table['J_mag'])
J_app_mag_err_list = np.array(data_table['J_mag_err'])
H_app_mag_list = np.array(data_table['H_mag'])
H_app_mag_err_list = np.array(data_table['H_mag_err'])
K_app_mag_list = np.array(data_table['K_mag'])
K_app_mag_err_list = np.array(data_table['K_mag_err'])

z_photo_list = np.array(data_table['z_photo'])
z_spec_list = np.array(data_table['z_spec'])

1. K-correction to rest-frame magnitudes:

<details><summary><b>get_maggy( )</b>: Convert the measurements of flux in magnitudes to maggies</summary> <p>

Return maggies from magnitudes.

r_maggies_list = lf.get_maggy(r_app_mag_list) 
print(r_maggies_list[0:4])
# returns 
# [2.17126084e-08 1.88972757e-08 9.39864400e-09 3.74726494e-08]

# rudimentarily:
r_maggies_result = lf.get_maggy(np.array([19.15822, 19.309002, 20.067337, 18.565714]))
print(r_maggies_result[0:4])
# returns
# [2.17126084e-08 1.88972757e-08 9.39864400e-09 3.74726494e-08]
</p> </details> <details><summary><b>get_maggy_inv_var( )</b>: Convert the magnitude errors to maggy inverse variances</summary> <p>

Return maggy inverse variances from maggies and magnitude errors.

r_maggy_inv_var_list = lf.get_maggy_inv_var(r_maggies_list, r_app_mag_err_list)
print(r_maggy_inv_var_list[0:4])
# returns 
# [2.61353653e+20 2.21539925e+20 2.63295704e+20 1.52030876e+20]

# rudimentarily:
r_maggy_inv_var_result = lf.get_maggy_inv_var(
    np.array([2.17126084e-08, 1.88972757e-08, 9.39864400e-09, 3.74726494e-08]),
    np.array([0.00309313, 0.0038601, 0.0071193, 0.00234987]))
print(r_maggy_inv_var_result[0:4])
# returns
# [2.61353484e+20 2.21540499e+20 2.63295631e+20 1.52031005e+20]
</p> </details> <details><summary><b>get_obs_maggies_file( )</b>: Save calculated maggies and inverse variances in a file</summary> <p>

Calculate maggy and inverse variance values from apparent magnitude and their error values and save the values in a space delimited csv file with columns (without headers):

redshift u_maggy g_maggy r_maggy... u_inv_var g_inv_var r_inv_var...

WARNING: any pre-existing file with the same name are over-written.

For 'ugriz' bands:

ugriz_test_obs_maggies_file_path = 'obs_maggies_ugriz_test.csv'
ugriz_test_bands = 'ugriz'
lf.get_obs_maggies_file(ugriz_test_obs_maggies_file_path,
                        ugriz_test_bands,
                        z_photo_list,
                        u_app_mag_list,
                        g_app_mag_list,
                        r_app_mag_list,
                        i_app_mag_list,
                        Z_app_mag_list,
                        u_app_mag_err_list = u_app_mag_err_list,
                        g_app_mag_err_list = g_app_mag_err_list,
                        r_app_mag_err_list = r_app_mag_err_list,
                        i_app_mag_err_list = i_app_mag_err_list,
                        Z_app_mag_err_list = Z_app_mag_err_list)
# saves file obs_maggies_ugriz_test.csv  

Or, for 'ugriZYJHKs' bands:

ugriZYJHKs_test_obs_maggies_file_path = 'obs_maggies_ugriZYJHKs_test.csv'
ugriZYJHKs_test_bands = 'ugriZYJHKs'
lf.get_obs_maggies_file(ugriZYJHKs_test_obs_maggies_file_path,
                        ugriZYJHKs_test_bands,
                        z_photo_list,
                        u_app_mag_list,
                        g_app_mag_list,
                        r_app_mag_list,
                        i_app_mag_list,
                        Z_app_mag_list,
                        Y_app_mag_list = Y_app_mag_list,
                        J_app_mag_list = J_app_mag_list,
                        H_app_mag_list = H_app_mag_list,
                        Ks_app_mag_list = K_app_mag_list,
                        u_app_mag_err_list = u_app_mag_err_list,
                        g_app_mag_err_list = g_app_mag_err_list,
                        r_app_mag_err_list = r_app_mag_err_list,
                        i_app_mag_err_list = i_app_mag_err_list,
                        Z_app_mag_err_list = Z_app_mag_err_list,
                        Y_app_mag_err_list = Y_app_mag_err_list,
                        J_app_mag_err_list = J_app_mag_err_list,
                        H_app_mag_err_list = H_app_mag_err_list,
                        Ks_app_mag_err_list = K_app_mag_err_list)
# saves file obs_maggies_ugriZYJHKs_test.csv
</p> </details> <details><summary><b>get_rec_maggies_files( )</b>: Save reconstructed maggies at required redshifts in a file</summary> <p>

Define an array of required redshift values to reconstruct the observed maggy at.

z_values = np.arange(0.00, 1.00, 0.01)
rec_z_list = np.around(z_values, decimals=2)

Using file from function <code>get_obs_maggies_file()</code>, obtain reconstructed maggy values by best-fitting galaxy SEDs on data using templates, filter transmission curves and functions from <a href="https://github.com/nirinA/kcorrect_python">kcorrect_python</a> package, and save the reconstructed maggy values in a space delimited csv file with columns (without headers):

redshift rec_u_maggy rec_g_maggy rec_r_maggy...

WARNING: pre-existing file with the same name are over-written.

Example, for 'ugriz' bands:

ugriz_test_n_bands = 5
lf.get_rec_maggies_files(ugriz_test_obs_maggies_file_path,
                         ugriz_test_n_bands,
                         rec_z_list,
                         rec_maggies_outfile_affix='ugriz_test',
                         survey='sdss',
                         band_z_shift=0.0,
                         template_vmatrix_file_path='vmatrix.default.dat',
                         template_lambda_file_path='lambda.default.dat',
                         filters_list_file_path='sdss_filters.dat')
# saves files maggies_at_z[redshift-value]_ugriz_test.csv

Or, for 'ugriZYJHKs' bands:

ugriZYJHKs_test_n_bands = 9
lf.get_rec_maggies_files(ugriZYJHKs_test_obs_maggies_file_path,
                         ugriZYJHKs_test_n_bands,
                         rec_z_list,
                         rec_maggies_outfile_affix='ugriZYJHKs_test',
                         survey='test',
                         band_z_shift=0.0,
                         template_vmatrix_file_path='vmatrix.test.dat',
                         template_lambda_file_path='lambda.test.dat',
                         filters_list_file_path='test_filters.dat')
# saves files maggies_at_z[redshift-value]_ugriZYJHKs_test.csv    
</p> </details> <details><summary><b>get_rest_maggy_ratio_file( )</b>: Save calculated rest-frame maggy ratios in a file</summary> <p>

Calculate rest-frame maggy ratios i.e. (obs_maggy/rest_maggy), and save them in a csv file with 3 space delimited columns, of headers:

ID rest_z maggy_ratio

WARNING: pre-existing file with the same name are over-written.

r_test_band_index = 3
ugriz_test_rest_maggies_file_path = 'maggies_at_z0.0_ugriz_test.csv'
lf.get_rest_maggy_ratio_file(ID_list,
                             ugriz_test_obs_maggies_file_path,
                             ugriz_test_rest_maggies_file_path,
                             r_test_band_index,
                             rest_maggy_ratio_outfile_affix='r_ugriz_test')
# saves file rest_maggy_ratios_ugriz_test.csv    
</p> </details> <details><summary><b>get_rest_mag( )</b>: Convert the measured apparent magnitudes into rest-frame magnitudes using the catalogue data and rest-frame maggy ratios</summary> <p>

Load maggy ratios output file from the <code>get_rest_maggy_ratio_file()</code>

View on GitHub
GitHub Stars5
CategoryDevelopment
Updated2y ago
Forks0

Languages

Python

Security Score

75/100

Audited on Feb 20, 2024

No findings