Accesing CALIPSO metadata with C++

Use this Forum to find information on, or ask a question about, NASA Earth Science data.
Post Reply
ricotta
Posts: 1
Joined: Wed Jul 24, 2024 10:43 am America/New_York
Answers: 0

Accesing CALIPSO metadata with C++

by ricotta » Wed Jul 24, 2024 10:58 am America/New_York

Hi,
I am trying to read metadata calipso from 5km Cloud Profile files (05kmCPro) using c++ code.
I have a problem for the Lidar_Data_Altitude which is a list of 399 float32. I am using a buffer to read metadata from the 1st one (Product_ID) until Lidar_Data_Altitude. No problem until this list of altitude.
I write this in the readmetadata method :
k = j;
j += 399;
for (i = k; i < j; i++){
METADATA->Lidar_Data_Altitude[i-k] = *(reinterpret_cast<float32*>(&buffer[i]));
}
And the error I have is this one :
CALIOP_L2_CloudProfile.cpp:1583:50: error: types « float32 {aka float}[int] » invalid for table index
1583 | METADATA->Lidar_Data_Altitude[i-k] = *(reinterpret_cast<float32*>(&buffer[i]));
| ^
CALIOP_L2_CloudProfile.cpp: injunction « void CALIOP_L2_CloudProfile::InitializeMETADATA(StructMETADATA_LIDl2cpro*) »:
CALIOP_L2_CloudProfile.cpp:1635:49: error: types « float32 {aka float}[int] » invalid for table index

Filters:

ASDCx - mcook
User Services
User Services
Posts: 98
Joined: Wed Sep 25, 2019 10:53 am America/New_York
Answers: 0
Has thanked: 1 time

Re: Accesing CALIPSO metadata with C++

by ASDCx - mcook » Wed Jul 24, 2024 11:21 am America/New_York

Dear Ricotta,

Thank you for contacting us with an interest in CALIPSO data.
A Subject Matter Expert has been notified of your question and will reply back to you shortly.

Warm Regards

ASDC - cheyenne.e.land
Subject Matter Expert
Subject Matter Expert
Posts: 165
Joined: Mon Mar 22, 2021 3:55 pm America/New_York
Answers: 1
Has thanked: 1 time
Been thanked: 11 times

Re: Accesing CALIPSO metadata with C++

by ASDC - cheyenne.e.land » Mon Jul 29, 2024 10:32 am America/New_York

Hello,

Thank you for your interest in CALIPSO data.

The example code below, provided by the CALIPSO Science Team, may be helpful. This code uses many of the HDF libraries supported by C++ to pull the VData. Please note that for future releases the CALIPSO Science team are going to be pulling the altitudes from VData and storing as an SDS.

Code: Select all

//******************************************************************************
// Function:
//      loadAltitude
//
// Description:
//      The purpose of this function is to extract the 'Lidar_Data_Altitudes'
//      component contained in the VDATA of the hdf file.
//
// Calling Sequence:
//
// Positional Parameters:
//      -i      inFile
//      -i      numAltBins
//
//******************************************************************************
float * loadAltitude(string& inFile, int *numAltBins)
{
 
   int totalBins = *numAltBins;
  
   //Convert string to character array
   int fileSize = inFile.size();
   char dataFile[fileSize];
   for (int kk=0; kk<=fileSize; kk++) { dataFile[kk] = inFile[kk]; }
  
   float *LidarAlt;  
   LidarAlt = new float[totalBins];
  
   int status_n;
   int status_32,
       hdf_id, vdata_id,
       vdata_ref,
       num_of_records,
       record_pos,
       rec_num; 
 
   hdf_id    = Hopen(dataFile, DFACC_READ, 0);
   status_n  = Vstart(hdf_id);
   vdata_ref = VSfind(hdf_id, "metadata");
   vdata_id  = VSattach(hdf_id, vdata_ref, "r");
  
   //Read in Lidar Altitudes
   status_n  = VSsetfields (vdata_id, "Lidar_Data_Altitudes");
   record_pos= VSseek (vdata_id, 0);
   num_of_records = VSread (vdata_id, (uint8 *)LidarAlt, 1, FULL_INTERLACE);
   status_n = Vend(hdf_id);
   status_32 = Hclose(hdf_id);
   
   return(LidarAlt);
  
} //int loadAltitude
//******************************************************************************
Regards,
ASDC

Post Reply