PAS 3D descriptors
==================

=== Parse_descriptor

----
t_err	Parse_descriptor (t_data_descr * dd, byte_t * data)
----

This function parse a first PAS L0 packet containing 3D data descriptor and extract:

- nb_cem + cem_offset
- nv_elevation + first elevation
- nb_energy + first_energy
- nb_sample
- nb_K

Then computes size of expected data, registered in the following PAS 3D data packets:

- sampling_size = nb_cem * nb_elevation * nb_energy * size (int16_t)
- total_size = sampling_size * nb_k

All these values are registered in the t_data_desr * dd structure.

=== Store_3D_counts 

This function populates a 9 x 11 x 96 matrix of counts :

* from a byte array of counts (dd->data)
* for a given k, where 0 <= k <= dd->k
* setting nb_elev x nb_cem x nb_cem values, in the corresponding cells
* taking in accounfs offset form first_energy, first_elevation and cem_offset

----
t_err	Store_3D_counts (t_data_descr *dd, t_counts_3d counts, int k)
{
	byte_t * ptr = dd->data + dd->sampling_size * k);

	for (energy = 0; energy < dd->nb_energy; energy++) {
	
		int	en = dd->first_energy + energy;

		for (elevation = 0 elevation < dd->nb_elevation; elevation++) {

			int	el = dd->first_elevation + elevation;

			for (cem = 0; cem <= dd->nb_cem; cem++) {

				int	c = dd->cem_offset + cem;

				short	value = get_int16 (ptr);

				counts [c][el][en] = value;

				ptr += 2;
			}
		}
	}
}
----

=== Write_CDF_record

This function will write k CDF records from data contained in t_data_descr descriptor.

----
t_err Write_CDF_record (char * key, t_data_descr * dd)
{
	// use key : swa-pas-3ds, swa-pas-3db, swa-pas-3dt, swa-pas-3dn
	// to select CDF output file

	for (k = 0; k < dd->k; k++) {

		// Populates 3D matrix with data from k sampling

		Store_3D_counts (dd, counts_3D, k);

		// Write counts in a new CDF record

		Put_CDF (cdf, "COUNTS", record, & counts_3d);

		record ++;
	}
}
----