Exemple #1
0
def make_pwn_pos(random_state, n_sources,
                 mean_intrinsic_extension=15, sigma_intrinsic_extension=10, ):
    table = make_base_catalog_galactic(
        n_sources=n_sources,
        max_age=0 * u.year,
        random_state=random_state,
    )

    size_physical = random_state.normal(mean_intrinsic_extension, sigma_intrinsic_extension, n_sources)

    for iii in range(0, len(size_physical)):
        if size_physical[iii] < 0:
            size_physical[iii] = 0.1

    size_physical = u.Quantity(size_physical, 'pc')
    type = []
    for iii in range(0, len(size_physical)):
        type.append('isolated')

    table.remove_column('age')
    table.remove_column('n_ISM')
    table.remove_column('v_abs')
    table.remove_column('vx')
    table.remove_column('vy')
    table.remove_column('vz')
    table.remove_column('x_birth')
    table.remove_column('y_birth')
    table.remove_column('z_birth')

    table['type'] = Column(type, description='type of PWN')

    table['size_physical'] = Column(size_physical, description='Physical size', unit='pc')

    return table
Exemple #2
0
def test_make_base_catalog_galactic():
    table = make_base_catalog_galactic(n_sources=10, random_state=0)
    d = table[0]

    assert len(table) == 10
    assert len(table.colnames) == 13

    assert table["age"].unit == "yr"
    assert_allclose(d["age"], 548813.50392732478)
    assert table["n_ISM"].unit == "cm-3"
    assert_allclose(d["n_ISM"], 1.0)
    assert table["spiralarm"].unit is None
    assert d["spiralarm"] == "Crux Scutum"
    assert table["x_birth"].unit == "kpc"
    assert_allclose(d["x_birth"], -5.856461, atol=1e-5)
    assert table["y_birth"].unit == "kpc"
    assert_allclose(d["y_birth"], 3.017292, atol=1e-5)
    assert table["z_birth"].unit == "kpc"
    assert_allclose(d["z_birth"], 0.049088, atol=1e-5)
    assert table["x"].unit == "kpc"
    assert_allclose(d["x"], -5.941061, atol=1e-5)
    assert table["y"].unit == "kpc"
    assert_allclose(d["y"], 3.081642, atol=1e-5)
    assert table["z"].unit == "kpc"
    assert_allclose(d["z"], 0.023161, atol=1e-5)
    assert table["vx"].unit == "km/s"
    assert_allclose(d["vx"], -150.727104, atol=1e-5)
    assert table["vy"].unit == "km/s"
    assert_allclose(d["vy"], 114.648494, atol=1e-5)
    assert table["vz"].unit == "km/s"
    assert_allclose(d["vz"], -46.193814, atol=1e-5)
    assert table["v_abs"].unit == "km/s"
    assert_allclose(d["v_abs"], 194.927693, atol=1e-5)
Exemple #3
0
def test_add_pwn_parameters():
    table = make_base_catalog_galactic(n_sources=10, random_state=0)
    # To compute PWN parameters we need PSR and SNR parameters first
    table = add_snr_parameters(table)
    table = add_pulsar_parameters(table, random_state=0)
    table = add_pwn_parameters(table)
    d = table[0]

    assert len(table) == 10
    assert len(table.colnames) == 27

    assert table["r_out_PWN"].unit == "pc"
    assert_allclose(d["r_out_PWN"], 1.378224, atol=1e-4)
Exemple #4
0
def test_chain_all():
    # Test that running the simulation functions in chain works
    table = make_base_catalog_galactic(n_sources=10, random_state=0)
    table = add_snr_parameters(table)
    table = add_pulsar_parameters(table, random_state=0)
    table = add_pwn_parameters(table)
    table = add_observed_parameters(table)
    d = table[0]

    # Note: the individual functions are tested above.
    # Here we just run them in a chain and do very basic asserts
    # on the output so that we make sure we notice changes.
    assert len(table) == 10
    assert len(table.colnames) == 34

    assert table["r_out_PWN"].unit == "pc"
    assert_allclose(d["r_out_PWN"], 1.378224, atol=1e-4)
    assert table["RA"].unit == "deg"
    assert_allclose(d["RA"], 244.347149, atol=1e-5)
