Exemplo n.º 1
0
        def test_USCRNDataTypeHasFlagIndex_performsFlagCorrection(self):
            lines = """63838 20170515 1100 20170515 0600 -9.000  -84.75   38.09 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 100 0 -99999 0 -99999 0 U -9999.0 0 -9999.0 0 -9999.0 0 -9999 0 -99.000 -99.000 -99.000 -99.000 -99.000 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0
63838 20170515 1200 20170515 0700 -9.000  -84.75   38.09 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -99999 0 -99999 0 -99999 0 U -9999.0 0 -9999.0 0 -9999.0 0 -9999 0 -99.000 -99.000 -99.000 -99.000 -99.000 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0
63838 20170515 1300 20170515 0800 -9.000  -84.75   38.09 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -99999 0 -99999 0 -99999 0 U -9999.0 0 -9999.0 0 -9999.0 0 -9999 0 -99.000 -99.000 -99.000 -99.000 -99.000 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0
63838 20170515 1400 20170515 0900 -9.000  -84.75   38.09 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -99999 0 -99999 0 -99999 0 U -9999.0 0 -9999.0 0 -9999.0 0 -9999 0 -99.000 -99.000 -99.000 -99.000 -99.000 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0
63838 20170515 1500 20170515 1000 -9.000  -84.75   38.09 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -99999 0 -99999 0 -99999 0 U -9999.0 0 -9999.0 0 -9999.0 0 -9999 0 -99.000 -99.000 -99.000 -99.000 -99.000 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0
63838 20170515 1600 20170515 1100  2.422  -84.75   38.09 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0    843 3    853 3    704 3 C    13.0 3    37.2 3     0.0 3 -9999 0 -99.000 -99.000 -99.000 -99.000 -99.000 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0
63838 20170515 1700 20170515 1200  2.422  -84.75   38.09    25.1    24.4    25.2    23.6     0.0    889 0    929 0    853 0 C    38.9 0    39.7 0    37.2 0    54 0   0.337   0.335   0.349   0.293   0.396    20.2    19.8    18.3    17.0    15.2
63838 20170515 1800 20170515 1300  2.422  -84.75   38.09    25.1    25.2    25.6    24.8     0.0    934 0    978 0     79 0 C    38.9 0    40.2 0    37.6 0    52 0   0.334   0.328   0.340   0.297   0.414    21.1    20.7    18.5    16.9    15.2
63838 20170515 1900 20170515 1400  2.422  -84.75   38.09    26.1    25.7    26.1    25.1     0.0    856 0    994 0    226 0 C    38.7 0    40.9 0    34.7 0    51 0   0.333   0.328   0.347   0.291   0.396    22.1    21.6    18.6    16.9    15.2"""
            rows = [re.split(r"\s+", line) for line in lines.splitlines()]
            solarad = USCRNDataType(13, -99999, 14)
            solarad._correct_data(rows, 1, 5, 100, 889)
            assert float(rows[0][14]) == 0
            assert float(rows[1][14]) == 0
            assert float(rows[2][14]) == 0
            assert float(rows[3][14]) == 0
            assert float(rows[4][14]) == 0
            assert float(rows[5][14]) == 0
            assert float(rows[6][14]) == 0
Exemplo n.º 2
0
        def test_USCRNDataTypeHasNoFlagIndex_performsLinearInterpolation(self):
            lines = """63838 20170515 1100 20170515 0600 -9.000  -84.75   38.09 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 100 0 -99999 0 -99999 0 U -9999.0 0 -9999.0 0 -9999.0 0 -9999 0 -99.000 -99.000 -99.000 -99.000 -99.000 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0
63838 20170515 1200 20170515 0700 -9.000  -84.75   38.09 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -99999 0 -99999 0 -99999 0 U -9999.0 0 -9999.0 0 -9999.0 0 -9999 0 -99.000 -99.000 -99.000 -99.000 -99.000 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0
63838 20170515 1300 20170515 0800 -9.000  -84.75   38.09 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -99999 0 -99999 0 -99999 0 U -9999.0 0 -9999.0 0 -9999.0 0 -9999 0 -99.000 -99.000 -99.000 -99.000 -99.000 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0
63838 20170515 1400 20170515 0900 -9.000  -84.75   38.09 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -99999 0 -99999 0 -99999 0 U -9999.0 0 -9999.0 0 -9999.0 0 -9999 0 -99.000 -99.000 -99.000 -99.000 -99.000 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0
63838 20170515 1500 20170515 1000 -9.000  -84.75   38.09 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0 -99999 0 -99999 0 -99999 0 U -9999.0 0 -9999.0 0 -9999.0 0 -9999 0 -99.000 -99.000 -99.000 -99.000 -99.000 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0
63838 20170515 1600 20170515 1100  2.422  -84.75   38.09 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0    843 3    853 3    704 3 C    13.0 3    37.2 3     0.0 3 -9999 0 -99.000 -99.000 -99.000 -99.000 -99.000 -9999.0 -9999.0 -9999.0 -9999.0 -9999.0
63838 20170515 1700 20170515 1200  2.422  -84.75   38.09    25.1    24.4    25.2    23.6     0.0    889 0    929 0    853 0 C    38.9 0    39.7 0    37.2 0    54 0   0.337   0.335   0.349   0.293   0.396    20.2    19.8    18.3    17.0    15.2
63838 20170515 1800 20170515 1300  2.422  -84.75   38.09    25.1    25.2    25.6    24.8     0.0    934 0    978 0     79 0 C    38.9 0    40.2 0    37.6 0    52 0   0.334   0.328   0.340   0.297   0.414    21.1    20.7    18.5    16.9    15.2
63838 20170515 1900 20170515 1400  2.422  -84.75   38.09    26.1    25.7    26.1    25.1     0.0    856 0    994 0    226 0 C    38.7 0    40.9 0    34.7 0    51 0   0.333   0.328   0.347   0.291   0.396    22.1    21.6    18.6    16.9    15.2"""
            rows = [re.split(r"\s+", line) for line in lines.splitlines()]
            t_calc = USCRNDataType(8, -9999.0)
            t_calc._correct_data(
                rows, 0, 5, 0.1, 25.1
            )  # 0.1 is made up. Pretend it comes from the previous year
            assert float(rows[0][8]) == 3.7
            assert float(rows[1][8]) == 7.2
            assert float(rows[2][8]) == 10.8
            assert float(rows[3][8]) == 14.4
            assert float(rows[4][8]) == 18.0
            assert float(rows[5][8]) == 21.5
            assert float(rows[6][8]) == 25.1