参考/API#

astropy.io.misc包裹#

这个软件包包含了用于astropy数据输入/输出的各种实用程序函数。

功能#

fnpickle(object, fileorname[, protocol, append])

自 6.0 版本弃用.

fnunpickle(fileorname[, number])

自 6.0 版本弃用.

astropy.io.misc.hdf5模块#

此程序包包含用于读取和写入HDF5表的函数,这些表不应直接使用,而是可作为中的读取器/写入器使用 astropy.table 。看见 统一文件读写接口 了解更多详细信息。

功能#

read_table_hdf5(input[, path, ...])

从HDF5文件中读取表对象。

write_table_hdf5(table, output[, path, ...])

将表对象写入HDF5文件。

astropy.io.misc.yaml模块#

将Asty对象序列化为YAML的函数。

它提供了功能 dump, load, and load_all which call the corresponding functions in PyYaml 但请使用 AstropyDumperAstropyLoader 类来定义下列Astery类的自定义YAML标记:- astropy.units.Unit - astropy.units.Quantity - astropy.time.Time - astropy.time.TimeDelta - astropy.coordinates.SkyCoord - astropy.coordinates.Angle - astropy.coordinates.Latitude - astropy.coordinates.Longitude - astropy.coordinates.EarthLocation - astropy.table.SerializedColumn

实例#

>>> from astropy.io.misc import yaml
>>> import astropy.units as u
>>> from astropy.time import Time
>>> from astropy.coordinates import EarthLocation
>>> t = Time(2457389.0, format='mjd',
...          location=EarthLocation(1000, 2000, 3000, unit=u.km))
>>> td = yaml.dump(t)
>>> print(td)
!astropy.time.Time
format: mjd
in_subfmt: '*'
jd1: 4857390.0
jd2: -0.5
location: !astropy.coordinates.earth.EarthLocation
ellipsoid: WGS84
x: !astropy.units.Quantity
    unit: &id001 !astropy.units.Unit {unit: km}
    value: 1000.0
y: !astropy.units.Quantity
    unit: *id001
    value: 2000.0
z: !astropy.units.Quantity
    unit: *id001
    value: 3000.0
out_subfmt: '*'
precision: 3
scale: utc
>>> ty = yaml.load(td)
>>> ty
<Time object: scale='utc' format='mjd' value=2457389.0>
>>> ty.location  
<EarthLocation (1000., 2000., 3000.) km>

功能#

load \(流)

使用AstropyLoader解析流中的第一个YAML文档并生成相应的Python对象。

load_all \(流)

使用AstropyLoader类解析流中的所有YAML文档并生成相应的Python对象。

dump(data[, stream])

使用AstropyDumper类将Python对象序列化为YAML流。

Classes#

AstropyLoader \(流)

自定义SafeLoader,用于构造astropy核心对象以及Python元组和unicode对象。

AstropyDumper(stream[, default_style, ...])

自定义SafeDumper,表示astropy核心对象以及Python元组和unicode对象。

类继承图#

Inheritance diagram of astropy.io.misc.yaml.AstropyLoader, astropy.io.misc.yaml.AstropyDumper

Asterpy.io.misc.拼花地板模块#

此包包含用于读取和写入拼图表格的函数,这些函数并非直接使用,而是作为中的读取器/写入器使用 astropy.table 。看见 统一文件读写接口 了解更多详细信息。