MATLAB datenum日期转换为Python日期
摘要
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)
'''
截图(仅供参考)

验证:

参考
- 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日期的更多相关文章
- 简单的分页存储过程,Json格式日期转换为一般日期
简单的分页存储过程 CREATE PROC Paged @pageIndex INT, @pageCount INT OUTPUT, @pageSize INT AS DECLARE @count I ...
- Json格式日期转换为一般日期
Json日期转换为一般日期:json日期:/Date(1316756746000)/ 转换为2013-09-01格式的 1 //将json格式的时间转换成一般时间 2 function Chang ...
- 【310】◀▶ Python 日期和时间
参考: python 时间日期计算 Python 日期和时间(菜鸟教程) 8.1. datetime — Basic date and time types python中datetime模块中dat ...
- python 日期 & 时间
1. Python 提供了一个 time 和 calendar 模块可以用于格式化日期和时间. 2. 时间间隔是以秒为单位的浮点小数. 3. 每个时间戳都以自从1970年1月1日午夜(历元)经过了多长 ...
- (转)Python 日期和时间
转自http://www.runoob.com/python/python-date-time.html Python 日期和时间 Python 程序能用很多方式处理日期和时间,转换日期格式是一个常见 ...
- python日期格式化操作
1.将字符串的时间转换为时间戳 方法: a = "2013-10-10 23:40:00" #将其转换为时间数组 import time timeArray = time.strp ...
- 【转载】Python日期时间模块datetime详解与Python 日期时间的比较,计算实例代码
本文转载自脚本之家,源网址为:https://www.jb51.net/article/147429.htm 一.Python中日期时间模块datetime介绍 (一).datetime模块中包含如下 ...
- Python日期格式化知识
Python中日期格式化是非常常见的操作,Python 中能用很多方式处理日期和时间,转换日期格式是一个常见的功能.Python 提供了一个 time 和 calendar 模块可以用于格式化日期和时 ...
- Python 日期时间处理模块学习笔记
来自:标点符的<Python 日期时间处理模块学习笔记> Python的时间处理模块在日常的使用中用的不是非常的多,但是使用的时候基本上都是要查资料,还是有些麻烦的,梳理下,便于以后方便的 ...
随机推荐
- CDH报错:PersistenceException: [PersistenceUnit: cmf.server] Unable to build EntityManagerFactory
1.在启动CDH中master的服务cloudera-scm-server start并立刻挂掉了,提示如下错误 org.springframework.beans.factory.BeanCreat ...
- 关于如何修改一张表中所有行与选定字段的同sql多行语句的添加方法
利用Excel以及word文档进行操作 将表的字段以及数据全部放入Excel表中并保存. 在word表中将写好的sql语句放入文档,利用邮件--选择收件人--使用现有列表--(选择之前做好的Excel ...
- Linux文件增删改
Linux目录/文件增删改 创建文件 (1) # touch <文件名称> (2) 花括号展开 touch /root/{1,3,9}.txt touch /root/{0..100}. ...
- Linux的DNS正向解析部署
前面介绍了DNS的作用及其相关的结果.Linux服务之DNS介绍 下面开始有关DNS的服务部署.<DNS正向解析示例> 工具:虚拟机 centos7 配置:Linux IP 192.1 ...
- springboot easypoi 报错The bean 'beanNameViewResolver', defined in class path resource [cn/afterturn/e
事故现场: The bean 'beanNameViewResolver', defined in class path resource [cn/afterturn/easypoi/configur ...
- zookeper分布式搭建
zookeper的安装如下链接 https://www.cnblogs.com/wanerhu/p/11144815.html
- 宝塔https部署没成功的原因排查
今天ytkah在迁移一个客户网站的时候出了点问题,网站从旧的服务器(windows)换到新的服务器(阿里云centos 7,已经安装了宝塔面板),网站之前有用comodo的ssl证书,因为快要过期了, ...
- C++stringstream使用
链接 建议在使用是直接使用stringstream,不需要再去分输入用istringstream,输出用ostringstream.
- centos virtualbox虚拟机无法连接外网
各种方法都试了,不好使. 最后重启了很多次,最后一次成功了... ----详情---- 发生的原因是因为突然断电导致的异常. 先通过systemctl restart network 来启动,结果报错 ...
- 【Mybatis】拼接表名