本文整理汇总了Python中netcdftime.nc_datetime函数的典型用法代码示例。如果您正苦于以下问题:Python nc_datetime函数的具体用法?Python nc_datetime怎么用?Python nc_datetime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了nc_datetime函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_lbcode3x23
def test_lbcode3x23(self):
time_bounds = np.array([[0.875, 1.125], [1.125, 1.375],
[1.375, 1.625], [1.625, 1.875]])
field = mock.MagicMock(
lbproc=0, bzx=0, bdx=0, lbnpt=3, lbrow=4,
t1=nc_datetime(2000, 1, 2, hour=0, minute=0, second=0),
t2=nc_datetime(2000, 1, 3, hour=0, minute=0, second=0),
lbtim=mock.Mock(ia=1, ib=2, ic=2),
lbcode=SplittableInt(31323, {'iy': slice(0, 2),
'ix': slice(2, 4)}),
x_bounds=None,
y_bounds=time_bounds,
_x_coord_name=lambda: 'longitude',
_y_coord_name=lambda: 'latitude')
spec = ['lbtim', 'lbcode', 'lbrow', 'lbnpt', 'lbproc', 'lbsrce',
'lbuser', 'bzx', 'bdx', 'bdy', 'bmdi', 't1', 't2', 'stash',
'x_bounds', 'y_bounds', '_x_coord_name', '_y_coord_name']
field.mock_add_spec(spec)
res = _all_other_rules(field)[DIM_COORDS_INDEX]
expected_time_points = np.array([1, 1.25, 1.5, 1.75]) + (2000 * 360)
expected_unit = Unit('days since 0000-01-01 00:00:00',
calendar=CALENDAR_360_DAY)
expected = [(DimCoord(expected_time_points, standard_name='time',
units=expected_unit, bounds=time_bounds), 0)]
self.assertCoordsAndDimsListsMatch(res, expected)
开发者ID:corinnebosley,项目名称:iris,代码行数:27,代码来源:test__all_other_rules.py
示例2: test_t1_list_t2_scalar
def test_t1_list_t2_scalar(self):
# lbtim ia = 0, ib = 1, ic = 1
# with a single forecast reference time (t2) and a series
# of validity times (t1).
lbcode = _lbcode(1)
lbtim = _lbtim(ia=0, ib=1, ic=1)
forecast_period_in_hours = np.array([0, 3, 6, 9, 12])
# Validity time - vector of different values
t1 = [nc_datetime(1970, 1, 9, hour=(3 + fp)) for fp in
forecast_period_in_hours]
t1_dims = (0,)
# Forecast reference time - scalar
t2 = nc_datetime(1970, 1, 9, hour=3)
lbft = None # Not used.
coords_and_dims = _convert_time_coords(
lbcode=lbcode, lbtim=lbtim, epoch_hours_unit=_EPOCH_HOURS_UNIT,
t1=t1, t2=t2, lbft=lbft,
t1_dims=t1_dims)
# Expected coords.
fp_coord = DimCoord(forecast_period_in_hours,
standard_name='forecast_period',
units='hours')
time_coord = DimCoord((24 * 8) + 3 + forecast_period_in_hours,
standard_name='time',
units=_EPOCH_HOURS_UNIT)
fref_time_coord = DimCoord((24 * 8) + 3,
standard_name='forecast_reference_time',
units=_EPOCH_HOURS_UNIT)
expected = [(fp_coord, (0,)),
(time_coord, (0,)),
(fref_time_coord, None)]
self.assertCoordsAndDimsListsMatch(coords_and_dims, expected)
开发者ID:bamundi,项目名称:iris,代码行数:34,代码来源:test__convert_time_coords.py
示例3: _check_forecast
def _check_forecast(self, lbcode, expect_match=True):
lbtim = _lbtim(ib=1, ic=1)
# Validity time
t1 = nc_datetime(1970, 1, 10, hour=6, minute=0, second=0)
# Forecast time
t2 = nc_datetime(1970, 1, 9, hour=3, minute=0, second=0)
lbft = None # unused
coords_and_dims = _convert_time_coords(
lbcode=lbcode, lbtim=lbtim, epoch_hours_unit=_EPOCH_HOURS_UNIT,
t1=t1, t2=t2, lbft=lbft)
if expect_match:
expect_result = [
(DimCoord(24 * 1.125,
standard_name='forecast_period', units='hours'),
None),
(DimCoord(24 * 9.25,
standard_name='time', units=_EPOCH_HOURS_UNIT),
None),
(DimCoord(24 * 8.125,
standard_name='forecast_reference_time',
units=_EPOCH_HOURS_UNIT),
None)]
else:
expect_result = []
self.assertCoordsAndDimsListsMatch(coords_and_dims, expect_result)
开发者ID:bamundi,项目名称:iris,代码行数:25,代码来源:test__convert_time_coords.py
示例4: _check_period
def _check_period(self, lbcode, expect_match=True):
lbtim = _lbtim(ib=2, ic=1)
# Start time
t1 = nc_datetime(1970, 1, 9, hour=3, minute=0, second=0)
# End time
t2 = nc_datetime(1970, 1, 10, hour=3, minute=0, second=0)
lbft = 2.0 # sample period
coords_and_dims = _convert_scalar_time_coords(
lbcode=lbcode, lbtim=lbtim, epoch_hours_unit=_EPOCH_TIME_UNIT, t1=t1, t2=t2, lbft=lbft
)
if expect_match:
expect_result = [
(DimCoord(24 * 9.125 - 2.0, standard_name="forecast_reference_time", units=_EPOCH_TIME_UNIT), None),
(DimCoord(standard_name="forecast_period", units="hours", points=[-10.0], bounds=[-22.0, 2.0]), None),
(
DimCoord(
standard_name="time",
units=_EPOCH_TIME_UNIT,
points=[24 * 8.625],
bounds=[24 * 8.125, 24 * 9.125],
),
None,
),
]
else:
expect_result = []
self.assertCoordsAndDimsListsMatch(coords_and_dims, expect_result)
开发者ID:philippjfr,项目名称:iris,代码行数:27,代码来源:test__convert_scalar_time_coords.py
示例5: _check_yearly
def _check_yearly(self, lbcode, expect_match=True):
lbtim = _lbtim(ib=3, ic=1)
# Start time
t1 = nc_datetime(1970, 1, 9, hour=9, minute=0, second=0)
# End time
t2 = nc_datetime(1972, 1, 11, hour=9, minute=0, second=0)
lbft = 3.0 # sample period
coords_and_dims = _convert_time_coords(
lbcode=lbcode, lbtim=lbtim, epoch_hours_unit=_EPOCH_HOURS_UNIT,
t1=t1, t2=t2, lbft=lbft)
if expect_match:
t1_hours = 24 * 8.375
t2_hours = 24 * (10.375 + 2 * 365)
period_hours = 24.0 * (2 * 365 + 2)
expect_result = [
(DimCoord([t2_hours - lbft],
standard_name='forecast_reference_time',
units=_EPOCH_HOURS_UNIT), None),
(DimCoord(standard_name='forecast_period', units='hours',
points=[lbft], bounds=[lbft - period_hours, lbft]),
None),
(DimCoord(standard_name='time', units=_EPOCH_HOURS_UNIT,
points=[t2_hours],
bounds=[t1_hours, t2_hours]), None)]
else:
expect_result = []
self.assertCoordsAndDimsListsMatch(coords_and_dims, expect_result)
开发者ID:bamundi,项目名称:iris,代码行数:27,代码来源:test__convert_time_coords.py
示例6: test_unrecognised
def test_unrecognised(self):
lbtim = _lbtim(ib=4, ic=1)
t1 = nc_datetime(0, 0, 0)
t2 = nc_datetime(0, 0, 0)
lbft = None
lbcode = _lbcode(0)
coords_and_dims = _convert_time_coords(
lbcode=lbcode, lbtim=lbtim, epoch_hours_unit=_EPOCH_HOURS_UNIT,
t1=t1, t2=t2, lbft=lbft)
self.assertEqual(coords_and_dims, [])
开发者ID:bamundi,项目名称:iris,代码行数:10,代码来源:test__convert_time_coords.py
示例7: test_
def test_(self):
lbtim = _lbtim(ib=2, ic=1)
t1 = nc_datetime(0, 1, 1)
t2 = nc_datetime(0, 1, 31, 23, 59, 00)
lbft = 0
lbcode = _lbcode(1)
coords_and_dims = _convert_time_coords(
lbcode=lbcode, lbtim=lbtim, epoch_hours_unit=_EPOCH_HOURS_UNIT,
t1=t1, t2=t2, lbft=lbft)
self.assertEqual(coords_and_dims, [])
开发者ID:MahatmaCane,项目名称:iris,代码行数:10,代码来源:test__convert_time_coords.py
示例8: test_not_exact_hours
def test_not_exact_hours(self):
lbtim = _lbtim(ib=1, ic=1)
t1 = nc_datetime(2015, 1, 20, hour=7, minute=10, second=0)
t2 = nc_datetime(2015, 1, 20, hour=0, minute=0, second=0)
coords_and_dims = _convert_time_coords(
lbcode=_lbcode(1), lbtim=lbtim, epoch_hours_unit=_EPOCH_HOURS_UNIT,
t1=t1, t2=t2, lbft=None)
(fp, _), (t, _), (frt, _) = coords_and_dims
self.assertEqual(fp.points[0], 7.1666666641831398)
self.assertEqual(t.points[0], 394927.16666666418)
开发者ID:MahatmaCane,项目名称:iris,代码行数:10,代码来源:test__convert_time_coords.py
示例9: test_exact_hours
def test_exact_hours(self):
lbtim = _lbtim(ib=1, ic=1)
t1 = nc_datetime(2015, 1, 20, hour=7, minute=0, second=0)
t2 = nc_datetime(2015, 1, 20, hour=0, minute=0, second=0)
coords_and_dims = _convert_time_coords(
lbcode=_lbcode(1), lbtim=lbtim, epoch_hours_unit=_EPOCH_HOURS_UNIT,
t1=t1, t2=t2, lbft=None)
(fp, _), (t, _), (frt, _) = coords_and_dims
# These should both be exact whole numbers.
self.assertEqual(fp.points[0], 7)
self.assertEqual(t.points[0], 394927)
开发者ID:MahatmaCane,项目名称:iris,代码行数:11,代码来源:test__convert_time_coords.py
示例10: _check_timepoint
def _check_timepoint(self, lbcode, expect_match=True):
lbtim = _lbtim(ib=0, ic=1)
t1 = nc_datetime(1970, 1, 1, hour=6, minute=0, second=0)
t2 = nc_datetime(0, 0, 0) # not used in result
lbft = None # unused
coords_and_dims = _convert_scalar_time_coords(
lbcode=lbcode, lbtim=lbtim, epoch_hours_unit=_EPOCH_TIME_UNIT, t1=t1, t2=t2, lbft=lbft
)
if expect_match:
expect_result = [(DimCoord(24 * 0.25, standard_name="time", units=_EPOCH_TIME_UNIT), None)]
else:
expect_result = []
self.assertCoordsAndDimsListsMatch(coords_and_dims, expect_result)
开发者ID:philippjfr,项目名称:iris,代码行数:13,代码来源:test__convert_scalar_time_coords.py
示例11: test
def test(self):
lbcode = _lbcode(value=31323)
lbtim = _lbtim(ib=2, ic=2)
t1 = nc_datetime(1970, 1, 3, hour=0, minute=0, second=0)
t2 = nc_datetime(1970, 1, 4, hour=0, minute=0, second=0)
lbft = 24 * 4
coords_and_dims = _convert_time_coords(
lbcode=lbcode, lbtim=lbtim, epoch_hours_unit=_EPOCH_HOURS_UNIT,
t1=t1, t2=t2, lbft=lbft)
t2_hours = 24 * 3
expected_result = [(DimCoord([t2_hours-lbft],
standard_name='forecast_reference_time',
units=_EPOCH_HOURS_UNIT), None)]
self.assertCoordsAndDimsListsMatch(coords_and_dims, expected_result)
开发者ID:MahatmaCane,项目名称:iris,代码行数:14,代码来源:test__convert_time_coords.py
示例12: test_t1_scalar_t2_list
def test_t1_scalar_t2_list(self):
lbtim = _lbtim(ib=3, ic=1)
lbcode = _lbcode(1)
years = np.array([1972, 1973, 1974])
# Start times - scalar
t1 = nc_datetime(1970, 1, 9, hour=9)
# End time - vector
t2 = [nc_datetime(year, 1, 11, hour=9) for
year in years]
t2_dims = (0,)
lbft = 3.0 # Sample period
coords_and_dims = _convert_time_coords(
lbcode=lbcode, lbtim=lbtim, epoch_hours_unit=_EPOCH_HOURS_UNIT,
t1=t1, t2=t2, lbft=lbft,
t2_dims=t2_dims)
# Expected coords.
points = np.ones_like(years) * lbft
bounds = np.array([lbft - ((years - 1970) * 365 * 24 + 2 * 24),
points]).transpose()
fp_coord = AuxCoord(points,
standard_name='forecast_period',
units='hours',
bounds=bounds)
points = (years - 1970) * 365 * 24 + 10 * 24 + 9
bounds = np.array([np.ones_like(points) * (8 * 24 + 9),
points]).transpose()
# The time coordinate is an AuxCoord as the lower bound for each
# cell is the same so it does not meet the monotonicity requirement.
time_coord = AuxCoord(points,
standard_name='time',
units=_EPOCH_HOURS_UNIT,
bounds=bounds)
fref_time_coord = DimCoord(points - lbft,
standard_name='forecast_reference_time',
units=_EPOCH_HOURS_UNIT)
expected = [(fp_coord, (0,)),
(time_coord, (0,)),
(fref_time_coord, (0,))]
开发者ID:bamundi,项目名称:iris,代码行数:40,代码来源:test__convert_time_coords.py
示例13: test_t1_and_t2_orthogonal_lists
def test_t1_and_t2_orthogonal_lists(self):
# lbtim ia = 0, ib = 1, ic = 1
# with a single repeated forecast reference time (t2) and a series
# of validity times (t1).
lbcode = _lbcode(1)
lbtim = _lbtim(ia=0, ib=1, ic=1)
years = np.array([1970, 1971, 1972])
hours = np.array([3, 6, 9, 12])
# Validity time - vector of different values
t1 = [nc_datetime(year, 1, 9, hour=12) for year in years]
t1_dims = (0,)
# Forecast reference time - vector of different values
t2 = [nc_datetime(1970, 1, 9, hour=hour) for hour in hours]
t2_dims = (1,)
lbft = None # Not used.
coords_and_dims = _convert_time_coords(
lbcode=lbcode, lbtim=lbtim, epoch_hours_unit=_EPOCH_HOURS_UNIT,
t1=t1, t2=t2, lbft=lbft,
t1_dims=t1_dims, t2_dims=t2_dims)
# Expected coords.
points = [[(year - 1970) * 365 * 24 + 12 - hour for hour
in hours] for year in years]
fp_coord = AuxCoord(points,
standard_name='forecast_period',
units='hours')
points = (years - 1970) * 24 * 365 + (24 * 8) + 12
time_coord = DimCoord(points,
standard_name='time',
units=_EPOCH_HOURS_UNIT)
points = (24 * 8) + hours
fref_time_coord = DimCoord(points,
standard_name='forecast_reference_time',
units=_EPOCH_HOURS_UNIT)
expected = [(fp_coord, (0, 1)), # Spans dims 0 and 1.
(time_coord, (0,)),
(fref_time_coord, (1,))]
self.assertCoordsAndDimsListsMatch(coords_and_dims, expected)
开发者ID:bamundi,项目名称:iris,代码行数:39,代码来源:test__convert_time_coords.py
示例14: test_t1_multi_dim_list_t2_scalar
def test_t1_multi_dim_list_t2_scalar(self):
# Another case of lbtim ia = 0, ib = 1, ic = 1 but
# with a changing forecast reference time (t2) and
# validity time (t1).
lbcode = _lbcode(1)
lbtim = _lbtim(ia=0, ib=1, ic=1)
forecast_period_in_hours = np.array([0, 3, 6, 9, 12])
years = np.array([1970, 1971, 1972])
# Validity time - 2d array of different values
t1 = [[nc_datetime(year, 1, 9, hour=(3 + fp)) for fp in
forecast_period_in_hours] for year in years]
t1_dims = (0, 1)
# Forecast reference time - vector of different values
t2 = nc_datetime(1970, 1, 9, hour=3)
lbft = None # Not used.
coords_and_dims = _convert_time_coords(
lbcode=lbcode, lbtim=lbtim, epoch_hours_unit=_EPOCH_HOURS_UNIT,
t1=t1, t2=t2, lbft=lbft,
t1_dims=t1_dims)
# Expected coords.
fp_coord = AuxCoord([forecast_period_in_hours +
(year - 1970) * 365 * 24 for year in years],
standard_name='forecast_period',
units='hours')
time_coord = AuxCoord([(24 * 8) + 3 + forecast_period_in_hours +
(year - 1970) * 365 * 24 for year in years],
standard_name='time',
units=_EPOCH_HOURS_UNIT)
fref_time_coord = DimCoord((24 * 8) + 3,
standard_name='forecast_reference_time',
units=_EPOCH_HOURS_UNIT)
expected = [(fp_coord, (0, 1)),
(time_coord, (0, 1)),
(fref_time_coord, None)]
self.assertCoordsAndDimsListsMatch(coords_and_dims, expected)
开发者ID:bamundi,项目名称:iris,代码行数:37,代码来源:test__convert_time_coords.py
示例15: test_t1_list
def test_t1_list(self):
# lbtim ia = 0, ib = 0, ic = 1
# with a series of times (t1).
lbcode = _lbcode(1)
lbtim = _lbtim(ia=0, ib=0, ic=1)
hours = np.array([0, 3, 6, 9, 12])
# Validity time - vector of different values
t1 = [nc_datetime(1970, 1, 9, hour=3 + hour) for hour in hours]
t1_dims = (0,)
# Forecast reference time - scalar (not used)
t2 = nc_datetime(1970, 1, 9, hour=3)
lbft = None
coords_and_dims = _convert_time_coords(
lbcode=lbcode, lbtim=lbtim, epoch_hours_unit=_EPOCH_HOURS_UNIT,
t1=t1, t2=t2, lbft=lbft,
t1_dims=t1_dims)
# Expected coords.
time_coord = DimCoord((24 * 8) + 3 + hours,
standard_name='time',
units=_EPOCH_HOURS_UNIT)
expected = [(time_coord, (0,))]
self.assertCoordsAndDimsListsMatch(coords_and_dims, expected)
开发者ID:bamundi,项目名称:iris,代码行数:24,代码来源:test__convert_time_coords.py
注:本文中的netcdftime.nc_datetime函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论