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的时间处理模块在日常的使用中用的不是非常的多,但是使用的时候基本上都是要查资料,还是有些麻烦的,梳理下,便于以后方便的 ...
随机推荐
- 分布式CAP定理
根据百度百科的定义,CAP定理又称CAP原则,指的是在一个分布式系统中,Consistency(一致性). Availability(可用性).Partition tolerance(分区容错性),最 ...
- Windows实时预览markdown
1.安装Notepad++ 2.打开Notepad++菜单栏的"插件(P)",然后打开"插件管理" 3.搜索"MarkdownViewer++&quo ...
- pymysql操作(老版本的,新版有基础不同)
导入库 import pymysql 创建链接 conn=pymysql.connect(host='127.0.0.1',port='3306',user='root',passwd='123456 ...
- Nginx服务加到systemctl
当我们编译安装nginx服务后,可以用手执行启动脚本也可以作为服务的形式运行. 添加启动文件:vim /usr/lib/systemd/system/nginx.service [Unit] Desc ...
- Java字符串——String深入
转载请注明原文地址:https://www.cnblogs.com/ygj0930/p/10840495.html 一:字符串的不可变性 1.可变 与 不可变 辨析 Java中的对象按照创建后,对象的 ...
- HDU 1372 Knight Moves 题解
Knight Moves Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
- 关于python中lambda 函数使用小结
例子: 如果定义普通函数,一般都是这样写: def:ds(x): return 2*x+1 调用即: ds(5) 如果用lambda函数就是这么写,就是一句话: g =lambda x:2*x+1 调 ...
- 【oracle】select into from 和 insert into select 的用法和区别
select into from 和 insert into select都是用来复制表,两者的主要区别为: select into from 要求目标表不存在,因为在插入时会自动创建.insert ...
- NOIP2013-2014提高组题目浅析
1.前言 迎接NOIP的到来...在这段闲暇时间,决定刷刷水题.这里只是作非常简单的一些总结. 2.NOIP2014 <1> 生活大爆炸之石头剪刀布(模拟) 这是一道考你会不会编程的题目. ...
- 搜索法 | 1091bfs搜索:三维bfs
首先我们来理解样例输入: 尺寸:3行4列5片 阈值:2 1 1 1 1 1 1 1 1 1 1 1 1 ------- 0 0 1 1 0 0 1 1 0 0 1 1 ------- 0 1 1 ...