科学网

 找回密码
  注册

tag 标签: HDF5

相关帖子

版块 作者 回复/查看 最后发表

没有相关内容

相关日志

python读hdf5文件
qianlivan 2020-10-23 14:14
读hdf5文件和读fits差不多,需要知道类似文件头的东西,这里是一个变量的名称。这可以通过定义一个prt函数结合h5py报的工具来实现如下 def prt(name): print(name) filename=sys.argv f = h5py.File(filename, 'r') f.visit(prt) 知道了变量名以后就可以读取相应的数据了。例如 vx=np.array(f ) 之后就和通常的操作一样了。总的读取数据画图的脚本如下。 import h5py import sys import numpy as np import matplotlib.pyplot as plt import matplotlib matplotlib.style.use('classic') def prt(name): print(name) filename=sys.argv f = h5py.File(filename, 'r') f.visit(prt) vx=np.array(f ) integrated_vx=np.sum(vx,axis=0) plt.imshow(integrated_vx) plt.show()
个人分类: 知识|2382 次阅读|0 个评论
LEDAPS&LaSRC安装(1) WSL下源码安装hdf4, hdf5, hdfeos-2018年
sunqing3020590 2018-10-24 10:51
处理遥感数据,为了安装LEDAPS和LaSRC,必须先安装hdf4和hdf5,hdfeos。 但是经过测试,由apt-get install 安装的hdf4, hdf5,hdfeos的静态库在安装espa-product-formatter时老是出现各种ERROR,无奈只能所有手动安装,之后才能正常使用。也许可能没找对库的版本吧。。。。 由于环境的需要,以及方便的使用Win及Linux 系统,本人的环境是在WSL下Ubuntu 16.04.3 (Win subsystem for linux) 主要参考姜浩师兄的博文 http://blog.sciencenet.cn/blog-2919002-1053770.html 其实手动安装也比较简单,主要是安装到自己指定的目录里(例如/home/sunqing/libs/hdf4/)。 以下是安装步骤: 在安装时出现找不到byacc,yacc库, 安装hdf4时候出现错误提示:configure: error: cannot find yacc utility 于是安装之: Install yacc: apt-get install bison flex byacc Install HDF4: wget ftp://edhs1.gsfc.nasa.gov/edhs/hdfeos/latest_release/hdf-4.2.13.tar.gz ./configure --disable-fortran -- prefix=/home/sunqing/libs/hdf4/ make make check make install 然后在~/.bashrc中设置: export HDFINC=/home/chexh/LIBS/hdf-4.2.13/include/ export HDFLIB=/home/chexh/LIBS/hdf-4.2.13/lib/ 安装hdfeos出现错误: install hdfeos can't link against HDF4 library 主要原因是没有安装对hdf4的库,由于我之前是有apt-get安装的,所以手动安装更可靠。同时要在bashrc中更改hdf4指定路径。 Install HDFEOS and GCTP: wget ftp://edhs1.gsfc.nasa.gov/edhs/hdfeos/latest_release/HDF-EOS2.20v1.00.tar.Z ./configure --prefix=/home/chexh/LIBS/hdfeos --with-hdf4=/home/chexh/LIBS/hdf-4.2.13 make make check make install 然后在bashrc中设置: export HDFEOS_GCTPINC=/home/chexh/LIBS/hdfeos/include/ export HDFEOS_GCTPLIB=/home/chexh/LIBS/hdfeos/lib/ export HDFEOS_INC=/home/chexh/LIBS/hdfeos/include/ export HDFEOS_LIB=/home/chexh/LIBS/hdfeos/lib/ Install HDF5: wget https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.10/hdf5-1.10.4/src/hdf5-1.10.4.tar.gz ./configure --prefix=/home/chexh/LIBS/hdf5 make make install 然后在bashrc中设置: export HDF5INC=/home/chexh/LIBS/hdf5-1.10.4/include/ export HDF5LIB=/home/chexh/LIBS/hdf5-1.10.4/lib/ 安装成功! NEXT STEP~ 当然,是边编译espa-product-formatter之后才发现这么多问题才去解决的。
4613 次阅读|0 个评论
Compile GDAL with supports for HDF4, HDF5 and netCDF
peluo 2017-7-28 08:34
Ref: https://trac.osgeo.org/gdal/ticket/3957 There will be a conflict between the internal netcdf api in hdf4 and netcdf. To avoid this conflict, disable the netcdf api when building the hdf4 library using --disable-netcdf The following configuration works on Bluewaters: hdf5: ./configure --prefix=$prefix --with-szlib=$prefix --disable-fortran --enable-cxx hdf4: ./configure --prefix=$prefix --with-szlib=$prefix --disable-netcdf --disable-fortran --enable-shared netcdf: ./configure --prefix=$prefix --with-hdf5=$prefix --enable-netcdf4 --enable-hdf4 --with-hdf4=$prefix --with-szlib=$prefix --with-zlib=/usr --enable-shared ************************** (1) script to build hdf4: #!/bin/bash cd /u/sciteam/peng1/bin/HDF4/hdf-4.2.12 ./configure --prefix=/projects/sciteam/gkj/local/hdf-4.2.12/ \ --with-zlib=/projects/sciteam/gkj/local/zlib-1.2.11/ \ --with-jpeg=/projects/sciteam/gkj/local/jpeg-6b/ \ --with-szlib=/projects/sciteam/gkj/local/szip-2.1.1/ \ --disable-fortran --disable-netcdf --enable-shared make make install (2) script to build hdf5 #!/bin/bash cd /u/sciteam/peng1/bin/hdf5-1.10.1 ./configure --prefix=/projects/sciteam/gkj/local/hdf5-1.10.1/ \ --with-zlib=/projects/sciteam/gkj/local/zlib-1.2.11/ \ --with-szlib=/projects/sciteam/gkj/local/szip-2.1.1/ \ --disable-fortran \ --enable-cxx make make install (3) script to build netCDF C version #!/bin/bash export H5DIR=/projects/sciteam/gkj/local/hdf5-1.10.1/ export H4DIR=/projects/sciteam/gkj/local/hdf-4.2.12/ export CPPFLAGS=-I${H5DIR}/include -I${H4DIR}/include export LDFLAGS=-L${H5DIR}/lib -L${H4DIR}/lib export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${H5DIR}/lib:${H4DIR}/lib cd /u/sciteam/peng1/bin/netcdf-c-4.4.1 ./configure --prefix=/projects/sciteam/gkj/local/netcdf-c-4.4.1/ \ --enable-netcdf4 \ --enable-hdf4 \ --enable-shared make check make install (4) script to build GDAL with supports to HDF4, HDF5 and netCDF #!/bin/bash module switch PrgEnv-cray/5.2.82 PrgEnv-gnu/5.2.82 export CFLAGS=-fPIC export CXXFLAGS=-fPIC export H5DIR=/projects/sciteam/gkj/local/hdf5-1.10.1/ export H4DIR=/projects/sciteam/gkj/local/hdf-4.2.12/ export NCDIR=/projects/sciteam/gkj/local/netcdf-c-4.4.1/ export CPPFLAGS=${CPPFLAGS} -I${H5DIR}/include -I${H4DIR}/include -I${NCDIR}/include export LDFLAGS=${LDFLAGS} -L${H5DIR}/lib -L${H4DIR}/lib -L${NCDIR}/lib -lnetcdf export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${H5DIR}/lib:${H4DIR}/lib:${NCDIR}/lib SOURCE_DIR='/u/sciteam/peng1/bin/gdal-2.2.0' INSTALL_DIR='/projects/sciteam/gkj/local/' cd $SOURCE_DIR ./configure \ --prefix=${INSTALL_DIR} \ --with-static-proj4 \ --with-geos \ --with-geotiff=internal \ --with-hide-internal-symbols \ --with-libtiff=internal \ --with-libz=internal \ --with-threads \ --without-bsb \ --without-cfitsio \ --without-cryptopp \ --without-curl \ --without-ecw \ --without-expat \ --without-fme \ --without-freexl \ --without-gif \ --without-gif \ --without-gnm \ --without-grass \ --without-grib \ -- without-hdf4 \ #when netcdf was build with enable hdf4, here we build GDAL without hdf4. Otherwise, gdal cannot open hdf4 files (for example, we may come across problems with gdalinfo for hdf4 files). --with-hdf5=${H5DIR} \ --without-idb \ --without-ingres \ --without-jasper \ --without-jp2mrsid \ --with-jpeg=internal \ --without-kakadu \ --without-libgrass \ --without-libkml \ --without-libtool \ --without-mrf \ --without-mrsid \ --without-mysql \ --with-netcdf=${NCDIR} \ --without-odbc \ --without-ogdi \ --without-openjpeg \ --without-pcidsk \ --without-pcraster \ --without-pcre \ --without-perl \ --without-pg \ --without-php \ --with-png=internal \ --with-python \ --without-qhull \ --without-sde \ --without-sqlite3 \ --without-webp \ --without-xerces \ --without-xml2 make clean make make install
个人分类: Linux|0 个评论
[转载]HDF5
gll89 2017-5-9 23:36
1.HDF5 is a completely new Hierarchical Data Format product consisting of a data format specification and a supporting library implementation. HDF5 is designed to address some of the limitations of the older HDF product . Note that HDF and HDF5 are two different products. HDF is a data format first developed in the 1980s and currently in Release 4. x (HDF Release 4. x ).HDF5 is a new data format first released in Beta in 1998 and designed to better meet the ever-increasing demands of scientific computing and to take better advantage of the ever-increasing capabilities of computing systems.HDF5 is currently in Release 1. x (HDF5 Release 1. x ). 2.HDF5 files are organized in a hierarchical structure, with two primary structures: groups and datasets . HDF5 group: a grouping structure containing instances of zero or more groups or datasets, together with supporting metadata. An HDF5 group is a structure containing zero or more HDF5 objects. A group has two parts A group header , which contains a group name and a list of group attributes. A group symbol table, which is a list of the HDF5 objects that belong to the group. HDF5 dataset: a multidimensional array of data elements, together with supporting metadata. A dataset is stored in a file in two parts: a header and a data array. The header contains information that is needed to interpret the array portion of the dataset, as well as metadata (or pointers to metadata) that describes or annotates the dataset. Header information includes the name of the object, its dimensionality, its number-type, information about how the data itself is stored on disk, and other information used by the library to speed up access to the dataset or maintain the file's integrity. There are four essential classes of information in any header: name , datatype , dataspace , and storage layout : Name. A dataset name is a sequence of alphanumeric ASCII characters. Datatype. HDF5 allows one to define many different kinds of datatypes. There are two categories of datatypes: atomic datatypes and compound datatypes. Atomic datatypes can also be system-specific, or NATIVE, and all datatypes can be named : Atomic datatypes include integers and floating-point numbers. Each atomic type belongs to a particular class and has several properties: size, order, precision, and offset. IEEE floating point datatypes: 32-bit and 64-bit Big-endian and little-endian H5T_IEEE_F32BE H5T_IEEE_F32LE H5T_IEEE_F64BE H5T_IEEE_F64LE Dataspace. A dataset dataspace describes the dimensionality of the dataset. The dimensions of a dataset can be fixed (unchanging), or they may be unlimited , which means that they are extendible (i.e. they can grow larger). Properties of a dataspace consist of the rank (number of dimensions) of the data array, the actual sizes of the dimensions of the array, and the maximum sizes of the dimensions of the array. For a fixed-dimension dataset, the actual size is the same as the maximum size of a dimension. When a dimension is unlimited, the maximum size is set to the value H5P_UNLIMITED. From: https://support.hdfgroup.org/HDF5/doc1.8/H5.intro.html
个人分类: Python|1203 次阅读|0 个评论
Linux下实现HDF4、HDF5、NetCDF-C和NetCDF-Fortran源码编译安装
zhoufcumt 2015-5-1 03:59
Fedora 20下实现HDF4、HDF5、NetCDF-C和NetCDF-Fortran源码编译安装,有需要的可发送邮件至zhouforme@163.com索取安装包、配置流程及运行脚本,邮件请注明单位、姓名及用途。
个人分类: LINUX|10962 次阅读|0 个评论
install netcdf hdf5 antlr udunits in linux
yaozhixiong 2012-11-30 10:50
在集群上面安装软件netcdf hdf5 antlr udunits **************************************** Install hdf (hdf5-1.8.10) . / configure -- prefix = /public/userspace/yaozhixiong/program/hdf -- enable - shared -- enable - hl make make install **************************************** Install netcdf (netcdf-4.2.1) LDFLAGS =- L / public/userspace/yaozhixiong/program/hdf / lib CPPFLAGS =- I / public/userspace/yaozhixiong/program/hdf / include ./ configure -- enable - netcdf - 4 -- enable - dap -- enable - shared -- prefix = / public/userspace/yaozhixiong/program/netcdf make make install **************************************** Install antlr ( antlr2.7.7) 参考 http://blog.wamaker.net/post/antlr-installation ./configure –with-cxx=g++ –with-java –enable-cxx –prefix=/public/userspace/yaozhixiong/program/antlr make make install **************************************** install udunits (udunits-2.1.24) 参考 http://bla.sphemo.us/2011/03/18/compile-and-install-nco-netcdf-operators-on-linux/ CC=gcc CXX=' ' F77=gfortran ./configure --prefix=/public/userspace/yaozhixiong/program/udunits make make install
个人分类: linux|6700 次阅读|0 个评论
netcdf安装 、zlib 、szip、hdf5、mpich2、curl系列软件安装
热度 5 cwjwang 2012-9-20 14:00
最近装netcdf, 发现网上的许多方法都不完善,许多库文件与头文件的位置没有加入默认的文件夹里,以至于安装netcdf总会提醒缺少这个库,那个库的。亲自动手,记录安装过程,以便查询 装netcdf 需要 zlib szip netcdf hdf5 curl mpich2 这些软件 其中zlib,szip是hdf5与netcdf需要的库文件,二者可以二选一。 (1) 下载这些源代码 (2) 安装zlib tar -zxvf zlib***.tar.gz cd zlib* mkdir /usr/local/zlib ./configure --prefix=/usr/local/zlib --libdir=/usr/lib/ --includedir=/usr/lib/ --sharedlibdir=/usr/share 其中 --libdir=/usr/lib/ --includedir=/usr/lib/一定写上,把库文件与头文件装在系统默认搜寻的地方,免得后面设置LD_LIBRARY_PATH ,如果不懂可用./configure --help 查看 make make check make install (3)安装szip tar -zxvf szip***.tar.gz cd szip* mkdir /usr/local/szip ./configure --prefix=/usr/local/szip --libdir=/usr/lib/ --includedir=/usr/lib/ --sharedstatedir=/usr/share --bindir=/usr/bin/ 其中--bindir=/usr/bin/表示把可执行的二进制的文件放入默认的地方,就不用设置PATH了 make make check make install (3) 安装curl tar -zxvf curl***.tar.gz cd curl* mkdir /usr/local/curl ./configure --prefix=/usr/local/curl --libdir=/usr/lib/ --includedir=/usr/include/ --sharedstatedir=/usr/share --bindir=/usr/bin/ make make check make install (4)安装mpich2 tar -zxvf mpich***.tar.gz cd mpich* mkdir /usr/local/mpich ./configure --prefix=/usr/local/mpich --libdir=/usr/lib/ --includedir=/usr/lib/ --sharedstatedir=/usr/share --bindir=/usr/bin/ make make check make install (5) 安装hdf5 tar -zxvf hdf5***.tar.gz cd hdf5* mkdir /usr/local/hdf5 ./configure --prefix=/usr/local/hdf5 --libdir=/usr/lib/ --includedir=/usr/lib/ --sharedstatedir=/usr/share --bindir=/usr/bin/ make make check make install (6)安装netcdf tar -zxvf netcdf***.tar.gz cd netcdf* mkdir /usr/local/netcdf ./configure --prefix=/usr/local/netcdf --libdir=/usr/lib/ --includedir=/usr/lib/ --sharedstatedir=/usr/share --bindir=/usr/bin/ 如果装了intel编译器,会提示math.h的错误,加上CC=icc make make check make install 完美收官!
27261 次阅读|17 个评论
认识HDF
bluewind23 2010-12-27 09:58
HDF是用于存储和分发科学数据的一种自我描述、多对象文件格式。HDF是由美国国家超级计算应用中心(NCSA)创建的,以满足不同群体的科学家在不同工程项目领域之需要。HDF可以表示出科学数据存储和分布的许多必要条件。HDF被设计为: 自述性:对于一个HDF文件里的每一个数据对象,有关于该数据的综合信息(元数据)。在没有任何外部信息的情况下,HDF允许应用程序解释HDF文件的结构和内容。 通用性:许多数据类型都可以被嵌入在一个HDF文件里。例如,通过使用合适的HDF数据结构,符号、数字和图形数据可以同时存储在一个HDF文件里。 灵活性:HDF允许用户把相关的数据对象组合在一起,放到一个分层结构中,向数据对象添加描述和标签。它还允许用户把科学数据放到多个HDF文件里。 扩展性:HDF极易容纳将来新增加的数据模式,容易与其他标准格式兼容。 跨平台性:HDF是一个与平台无关的文件格式。HDF文件无需任何转换就可以在不同平台上使用。 HDF提供6种基本数据类型:光栅图像(RasterImage),调色板(Palette),科学数据集(ScientificDataSet),注解(Annotation),虚拟数据(Vdata)和虚拟组(Vgroup)。 RasterImage数据模型被设计成能为光栅图像数据的存储和描述提供一个灵活的方法,包括8比特和24比特光栅图像。 Palette作为颜色查找表提供图像的色谱。它是一个表格,其表中每列的数字表示特定颜色的数字。 ScientificDataSet模型是用来存储和描述科学数据的多维数组。 Vdata模式是用来存储和描述数据表格的结构。 HDF的Annotations是文本字符串,用来描述HDF文件,或HDF文件包含的HDF数据对象。 Vgroup结构模型被设计为与相关数据对象有关。一个Vgroup可以包含另一个Vgroup以及数据对象。任何HDF对象都可以包含在一个Vgroup中。 HDF库为每一个数据模型提供一个应用编程接口。 最好的办法是把HDF文件看成为一本有表格内容的多章节书。HDF文件是“数据书”,其中每章都包含一个不同类型的数据内容。正如书籍用一个目录表列出它的章节一样,HDF文件用“dataindex”(数据索引)列出其数据内容。 HDF文件结构包括一个fileid(文件号)、至少一个datadescriptor(数据描述符)、没有或多个dataelement(数据内容)数据内容。 fileid(文件号)是一个32比特的值,最多占用HDF文件的头4个字节。通过读取这个值,应用程序就知道此文件是否是一个HDF文件。 Datadescriptorblock(数据描述符块)包含一个数据描述符数值。所有的数据描述符都是12字节长,包含4个域,即一个16比特长的标签,一个16比特的引用字,一个32比特的数据偏移量和一个32比特的数据长度。 tag(标记)是数据描述符域,表示存于相应数据内容的数据类型。例如306是光栅图像对象的识别符。 Referencenumber(引用号)是一个16比特无符号整型数。HDF文件中的每一个对象,由HDF库和数据描述符中的标签确定一个唯一的引用字。在引用字确定的数据对象期间,标签和引用字不能改变。标签和引用字的结合可以唯一确定文件中对应的数据对象。 引用字没有必要连续指定,因此,在一个具有相同标签区分对象的方法后,不能假设引用字的值有任何意义。有时应用程序员也会发现在他们的程序中把一些另外的信息加到引用字中是很方便的,但必须强调的是,HDF库本身并不识别这些含义。 Dataoffsetfield(数据偏移量)是一个32比特无符号整型字。通过存储文件开始时的字节数和数据内容开始时的字节数,指明文件中数据内容的位置。 Lengthfield(长度域)是一个32比特无符号整型字。它表示整个数据内容的字节大小。数据内容增加,其长度也要增加。 Dataelement(数据成分)是数据对象的原始数据部分,包含每个象素的值。 HDF5被设计为改善HDF4的一些局限性。HDF4的某些局限性有:单个文件不能存放多于20000个对象,单个文件大小也不能大于2G字节。数据模式的兼容性不够好,有过多的对象类型,数据类型太严格。库函数过时和过于复杂,不能有效地支持并行口的I/O,很难用于线程应用中。 HDF5包含如下的改进: 被设计为一种新的格式用来改进HDF4.x,特别是每个文件可以存储更大的文件和更多的对象。 数据模式更简洁、更全面,它包含两个基本结构:多维数组记录结构,和分组结构。 更简洁、更利于工程库和应用编程接口,支持并行I/O,线程和其他一些现代系统和应用要求。 HDF文件的3层交互 HDF文件可以在几个交互层次中可视。在最底层,HDF是一个存储科学数据的物理文件格式。在它的最高层,HDF是集工具和应用于一体的数据文件,可以对HDF文件中的数据进行修改、显示和分析。在这两个层次之间,HDF是一个能提供高层和底层编程接口的软件库。 基本接口层,或称为底层的应用编程接口(API),是为软件开发者保留的。它是为数据流的直接文件I/O、错误处理、内存管理和物理存储而设计的。它是一个为有经验的HDF程序员提供的软件工具。比较目前从高层接口得到的功能,通过使用这些基本接口层,HDF程序员创建HDF文件时能够做更多的事。底层接口例程只提供C语言。 HDFAPIs(HDF应用编程接口)分为两类:多文档接口(用于新版本)和单文档接口(用于旧版本)。多文档接口是提供从一个应用中同时连接几个HDF文件的接口,这点很重要,但单文档接口并不支持这点。用户在开发新的接口和界面时,必须提醒他们是在一个改进了的新接口版本下开发的。为了向上兼容,旧版本仍然保留。 HDFAPIs包含几个独立的例程集,每个例程集是专门为简化一种数据类型的存储处理而设计的。这些接口作为单文件和多文件层。尽管每个接口都要求程序调用,但所有底层细节都可以忽略。大多数情况下,只须在正确的时间调用正确的函数,剩下的事就由接口程序处理。多数HDF接口例程都有FORTRAN-77和C语言。也有用于Java程序员访问HDF文件的JavaHDF接口程序。
个人分类: 高性能服务|6847 次阅读|0 个评论

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-6-11 16:51

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部