gravelamps.models.navarro_frenk_white

Navarro, Frenk, and White Lensing Implementation

These functions are wrappers around the C++ functions implemeted in gravelamps/models/navrro-frenk-white.h. These are able to compute the amplification factor in both the wave and geometric optics regimes.

gravelamps.models.navarro_frenk_white.amplification()

Computes the amplification factor.

Will compute in the wave optics regime with the specified precision below the specified dimensionless frequency and in the geometric optics regime with standard double precision above it. Adheres to numpy broadcasting rules.

Parameters:
dimensionless_frequency: float or ArrayLike

Dimensionless frequencies.

source_position: float or ArrayLike

Dimensionless displacements of the source.

scaling_constant: float

Scale factor for the NFW profile.

integration_limit: int, optional, default=100

Upper limit of the indefinite integral to compute in wave optics.

precision: int, optional, default=128

Number of bits of precision for arbitrary precision calculations in wave optics.

image_positions: ArrayLike, optional

Image positions corresponding to source positions. Shape must be M x 3 where M corresponds to the total number of elements of source position. This will be handled in the order given by np.flatten(source_position). On rows corresponding to source positions that yield a single image, the other spaces should be filled with np.NaN. Will be ignored if minimum_phase is not also given.

minimum_phase: ArrayLike, optional

Phases required for minimum time delay corresponding to source position. Will be ignored if image_positions is not also given.

Returns:
amp: complex or ArrayLike

Amplification factor values.

Raises:
RuntimeError

If arguments cannot be parsed.

ValueError

If image_positions has incorrect dimensions.

RuntimeWarning

If one of the two linked keyword arguments is missing when the other is given or is not the required shape.

gravelamps.models.navarro_frenk_white.generate_data()

Constructs interpolator data file for the Navarro, Frenk, and White mass density profile.

From the input files, the amplification factor files will be populated with a grid of amplification factor values correpsonding to the dimensionless frequency and source position values in their respective files. This function will checkpoint the files and return 85 upon receiving a SIGALRM or SIGINT.

Parameters:
dimensionless_frequency_file: str

Path to file containing dimensionless freuqency values.

source_position_file: str

Path to file containing source position values.

amplification_factor_real_file: str

Path to file containing real component of amplification factor values.

amplification_factor_imag_file: str

Path to file containing imaginary component of amplification factor values.

scaling_constant: float

Scale factor the NFW profile.

integration_limit: int, optional, default=100

Upper limit of the indefinite integral to compute in wave optics.

geo_switch: int, optional, default=1000

Dimensionless frequnecy above which to use geometric optics.

precision: int, optional, default=128

Number of bits of precision for arbitrary precision calculations in wave optics.

Returns:
int

0 if completed sucessfully, 85 if received checkpoint instruction.

Raises:
RuntimeError

If arguments cannot be understood.

RuntimeWarning

If precision > 50000 warns about run time.

gravelamps.models.navarro_frenk_white.geometric_amplification()

Computes the amplification factor in the geometric optics regime. Adheres to numpy broadcasting rules.

Parameters:
dimensionless_frequency: float or ArrayLike

Dimensionless frequencies.

source_position: float or ArrayLike

Dimensionless displacements of the source.

scaling_constant: float

Scale factor for the NFW profile.

image_positions: ArrayLike, optional

Image positions corresponding to source positions. Shape must be M x 3 where M corresponds to the total number of elements of source position. This will be handled in the order given by np.flatten(source_position). On rows corresponding to source positions that yield a single image, the other spaces should be filled with np.NaN. Will be ignored if minimum_phase is not also given.

minimum_phase: ArrayLike, optional

Phases required for minimum time delay corresponding to source position. Will be ignored if image_positions is not also given.

Returns:
amp: complex or ArrayLike

Amplification factor values.

Raises:
RuntimeError

If arguments cannot be parsed

ValueError

If image_positions has incorrect dimensions.

RuntimeWarning

If one of the kwargs is missing when the other is given or if one of the given kwarg arrays is not the required shape.

gravelamps.models.navarro_frenk_white.geometric_contribution()

