def read_metadata(data_dict, data_type): if data_type == 'VD': out = hdf_vd.get_metadata(data_dict[0]) elif data_type == 'SD': out = hdf_sd.get_metadata(data_dict[0]) else: raise ValueError("Invalid data-type: %s, HDF variables must be VD or SD only" % data_type) return out
def read_metadata(data_dict, data_type): if data_type == 'VD': out = hdf_vd.get_metadata(data_dict[0]) elif data_type == 'SD': out = hdf_sd.get_metadata(data_dict[0]) else: raise ValueError( "Invalid data-type: %s, HDF variables must be VD or SD only" % data_type) return out
def test_that_can_get_variable_metadata(): vd = hdf_vd.read(valid_hdf_vd_file, 'DEM_elevation')['DEM_elevation'] metadata = hdf_vd.get_metadata(vd) eq_(metadata._name, "DEM_elevation") eq_(metadata.long_name, "Digital Elevation Map") eq_(metadata.shape, [37081]) eq_(metadata.units, "meters") eq_(metadata.range, [-9999, 8850]) eq_(metadata.factor, 1.0) eq_(metadata.offset, 0.0) eq_(metadata.missing_value, 9999)
def test_that_can_get_coord_metadata(): vd = hdf_vd.read(valid_hdf_vd_file, 'Longitude')['Longitude'] metadata = hdf_vd.get_metadata(vd) eq_(metadata._name, "Longitude") eq_(metadata.standard_name, "longitude") eq_(metadata.long_name, "Spacecraft Longitude") eq_(metadata.shape, [37081]) eq_(metadata.units, "degrees") eq_(metadata.range, [-180.0, 180.0]) eq_(metadata.factor, 1.0) eq_(metadata.offset, 0.0) eq_(metadata.missing_value, None)
def test_that_can_get_variable_metadata(): vd = hdf_vd.read(escape_colons(valid_hdf_vd_file), 'DEM_elevation')['DEM_elevation'] metadata = hdf_vd.get_metadata(vd) eq_(metadata._name, "DEM_elevation") eq_(metadata.long_name, "Digital Elevation Map") eq_(metadata.shape, [37081]) eq_(metadata.units, "meters") eq_(metadata.factor, 1.0) eq_(metadata.offset, 0.0) eq_(metadata.missing_value, 9999) eq_(metadata.misc['valid_range'], [-9999, 8850])
def test_that_can_get_coord_metadata(): vd = hdf_vd.read(escape_colons(valid_hdf_vd_file), 'Longitude')['Longitude'] metadata = hdf_vd.get_metadata(vd) eq_(metadata._name, "Longitude") eq_(metadata.standard_name, "longitude") eq_(metadata.long_name, "Spacecraft Longitude") eq_(metadata.shape, [37081]) eq_(metadata.units, "degrees") eq_(metadata.factor, 1.0) eq_(metadata.offset, 0.0) eq_(metadata.missing_value, None) eq_(metadata.misc['valid_range'], [-180.0, 180.0])