def test_export2thredds_longlat_list(self): d = Domain("+proj=latlong +datum=WGS84 +ellps=WGS84 +no_defs", "-te 27 70 31 72 -ts 200 200") n = Nansat(domain=d) n.add_band(np.ones(d.shape(), np.float32), parameters={'name': 'L_469'}) n.set_metadata('time_coverage_start', '2016-01-19') tmpfilename = os.path.join(ntd.tmp_data_path, 'nansat_export2thredds_longlat.nc') n.export2thredds(tmpfilename, ['L_469']) ncI = netcdf_file(tmpfilename, 'r') ncIVar = ncI.variables['L_469'] self.assertTrue(ncIVar.grid_mapping in ncI.variables.keys())
def test_export2thredds_longlat_dict(self): d = Domain("+proj=latlong +datum=WGS84 +ellps=WGS84 +no_defs", "-te 27 70 31 72 -ts 200 200") n = Nansat.from_domain(d) n.add_band(np.ones(d.shape(), np.float32), parameters={'name': 'L_469'}) n.set_metadata('time_coverage_start', '2016-01-19') tmpfilename = os.path.join(self.tmp_data_path, 'nansat_export2thredds_longlat.nc') n.export2thredds(tmpfilename, {'L_469': {'type': '>i1'}}) ncI = Dataset(tmpfilename, 'r') ncIVar = ncI.variables['L_469'] self.assertTrue(ncIVar.grid_mapping in ncI.variables.keys()) self.assertEqual(ncIVar[:].dtype, np.int8)
relation between pixel/line coordinates and geographical coordinates, type of data projection (e.g. geographical or stereographic) ''' # Create Domain object. It describes the desired grid of reprojected image: # projection, resolution, size, etc. In this case it is geographic projection; # -10 - 30 E, 50 - 70 W; 2000 x 2000 pixels d = Domain("+proj=latlong +datum=WGS84 +ellps=WGS84 +no_defs", "-te 25 70 35 72 -ts 2000 2000") d = Domain(4326, "-te 25 70 35 72 -ts 2000 2000") d.write_map(oFileName + '01_latlong_map.png') print 'Latlong Domain:', d, '\n' # get shape print 'shape:', d.shape(), '\n' # Generate two vectors with values of lat/lon for the border of domain lonVec, latVec = d.get_border() print 'lonVec :', lonVec, '\n' print 'latVec :', latVec, '\n' # Get upwards azimuth direction of domain. bearing_center = d.upwards_azimuth_direction() print 'bearing_center :', bearing_center, '\n' # Create domain with stereographic projection # -- Get corners of the image lons, lats = d.get_corners() meanLon = sum(lons, 0.0) / 4. meanLat = sum(lats, 0.0) / 4.
def test_init_from_lonlat(self): lat, lon = np.mgrid[-90:90:0.5, -180:180:0.5] d = Domain(lon=lon, lat=lat) self.assertEqual(type(d), Domain) self.assertEqual(d.shape(), lat.shape)
def test_shape(self): d = Domain(4326, "-te 25 70 35 72 -ts 500 500") shape = d.shape() self.assertEqual(shape, (500, 500))