Exemple #5
0
def test_add_observed_parameters():
    table = make_base_catalog_galactic(n_sources=10, random_state=0)
    table = add_observed_parameters(table)
    d = table[0]

    assert len(table) == 10
    assert len(table.colnames) == 20

    assert table["distance"].unit == "pc"
    assert_allclose(d["distance"], 13016.572756, atol=1e-5)
    assert table["GLON"].unit == "deg"
    assert_allclose(d["GLON"], -27.156565, atol=1e-5)
    assert table["GLAT"].unit == "deg"
    assert_allclose(d["GLAT"], 0.101948, atol=1e-5)
    assert table["VGLON"].unit == "deg / Myr"
    assert_allclose(d["VGLON"], 0.368166, atol=1e-5)
    assert table["VGLAT"].unit == "deg / Myr"
    assert_allclose(d["VGLAT"], -0.209514, atol=1e-5)
    assert table["RA"].unit == "deg"
    assert_allclose(d["RA"], 244.347149, atol=1e-5)
    assert table["DEC"].unit == "deg"
    assert_allclose(d["DEC"], -50.410142, atol=1e-5)
Exemple #6
0
# Simulation Parameters

# source density at the sun (sources kpc^-1)
rho_sun = 3
# number of sources
n_sources = int(5e2)
# Spatial distribution using Lorimer (2006) model
rad_dis = 'L06'
# Velocity dispersion
vel_dis = 'F06B'
# Includes spiral arms
spiralarms = True
# Creates table
table = population.make_base_catalog_galactic(n_sources=n_sources,
                                              rad_dis=rad_dis,
                                              vel_dis=vel_dis,
                                              max_age=1e6,
                                              spiralarms=spiralarms,
                                              random_state=0)

# Minimum source luminosity (ph s^-1)
luminosity_min = 4e34
# Maximum source luminosity (ph s^-1)
luminosity_max = 4e37
# Luminosity function differential power-law index
luminosity_index = 1.5

# Assigns luminosities to sources
luminosity = sample_powerlaw(luminosity_min,
                             luminosity_max,
                             luminosity_index,
                             n_sources,
# Simulation Parameters

# source density at the sun (sources kpc^-1)
rho_sun = 3
# number of sources
n_sources = int(5e2)
# Spatial distribution using Lorimer (2006) model
rad_dis = 'L06'
# Velocity dispersion
vel_dis = 'F06B'
# Includes spiral arms
spiralarms = True
# Creates table
table = population.make_base_catalog_galactic(n_sources=n_sources, rad_dis=rad_dis,
                                              vel_dis=vel_dis, max_age=1e6,
                                              spiralarms=spiralarms, random_state=0)

# Minimum source luminosity (ph s^-1)
luminosity_min = 4e34
# Maximum source luminosity (ph s^-1)
luminosity_max = 4e37
# Luminosity function differential power-law index
luminosity_index = 1.5

# Assigns luminosities to sources
luminosity = sample_powerlaw(luminosity_min, luminosity_max, luminosity_index,
                             n_sources, random_state=0)
table['luminosity'] = luminosity

# Adds parameters to table: distance, glon, glat, flux, angular_extension
Exemple #8
0
import numpy as np
import astropy.units as u
from gammapy.utils.random import sample_powerlaw
from gammapy.astro import population

# ## Simulate positions

# In[3]:

# Spatial distribution using Lorimer (2006) model
n_sources = int(1e5)

table = population.make_base_catalog_galactic(
    n_sources=n_sources,
    rad_dis='L06',
    vel_dis='F06B',
    max_age=1e6 * u.yr,
    spiralarms=True,
)

# ## Simulate luminosities

# Several source population models, e.g. the 1FHL paper or Strong (2007), use power-law luminosity functions.
#
# Here we implement the "reference model" from the 1FHL catalog paper section 6.2.

# In[4]:

# Source luminosity (ph s^-1)

luminosity = sample_powerlaw(