def test_decimate(self): side1_lons = np.arange(8) side1_lats = np.arange(8) + 30 side2_lons = np.arange(8) + 7 side2_lats = np.arange(8) + 30 + 7 side3_lons = np.arange(8) + 14 side3_lats = np.arange(8) + 30 + 14 side4_lons = np.arange(8) + 21 side4_lats = np.arange(8) + 30 + 21 bond = AreaBoundary((side1_lons, side1_lats), (side2_lons, side2_lats), (side3_lons, side3_lats), (side4_lons, side4_lats)) bond.decimate(5) lons, lats = bond.contour() self.assertTrue(np.allclose(lons, np.array([0, 1, 6, 7, 8, 13, 14, 15, 20, 21, 22, 27]))) self.assertTrue(np.allclose(lats, np.array([30, 31, 36, 37, 38, 43, 44, 45, 50, 51, 52, 57])))
def _get_swathsegment(filelist, time_start, time_end=None, area=None): """ Return only the granule files for the time interval or area. """ if area is not None: from trollsched.spherical import SphPolygon from trollsched.boundary import AreaBoundary lons, lats = area.get_boundary_lonlats() area_boundary = AreaBoundary((lons.side1, lats.side1), (lons.side2, lats.side2), (lons.side3, lats.side3), (lons.side4, lats.side4)) area_boundary.decimate(500) contour_poly = area_boundary.contour_poly segment_files = [] for filename in filelist: timetup = _get_times_from_npp(filename) # Search for multiple granules using an area if area is not None: md = NPPMetaData(filename) md.read() coords = np.vstack(md.get_ring_lonlats()) poly = SphPolygon(np.deg2rad(coords)) if poly.intersection(contour_poly) is not None: segment_files.append(filename) continue # Search for single granule using time start if time_end is None: if time_start >= timetup[0] and time_start <= timetup[1]: segment_files.append(filename) continue # search for multiple granules else: # check that granule start time is inside interval if timetup[0] >= time_start and timetup[0] <= time_end: segment_files.append(filename) continue # check that granule end time is inside interval if timetup[1] >= time_start and timetup[1] <= time_end: segment_files.append(filename) continue segment_files.sort() return segment_files
def _get_swathsegment(filelist, time_start, time_end=None, area=None): """ Return only the granule files for the time interval or area. """ if area is not None: from trollsched.spherical import SphPolygon from trollsched.boundary import AreaBoundary lons, lats = area.get_boundary_lonlats() area_boundary = AreaBoundary( (lons.side1, lats.side1), (lons.side2, lats.side2), (lons.side3, lats.side3), (lons.side4, lats.side4)) area_boundary.decimate(500) contour_poly = area_boundary.contour_poly segment_files = [] for filename in filelist: timetup = _get_times_from_npp(filename) # Search for multiple granules using an area if area is not None: md = NPPMetaData(filename) md.read() coords = np.vstack(md.get_ring_lonlats()) poly = SphPolygon(np.deg2rad(coords)) if poly.intersection(contour_poly) is not None: segment_files.append(filename) continue # Search for single granule using time start if time_end is None: if time_start >= timetup[0] and time_start <= timetup[1]: segment_files.append(filename) continue # search for multiple granules else: # check that granule start time is inside interval if timetup[0] >= time_start and timetup[0] <= time_end: segment_files.append(filename) continue # check that granule end time is inside interval if timetup[1] >= time_start and timetup[1] <= time_end: segment_files.append(filename) continue segment_files.sort() return segment_files
def test_contour(self): side1_lons = np.arange(4) side1_lats = np.arange(4) + 20 side2_lons = np.arange(4) + 3 side2_lats = np.arange(4) + 20 + 3 side3_lons = np.arange(4) + 6 side3_lats = np.arange(4) + 20 + 6 side4_lons = np.arange(4) + 9 side4_lats = np.arange(4) + 20 + 9 bond = AreaBoundary((side1_lons, side1_lats), (side2_lons, side2_lats), (side3_lons, side3_lats), (side4_lons, side4_lats)) lons, lats = bond.contour() self.assertTrue(np.allclose(lons, np.arange(12))) self.assertTrue(np.allclose(lats, np.arange(12) + 20))