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!
Accessing CALIPSO metadata with Python
Accessing CALIPSO metadata with Python
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.
Go to full postI 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.
Filters:
-
- Posts: 197
- Joined: Fri Apr 23, 2021 9:14 am America/New_York
- Has thanked: 25 times
- Been thanked: 7 times
Re: Accessing CALIPSO metadata with Python
Thank you for your question. A Subject Matter Expert has been notified and will answer your question shortly. Please stand by!
-
- Posts: 1
- Joined: Thu Jul 22, 2021 1:05 pm America/New_York
Re: Accessing CALIPSO metadata with Python
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.
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.
- Attachments
-
- Sample script pg3
- ScriptScreenShot3.png (75.72 KiB) Not viewed yet
-
- Sample script pg2
- ScriptScreenShot2.png (142.2 KiB) Not viewed yet
-
- Sample script pg1
- ScriptScreenShot1.png (130.74 KiB) Not viewed yet