Page 1 of 1

Accessing CALIPSO metadata with Python

Posted: Wed Jul 14, 2021 10:33 am America/New_York
by rmooers
Hello,

I am trying to plot a vertical profile of total backscatter from the CALIOP LiDAR on CALIPSO. However, I have been unable to access the “Lidar_Data_Altitudes” in the metadata group for the level 1B profile data product in Python using pyhdf.

I can view datasets in the root group with pyhdf’s SD module, but have not been able to read the metadata group with the vgroup module. I followed the example here (http://fhs.github.io/pyhdf/modules/V.ht ... g-a-vgroup) but did not see the metadata group in the output. Likewise, I am unable to view the altitude data in Panoply.

Is there a way to access the “Lidar_Data_Altitudes” using Python?

Thank you!

Re: Accessing CALIPSO metadata with Python

Posted: Thu Jul 15, 2021 1:19 pm America/New_York
by ASDC - ingridgs
Thank you for your question. A Subject Matter Expert has been notified and will answer your question shortly. Please stand by!

Re: Accessing CALIPSO metadata with Python

Posted: Thu Jul 22, 2021 1:27 pm America/New_York
by robert.ryan
Greetings,

I am able to access the "Lidar_Data_Altitudes" in the following way.

First, I initialize the HDF interface.

>>> hdf_interface = HDF(os.path.join(file_path, file_name))

Then, I initialize the VS API over the file and return a VS instance using the vstart() function of the HDF interface.

>>> vs_interface = hdf_interface.vstart()

Next, I use attach() to retrieve the "metadata" VD instance.

>>> meta = vs_interface.attach("metadata")

Finally, to access all of the fields of the metadata, there are a couple of methods but my preferred method is the following. Retrieve info about all vdata fields.

>>> field_infos = meta.fieldinfo()

Retrieve the values of the records...

>>> all_data = meta.read(meta._nrecs)[0]

Terminate access to the vdata. """

>>> meta.detach()

Create a more pythonic dictionary to easily access the data.

>>> data_dictionary = {}
>>> field_name_index = 0
>>> for field_info, data in zip(field_infos, all_data):
>>> data_dictionary[field_info[field_name_index]] = data
>>> lidar_altitudes = data_dictionary["Lidar_Data_Altitudes"]

Clean up access

>>> vs_interface.end()
>>> hdf_interface.close()

The variable lidar_altitudes should now hold a list of the lidar altitudes. The attached screenshots are of a full script that does what I believe you want to do.

Good luck and have a great day.