Commit e0b1ceb0 authored by Andrea Giannetti's avatar Andrea Giannetti
Browse files

Censored distance matrix before getting the minimum.

parent a57d2124
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -145,7 +145,7 @@ def compute_power_law_radial_profile(
    :return: the distance matrix
    """
    _value_at_reference = validate_parameter(value_at_reference, default=central_value)
    _distance_matrix = np.where(distance_matrix == 0, np.nanmin(distance_matrix),
    _distance_matrix = np.where(distance_matrix == 0, np.nanmin(distance_matrix[distance_matrix > 0]),
                                distance_matrix) if fill_reference_pixel is True else distance_matrix
    try:
        _distance_reference = distance_reference.to(u.cm).value
+14 −0
Original line number Diff line number Diff line
@@ -51,6 +51,20 @@ class Test(TestCase):
        )
        self.assertTrue(np.array_equal(radial_profile, 1.0 / distance_matrix))

    def test_compute_power_law_radial_profile_pl_with_reference(self):
        indices = np.indices([3, 3]) - 1
        distance_matrix = np.sqrt(indices[0, :, :] ** 2 + indices[1, :, :] ** 2)
        radial_profile = compute_power_law_radial_profile(
            central_value=2,
            value_at_reference=1,
            distance_reference=1,
            power_law_index=-1,
            distance_matrix=distance_matrix
        )
        censored_rp = radial_profile.copy()
        censored_rp[1, 1] = np.nan
        self.assertEqual(radial_profile[1, 1], np.nanmax(censored_rp))

    def test_get_grid_properties_uniform(self):
        _config_filename = os.path.join('test_files', self.config_filename)
        config_dict = {