-
大小: 7KB文件类型: .gz金币: 1下载: 0 次发布日期: 2021-05-07
- 语言: 其他
- 标签: jdcal-1.4.1. jdcal-1.4.1- et_xmlfile-1 openpyxl-3.0
资源简介
只下载 openpyxl 模块是无法安装成功的,你要先下载安装jdcal, et-xmlfile模块
代码片段和文件信息
# -*- coding:utf-8 -*-
“““Functions for converting between Julian dates and calendar dates.
A function for converting Gregorian calendar dates to Julian dates and
another function for converting Julian calendar dates to Julian dates
are defined. Two functions for the reverse calculations are also
defined.
Different regions of the world switched to Gregorian calendar from
Julian calendar on different dates. Having separate functions for Julian
and Gregorian calendars allow maximum flexibility in choosing the
relevant calendar.
All the above functions are “proleptic“. This means that they work for
dates on which the concerned calendar is not valid. For example
Gregorian calendar was not used prior to around October 1582.
Julian dates are stored in two floating point numbers (double). Julian
dates and Modified Julian dates are large numbers. If only one number
is used then the precision of the time stored is limited. Using two
numbers time can be split in a manner that will allow maximum
precision. For example the first number could be the Julian date for
the beginning of a day and the second number could be the fractional
day. Calculations that need the latter part can now work with maximum
precision.
A function to test if a given Gregorian calendar year is a leap year is
defined.
Zero point of Modified Julian Date (MJD) and the MJD of 2000/1/1
12:00:00 are also given.
This module is based on the TPM C library by Jeffery W. Percival. The
idea for splitting Julian date into two floating point numbers was
inspired by the IAU SOFA C library.
:author: Prasanth Nair
:contact: prasanthhn@gmail.com
:license: BSD (https://opensource.org/licenses/bsd-license.php)
“““
from __future__ import division
from __future__ import print_function
import math
__version__ = “1.4.1“
MJD_0 = 2400000.5
MJD_JD2000 = 51544.5
def ipart(x):
“““Return integer part of given number.“““
return math.modf(x)[1]
def is_leap(year):
“““Leap year or not in the Gregorian calendar.“““
x = math.fmod(year 4)
y = math.fmod(year 100)
z = math.fmod(year 400)
# Divisible by 4 and
# either not divisible by 100 or divisible by 400.
return not x and (y or not z)
def gcal2jd(year month day):
“““Gregorian calendar date to Julian date.
The input and output are for the proleptic Gregorian calendar
i.e. no consideration of historical usage of the calendar is
made.
Parameters
----------
year : int
Year as an integer.
month : int
Month as an integer.
day : int
Day as an integer.
Returns
-------
jd1 jd2: 2-element tuple of floats
When added together the numbers give the Julian date for the
given Gregorian calendar date. The first number is always
MJD_0 i.e. 2451545.5. So the second is the MJD.
Examples
--------
>>> gcal2jd(200011)
(2400000.5 51544.0)
>>> 2400000.5 + 51544.0 + 0.5
2451545.0
>>> year = [-46
- 上一篇:HID 免驱 描述符
- 下一篇:多目标跟踪方法综述.pdf
评论
共有 条评论