def test_LatLonLists(self):
     self.assertEqual(len(latList(18)), 18)
     self.assertEqual(latList(19), [
         -90.0, -80.0, -70.0, -60.0, -50.0, -40.0, -30.0, -20.0, -10.0, 0.0,
          10.0,  20.0,  30.0,  40.0,  50.0,  60.0,  70.0,  80.0,  90.0])
     self.assertEqual(len(lonList(500)), 500)
     self.assertEqual(lonList(6), [-180.0, -120.0, -60.0, 0.0, 60.0, 120.0])
Example #2
0
 def test_LatLonLists(self):
     self.assertEqual(len(latList(18)), 18)
     self.assertEqual(latList(19), [
         -90.0, -80.0, -70.0, -60.0, -50.0, -40.0, -30.0, -20.0, -10.0, 0.0,
         10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0
     ])
     self.assertEqual(len(lonList(500)), 500)
     self.assertEqual(lonList(6), [-180.0, -120.0, -60.0, 0.0, 60.0, 120.0])
Example #3
0
def generate2D(filename, start, months, lats, lons):
	cdf = Dataset(filename, 'w', format='NETCDF4')

	cdf.createDimension('time', months)
	times = cdf.createVariable('time', 'f8', ('time', ))
	times.units = 'days since %04d-%02d-%02d 00:00:00.0' % start
	times.calendar = 'gregorian'
	times[:] = monthlist(start, months)

	cdf.createDimension('lat', lats)
	latitudes = cdf.createVariable('lat', 'f4', ('lat', ))
	latitudes.units = 'degrees north'
	latitudes[:] = latList(lats)

	cdf.createDimension('lon', lons)
	longitudes = cdf.createVariable('lon', 'f4', ('lon', ))
	longitudes.units = 'degrees east'
	longitudes[:] = lonList(lons)

	randoms = cdf.createVariable('random', 'i4', ('time', 'lat', 'lon', ))
	randoms.units = 'random values'
	randoms[:] = numpy.random.randint(-5, 6, (months, lats, lons, ))

	cdf.close()
	return