comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Looking for IDL Structures to Python compatible HDF5 Examples
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Looking for IDL Structures to Python compatible HDF5 Examples [message #91813] Tue, 01 September 2015 10:33 Go to previous message
eben.pendleton is currently offline  eben.pendleton
Messages: 2
Registered: September 2015
Junior Member
Hi all,

I'm looking for code examples of writing ODL structures to HDF5 tables that can be read in Python (2.7). Filenames are removed

I've tried the following approach using the IDL coyote guide to create the file in IDL 7.1:

pro write_idl_struct_to_hdf5,struct,dir_out,outfile

file = dir_out+outfile+'.h5'
fid = H5F_CREATE(file)

datatype_id = H5T_IDL_CREATE(struct)
dataspace_id=H5S_CREATE_SIMPLE(1) ; not so simple..

dataset_id = H5D_CREATE(fid,'o',datatype_id,dataspace_id)
H5D_WRITE, dataset_id, struct

H5S_CLOSE, dataspace_id
H5T_CLOSE, datatype_id

H5F_CLOSE, fid

print,'---Finished Writing IDL struct to HDF5---'
end


Python code and Error
import pandas as pd
dir_in=r'C:\D_Drive\Python\hdf5'
infile=...

mynewdf = pd.HDFStore(dir_in+'\\'+infile)
print(mynewdf)

print(mynewdf.select('o',columns='TASK_NAME'))


resulting in:
<class 'pandas.io.pytables.HDFStore'>
File path: ...
/o frame_table [0.0.0] (typ->generic,nrows->1,ncols->63,indexers->[index],dc-> [TASK_CODE,TASK_NAME,EVENT,SYS_LOC_CODE,SUBFACILITY_CODE,ARE A,RIVER_STREAM_MILE,MILES_FROM_NC_MOUTH,X_COORD,Y_COORD,COOR D_TYPE_CODE,REFERENCE_POINT,ELEV,ELEV_UNIT,ELEV_COLLECT_METH OD_CODE,ELEV_DATUM_CODE,WATER_COLUMN_DEPTH,WATER_COLUMN_DEPT H_UNIT_CODE,SYS_SAMPLE_CODE,PARENT_SAMPLE_CODE,MATRIX_CODE,L AB_MATRIX_CODE,SAMPLE_TYPE_CODE,SAMPLE_DATE,START_DEPTH,END_ DEPTH,DEPTH_UNIT,DEPTH_INTERVAL,SEDIMENT_NATIVE,GROUP_DESC,C HEMICAL_NAME,CAS_RN,FRACTION,ANALYTIC_METHOD,LEACHATE_METHOD ,PREP_METHOD,RESULT_VALUE,LAB_QUALIFIERS,VALIDATOR_QUALIFIER S,INTERPRETED_QUALIFIERS,DETECT_FLAG,TARGET_UNIT,REPORTABLE_ RESULT,VALIDATED_YN,VALIDATOR_REASON_CODE,BASIS,METHOD_DETEC TION_LIMIT,REPORTING_DETECTION_LIMIT,DILUTION_FACTOR,LAB_NAM E_CODE,LAB_SAMPLE_ID,ANL_SHORT_NAME,PARENT_LOC_CODE,DATA_REL EASE_STATUS,DATA_ANALYSIS_HIERARCHY,RESULT_VALUE_MDL,RISK_SC REEN_USABILITY,BASELINE_RA_USABILITY,CAS_RN_4PROUCL,CHEMICAL _NAME_4PROUCL,TREATMENT_FLAG_4PROUCL,CHEMICAL_NAME_4LABEL,US ABILITY_HIERARCHY])

The error generated is
ValueError: Wrong number of items passed 283774, placement implies 1

The 283774 number is the number of rows in the structure and it seems that each tag in the dataframe has one row with 283774 elements.

Is there some layout adjustment that's needed to read a structure correctly in HDF5?

Eben
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Dialog_pickfile /DIRECTORY too low on the screen
Next Topic: converting netcdf data format to hdf5

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 08:51:07 PDT 2025

Total time taken to generate the page: 0.00467 seconds