Read Matlab Files In Idl
Posted By admin On 10/05/18Contents • • • • • • • • • • • • • • ICARE HDF reader ICARE has developed a package of libraries written in Fortran77, Fortran90, C, Python, IDL, MATLAB and R. They mainly contain functions for: • obtaining informations about the structure of an HDF file • extracting SDS data • reading SDS and file attributes • calibrating data Download Sources can be downloaded here: Packages can be browsed here: Usage See the the README files of the desired language for a detailed description of the way to use the library Examples In all languages directories, some real examples of usage of the library are available in the./example directory. This is the place to begin for a quick start Language HDF4 PYTHON. # -*- coding: utf-8 -*- #!/usr/local/bin/python from pyhdf import SD # HDF file and SDS names FILE_NAME = 'MYD04_L2. Numark Cue 4.3 Serial Number more. A20.0021359.hdf' SDS_NAME = 'Optical_Depth_Land_And_Ocean' # open the hdf file hdf = SD. SD (FILE_NAME ) # select and read the sds data sds = hdf. Select (SDS_NAME ) data = sds.
Get ( ) # get dataset dimensions nrows, ncols = data. Shape # data.shape: (3712, 3712) in the SEVIRI AER-OC example, 203 print data. Shape # data.shape: (3712, 3712) in the SEVIRI AER-OC example, (203, 135) i= 200 # row index j= 125 # col index print data [ 200, 125 ] # Terminate access to the data set sds. Sik Trix Bmx Full Game.
Endaccess ( ) # Terminate access to the SD interface and close the file hdf. PRO read_hdf FILE_NAME = 'MYD04_L2.A20.0021359. Smart Plant P. hdf'; nrows=203, ncols=135 SDS_NAME = 'Optical_Depth_Land_And_Ocean'; Open the file sd_id = HDF_SD_START (FILE_NAME, / read ); Find the index of the sds to read using its name sds_index = HDF_SD_NAMETOINDEX (sd_id, SDS_NAME ); Select it sds_id = HDF_SD_SELECT (sd_id, sds_index ); Get data set information including dimension information HDF_SD_GetInfo, sds_id, name = SDS_NAME, natts = num_attributes, ndim = num_dims, dims = dim_sizes nrows = dim_sizes [ 1 ] ncols = dim_sizes [ 0 ]; Define subset to read. Start is [0,0].
Start = INTARR ( 2 ); the start position of the data to be read start [ 0 ] = 0 start [ 1 ] = 0 edges = INTARR ( 2 ); the number of elements to read in each dimension edges [ 0 ] = dim_sizes [ 0 ] edges [ 1 ] = dim_sizes [ 1 ]; Read the data: you can notice that here, it is not needed to allocate the data array yourself HDF_SD_GETDATA, sds_id, data, start = start, count = edges i = 200; row index j = 125; col index PRINT, FORMAT = '(I,' ',$)', data [j,i ]; 65 PRINT, '; end access to SDS HDF_SD_ENDACCESS, sds_id; close the hdf file HDF_SD_END, sd_id END MATLAB. Program sds_info use hdf5 implicit none! Variables declaration CHARACTER * 100:: file_name CHARACTER * 100:: sds_name CHARACTER * 100:: gr_name CHARACTER * 100:: attr_name INTEGER (HID_T ):: file_id, gr_id, dset_id, attr_id INTEGER:: status, error, storage, nlinks,max_corder, attr_num REAL, DIMENSION ( 10, 10 ):: dset_data, data_out INTEGER, DIMENSION ( 1: 10 ):: buf INTEGER (HSIZE_T ), DIMENSION ( 2 ):: data_dims INTEGER (HSIZE_T ), DIMENSION ( 1 ):: dims! Variables initalization file_name = 'example.h5' sds_name = '/g1/g1.1/dset1.1.1' gr_name = 'g3' attr_name = 'attr1'! Initialize the interface call h5open_f ( status )!