matlab datenum 周几,MATLAB datenum日期转换为Python日期

标签:test   panda   ber   alt   nat   stack   work   html   https

目录

摘要

示例1:小时制,基准年份1800-1-1

示例2:一天制,基准年份1800-1-1

示例3:时间列表转换

截图(参考)

参考

摘要

MATLAB datenum时间格式参数众多,本文只简单关注 units 参数,即基准年份和计时度量(天、小时)。

命令行演示在 ipython 和 Octave 中进行。

示例1:小时制,基准年份1800-1-1

Time Attributes:

units = 'hours since 1800-1-1 00:00:0.0'

long_name = 'Time'

axis = 'T'

standard_name = 'time'

coordinate_defines = 'start'

delta_t = '0000-00-01 00:00:00'

actual_range = [1.74e+06 1.75e+06]

avg_period = '0000-00-01 00:00:00'

time(1:5):

1744392

1744416

1744440

1744464

1744488

#来源: 参考1

# python

import numpy as np

origin = np.datetime64('1800-01-01', 'D')

date1 = 1744392/24 * np.timedelta64(1, 'D') + origin # '1999-01-01'

示例2:一天制,基准年份1800-1-1

time {

String units "days since 1800-1-1 00:00:00";

String long_name "Time";

Float64 actual_range 19723.00000000000, 76214.00000000000;

String delta_t "0000-01-00 00:00:00";

String avg_period "0000-01-00 00:00:00";

String prev_avg_period "0000-00-07 00:00:00";

String standard_name "time";

String axis "t";

}

#来源: 参考2

# python

import numpy as np

origin = np.datetime64('1800-01-01', 'D')

date2 = 19723 * np.timedelta64(1, 'D') + origin # '1854-01-01'

示例3:时间列表转换

import numpy as np

import pandas as pd

datenums = np.array([730990, 733301, 729159, 734471, 736858, 731204]) # 来源:参考7

timestamps = pd.to_datetime(datenums-719529, unit='D')

'''

DatetimeIndex(['2001-05-19', '2007-09-16', '1996-05-14',

'2010-11-29', '2017-06-12', '2001-12-19'],

dtype='datetime64[ns]', freq=None)

'''

截图(参考)

20191003010318740689.png

验证:

20191003010319041481.png

参考

convert narr model data time to datevec or datestr https://ww2.mathworks.cn/matlabcentral/answers/141304-convert-narr-model-data-time-to-datevec-or-datestr

OPeNDAP-某数据集格式:http://test.opendap.org/dap/data/nc/sst.mnmean.nc.gz.das

Python datetime to Matlab datenum https://stackoverflow.com/questions/8776414/python-datetime-to-matlab-datenum

Converting Matlab‘s datenum format to Python https://stackoverflow.com/questions/13965740/converting-matlabs-datenum-format-to-python/36249553

[Tutor] datenum https://mail.python.org/pipermail/tutor/2003-September/025454.html

在日期时间数组、数值和文本之间转换 https://ww2.mathworks.cn/help/matlab/matlab_prog/convert-between-datetime-arrays-numbers-and-strings.html

datenum用法 https://ww2.mathworks.cn/help/matlab/ref/datenum.html

日期和时间 https://ww2.mathworks.cn/help/matlab/date-and-time-operations.html?s_tid=CRUX_lftnav

MATLAB datenum日期转换为Python日期

标签:test   panda   ber   alt   nat   stack   work   html   https

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值