Esempio n. 1
0
 def test_get_spectrum(self):
     res_a = self.Prof1.get_spectrum()
     # imtio.export_to_file(res_a, "Prof1_get_spectrum_a.cimt")
     res_a2 = imtio.import_from_file("Prof1_get_spectrum_a.cimt")
     assert res_a == res_a2
     #
     res_b = self.Prof1.get_spectrum(welch_seglen=10)
     # imtio.export_to_file(res_b, "Prof1_get_spectrum_b.cimt")
     res_b2 = imtio.import_from_file("Prof1_get_spectrum_b.cimt")
     assert res_b == res_b2
     #
     res_c = self.Prof1.get_spectrum(scaling="spectrum", detrend='linear')
     # imtio.export_to_file(res_c, "Prof1_get_spectrum_c.cimt")
     res_c2 = imtio.import_from_file("Prof1_get_spectrum_c.cimt")
     assert res_c == res_c2
     #
     res_d = self.Prof1.get_spectrum(scaling="density", detrend='none')
     # imtio.export_to_file(res_d, "Prof1_get_spectrum_d.cimt")
     res_d2 = imtio.import_from_file("Prof1_get_spectrum_d.cimt")
     assert res_d == res_d2
     #
     res_e = self.Prof1.get_spectrum(scaling="density")
     # imtio.export_to_file(res_e, "Prof1_get_spectrum_e.cimt")
     res_e2 = imtio.import_from_file("Prof1_get_spectrum_e.cimt")
     assert res_e == res_e2
Esempio n. 2
0
 def setup(self):
     sane_parameters()
     self.VF1 = imtio.import_from_file("VF1.cimt")
     self.VF1_nomask = imtio.import_from_file("VF1_nomask.cimt")
     self.VF2 = imtio.import_from_file("VF2.cimt")
     self.VF_notevenlyspaced = imtio.import_from_file(
         "VF_notevenlyspaced.cimt")
Esempio n. 3
0
 def test_get_spatial_autocorrelation(self):
     res_x = self.SF1.get_spatial_autocorrelation('x')
     # imtio.export_to_file(res_x, "spatial_autocorrelation_x.cimt")
     res_x2 = imtio.import_from_file("spatial_autocorrelation_x.cimt")
     assert res_x == res_x2
     res_y = self.SF1.get_spatial_autocorrelation('y')
     # imtio.export_to_file(res_y, "spatial_autocorrelation_y.cimt")
     res_y2 = imtio.import_from_file("spatial_autocorrelation_y.cimt")
     assert res_y == res_y2
Esempio n. 4
0
 def test_integrate_over_line(self):
     res_x = self.SF1_nomask.integrate_over_line('x', [3.2, 17.8])
     # imtio.export_to_file(res_x, "integrate_over_line_x.cimt")
     res_x2 = imtio.import_from_file("integrate_over_line_x.cimt")
     assert res_x == res_x2
     res_y = self.SF1_nomask.integrate_over_line('y', [3.2, 17.8])
     # imtio.export_to_file(res_y, "integrate_over_line_y.cimt")
     res_y2 = imtio.import_from_file("integrate_over_line_y.cimt")
     assert res_y == res_y2
Esempio n. 5
0
 def test_get_value(self):
     res = self.VF1.get_value(7.5, 20.12)
     # imtio.export_to_file(res, "VF1_get_value.cimt")
     res2 = imtio.import_from_file("VF1_get_value.cimt")
     assert np.all(res == res2)
     res_b = self.VF1.get_value(5, 10, ind=True)
     # imtio.export_to_file(res_b, "VF1_get_value_b.cimt")
     res_b2 = imtio.import_from_file("VF1_get_value_b.cimt")
     assert np.all(res_b == res_b2)
Esempio n. 6
0
 def test_crop(self):
     res_a = self.Prof1.crop(intervx=[9, 15])
     # imtio.export_to_file(res_a, "Prof1_crop_a.cimt")
     res_a2 = imtio.import_from_file("Prof1_crop_a.cimt")
     assert res_a == res_a2
     #
     res_b = self.Prof1.crop(intervy=[.5, .7])
     # imtio.export_to_file(res_b, "Prof1_crop_b.cimt")
     res_b2 = imtio.import_from_file("Prof1_crop_b.cimt")
     assert res_b == res_b2
Esempio n. 7
0
 def test_change_unit(self):
     res_a = self.Prof1.change_unit('x', 'km')
     # imtio.export_to_file(res_a, "Prof1_change_unit_a.cimt")
     res_a2 = imtio.import_from_file("Prof1_change_unit_a.cimt")
     assert res_a == res_a2
     #
     res_b = self.Prof1.change_unit('y', 'um/ks')
     # imtio.export_to_file(res_b, "Prof1_change_unit_b.cimt")
     res_b2 = imtio.import_from_file("Prof1_change_unit_b.cimt")
     assert res_b == res_b2
