Example #1
0
    def get_tindex(self, month, day):
        '''
        Get the time index of the input month and day
        
        :param month: month for which the time index is required
        :param day: day for which the time index is required
        :type month: integer
        :type day: integer
        :return: time index for specified month and day.
        :rtype: integer
        '''
        if self.n == 1:
            tindex = 0
        if self.n == 73:
            tindex = qc.which_pentad(month, day) - 1
        if self.n == 365:
            tindex = qc.day_in_year(month, day) - 1

        return tindex
    def __init__(self, lat, lon, year, month=None, day=None):
        '''
        Make a :class:`.Gridpt` object from lat, lon, year, month and day
        
        :param lat: latitude of the observation
        :param lon: longitude of observation
        :param year: year of the observation
        :param month: month of the observation
        :param day: day of the observation
        :type lat: float
        :type lon: float
        :type year: integer
        :type month: integer
        :type day: integer
        '''
        self.lat = lat
        self.lon = lon
        
        self.year = year
        self.month = month
        self.day = day
        
        if month == None:
            self.ptd = year
        else:
            self.ptd = qc.which_pentad(month, day)

        self.xindex = qc.lon_to_xindex(lon)
        self.yindex = qc.lat_to_yindex(lat)
        
        self.latitude_approx = 89.5 - self.yindex
        self.longitude_approx = -179.5 + self.xindex

        self.idstring = '%(lat)04d%(lon)04d%(ptd)04d' % {"lat": self.yindex, 
                                                         "lon": self.xindex, 
                                                         "ptd": self.ptd }
Example #3
0
 def test_all_ps(self):
     for p in range(1, 74):
         m, d = qc.pentad_to_month_day(p)
         self.assertEqual(p, qc.which_pentad(m, d))
Example #4
0
 def test_pentad_of_feb_29th(self):
     self.assertEqual(12, qc.which_pentad(2, 29))
Example #5
0
 def test_pentad_of_dec_31st(self):
     self.assertEqual(73, qc.which_pentad(12, 31))
Example #6
0
 def test_pentad_of_jan_1st(self):
     self.assertEqual(1, qc.which_pentad(1, 1))
Example #7
0
 def test_second_to_last_pentad(self):
     self.assertEqual(72, qc.which_pentad(12, 26))
Example #8
0
 def test_second_and_fifth_pentad(self):
     self.assertEqual(2, qc.which_pentad(1, 6))
     self.assertEqual(5, qc.which_pentad(1, 21))