-
Notifications
You must be signed in to change notification settings - Fork 16
Gridpp in C plus plus
Thomas Nipen edited this page Dec 15, 2022
·
14 revisions
include <gridpp.h>
int main(void) {
// Create some fake data
coarse_lats = gridpp::init_vec2(6, 5);
coarse_lons = gridpp::init_vec2(6, 5);
coarse_temperature = gridpp::init_vec2(6, 5);
for(int y = 0; y < 6; y++) {
for(int x = 0; x < 5; x++) {
coarse_lats[y][x] = y;
coarse_lons[y][x] = x;
coarse_temperature[y][x] = 2 * y * y + x * x
}
}
coarse_grid = gridpp::Grid(lats, lons)
fine_lats = gridpp::init_vec2(61, 51);
fine_lons = gridpp::init_vec2(61, 51);
for(int y = 0; y < 61; y++) {
for(int x = 0; x < 51; x++) {
fine_lats[y][x] = y / 10;
fine_lons[y][x] = x / 10;
}
}
fine_grid = gridpp::Grid(lats, lons)
// Perform interpolation
fine_temperature = gridpp::bilinear(coarse_grid, fine_grid, coarse_temperature)
}