我已经屏蔽了数组,从中我提取了datetime,并将其从从开始日期以秒为单位的时间序列转换为“对象数组”。在python中使用以下命令。 date=num2date(time, units = data.variables['time'].units)
当我打印日期时,我得到
Out[41]:
masked_array(data=[cftime.DatetimeGregorian(2002, 8, 23, 9, 0, 0, 0, has_year_zero=False),
cftime.DatetimeGregorian(2003, 9, 3, 9, 0, 0, 0, has_year_zero=False),
cftime.DatetimeGregorian(2004, 12, 24, 9, 0, 0, 0, has_year_zero=False),
cftime.DatetimeGregorian(2005, 6, 18, 9, 0, 0, 0, has_year_zero=False),
cftime.DatetimeGregorian(2006, 9, 14, 9, 0, 0, 0, has_year_zero=False),
cftime.DatetimeGregorian(2007, 9, 19, 9, 0, 0, 0, has_year_zero=False),
cftime.DatetimeGregorian(2008, 3, 14, 9, 0, 0, 0, has_year_zero=False),
cftime.DatetimeGregorian(2009, 8, 16, 9, 0, 0, 0, has_year_zero=False),
cftime.DatetimeGregorian(2010, 11, 21, 9, 0, 0, 0, has_year_zero=False),
cftime.DatetimeGregorian(2011, 11, 7, 9, 0, 0, 0, has_year_zero=False),
cftime.DatetimeGregorian(2012, 2, 27, 9, 0, 0, 0, has_year_zero=False),
cftime.DatetimeGregorian(2013, 6, 29, 9, 0, 0, 0, has_year_zero=False),
cftime.DatetimeGregorian(2014, 6, 15, 9, 0, 0, 0, has_year_zero=False),
cftime.DatetimeGregorian(2015, 3, 7, 9, 0, 0, 0, has_year_zero=False),
cftime.DatetimeGregorian(2016, 1, 10, 9, 0, 0, 0, has_year_zero=False),
cftime.DatetimeGregorian(2017, 7, 25, 9, 0, 0, 0, has_year_zero=False),
cftime.DatetimeGregorian(2018, 1, 6, 9, 0, 0, 0, has_year_zero=False),
cftime.DatetimeGregorian(2019, 1, 26, 9, 0, 0, 0, has_year_zero=False),
cftime.DatetimeGregorian(2020, 12, 23, 9, 0, 0, 0, has_year_zero=False),
cftime.DatetimeGregorian(2021, 4, 30, 9, 0, 0, 0, has_year_zero=False)],
mask=False,
fill_value='?',
dtype=object)
现在我想从中提取的是年份和月份。如果它是一个蒙版数组,我将如何执行此操作?
暂无答案!
目前还没有任何答案,快来回答吧!