Esempio n. 8
0
 def test_get_divergence(self):
     res_a = imtft.get_divergence(self.VF1)
     # imtio.export_to_file(res_a, "VF1_get_divergence_a.cimt")
     res_a2 = imtio.import_from_file("VF1_get_divergence_a.cimt")
     assert res_a == res_a2
     #
     res_b = imtft.get_divergence(self.TVF1)
     # imtio.export_to_file(res_b, "VF1_get_divergence_b.cimt")
     res_b2 = imtio.import_from_file("VF1_get_divergence_b.cimt")
     assert res_b == res_b2
Esempio n. 9
0
 def test_mirroring(self):
     res_a = self.VF1.mirroring('x', 4)
     # imtio.export_to_file(res_a, "VF1_mirroring_a.cimt")
     res_a2 = imtio.import_from_file("VF1_mirroring_a.cimt")
     assert res_a == res_a2
     #
     res_b = self.VF1.copy()
     res_b.mirroring('x', 10, mir_coef=-1.2, inplace=True)
     # imtio.export_to_file(res_b, "VF1_mirroring_b.cimt")
     res_b2 = imtio.import_from_file("VF1_mirroring_b.cimt")
     assert res_b == res_b2
Esempio n. 10
0
 def test_mirroring(self):
     res = self.SF1.mirroring('x', 35, mir_coef=1.5)
     # imtio.export_to_file(res, "mirroring.cimt")
     res2 = imtio.import_from_file("mirroring.cimt")
     assert res == res2
     #
     tmpsf = self.SF1.copy()
     tmpsf.mirroring('x', 35, mir_coef=1.5, inplace=True)
     res_b = tmpsf
     # imtio.export_to_file(res_b, "mirroring_b.cimt")
     res_b2 = imtio.import_from_file("mirroring_b.cimt")
     assert res_b == res_b2
Esempio n. 11
0
 def test_get_spatial_spectrum(self):
     res_x = self.SF1.get_spatial_spectrum('x',
                                           intervx=[5, 19],
                                           intervy=[10.2, 29])
     # imtio.export_to_file(res_x, "get_spatial_spectrum_x.cimt")
     res_x2 = imtio.import_from_file("get_spatial_spectrum_x.cimt")
     assert res_x == res_x2
     res_y = self.SF1.get_spatial_spectrum('y',
                                           intervx=[5, 19],
                                           intervy=[10.2, 29])
     # imtio.export_to_file(res_y, "get_spatial_spectrum_y.cimt")
     res_y2 = imtio.import_from_file("get_spatial_spectrum_y.cimt")
     assert res_y == res_y2
Esempio n. 12
0
    def test_get_fitting(self):
        def fit_fun(x, a, b, c, d):
            return a * x + b * x**2 + c * x**3 + d

        res_a = self.Prof1.get_fitting(fit_fun)
        # imtio.export_to_file(res_a, "Prof1_get_fitting_a.cimt")
        res_a2 = imtio.import_from_file("Prof1_get_fitting_a.cimt")
        assert res_a == res_a2
        #
        res_b = self.Prof1.get_fitting(fit_fun, output_param=True)
        # imtio.export_to_file(res_b, "Prof1_get_fitting_b.cimt")
        res_b2 = imtio.import_from_file("Prof1_get_fitting_b.cimt")
        assert res_b[0] == res_b2[0]
        assert np.all(res_b[1] == res_b2[1])
Esempio n. 13
0
 def test_get_gradients(self):
     res_a = imtft.get_gradients(self.VF1)
     # imtio.export_to_file(res_a, "VF1_get_gradients_a.cimt")
     res_a2 = imtio.import_from_file("VF1_get_gradients_a.cimt")
     assert res_a == res_a2
     #
     res_b = imtft.get_gradients(self.SF1)
     # imtio.export_to_file(res_b, "SF1_get_gradients_b.cimt")
     res_b2 = imtio.import_from_file("SF1_get_gradients_b.cimt")
     assert res_b == res_b2
     #
     res_c = imtft.get_gradients(self.Prof1)
     # imtio.export_to_file(res_c, "Prof1_get_gradients_c.cimt")
     res_c2 = imtio.import_from_file("Prof1_get_gradients_c.cimt")
     assert res_c == res_c2
