通用的日期格式与儒略日(julianday)格式的互相转换.doc_第1页
通用的日期格式与儒略日(julianday)格式的互相转换.doc_第2页
通用的日期格式与儒略日(julianday)格式的互相转换.doc_第3页
通用的日期格式与儒略日(julianday)格式的互相转换.doc_第4页
通用的日期格式与儒略日(julianday)格式的互相转换.doc_第5页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

通用的日期格式与儒略日(julian day)格式的互相转换李文军中国地震局地震预测研究所 北京 100036 儒略日(Julian day)是指由公元前4713年1月1日,协调世界时中午12时开始所经过的天数,多为天文学家采用,用以作为天文学的单一历法,把不同历法的年表统一起来。儒略日是一种不用年月的长期纪日法,简写为JD。是由法国纪年学家史迦利日(Joseph Justus Scliger 1540年-1609年)在1583年所创,这名称是为了纪念他的父亲意大利学者Julius Caesar Scaliger(1484年-1558年)。以儒略日计日是为方便计算年代相隔久远或不同历法的两事件所间隔的日数。为简化起见,在地震学中用到的Julian 日期有时用来指这样的日期格式,即当前年份和当天位于这一年的第几天的结合。例如,2006 年 1 月 1 日表示为 2006001,而 2008 年 12 月 31 日表示为 2008366。因此,该格式并不等同于 Julian 日历计算的日期,但是,可以极大地方便我们在地震学中的数据处理,在许多地震学数据格式中都用这种简化儒略日表示日期,如sac、seed、miniseed等格式。而在撰写论文的图件中我们又希望恢复成普通的日期格式,因而通用格式和简化儒略日之间的转换是一个经常要做的事以下有两个程序,第一个是matlab编写的普通通用日期转换为上述简化儒略日(Julian day)的程序代码,第二个是同样用matlab编写的将儒略日转回普通日期格式的代码: 1、普通通用日期转换为简化儒略日(Julian day)的程序代码function y=julia(theyear,themonth,theday);%return the julian day (year,day)定义函数julia为转换为julian日期函数,变量y为返回的julian日期,输入变量为theyear/年,themonth/月,theday/日leapyear=rem(theyear,4); %年对4求余数if leapyear0 leap=0; %判断余数大于0,不能被4整除,则用leap标记这一年不是闰年(标记为0)else if rem(theyear,100)=0 & rem(theyear,400)=0 leap=0; %能被4整除但是不能被400整除也不是闰年,则用leap标记这一年不是闰年 else leap=1; %其他情况是闰年 endend%采用平年的日历,按1-12月分月计算julian日期 if themonth=1 juliaday=theday; end if themonth=2 juliaday=theday+31; end if themonth=3 juliaday=theday+59; end if themonth=4 juliaday=theday+90; end if themonth=5 juliaday=theday+120; end if themonth=6 juliaday=theday+151; end if themonth=7 juliaday=theday+181; end if themonth=8 juliaday=theday+212; end if themonth=9 juliaday=theday+243; end if themonth=10 juliaday=theday+273; end if themonth=11 juliaday=theday+304; end if themonth=12 juliaday=theday+334; endif leap=1 if themonth=3 juliaday=juliaday+1; %当月份大于2月时,在平年的基础上加一天 endendy(1)=theyear; y(2)=juliaday; %返回的矢量y,第一个元素为年,第二个元素为Julian日将儒略日转回普通日期格式的代码与上述代码类似2、儒略日(Julian day)转为普通日期格式的程序代码:function y=rejulia(theyear,theday);%change julian day to normal day (year month day)leapyear=rem(theyear,4);if leapyear0 leap=0;else if rem(theyear,100)=0 & rem(theyear,400)=0 leap=0; else leap=1; endendif leap=0 if theday=32 & theday=60 & theday=91 & theday=121 & theday=152 & theday=182 & theday=213 & theday=244 & theday=274 & theday=305 & theday=335 & theday=365 therealmonth=12; therealday=theday-334; endendif leap=1 if theday=32 & theday=61 & theday=92 & theday=122 & theday=153 & theday=183 & theday=214 & theday=245 & theday=275 & theday=306 & theday=336 & theday=366; therealmonth=12; therealday=theday-335; endendy(1)=theyear;y(2)=therealmonth;y(3)=therealday;参考文献:1、 /wiki/Julian_day 维基百科词条:儒略日(Julian day)2、 /man

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论