11
11
// Grid class
12
12
// ----------------------------------------------------------------------------
13
13
14
+ struct interp_coef_t
15
+ {
16
+ // The point is inside the cube of [iRow, iRow+1], [iCol, iCol+1], [iAlt, iAlt+1]
17
+ uint64_t iRow;
18
+ uint64_t iCol;
19
+ uint64_t iAlt;
20
+ // The coefficients along row, column and altitude
21
+ precision_t rRow;
22
+ precision_t rCol;
23
+ precision_t rAlt;
24
+ // Whether the point is within this grid or not
25
+ bool in_grid;
26
+ // If this is set to true:
27
+ bool above_grid, below_grid;
28
+ // do interpolation in lat and lon, but extrapolate in altitude
29
+ };
30
+
31
+ struct grid_to_grid_t {
32
+ int64_t iProcTo;
33
+ int64_t nPts;
34
+ int64_t nPtsReceive;
35
+ std::vector<struct interp_coef_t > interpCoefs;
36
+ std::vector<precision_t *> valueToSend;
37
+ std::vector<precision_t *> valueToReceive;
38
+ };
39
+
40
+
14
41
class Grid
15
42
{
16
43
@@ -20,13 +47,24 @@ class Grid
20
47
const int iDipole_ = 3 ;
21
48
int iGridShape_ = -1 ;
22
49
23
- // Armidillo Cube Versions:
50
+ // The index and coefficient used for interpolation
51
+ // Each point is processed by the function set_interpolation_coefs and stored
52
+ // in the form of this structure.
53
+ // If the point is out of the grid, in_grid = false and all other members are undefined
54
+
55
+ std::vector<struct grid_to_grid_t > gridToGridCoefs;
56
+ arma::Cube<int > gridToGridMap;
57
+
58
+ // Armadillo Cube Versions:
24
59
// Cell Center Coordinates
25
60
arma_cube geoLon_scgc, geoX_scgc;
26
61
arma_cube geoLat_scgc, geoY_scgc;
27
62
arma_cube geoAlt_scgc, geoZ_scgc;
28
63
arma_cube geoLocalTime_scgc;
29
64
65
+ // This is an array for testing things:
66
+ arma_cube test_scgc;
67
+
30
68
// Reference coordinate
31
69
arma_cube refx_scgc, refy_scgc;
32
70
@@ -434,6 +472,22 @@ class Grid
434
472
bool set_interpolation_coefs (const std::vector<precision_t > &Lons,
435
473
const std::vector<precision_t > &Lats,
436
474
const std::vector<precision_t > &Alts);
475
+
476
+ /* *
477
+ * \brief Set the interpolation coefficients
478
+ * \param Lons The longitude of points
479
+ * \param Lats The latitude of points
480
+ * \param Alts The altitude of points
481
+ * \pre This instance is an geo grid
482
+ * \pre Lons, Lats and Alts have the same size
483
+ * \return list of interpolation coefficients
484
+ */
485
+
486
+ std::vector<struct interp_coef_t > get_interpolation_coefs (
487
+ const std::vector<precision_t > &Lons,
488
+ const std::vector<precision_t > &Lats,
489
+ const std::vector<precision_t > &Alts);
490
+
437
491
/* *
438
492
* \brief Create a map of geographic locations to data and do the interpolation
439
493
* \param data The value at the positions of geoLon, geoLat, and geoAlt
@@ -443,6 +497,8 @@ class Grid
443
497
* an empty vector if the data is not the same size as the geo grid.
444
498
*/
445
499
std::vector<precision_t > get_interpolation_values (const arma_cube &data) const ;
500
+ std::vector<precision_t > get_interpolation_values (arma_cube data,
501
+ std::vector<struct interp_coef_t > coefArray);
446
502
447
503
private:
448
504
bool IsGeoGrid;
@@ -513,24 +569,6 @@ class Grid
513
569
bool col_max_exclusive;
514
570
};
515
571
516
- // The index and coefficient used for interpolation
517
- // Each point is processed by the function set_interpolation_coefs and stored
518
- // in the form of this structure.
519
- // If the point is out of the grid, in_grid = false and all other members are undefined
520
- struct interp_coef_t
521
- {
522
- // The point is inside the cube of [iRow, iRow+1], [iCol, iCol+1], [iAlt, iAlt+1]
523
- uint64_t iRow;
524
- uint64_t iCol;
525
- uint64_t iAlt;
526
- // The coefficients along row, column and altitude
527
- precision_t rRow;
528
- precision_t rCol;
529
- precision_t rAlt;
530
- // Whether the point is within this grid or not
531
- bool in_grid;
532
- };
533
-
534
572
// Return the index of the last element that has altitude smaller than or euqal to the input
535
573
uint64_t search_altitude (const precision_t alt_in) const ;
536
574
@@ -540,11 +578,11 @@ class Grid
540
578
void get_cubesphere_grid_range (struct cubesphere_range &cr) const ;
541
579
542
580
// Helper function for set_interpolation_coefs
543
- void set_interp_coef_sphere (const sphere_range &sr,
581
+ struct interp_coef_t get_interp_coef_sphere (const sphere_range &sr,
544
582
const precision_t lon_in,
545
583
const precision_t lat_in,
546
584
const precision_t alt_in);
547
- void set_interp_coef_cubesphere (const cubesphere_range &cr,
585
+ struct interp_coef_t get_interp_coef_cubesphere (const cubesphere_range &cr,
548
586
const precision_t lon_in,
549
587
const precision_t lat_in,
550
588
const precision_t alt_in);
0 commit comments