Beispiel #1
0
def test_build_interpolator_stag():
    targets = [60, 350, 550]
    ipor = build_interpolator(DATA_Z_STAG, targets, True)
    assert type(ipor) == Interpolator
    assert ipor.dimension == DIM_BOTTOM_TOP_STAG
    assert ipor.max_k == 5
    assert str(ipor) == 'Interpolator[bottom_top_stag: (60, 350, 550)]'
Beispiel #2
0
def test_build_interpolator_alig():
    targets = [60, 350, 550]
    DATA_Z_ALIG = destagger_array(DATA_Z_STAG, 1)
    ipor = build_interpolator(DATA_Z_ALIG, targets, False)
    assert type(ipor) == Interpolator
    assert ipor.dimension == DIM_BOTTOM_TOP
    assert ipor.max_k == 4  # Don't need 5th since 550m is completely masked out
    assert str(ipor) == 'Interpolator[bottom_top: (60, 350, 550)]'
Beispiel #3
0
def test_interpolate_t():
    targets = [60, 350, 550]
    DATA_Z_ALIG = destagger_array(DATA_Z_STAG, 1)
    ipor = build_interpolator(DATA_Z_ALIG, targets, False)

    t_tgt = ipor(DATA_T)
    assert t_tgt[:, 0, 0, 0].tolist() == [-17.10787269681742, -17.40796311818944, -17.70822147651007]
    assert t_tgt[:, 1, 0, 0].tolist() == [-17.7, -18.1, -18.400000000000002]

    # 550m is completely masked out in the aligne interpolator
    assert np.sum(ipor.vics[2].mask) == 48
Beispiel #4
0
def test_interpolate_z():
    targets = [60, 350, 550]
    ipor = build_interpolator(DATA_Z_STAG, targets, True)
    z_tgt = ipor(DATA_Z_STAG)

    # 60m crosses sigma-0 and sigma-1
    assert min_max_round(ipor.vics[0].k_fl) == (0, 1)
    assert np.sum(ipor.vics[0].mask) == 0
    assert round(np.min(z_tgt[:, 0]), 5) == 60
    assert round(np.max(z_tgt[:, 0]), 5) == 60

    # 350m is in sigma-3
    assert min_max_round(ipor.vics[1].k_fl) == (3, 3)
    assert np.sum(ipor.vics[1].mask) == 0
    assert round(np.min(z_tgt[:, 1]), 5) == 350
    assert round(np.max(z_tgt[:, 1]), 5) == 350

    # 550m is in sigma-4 but blows out of the top at 42 points
    assert min_max_round(ipor.vics[2].k_fl) == (4, 4)
    assert np.sum(ipor.vics[2].mask) == 42
    assert np.isnan(np.min(z_tgt[:, 2]))
    assert np.isnan(np.max(z_tgt[:, 2]))
    assert z_tgt[:, 2, 2, 2].tolist() == [550, 550, 550]
Beispiel #5
0
 def ipor_alig(self) -> Interpolator:
     if self._ipor_alig is None:
         self._ipor_alig = build_interpolator(self.z_alig(), self.heights,
                                              False)
     return self._ipor_alig
Beispiel #6
0
 def ipor_stag(self) -> Interpolator:
     if self._ipor_stag is None:
         self._ipor_stag = build_interpolator(self.z_stag(), self.heights,
                                              True)
     return self._ipor_stag