Elaboradar 0.1
Caricamento in corso...
Ricerca in corso...
Nessun risultato
elev_fin.h
Vai alla documentazione di questo file.
1
5#ifndef RADARELAB_ELEV_FIN_H
6#define RADARELAB_ELEV_FIN_H
7
8#include <radarelab/volume.h>
9#include <H5Cpp.h>
10
11namespace radarelab {
12namespace volume {
13
14typedef Eigen::Matrix<unsigned char, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> IndexMatrix;
15
16template<typename T>
17struct ElevFin : public IndexMatrix
18{
19 const Volume<T>& volume;
20
21 ElevFin(const Volume<T>& volume)
22 : volume(volume)
23 {
24 // FIXME: set to 0 to have the right size. We start from 512 (MAX_BIN)
25 // to allocate enough memory for legacy code that iterates on MAX_BIN
26 // to successfully read zeroes
27 unsigned max_size = 512;
28 for (unsigned iel = 0; iel < volume.size(); ++iel)
29 {
30 if (volume.scan(iel).beam_size && volume.scan(iel).beam_size > max_size)
31 max_size = volume.scan(iel).beam_size;
32 }
33
34 IndexMatrix::operator=(IndexMatrix::Zero(volume.beam_count, max_size));
35 }
36
37 inline double elevation_rad_at_elev_preci(unsigned az_idx, unsigned ray_idx) const
38 {
39 return elevation_at_elev_preci(az_idx, ray_idx) * M_PI / 180.;
40 }
41
42 inline double elevation_at_elev_preci(unsigned az_idx, unsigned ray_idx) const
43 {
44 unsigned el = (*this)(az_idx, ray_idx);
45 return volume.scan(el).elevations_real(az_idx);
46 }
47
48 inline double db_at_elev_preci(unsigned az_idx, unsigned ray_idx) const
49 {
50 const PolarScan<T>& s = volume.scan((*this)(az_idx, ray_idx));
51 if (ray_idx < s.beam_size)
52 return s.get(az_idx, ray_idx);
53 else
54 // If we are reading out of bounds, return 1 (the missing value)
55 return MINVAL_DB;
56 }
57
58 void write_info_to_debug_file(H5::H5File out)
59 {
60 using namespace H5;
61
62 // Compute dimensions
63 hsize_t dims[2] = { this->rows(), this->cols() };
64 DataSpace file_data_space(2, dims);
65
66 // Dataset data type
67 IntType datatype( PredType::NATIVE_UCHAR );
68
69 // Dataset fill value
70 DSetCreatPropList props;
71 unsigned char fill_value(0);
72 props.setFillValue(datatype, &fill_value);
73
74 // Create the dataset
75 DataSet ds = out.createDataSet("/elev_fin", datatype, file_data_space, props);
76
77 // Write elev_fin to it
78 hsize_t mdims[1] = { this->cols() };
79 DataSpace memory_data_space(1, mdims);
80 hsize_t count[] = { 1, this->cols() };
81 for (unsigned i = 0; i < this->rows(); ++i)
82 {
83 hsize_t start[] = { i, 0 };
84 file_data_space.selectHyperslab(H5S_SELECT_SET, count, start);
85
86 ds.write(this->row(i).data(), datatype, memory_data_space, file_data_space);
87 }
88 }
89};
90
91}
92}
93
94#endif
T get(unsigned az, unsigned beam) const
Get a beam value.
Definition volume.h:161
PolarScan - structure to describe a polarScan containing a matrix of data and conversion factors.
Definition volume.h:113
Homogeneous volume with a common beam count for all PolarScans.
Definition volume.h:431
Namespace per volume dati.
Definition elev_fin.h:12
String functions.
Definition cart.cpp:4
unsigned beam_size
Number of samples in each beam.
Definition volume.h:33
Definisce le principali strutture che contengono i dati.