Ejemplo n.º 1
0
 def test_GIVEN_masked_array_WHEN_fix_longitude_THEN_longitudes_fixed_but_masked_values_untouched(
         self):
     lons = numpy.ma.masked_less([0, -639, 90, 180, -639, 270, 360, -639],
                                 -360)
     new_lons = fix_longitude_range(lons, -180)
     expected_new_lons = numpy.ma.masked_invalid(
         [0, float('Nan'), 90, -180,
          float('Nan'), -90, 0,
          float('Nan')])
     compare_masked_arrays(new_lons, expected_new_lons)
Ejemplo n.º 2
0
    def test_GIVEN_ungridded_missing_values_WHEN_calculate_THEN_missing_values_preserved(self):
        data = mock.make_regular_2d_ungridded_data_with_missing_values()
        data.metadata._name = 'var1'
        self.data = [data]
        expr = 'var1 + 10'

        res = self.calc.evaluate(self.data, expr)
        expected = numpy.ma.masked_invalid([[11, 12, 13], [14, float('Nan'), 16], [17, 18, float('Nan')],
                                            [20, 21, 22], [float('Nan'), 24, 25]]).flatten()
        compare_masked_arrays(res.data, expected)
Ejemplo n.º 3
0
 def test_GIVEN_masked_array_WHEN_fix_longitude_THEN_longitudes_fixed_but_masked_values_untouched(self):
     lons = numpy.ma.masked_less([0, -639, 90, 180, -639, 270, 360, -639], -360)
     new_lons = fix_longitude_range(lons, -180)
     expected_new_lons = numpy.ma.masked_invalid([0, float('Nan'), 90, -180, float('Nan'), -90, 0, float('Nan')])
     compare_masked_arrays(new_lons, expected_new_lons)