예제 #1
0
    def get_value_ostia(self, lat, lon):
        """
        :param lat: latitude of location to extract value from in degrees of arc
        :param lon: longitude of location to extract value from in degrees of arc
        :return: SST at that location or None

        :type lat: float
        :type lon: float
        :rtype: float
        """
        yindex = qc.mds_lat_to_yindex(lat, res=0.05)
        xindex = qc.mds_lon_to_xindex(lon, res=0.05)
        tindex = 0

        result = self.field[tindex, yindex, xindex]

        if type(result) is np.float64 or type(result) is np.float32:
            pass
        else:
            if result.mask:
                result = None
            else:
                result = result.data[0]

        return result
예제 #2
0
파일: test_qc.py 프로젝트: zqtzt/MarineQC
    def test_lats_with_res(self):
        self.assertEqual(qc.mds_lat_to_yindex(90.0, 5.0), 0)
        self.assertEqual(qc.mds_lat_to_yindex(88.0, 5.0), 0)
        self.assertEqual(qc.mds_lat_to_yindex(85.0, 5.0), 0)

        self.assertEqual(qc.mds_lat_to_yindex(-85.0, 5.0), 35)
        self.assertEqual(qc.mds_lat_to_yindex(-88.4, 5.0), 35)
        self.assertEqual(qc.mds_lat_to_yindex(-90.0, 5.0), 35)

        self.assertEqual(qc.mds_lat_to_yindex(0.0, 5.0), 18)
예제 #3
0
    def get_value_ostia(self, lat, lon):

        yindex = qc.mds_lat_to_yindex(lat, res=0.05)
        xindex = qc.mds_lon_to_xindex(lon, res=0.05)
        tindex = 0

        result = self.field[tindex, yindex, xindex]

        if type(result) is np.float64 or type(result) is np.float32:
            pass
        else:
            if result.mask:
                result = None
            else:
                result = result.data[0]

        return result
예제 #4
0
    def get_value_mds_style(self, lat, lon, month, day):
        '''
        Get the value from the climatology at the give position and time using the MDS 
        method for deciding which grid cell borderline cases fall into
        
        :param lat: latitude of location to extract value from in degrees
        :param lon: longitude of location to extract value from in degrees
        :param month: month for which the value is required
        :param day: day for which the value is required
        :type lat: float
        :type lon: float
        :type month: integer
        :type day: integer
        :return: climatology value at specified location and time.
        :rtype: float
        '''
        if month < 1 or month > 12:
            return None
        ml = qc.month_lengths(2004)
        if day < 1 or day > ml[month - 1]:
            return None

        yindex = qc.mds_lat_to_yindex(lat)
        xindex = qc.mds_lon_to_xindex(lon)
        tindex = self.get_tindex(month, day)

        result = self.field[tindex, yindex, xindex]

        if type(result) is np.float64 or type(result) is np.float32:
            pass
        else:
            if result.mask:
                result = None
            else:
                result = result.data[0]

        return result
예제 #5
0
파일: test_qc.py 프로젝트: zqtzt/MarineQC
    def test_lats(self):
        self.assertEqual(qc.mds_lat_to_yindex(90.0), 0)
        self.assertEqual(qc.mds_lat_to_yindex(89.0), 0)
        self.assertEqual(qc.mds_lat_to_yindex(88.0), 1)
        self.assertEqual(qc.mds_lat_to_yindex(87.0), 2)

        self.assertEqual(qc.mds_lat_to_yindex(88.7), 1)

        self.assertEqual(qc.mds_lat_to_yindex(-90.0), 179)
        self.assertEqual(qc.mds_lat_to_yindex(-89.0), 179)
        self.assertEqual(qc.mds_lat_to_yindex(-88.0), 178)
        self.assertEqual(qc.mds_lat_to_yindex(-87.0), 177)

        self.assertEqual(qc.mds_lat_to_yindex(-88.7), 178)

        self.assertEqual(qc.mds_lat_to_yindex(0.0), 90)
        self.assertEqual(qc.mds_lat_to_yindex(0.5), 89)
        self.assertEqual(qc.mds_lat_to_yindex(1.0), 88)
        self.assertEqual(qc.mds_lat_to_yindex(-0.5), 90)
        self.assertEqual(qc.mds_lat_to_yindex(-1.0), 91)