Astropy提供了强大的时间处理功能。例如,可以使用Time类来表示时间: fromastropy.timeimportTime# 创建一个表示当前时间的Time对象now=Time.now()print("当前时间:",now)# 将时间转换为UTC格式utc_now=Time.now(SCALE='utc')print("UTC时间:",utc_now) 坐标转换 天文观测中经常需要进行坐标转换。Astropy提供了...
Astropy的time模块可以处理各种时间格式,包括UTC、JD、MJD等。 以下示例展示如何将UTC时间转换为JD时间。 fromastropy.timeimportTime # 创建一个UTC时间对象 utc_time=Time('2023-10-01 00:00:00',scale='utc') # 转换为JD时间 jd_time=utc_time.jd print(f"JD时间:{jd_time:.5f}") 单位和量 Astrop...
after 1999 in this versionfromastropy.timeimportTimefromdatetimeimportdatetimedefdelta_t_astropy(dt):t = Time(dt, scale='utc')return-(dt - t.tt.value).total_seconds()# years
""" lc = KeplerLightCurve.read(path, quality_bitmask=None) sff = SFFCorrector(lc.remove_nans()) > sff.correct(windows=10, bins=5, timescale=0.5) tests/correctors/test_sffcorrector.py:31: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _...
astropy.time Mean and apparent sidereal time can now be calculated using the sidereal_time method [#1418]. The time scale now defaults to UTC if no scale is provided. [#2091] TimeDelta objects can have all scales but UTC, as well as, for consistency with time-like quantities, undefined...
fromastropy.timeimportTime # 创建一个UTC时间对象 utc_time=Time('2023-10-01 00:00:00',scale='utc') # 转换为JD时间 jd_time=utc_time.jd print(f"JD时间:{jd_time:.5f}") 单位和量 Astropy的units模块支持物理单位的处理和转换。 以下示例展示如何进行单位转换。
In [2]: t = Time([1, 2], format="cxcsec") In [3]: t[0] = np.nan In [4]: t Out[4]: <Time object: scale='tt' format='cxcsec' value=[NaT, 2.]> and: In [2]: t = Time([1, 2], format="cxcsec") In [3]: t.mask[0] = True In [4]: t Out[4]: <Time...
(self, val1, val2, scale, precision, in_subfmt, out_subfmt, from_jd) 148 else: --> 149 val1, val2 = self._check_val_type(val1, val2) 150 self.set_jds(val1, val2) .../astropy/time/formats.py in _check_val_type(self, val1, val2) 424 if val1.dtype.kind == 'f'...
lon=long, height=float(3114) * U.m) e = tttime() print("Site Object created in {} seconds".format(e - s)) s = tttime() moon = get_moon(tm(date_obs, scale='utc')) e = tttime() print("Sky Object (Moon) created in {} seconds".format(e - s)) s = tttime() frame_...
(format='fits') 519 except UnitScaleError: /opt/anaconda3/envs/astro/lib/python3.7/site-packages/astropy/units/core.py in to_string(self, format) 604 f = unit_format.get_format(format) --> 605 return f.to_string(self) 606 /opt/anaconda3/envs/astro/lib/python3.7/site-packages/...