Esempio n. 14
0
 def test_mul(self):
     res_a = self.Prof1 * self.Prof2
     # imtio.export_to_file(res_a, "Prof1_mul_a.cimt")
     res_a2 = imtio.import_from_file("Prof1_mul_a.cimt")
     assert res_a == res_a2
     #
     res_b = self.Prof1 * 14
     # imtio.export_to_file(res_b, "Prof1_mul_b.cimt")
     res_b2 = imtio.import_from_file("Prof1_mul_b.cimt")
     assert res_b == res_b2
     #
     res_c = self.Prof1 * 32 * make_unit('Hz')
     # imtio.export_to_file(res_c, "Prof1_mul_c.cimt")
     res_c2 = imtio.import_from_file("Prof1_mul_c.cimt")
     assert res_c == res_c2
Esempio n. 15
0
 def test_sub(self):
     res_a = self.Prof1 - self.Prof2
     # imtio.export_to_file(res_a, "Prof1_sub_a.cimt")
     res_a2 = imtio.import_from_file("Prof1_sub_a.cimt")
     assert res_a == res_a2
     #
     res_b = self.Prof1 - 39
     # imtio.export_to_file(res_b, "Prof1_sub_b.cimt")
     res_b2 = imtio.import_from_file("Prof1_sub_b.cimt")
     assert res_b == res_b2
     #
     res_c = self.Prof1 - 23 * make_unit('km/us')
     # imtio.export_to_file(res_c, "Prof1_sub_c.cimt")
     res_c2 = imtio.import_from_file("Prof1_sub_c.cimt")
     assert res_c == res_c2
Esempio n. 16
0
 def test_add(self):
     res_a = self.Prof2 + self.Prof1
     # imtio.export_to_file(res_a, "Prof1_add_a.cimt")
     res_a2 = imtio.import_from_file("Prof1_add_a.cimt")
     assert res_a == res_a2
     #
     res_b = self.Prof2 + 18
     # imtio.export_to_file(res_b, "Prof1_add_b.cimt")
     res_b2 = imtio.import_from_file("Prof1_add_b.cimt")
     assert res_b == res_b2
     #
     res_c = self.Prof2 + 18 * make_unit('km/s')
     # imtio.export_to_file(res_c, "Prof1_add_c.cimt")
     res_c2 = imtio.import_from_file("Prof1_add_c.cimt")
     assert res_c == res_c2
Esempio n. 17
0
 def test_div(self):
     res_a = self.Prof1 / self.Prof2
     # imtio.export_to_file(res_a, "Prof1_div_a.cimt")
     res_a2 = imtio.import_from_file("Prof1_div_a.cimt")
     assert res_a == res_a2
     #
     res_b = self.Prof1 / 14
     # imtio.export_to_file(res_b, "Prof1_div_b.cimt")
     res_b2 = imtio.import_from_file("Prof1_div_b.cimt")
     assert res_b == res_b2
     #
     res_c = self.Prof1 / (32 * make_unit('Hz'))
     # imtio.export_to_file(res_c, "Prof1_div_c.cimt")
     res_c2 = imtio.import_from_file("Prof1_div_c.cimt")
     assert res_c == res_c2
 def test_get_critical_points_h(self):
     res_h = vod.get_critical_points(self.VF1_nomask, kind='pbi_crit',
                                     smoothing_size=2)
     # imtio.export_to_file(res_h, "VF1_get_hritical_points_h.cimt")
     res_h2 = imtio.import_from_file("VF1_get_hritical_points_h.cimt")
     assert len(res_h2.foc) > 0
     assert res_h == res_h2
Esempio n. 19
0
 def test_imt_to_imts(self):
     imtio.imts_to_imt("VFs_imts_to_imt", "TVF_imts_to_imt_a.cimt", 'TVF')
     TVF = TemporalVectorFields()
     TVF.add_field(self.VF1)
     TVF.add_field(self.VF2)
     TVF2 = imtio.import_from_file("TVF_imts_to_imt_a.cimt")
     assert TVF == TVF2
Esempio n. 20
0
 def test_crop(self):
     res = self.VF1.crop(intervx=[7.4, 19.0],
                         intervy=[2.1, 8],
                         inplace=False)
     # imtio.export_to_file(res, "VF1_crop.cimt")
     res2 = imtio.import_from_file("VF1_crop.cimt")
     assert res == res2
 def test_get_critical_points_c(self):
     res_c = vod.get_critical_points(self.TVF1_nomask, kind='gam_vort',
                                     thread='all')
     # imtio.export_to_file(res_c, "VF1_get_critical_points_c.cimt")
     res_c2 = imtio.import_from_file("VF1_get_critical_points_c.cimt")
     assert len(res_c2.foc) > 0
     assert res_c == res_c2
 def test_get_critical_points_d(self):
     res_d = vod.get_critical_points(self.VF1_nomask, kind='gam_vort',
                                     mirroring=[['x', 0.]])
     # imtio.export_to_file(res_d, "VF1_get_dritical_points_d.cimt")
     res_d2 = imtio.import_from_file("VF1_get_dritical_points_d.cimt")
     assert len(res_d2.foc) > 0
     assert res_d == res_d2