Computes the contribution to the amplification factor in the geometric optics regime for the image at the specified position. Adheres to numpy broadcasting rules.

Parameters:
dimensionless_frequency: float or ArrayLike

Dimensionless frequencies.

source_position: float

Dimensionless displacement of the source.

image_position: float or ArrayLike

Dimensionless displacement of the image.

scaling_constant: float

Scale factor for the NFW profile.

minimum_phase: float

Phase required for the minimum time delay to be zero.

Returns:
contrib: complex or ArrayLike

Contribution to amplification factor from specified image.

Raises:
RuntimeError

If arguments cannot be parsed.

ValueError

If dimensionless frequency or image position are given as ArrayLike with greater than one dimension.

gravelamps.models.navarro_frenk_white.image_position()

Computes the dimensionless displacements of the images in the geometric optics regime.

Parameters:
source_position: float or ArrayLike

Dimensionless displacement of the source.

scaling_constant: float

Scale factor for the NFW profile.

Returns:
ArrayLike

Positions of the images. Where images do not exist, i.e. in 1 image only regime, other images will be set to NaN such that three values exist for each source position.

Raises:
RuntimeError

If arguments cannot be parsed.

gravelamps.models.navarro_frenk_white.lensing_potential()

Computes the lensing potenital for the Navarro, Frenk, and White lensing profile.

Parameters:
image_position: float or ArrayLike

Dimensionless displacements of the images.

scaling_constant: float

Scale factor for NFW profile.

Returns:
complex or ArrayLike

Lensing Potential Values.

Raises:
RuntimeError

If arguments cannot be parsed.

gravelamps.models.navarro_frenk_white.magnification()

Computes the magnification in the geometic optics regime.

Parameters:
image_position: float or ArrayLike

Dimensionless displacements of the images.

scaling_constant: float

Scale factor for the NFW profile.

Returns:
complex or ArrayLike

Magnification of the images.

Raises:
RuntimeError

If arguments cannot be parsed.

gravelamps.models.navarro_frenk_white.minimum_phase()

Computes the minimum phase required for the time delay to be zero.

Parameters:
source_position: float or ArrayLike

Dimensionless displacement of the source.

scaling_constant: float

Scale factor for the NFW profile.

Returns:
complex or ArrayLike

Minimum phases

Raises:
RuntimeError

If arguments cannot be parsed.

gravelamps.models.navarro_frenk_white.morse_factor()

Computes the Morse factor for the given images in the geometric optics regime.

Parameters:
image_position: float or ArrayLike

Dimensionless displacements of the images.

scaling_constant: float

Scale factor for the NFW profile.

Returns:
float or ArrayLike

Morse factor of each of the images.

Raises:
RuntimeError

If arguments cannot be parsed.

gravelamps.models.navarro_frenk_white.time_delay()

Computes the dimensionless time delay for the Navarro, Frenk, and White lensing profile.

Parameters:
image_position: float or ArrayLike

Dimensionless displacements of the images.

source_position: float

Dimensionless displacement of the source.

scaling_constant: float

Scale factor for the NFW profile.

minimum_phase: float

Phase required for minimum time delay to be zero.

Returns:
complex or ArrayLike

Dimensionless time delays.

Raises:
RuntimeError

If arguments cannot be parsed.

gravelamps.models.navarro_frenk_white.wave_amplification()

Computes the amplification factor in the wave optics reigme.

Computation is done with the specified precision and approximating the indefinite integral up to the specified limit. Adheres to numpy broadcasting rules.

Parameters:
dimensionless_frequency: float or ArrayLike

Dimensionless frequencies.

source_position: float or ArrayLike

Dimensionless displacement from the optical axis.

scaling_constant: float

Scale factor for the NFW profile.

integration_limit: float, optional, default=100

Upper limit of the indefinite integral to compute.

precision: int, optional, default=128

Number of bits of precision for arbitrary precision calculations.

Returns:
amp: complex or ArrayLike

Amplification factor values.

Raises:
RuntimeError

If arguments cannot be parsed.

RuntimeWarning

If precision > 50000 warns about runtime. If integration_limit > 2 * precision warns about accuracy.