Adding CF Attributes to an HDF5 File

Slides:



Advertisements
Similar presentations
The HDF Group July 8, Summer ESIP Federation Meeting How to Meet the CF Conventions with NcML for NASA HDF/HDF-EOS Hyo-Kyung.
Advertisements

HDF-EOS 2/5 to netCDF Converter Bob Bane, Richard Ullman, Jingli Yang Data Usability Group NASA/Goddard Space Flight Center.
The HDF Group HDF/HDF-EOS Workshop XIV1 Easy Remote Access via OPeNDAP Kent Yang and Joe Lee The HDF Group The 14 th HDF/HDF-EOS Workshop.
The HDF Group November 3-5, 2009HDF/HDF-EOS Workshop XIII1 HDF-Java Products Peter Cao The HDF Group The 13 th HDF and HDF-EOS Workshop.
The HDF Group HDF Group Support for NPP/JPSS Mike Folk, Elena Pourmal, Larry Knox, Albert Cheng The HDF Group Briefing to ESDIS October.
The HDF Group HDF Group Support for NPP/JPSS Mike Folk, Elena Pourmal, Larry Knox, Albert Cheng The HDF Group The 15 th HDF and HDF-EOS.
The HDF Group ESIP Summer Meeting HDF-Java Overview Joel Plutchak The HDF Group 1 July 8 – 11, 2014.
HDF5 OPeNDAP Project Update and Demo MuQun Yang and Hyo-Kyung Lee (The HDF Group) James Gallagher (OPeNDAP, Inc.)
The Future of NetCDF Russ Rew UCAR Unidata Program Center Acknowledgments: John Caron, Ed Hartnett, NASA’s Earth Science Technology Office, National Science.
The HDF Group Apr , 2012HDF/HDF-EOS Workshop XV1 Interoperability with netCDF-4 Kent Yang, Larry Knox, Elena Pourmal The HDF Group.
11/6/07HDF and HDF-EOS Workshop XI, Landover, MD1 Introduction to HDF5 HDF and HDF-EOS Workshop XI November 6-8, 2007.
The HDF Group Introduction to HDF5 Barbara Jones The HDF Group The 13 th HDF & HDF-EOS Workshop November 3-5, HDF/HDF-EOS Workshop.
Support EOS: Review and Discussions Kent Yang and Joe Lee The HDF Group October 16, 2012 Oct. 16, 2012Annual HDF Briefing to ESDIS1.
The HDF Group HDF/HDF-EOS Workshop XIV1 Easy Access of NASA HDF data via OPeNDAP Kent Yang and Joe Lee The HDF Group September 28,2010.
1 CF Unleashed: Introduction to Cf/Radial Joe VanAndel National Center for Atmospheric Research 2013/1/8 The National Center for Atmospheric.
The HDF-EOS5 Tutorial Ray Milburn L3 Communciations, EER Systems Inc McCormick Drive, 170 Largo, MD USA
The HDF Group July 8, 2014HDF 2014 ESIP Summer Meeting HDF Product Designer Aleksandar Jelenak, H. Joe Lee, Ted Habermann The.
Ensuring Long Term Access to Remotely Sensed HDF4 Data with Layout Maps Mike Folks, The HDF Group Ruth Duerr, NSIDC 1.
1 of 14 Substituting HDF5 tools with Python/H5py scripts Daniel Kahn Science Systems and Applications Inc. HDF HDF-EOS Workshop XIV, 28 Sep
Netcdf course Intro CF convention Netcdf excercises.
NetCDF-4 The Marriage of Two Data Formats Ed Hartnett, Unidata June, 2004.
Important ESDIS 2009 tasks review Kent Yang, Mike Folk The HDF Group April 1st, /1/20151Annual briefing to ESDIS.
DM_PPT_NP_v01 SESIP_0715_AJ HDF Product Designer Aleksandar Jelenak, H. Joe Lee, Ted Habermann Gerd Heber, John Readey, Joel Plutchak The HDF Group HDF.
A Metadata Based Approach For Supporting Subsetting Queries Over Parallel HDF5 Datasets Vignesh Santhanagopalan Graduate Student Department Of CSE.
1 Introduction to HDF5 Data Model, Programming Model and Library APIs HDF and HDF-EOS Workshop VIII October 26, 2004.
Improving the usability of HDF-EOS2 data Kent Yang, Joe Lee, Choonghwan Lee The HDF Group March 31 st, /26/2016Annual briefing to ESDIS1.
HDF Converting between HDF4 and HDF5 MuQun Yang, Robert E. McGrath, Mike Folk National Center for Supercomputing Applications University of Illinois,
Tools for Interoperability between HDF and NetCDF Mike Folk and MuQun Yang The HDF Group The HDF Group provides the following tools for the NASA HDF and.
1/14/200925th IIPS Conference 1 Challenges to Archive and Access NASA HDF-EOS Data in the long Term MuQun Yang (The HDF Group) Choonghwan Lee (The HDF.
The netCDF-4 data model and format Russ Rew, UCAR Unidata NetCDF Workshop 25 October 2012.
HDF Dimension Scales in HDF5 HDF-EOS Workshop IX San Francisco, CA November 30 - December 2, 2005 Pedro Vicente Nunes THG/NCSA Champaign-Urbana, IL HDF.
The HDF Group October 28, 2010NetcDF Workshop1 Introduction to HDF5 Quincey Koziol The HDF Group Unidata netCDF Workshop October 28-29,
The HDF Group November 3-5, 2009 HDF-OPeNDAP Project Update HDF/HDF-EOS Workshop XIII1 Joe Lee and Kent Yang The HDF Group James Gallagher.
Ensuring Long Term Access to Remotely Sensed HDF4 Data with Layout Maps Ruth Duerr, NSIDC Christopher Lynnes, GES DISC The HDF Group Oct HDF and.
October 15, 2008HDF and HDF-EOS Workshop XII1 What will be new in HDF5?
HDF5 OPeNDAP Project Update and Demo MuQun Yang and Hyo-Kyung Lee (The HDF Group) James Gallagher (OPeNDAP, Inc.) 1HDF and HDF-EOS Workshop XII10/17/2008.
Integrating netCDF and OPeNDAP (The DrNO Project) Dr. Dennis Heimbigner Unidata Go-ESSP Workshop Seattle, WA, Sept
1 N-bit and ScaleOffset filters MuQun Yang National Center for Supercomputing Applications University of Illinois at Urbana-Champaign Urbana, IL
HDF OPeNDAP Project Update MuQun Yang and Hyo-Kyung Lee The HDF Group March 31, Annual briefing to ESDIS10/31/2015.
The HDF Group HDF/HDF-EOS Workshop XV1 Tools to Improve the Usability of NASA HDF Data Kent Yang and Joe Lee The HDF Group April 17, 2012.
- 1 - HDF5, HDF-EOS and Geospatial Data Archives HDF and HDF-EOS Workshop VII September 24, 2003.
The HDF Group Support for NPP/NPOESS by The HDF Group Mike Folk, Elena Pourmal, Peter Cao The HDF Group November 5, 2009 November 3-5,
NetCDF file generated from ASDC CERES SSF Subsetter ATMOSPHERIC SCIENCE DATA CENTER Conversion of Archived HDF Satellite Level 2 Swath Data Products to.
HDF Windows Support MuQun Yang, Xuan Bai, Elena Pourmal, Barbara Jones, Pedro Vincent, Robert E. McGrath National Center for Supercomputing Applications.
HDF5 OPeNDAP Project Update and Demo MuQun Yang and Hyo-Kyung Lee (The HDF Group) James Gallagher (OPeNDAP, Inc.) 1 HDF and HDF-EOS Workshop XII10/17/2008.
HDF5 OPeNDAP Project Update and Demo MuQun Yang and Hyo-Kyung Lee (The HDF Group) James Gallagher (OPeNDAP, Inc.) 1HDF and HDF-EOS Workshop XII, Aurora,
The HDF Group Data Interoperability The HDF Group Staff Sep , 2010HDF/HDF-EOS Workshop XIV1.
The HDF Group Introduction to netCDF-4 Elena Pourmal The HDF Group 110/17/2015.
HDF and HDF-EOS Workshop VII September 24, 2003 HDF5, HDF-EOS and Geospatial Data Archives Don Keefer Illinois State Geological Survey Mike Folk Univ.
Data File Formats: netCDF by Tom Whittaker University of Wisconsin-Madison SSEC/CIMSS 2009 MUG Meeting June, 2009.
11/8/2007HDF and HDF-EOS Workshop XI, Landover, MD1 Software to access HDF5 Datasets via OPeNDAP MuQun Yang, Hyo-Kyung Lee The HDF Group.
October 15-17, 2008HDF and HDF-EOS Workshop XII1 HDF-Java Products Peter Cao The HDF Group HDF and HDF-EOS Workshop XII October 15, 2008.
The HDF Group November 3-5, 2009HDF/HDF-EOS Workshop XIII1 The New HDF-EOS Web Site - How it can help you Kent Yang, Joe Lee The HDF Group.
The HDF Group 10/17/151 Introduction to HDF5 ICALEPCS 2015.
CF 2.0 Coming Soon? (Climate and Forecast Conventions for netCDF) Ethan Davis ESO Developing Standards - ESIP Summer Mtg 14 July 2015.
HDF5 OPeNDAP Project Update and Demo MuQun Yang and Hyo-Kyung Lee (The HDF Group) James Gallagher (OPeNDAP, Inc.) 1HDF and HDF-EOS Workshop XII, Aurora,
HDF/HDF-EOS Meeting Oct th 2008, Aurora CO Proposal for adding Named Dimensions to HDF5 Arrays Daniel Kahn Science Systems and Applications, Inc.
HDF and HDF-EOS Workshop XII
Can Data be Organized for Science and Reuse?
Plans for an Enhanced NetCDF-4 Interface to HDF5 Data
Introduction to HDF5 for HDF4 users
Access HDF5 Datasets via OPeNDAP’s Data Access Protocol (DAP)
HDF Support for NASA Data Producers
NetCDF and Scientific Data Standard
Introduction to HDF5 Mike McGreevy The HDF Group
Libcf – A CF Convention Library for NetCDF
Dimension Scales in HDF-EOS2 & HDF-EOS5
HDF-EOS Workshop XXI / The 2018 ESIP Summer Meeting
HDF5 Tools Updates and Discussions
NCL variable based on a netCDF variable model
Presentation transcript:

Adding CF Attributes to an HDF5 File Isayah Reed The HDF Group

Climate and Forecast Conventions Metadata conventions for earth science data Included in same file as data Description of what the data represents Uses values of universal attribute Extension of COARDS* conventions Allows comparison of data from different sources *Cooperative Ocean/Atmosphere Research Data Service URL: http://cf-pcmdi.llnl.gov/documents/cf-conventions/1.5/cf-conventions.pdf Not enough

Overview Programming examples that add CF attributes to an HDF5 file C, FORTRAN90, Python netCDF4 C, FORTRAN90 HDF5-EOS5 C, FORTRAN77 HDFView to add CF attributes

Problem Set Examples are based on a simple application Field Description temp Temperature 180x360 array lat Latitude 1-D array, size 180 lon Longitude 1-D array, size 360 Change the Overview( wrong words)

CF attributes added Attribute Description long_name A long descriptive name for the data. units The quantity of measurement. coordinates A list of the associated coordinate variable names of the variable. _FillValue A missing or undefined value. Short the description

HDF5-C Example Create the HDF5 file: Create temperature dataset: file = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); Create temperature dataset: dimsa[0] = 180; dimsa[1] = 360; dataset= H5Dcreate(file, “temp”, H5T_NATIVE_FLOAT, H5Screate_simple(2, dimsa, NULL), H5P_DEFAULT); Write temperature dataset: H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, temp_array); dimsa[0]= 180; dimsa[1]= 360; Figure 4.2 Add the units attribute stringType= H5Tcopy(H5T_C_S1); stringSpace= H5Screate(H5S_SCALAR); H5Tset_size(stringType, (hsize_t)strlen(“kelvin”)); attr= H5Acreate(dataset, “units”, stringType, stringSpace, H5P_DEFAULT); H5Awrite(attr,stringType,”kelvin”); float value= -999.0; floatSpace= H5Screate(H5S_SCALAR); floatType= H5Tcopy(H5T_NATIVE_FLOAT); attr= H5Acreate(dataset, “_FillValue”, floatType, floatSpace, H5Awrite(attr,floatType,&value); Add the _FillValue: H5Acreate(dataset, “_FillValue”, H5T_NATIVE_FLOAT, H5Screate(H5S_SCALAR), H5P_DEFAULT); H5Awrite(attr, H5T_NATIVE_FLOAT,&value);

HDF5-C Example Add the units attribute: Add the long_name attribute: H5Tset_size(stringType, (hsize_t)strlen(“kelvin”)); attr= H5Acreate(dataset, “units”, stringType, H5S_SCALAR, H5P_DEFAULT); H5Awrite(attr, stringType, ”kelvin”); Add the long_name attribute: H5Tset_size(stringType, (hsize_t) strlen("temperature")); attr= H5Acreate(dataset, “long_name”, stringType, stringSpace, H5P_DEFAULT, H5P_DEFAULT); H5Awrite(attr, stringType, "temperature"); dimsa[0]= 180; dimsa[1]= 360; Figure 4.2 Add the units attribute stringType= H5Tcopy(H5T_C_S1); stringSpace= H5Screate(H5S_SCALAR); H5Tset_size(stringType, (hsize_t)strlen(“kelvin”)); attr= H5Acreate(dataset, “units”, stringType, stringSpace, H5P_DEFAULT); H5Awrite(attr,stringType,”kelvin”); float value= -999.0; floatSpace= H5Screate(H5S_SCALAR); floatType= H5Tcopy(H5T_NATIVE_FLOAT); attr= H5Acreate(dataset, “_FillValue”, floatType, floatSpace, H5Awrite(attr,floatType,&value); Add the coordinates attribute: arraySpace = H5Screate_simple(1, &dimsa[0], NULL); H5Tset_size(arrayType, H5T_VARIABLE); attr= H5Acreate(dataset, “coordinates”, arrayType, arraySpace, H5P_DEFAULT); H5Awrite(attr, arrayType, coorlist);

FORTRAN90 Example Initialize FORTRAN interface and create the HDF5 file: CALL h5open_f(hdferr) CALL h5fcreate_f(FILENAME, H5F_ACC_TRUNC_F, file, hdferr) Create temperature dataset: CALL h5screate_simple_f(2, temp_dims, space, status) !! temp_dims = (360, 180) CALL h5dcreate_f(file, TEMPERATURE, h5t_ieee_f32le, space, dset, status) Write temperature dataset: CALL h5dwrite_f(dset, H5T_NATIVE_DOUBLE, temp_data, & temp_dims, status) dimsa[0]= 180; dimsa[1]= 360; Figure 4.2 Add the units attribute stringType= H5Tcopy(H5T_C_S1); stringSpace= H5Screate(H5S_SCALAR); H5Tset_size(stringType, (hsize_t)strlen(“kelvin”)); attr= H5Acreate(dataset, “units”, stringType, stringSpace, H5P_DEFAULT); H5Awrite(attr,stringType,”kelvin”); float value= -999.0; floatSpace= H5Screate(H5S_SCALAR); floatType= H5Tcopy(H5T_NATIVE_FLOAT); attr= H5Acreate(dataset, “_FillValue”, floatType, floatSpace, H5Awrite(attr,floatType,&value); Add the _FillValue: CALL h5screate_f(H5S_SCALAR_F, space, status) CALL h5tcopy_f(h5t_ieee_f32le, atype_id, status) CALL h5acreate_f(dset, FILLVALUE, atype_id, space, & attr_id, status) CALL h5awrite_f(attr_id, H5T_NATIVE_DOUBLE, -999, 1, status)

FORTRAN90 Example Add the units attribute: CALL h5screate_f(H5S_SCALAR_F, space, status) CALL h5tcopy_f(H5T_NATIVE_CHARACTER, atype_id, status) CALL h5tset_size_f(atype_id, 6, status) CALL h5acreate_f(dset, UNITS, atype_id, space, attr_id, status) CALL h5awrite_f(attr_id, atype_id, "kelvin", dimsf, status) Add the long_name attribute: CALL h5tset_size_f(atype_id, strlen, status) CALL h5acreate_f(dset, “long_name”, atype_id, space, & attr_id, status) CALL h5awrite_f(attr_id, atype_id, “temperature”, 1, status) dimsa[0]= 180; dimsa[1]= 360; Figure 4.2 Add the units attribute stringType= H5Tcopy(H5T_C_S1); stringSpace= H5Screate(H5S_SCALAR); H5Tset_size(stringType, (hsize_t)strlen(“kelvin”)); attr= H5Acreate(dataset, “units”, stringType, stringSpace, H5P_DEFAULT); H5Awrite(attr,stringType,”kelvin”); float value= -999.0; floatSpace= H5Screate(H5S_SCALAR); floatType= H5Tcopy(H5T_NATIVE_FLOAT); attr= H5Acreate(dataset, “_FillValue”, floatType, floatSpace, H5Awrite(attr,floatType,&value); Add the coordinates attribute: CALL h5screate_simple_f(1, 2, space, status) CALL h5tset_size_f(atype_id, strlen, status) CALL h5acreate_f(dset, “coordinates”, atype_id, space, & attr_id, status) CALL h5awrite_f(attr_id, atype_id, coorlist, 2, status)

H5PY A Python interface to the HDF5 library Supports nearly all HDF5-C features Combines advantages of Python and C Shorter and simpler function calls Powerful computational abilities Requires numpy and scipy   URL: http://code.google.com/p/h5py

H5PY Example Create an HDF5 file: Create/write dataset: file = h5py.File ("cf_example.h5", 'w') Create/write dataset: temp_dset = file.create_dataset ('temp', data=temp_array) Add the _FIllValue: temp_dset.attrs.create ('_FillValue', data=-999.0, dtype ='f')

H5PY Example Add the units attribute: Add the long_name attribute: temp_dset.attrs["units"] = "kelvin” Add the long_name attribute: temp_dset.attrs["long_name"] = "temperature” Add the coordinates attribute: vlen = h5py.special_dtype (vlen = str) temp_dset.attrs.create ('coordinates', data = ['lat', 'lon'], dtype=vlen)

netCDF-4 Extends netCDF3 Built on the HDF5 library Uses HDF5 for storage and performance Chunking and compression C and FORTRAN libraries Simple function calls URL: http://www.unidata.ucar.edu/software/netcdf/docs/netcdf Reduce the words

C Example Create a netCDF4 file: Define the temperature variable: nc_create(FILE_NAME, NC_NETCDF4|NC_CLOBBER, &ncid) Define the temperature variable: nc_def_var(ncid, “temp”, NC_FLOAT, 2,dimsa, &varid); Add the _FillValue: nc_def_var_fill(ncid, varid, 0, &fillvalue); Write the temperature data: nc_put_var_float(ncid, varid, &temp_array[0][0]));

C Example Add the units attribute: Add the long_name attribute: nc_put_att_text(ncid, varid, “units”, strlen(“kelvin”), “kelvin”); Add the long_name attribute: nc_put_att_text(ncid, varid, “long_name”, strlen(“temperature”), “temperature”); Add the coordinates attribute: char *coorlist[2]= {"lat", "lon"}; nc_put_att_string(ncid, varid, “coordinates”, 2, (const char**)&coorlist);

FORTRAN90 Example Create the netCDF4 file: nf90_create(path=filename, cmode=IOR(NF90_CLOBBER,NF90_HDF5), ncid=ncid) Define the temperature variable: nf90_def_var(ncid, “temp”, NF90_FLOAT, (/180,360/), varid) Add the _FillValue: nf90_def_var_fill(ncid, varid, 0, -999) Write the temperature data: nf90_put_var(ncid, varid, temp_data)

FORTRAN90 Example Add the units attribute: nf90_put_att(ncid, varid, “units, "kelvin") Add the long_name attribute: nf90_put_att(ncid, varid, “long_name”, "temperature")   Add the coordinates attribute: nf90_put_att(ncid, varid, “coordinates”, “latitude”) nf90_put_att(ncid, varid, “coordinates”, “longitude”)

HDF-EOS5 Built on HDF5 Associates geolocation data to scientific data extends HDF5 uses HDF5 library calls as a foundation Associates geolocation data to scientific data Additional definitions points, swaths, grids URL: http://newsroom.gsfc.nasa.gov/sdptoolkit/docs/HDF-EOS_UG.pdf

C Example Create a swath: Define dimensions: HE5_SWcreate(file, "Swath 1"); Define dimensions: HE5_SWdefdim(swid, "GeoXtrack", 180); HE5_SWdefdim(swid, "GeoTrack", 360); Define temperature data field: HE5_SWdefdatafield(swid, “temp”, "GeoTrack,GeoXtrack", NULL, H5T_NATIVE_FLOAT, 0); Set _FillValue: HE5_SWsetfillvalue(swid, “temp”, H5T_NATIVE_FLOAT, &value); Write the temperature data: HE5_SWwritefield(swid, “temp”, NULL, NULL, NULL, temp_array);

C Example Add units attribute: Add long_name: Add coordinates: size= strlen("Kelvin"); HE5_SWwritelocattr(swid, TEMP, UNITS, H5T_C_S1, &size[0], (void*)kelvin); Add long_name: size= strlen("temperature"); HE5_SWwritelocattr(swid, “temp”, “long_name”, H5T_C_S1, &size, (void*)temperature); Add coordinates:  size= 2; dtype= H5Tcopy(H5T_C_S1); H5Tset_size(dtype, H5T_VARIABLE); HE5_SWwritelocattr(swid, “temp”, “coordinates”, dtype, &size, coorlist);

FORTRAN77 Example Create a swath: Define the dimensions: swid = he5_swcreate(swfid, "Swath1") Define the dimensions: he5_swdefdim(swid, "GeoXtrack", 180) he5_swdefdim(swid, "GeoTrack", 360) Add the _FillValue: he5_swsetfill(swid, "temp", HE5T_NATIVE_FLOAT, value) Define the datafield: he5_swdefdfld(swid, "temp", "GeoTrack,GeoXtrack", " ", HE5T_NATIVE_FLOAT, 0)

FORTRAN77 Example Write the temperature data: start= 0 stride= 1 edge(1)= 360 edge(2)= 180 he5_swwrfld(swid, "temp", start, stride, edge, temp_data) Add the units attribute attribute: he5_swwrlattr(swid,"temp","units", HE5T_NATIVE_CHAR, 6, "kelvin") Add the long_name attribute: he5_swwrlattr(swid, “temp”, “long_name”, HE5T_NATIVE_CHAR, 11, "temperature”) Add the coordinates attribute:  he5_swwrlattr(swid, “temp”, “coordinates”, HE5T_NATIVE_CHAR, 3, "lat") he5_swwrlattr(swid, “temp”, “coordinates”, HE5T_NATIVE_CHAR, 3, "lon")

HDFView A java tool used to browse and modify HDF4 and HDF5 files Easy-to-use GUI for fast editing

HDFView Step 1: Select an existing dataset Step 2: Open the dataset attributes Step 3: Add the attribute Bigger font and animation

URLs

Future Work h5edit to add CF attributes

Thank You!

Acknowledgements This work was supported by cooperative agreement number NNX08AO77A from the National Aeronautics and Space Administration (NASA). Any opinions, findings, conclusions, or recommendations expressed in this material are those of the author[s] and do not necessarily reflect the views of the National Aeronautics and Space Administration.

Questions/comments?

Dimension Scales API included with HDF5 HDF5 datasets with additional metadata shows relationship to a dataset independent of a dataset URL: http://www.hdfgroup.org/HDF5/doc/HL/RM_H5DS.html

Programming Example Uses same code as HDF5 example Declare datasets as a dimension scale: hid_t dataset[3]; // declare latitude and longitude datasets as a dimension scale H5DSset_scale(dataset[1], “lat”); H5DSset_scale(dataset[2], LON); Attach the dimension scale: // attach latitude to the temperature dataset H5Dsattach_scale(dataset[0], dataset[1], 0); // attach longitude to the temperature dataset H5Dsattach_scale(dataset[0], dataset[2], 1);