Esempio n. 23
0
 def test_crop_masked_border(self):
     self.Prof1.mask[0:10] = True
     self.Prof1.mask[-7::] = True
     res_a = self.Prof1.crop_masked_border()
     # imtio.export_to_file(res_a, "Prof1_crop_masked_border_a.cimt")
     res_a2 = imtio.import_from_file("Prof1_crop_masked_border_a.cimt")
     assert res_a == res_a2
 def test_get_critical_points_g(self):
     res_g = vod.get_critical_points(self.TVF1_nomask, kind='pbi_crit',
                                     thread='all')
     # imtio.export_to_file(res_g, "VF1_get_gritical_points_g.cimt")
     res_g2 = imtio.import_from_file("VF1_get_gritical_points_g.cimt")
     assert len(res_g2.foc) > 0
     assert res_g == res_g2
 def test_get_critical_points_f(self):
     res_f = vod.get_critical_points(self.VF1_nomask, kind='pbi_cell',
                                     mirroring=[['x', 0.]])
     # imtio.export_to_file(res_f, "VF1_get_fritical_points_f.cimt")
     res_f2 = imtio.import_from_file("VF1_get_fritical_points_f.cimt")
     assert len(res_f2.foc) > 0
     assert res_f == res_f2
Esempio n. 26
0
def parametric_test(func, kwargs, update=False):
    alphabet = [
        "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n",
        "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"
    ]
    fun_name = func.__name__
    for let, kwarg in zip(alphabet, kwargs):
        filename = "test_{}_{}.cimt".format(fun_name, let)
        res = func(**kwarg)
        # Update if necessary
        if update:
            imtio.export_to_file(res, filename)
        # If the file is not present, create it
        try:
            res2 = imtio.import_from_file(filename)
        except FileNotFoundError:
            print("file '{}' is not present (normal for a first run),"
                  "I created it for you !".format(filename))
            imtio.export_to_file(res, filename)
            continue
        # Else try recursively to test for equality
        try:
            res[0][0]
            for r, r2 in zip(res, res2):
                assert np.all(r == r2)
        except TypeError:
            try:
                res[0]
                assert np.all(res == res2)
            except TypeError:
                assert res == res2
Esempio n. 27
0
 def test_change_unit(self):
     res_a = self.VF1.copy()
     res_a.change_unit("x", "km")
     res_a.change_unit('y', 'um')
     res_a.change_unit('values', 'km/us')
     # imtio.export_to_file(res_a, "VF1_change_unit_a.cimt")
     res_a2 = imtio.import_from_file("VF1_change_unit_a.cimt")
     assert res_a == res_a2
Esempio n. 28
0
 def test_scale(self):
     res_a = self.VF1.scale(scalex=1.65,
                            scaley=0.64,
                            scalev=9,
                            inplace=False)
     # imtio.export_to_file(res_a, "VF1_scale_a.cimt")
     res_a2 = imtio.import_from_file("VF1_scale_a.cimt")
     assert res_a == res_a2
Esempio n. 29
0
 def test_get_profile(self):
     res = self.VF1.get_profile('vx', 'x', 7.2)
     # imtio.export_to_file(res, "VF1_get_profile.cimt")
     res2 = imtio.import_from_file("VF1_get_profile.cimt")
     assert res == res2
     res_b = self.VF1.get_profile('vy', 'x', 3, ind=True)
     # imtio.export_to_file(res_b, "VF1_get_profile_b.cimt")
     res_b2 = imtio.import_from_file("VF1_get_profile_b.cimt")
     assert res_b == res_b2
     res_c = self.VF1.get_profile('vy', 'y', 2.34)
     # imtio.export_to_file(res_c, "VF1_get_profile_c.cimt")
     res_c2 = imtio.import_from_file("VF1_get_profile_c.cimt")
     assert res_c == res_c2
     res_d = self.VF1.get_profile('vx', 'y', 19, ind=True)
     # imtio.export_to_file(res_d, "VF1_get_profile_d.cimt")
     res_d2 = imtio.import_from_file("VF1_get_profile_d.cimt")
     assert res_d == res_d2
 def test_get_critical_points_a(self):
     res_a = vod.get_critical_points(self.VF1_nomask,
                                     mirroring=[['x', 0.]],
                                     thread='all')
     # imtio.export_to_file(res_a, "VF1_get_critical_points_a.cimt")
     res_a2 = imtio.import_from_file("VF1_get_critical_points_a.cimt")
     assert len(res_a2.foc) > 0
     assert res_a == res_a2