摘要

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)
'''

截图(仅供参考)

验证:

参考

  1. 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
  2. OPeNDAP-某数据集格式:http://test.opendap.org/dap/data/nc/sst.mnmean.nc.gz.das
  3. Python datetime to Matlab datenum https://stackoverflow.com/questions/8776414/python-datetime-to-matlab-datenum
  4. Converting Matlab's datenum format to Python https://stackoverflow.com/questions/13965740/converting-matlabs-datenum-format-to-python/36249553
  5. [Tutor] datenum https://mail.python.org/pipermail/tutor/2003-September/025454.html
  6. 在日期时间数组、数值和文本之间转换 https://ww2.mathworks.cn/help/matlab/matlab_prog/convert-between-datetime-arrays-numbers-and-strings.html
  7. datenum用法 https://ww2.mathworks.cn/help/matlab/ref/datenum.html
  8. 日期和时间 https://ww2.mathworks.cn/help/matlab/date-and-time-operations.html?s_tid=CRUX_lftnav

MATLAB datenum日期转换为Python日期的更多相关文章

  1. 简单的分页存储过程,Json格式日期转换为一般日期

    简单的分页存储过程 CREATE PROC Paged @pageIndex INT, @pageCount INT OUTPUT, @pageSize INT AS DECLARE @count I ...

  2. Json格式日期转换为一般日期

    Json日期转换为一般日期:json日期:/Date(1316756746000)/ 转换为2013-09-01格式的   1 //将json格式的时间转换成一般时间 2 function Chang ...

  3. 【310】◀▶ Python 日期和时间

    参考: python 时间日期计算 Python 日期和时间(菜鸟教程) 8.1. datetime — Basic date and time types python中datetime模块中dat ...

  4. python 日期 & 时间

    1. Python 提供了一个 time 和 calendar 模块可以用于格式化日期和时间. 2. 时间间隔是以秒为单位的浮点小数. 3. 每个时间戳都以自从1970年1月1日午夜(历元)经过了多长 ...

  5. (转)Python 日期和时间

    转自http://www.runoob.com/python/python-date-time.html Python 日期和时间 Python 程序能用很多方式处理日期和时间,转换日期格式是一个常见 ...

  6. python日期格式化操作

    1.将字符串的时间转换为时间戳 方法: a = "2013-10-10 23:40:00" #将其转换为时间数组 import time timeArray = time.strp ...

  7. 【转载】Python日期时间模块datetime详解与Python 日期时间的比较,计算实例代码

    本文转载自脚本之家,源网址为:https://www.jb51.net/article/147429.htm 一.Python中日期时间模块datetime介绍 (一).datetime模块中包含如下 ...

  8. Python日期格式化知识

    Python中日期格式化是非常常见的操作,Python 中能用很多方式处理日期和时间,转换日期格式是一个常见的功能.Python 提供了一个 time 和 calendar 模块可以用于格式化日期和时 ...

  9. Python 日期时间处理模块学习笔记

    来自:标点符的<Python 日期时间处理模块学习笔记> Python的时间处理模块在日常的使用中用的不是非常的多,但是使用的时候基本上都是要查资料,还是有些麻烦的,梳理下,便于以后方便的 ...

随机推荐

  1. 分布式session的解决方案

    1.Nginx的ip_hash,对应tomcat的session,由tomcat保存 缺点:一旦tomcat单点挂机,session消失 2.session在tomcat之间复制, 缺点:保存全局se ...

  2. mac运行模拟器simulator突然很慢

    一直都正常,突然变慢,而且慢的离谱. 上网查了下,这里记录下,或许问题不仅限于此. simulator->Debug->Slow Animations. 这个Slow Animations ...

  3. Leetcode——3. 无重复字符的最长子串

    难度: 中等 题目 Given a string, find the length of the longest substring without repeating characters. 给定一 ...

  4. Jupyter notebook 中常用的快捷键

    1.注释和缩进 注释一行或多行: Ctrl + / 多行同时缩进:Tab 或者 Ctrl + ] 多行取消缩进: Shift + Tab 或者 ctrl + [ 2.编辑和运行 Enter : 转入编 ...

  5. 利用pandas映射替换两个字典中的映射值

    在公司处理报表,中英文映射表与数值表替换 import pandas as pd data = { "a":"值一", "b":" ...

  6. 如何将MultipartFile转换成based4

    public String test(MultipartFile file) throws Exception{ BASE64Encoder base64Encoder =new BASE64Enco ...

  7. VS Code配置Python

    安装 1.安装python插件 直接在VS Code里搜索“Python”插件,安装. 2.下载Python 去官网下载Python 其他的插件在第一次运行Python程序会提示,按要求安装即可. 运 ...

  8. React的使用小规范----长期更新

    用this.state控制组件显示,用this.props控制页面业务数据,用this.other保存其他需要的属性,如计时器setInterval的id

  9. 树莓派项目(1-2)人脸识别 C++

    级联分类器 在这里,我们学习如何使用objdetect在我们的图像或视频中查找对象 https://docs.opencv.org/3.3.0/db/d28/tutorial_cascade_clas ...

  10. 在CentOS 7 中安装Docker

    https://birdteam.net/135360 sudo systemctl enable docker sudo systemctl start docker