gizmo快照io的轻量级python包
gizio的Python项目详细描述
Gizio
用于GIZMO快照io的轻量级python包
关于
有two snapshot reading scriptsreadsnap.py
和load_from_snapshot.py
伴随着GIZMO source code。Gizio的目标是用几个改进来取代load_from_snapshot.py
:
- 由unyt 供电的单元系统
- 无需修改源代码即可轻松定制格式规范
- 更易于作为python包安装和维护
演示
可以下载样本数据here。
加载快照:
>>>importgizio>>>snap=gizio.load('data/FIRE_M12i_ref11/snapshot_600.hdf5')
查看标题:
>>>snap.header{'time':unyt_quantity(13.79874688,'Gyr'),'n_file':1,'mass_tab':unyt_array([0.,0.,0.,0.,0.,0.],'code_mass'),'f_sfr':1,'f_cool':1,'f_fb':1,'f_age':1,'f_met':11,'n_part':array([753678,1104128,2567905,0,361239,0],dtype=uint32),'n_part_pf':[array([753678,1104128,2567905,0,361239,0],dtype=int32)],'box_size':unyt_quantity(60000.,'code_length'),'Om0':0.272,'OmL':0.728,'h':0.702,'z':0.0,'cosmological':True}
加载字段:
>>>snap['PartType0','Masses']unyt_array([3.175186e-05,3.175186e-05,3.175186e-05,...,3.175186e-05,3.175186e-05,3.175186e-05],dtype=float32,units='code_mass')
使用速记加载字段:
>>>snap.pt['gas']['m']unyt_array([3.175186e-05,3.175186e-05,3.175186e-05,...,3.175186e-05,3.175186e-05,3.175186e-05],dtype=float32,units='code_mass')
通过掩蔽选择粒子:
>>>gas=snap.pt['gas']>>>hot_gas=gas[gas['t'].to_value('K')>1e5]>>>hot_gas['t'].min()unyt_quantity(100000.79,dtype=float32,units='K')
通过组合选择粒子:
>>>star=snap.pt['star']>>>baryon=gas|star>>>len(gas)753678>>>len(star)361239>>>len(baryon)1114917>>>baryon['m']unyt_array([3.1751861e-05,3.1751861e-05,3.1751861e-05,...,2.2581291e-05,2.3056862e-05,2.7417644e-05],dtype=float32,units='code_mass')
安装
从pypi安装最新稳定版本:
pip install gizio
从源安装开发版本:
git clone https://github.com/galaxy-lab/gizio.git
cd gizio
pip install -e .