| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
#include "coda.h" |
| 33 |
#include "harp-ingestion.h" |
| 34 |
|
| 35 |
#include <assert.h> |
| 36 |
#include <math.h> |
| 37 |
#include <stdio.h> |
| 38 |
#include <stdlib.h> |
| 39 |
#include <string.h> |
| 40 |
|
| 41 |
#define MAX_PATH_LENGTH 256 |
| 42 |
|
| 43 |
typedef struct ingest_info_struct |
| 44 |
{ |
| 45 |
coda_product *product; |
| 46 |
int rayleigh; |
| 47 |
int num_hloswind; |
| 48 |
int num_profiles; |
| 49 |
coda_cursor *geolocation_cursor; |
| 50 |
coda_cursor *hloswind_cursor; |
| 51 |
coda_cursor *profile_cursor; |
| 52 |
} ingest_info; |
| 53 |
|
| 54 |
|
| 55 |
static int read_dimensions(void *user_data, long dimension[HARP_NUM_DIM_TYPES]) |
| 56 |
{ |
| 57 |
dimension[harp_dimension_time] = ((ingest_info *)user_data)->num_profiles; |
| 58 |
dimension[harp_dimension_vertical] = 24; |
| 59 |
return 0; |
| 60 |
} |
| 61 |
|
| 62 |
static int get_int8_profile(coda_cursor profile_cursor, coda_cursor *result_cursor, const char *path, harp_array data) |
| 63 |
{ |
| 64 |
uint32_t result_id[24]; |
| 65 |
int index = 0; |
| 66 |
int i; |
| 67 |
|
| 68 |
if (coda_cursor_goto(&profile_cursor, "l2b_wind_profiles/wind_result_id_number") != 0) |
| 69 |
{ |
| 70 |
harp_set_error(HARP_ERROR_CODA, NULL); |
| 71 |
return -1; |
| 72 |
} |
| 73 |
if (coda_cursor_read_uint32_array(&profile_cursor, result_id, coda_array_ordering_c) != 0) |
| 74 |
{ |
| 75 |
harp_set_error(HARP_ERROR_CODA, NULL); |
| 76 |
return -1; |
| 77 |
} |
| 78 |
for (i = 0; i < 24; i++) |
| 79 |
{ |
| 80 |
|
| 81 |
if (result_id[23 - i] != 0) |
| 82 |
{ |
| 83 |
coda_cursor cursor = result_cursor[result_id[23 - i] - 1]; |
| 84 |
|
| 85 |
if (coda_cursor_goto(&cursor, path) != 0) |
| 86 |
{ |
| 87 |
harp_set_error(HARP_ERROR_CODA, NULL); |
| 88 |
return -1; |
| 89 |
} |
| 90 |
if (coda_cursor_read_uint8(&cursor, (uint8_t *)&data.int8_data[index]) != 0) |
| 91 |
{ |
| 92 |
harp_set_error(HARP_ERROR_CODA, NULL); |
| 93 |
return -1; |
| 94 |
} |
| 95 |
index++; |
| 96 |
} |
| 97 |
} |
| 98 |
for (i = index; i < 24; i++) |
| 99 |
{ |
| 100 |
data.int8_data[i] = 0; |
| 101 |
} |
| 102 |
|
| 103 |
return 0; |
| 104 |
} |
| 105 |
|
| 106 |
static int get_double_value(coda_cursor cursor, const char *field_name, harp_array data) |
| 107 |
{ |
| 108 |
if (coda_cursor_goto_record_field_by_name(&cursor, field_name) != 0) |
| 109 |
{ |
| 110 |
harp_set_error(HARP_ERROR_CODA, NULL); |
| 111 |
return -1; |
| 112 |
} |
| 113 |
if (coda_cursor_read_double(&cursor, data.double_data) != 0) |
| 114 |
{ |
| 115 |
harp_set_error(HARP_ERROR_CODA, NULL); |
| 116 |
return -1; |
| 117 |
} |
| 118 |
|
| 119 |
return 0; |
| 120 |
} |
| 121 |
|
| 122 |
static int get_double_profile(coda_cursor profile_cursor, coda_cursor *result_cursor, const char *path, harp_array data) |
| 123 |
{ |
| 124 |
uint32_t result_id[24]; |
| 125 |
int index = 0; |
| 126 |
int i; |
| 127 |
|
| 128 |
if (coda_cursor_goto(&profile_cursor, "l2b_wind_profiles/wind_result_id_number") != 0) |
| 129 |
{ |
| 130 |
harp_set_error(HARP_ERROR_CODA, NULL); |
| 131 |
return -1; |
| 132 |
} |
| 133 |
if (coda_cursor_read_uint32_array(&profile_cursor, result_id, coda_array_ordering_c) != 0) |
| 134 |
{ |
| 135 |
harp_set_error(HARP_ERROR_CODA, NULL); |
| 136 |
return -1; |
| 137 |
} |
| 138 |
for (i = 0; i < 24; i++) |
| 139 |
{ |
| 140 |
|
| 141 |
if (result_id[23 - i] != 0) |
| 142 |
{ |
| 143 |
coda_cursor cursor = result_cursor[result_id[23 - i] - 1]; |
| 144 |
|
| 145 |
if (coda_cursor_goto(&cursor, path) != 0) |
| 146 |
{ |
| 147 |
harp_set_error(HARP_ERROR_CODA, NULL); |
| 148 |
return -1; |
| 149 |
} |
| 150 |
if (coda_cursor_read_double(&cursor, &data.double_data[index]) != 0) |
| 151 |
{ |
| 152 |
harp_set_error(HARP_ERROR_CODA, NULL); |
| 153 |
return -1; |
| 154 |
} |
| 155 |
index++; |
| 156 |
} |
| 157 |
} |
| 158 |
for (i = index; i < 24; i++) |
| 159 |
{ |
| 160 |
data.double_data[i] = harp_nan(); |
| 161 |
} |
| 162 |
|
| 163 |
return 0; |
| 164 |
} |
| 165 |
|
| 166 |
static int init_cursors(ingest_info *info) |
| 167 |
{ |
| 168 |
coda_cursor cursor; |
| 169 |
long dataset_index; |
| 170 |
long num_elements; |
| 171 |
int available; |
| 172 |
int i; |
| 173 |
|
| 174 |
if (coda_cursor_set_product(&cursor, info->product) != 0) |
| 175 |
{ |
| 176 |
harp_set_error(HARP_ERROR_CODA, NULL); |
| 177 |
return -1; |
| 178 |
} |
| 179 |
if (coda_cursor_get_record_field_index_from_name(&cursor, info->rayleigh ? "rayleigh_profile" : "mie_profile", |
| 180 |
&dataset_index) != 0) |
| 181 |
{ |
| 182 |
harp_set_error(HARP_ERROR_CODA, NULL); |
| 183 |
return -1; |
| 184 |
} |
| 185 |
if (coda_cursor_get_record_field_available_status(&cursor, dataset_index, &available) != 0) |
| 186 |
{ |
| 187 |
harp_set_error(HARP_ERROR_CODA, NULL); |
| 188 |
return -1; |
| 189 |
} |
| 190 |
if (!available) |
| 191 |
{ |
| 192 |
info->num_profiles = 0; |
| 193 |
return 0; |
| 194 |
} |
| 195 |
if (coda_cursor_goto_record_field_by_index(&cursor, dataset_index) != 0) |
| 196 |
{ |
| 197 |
harp_set_error(HARP_ERROR_CODA, NULL); |
| 198 |
return -1; |
| 199 |
} |
| 200 |
if (coda_cursor_get_num_elements(&cursor, &num_elements) != 0) |
| 201 |
{ |
| 202 |
harp_set_error(HARP_ERROR_CODA, NULL); |
| 203 |
return -1; |
| 204 |
} |
| 205 |
info->num_profiles = num_elements; |
| 206 |
|
| 207 |
info->profile_cursor = malloc(info->num_profiles * sizeof(coda_cursor)); |
| 208 |
if (info->profile_cursor == NULL) |
| 209 |
{ |
| 210 |
harp_set_error(HARP_ERROR_OUT_OF_MEMORY, "out of memory (could not allocate %lu bytes) (%s:%u)", |
| 211 |
info->num_profiles * sizeof(coda_cursor), __FILE__, __LINE__); |
| 212 |
return -1; |
| 213 |
} |
| 214 |
if (coda_cursor_goto_first_array_element(&cursor) != 0) |
| 215 |
{ |
| 216 |
harp_set_error(HARP_ERROR_CODA, NULL); |
| 217 |
return -1; |
| 218 |
} |
| 219 |
for (i = 0; i < info->num_profiles; i++) |
| 220 |
{ |
| 221 |
info->profile_cursor[i] = cursor; |
| 222 |
if (i < info->num_profiles - 1) |
| 223 |
{ |
| 224 |
if (coda_cursor_goto_next_array_element(&cursor) != 0) |
| 225 |
{ |
| 226 |
harp_set_error(HARP_ERROR_CODA, NULL); |
| 227 |
return -1; |
| 228 |
} |
| 229 |
} |
| 230 |
} |
| 231 |
|
| 232 |
if (coda_cursor_goto(&cursor, info->rayleigh ? "/rayleigh_hloswind" : "/mie_hloswind") != 0) |
| 233 |
{ |
| 234 |
harp_set_error(HARP_ERROR_CODA, NULL); |
| 235 |
return -1; |
| 236 |
} |
| 237 |
if (coda_cursor_get_num_elements(&cursor, &num_elements) != 0) |
| 238 |
{ |
| 239 |
harp_set_error(HARP_ERROR_CODA, NULL); |
| 240 |
return -1; |
| 241 |
} |
| 242 |
info->num_hloswind = num_elements; |
| 243 |
|
| 244 |
info->hloswind_cursor = malloc(info->num_hloswind * sizeof(coda_cursor)); |
| 245 |
if (info->hloswind_cursor == NULL) |
| 246 |
{ |
| 247 |
harp_set_error(HARP_ERROR_OUT_OF_MEMORY, "out of memory (could not allocate %lu bytes) (%s:%u)", |
| 248 |
info->num_hloswind * sizeof(coda_cursor), __FILE__, __LINE__); |
| 249 |
return -1; |
| 250 |
} |
| 251 |
if (coda_cursor_goto_first_array_element(&cursor) != 0) |
| 252 |
{ |
| 253 |
harp_set_error(HARP_ERROR_CODA, NULL); |
| 254 |
return -1; |
| 255 |
} |
| 256 |
for (i = 0; i < info->num_hloswind; i++) |
| 257 |
{ |
| 258 |
info->hloswind_cursor[i] = cursor; |
| 259 |
if (i < info->num_hloswind - 1) |
| 260 |
{ |
| 261 |
if (coda_cursor_goto_next_array_element(&cursor) != 0) |
| 262 |
{ |
| 263 |
harp_set_error(HARP_ERROR_CODA, NULL); |
| 264 |
return -1; |
| 265 |
} |
| 266 |
} |
| 267 |
} |
| 268 |
|
| 269 |
if (coda_cursor_goto(&cursor, info->rayleigh ? "/rayleigh_geolocation" : "/mie_geolocation") != 0) |
| 270 |
{ |
| 271 |
harp_set_error(HARP_ERROR_CODA, NULL); |
| 272 |
return -1; |
| 273 |
} |
| 274 |
if (coda_cursor_get_num_elements(&cursor, &num_elements) != 0) |
| 275 |
{ |
| 276 |
harp_set_error(HARP_ERROR_CODA, NULL); |
| 277 |
return -1; |
| 278 |
} |
| 279 |
if (num_elements != info->num_hloswind) |
| 280 |
{ |
| 281 |
harp_set_error(HARP_ERROR_INGESTION, "product error detected (geolocation data set contains %ld records, " |
| 282 |
"but expected %d (= number of hloswind)", num_elements, info->num_hloswind); |
| 283 |
return -1; |
| 284 |
} |
| 285 |
|
| 286 |
info->geolocation_cursor = malloc(info->num_hloswind * sizeof(coda_cursor)); |
| 287 |
if (info->geolocation_cursor == NULL) |
| 288 |
{ |
| 289 |
harp_set_error(HARP_ERROR_OUT_OF_MEMORY, "out of memory (could not allocate %lu bytes) (%s:%u)", |
| 290 |
info->num_hloswind * sizeof(coda_cursor), __FILE__, __LINE__); |
| 291 |
return -1; |
| 292 |
} |
| 293 |
if (coda_cursor_goto_first_array_element(&cursor) != 0) |
| 294 |
{ |
| 295 |
harp_set_error(HARP_ERROR_CODA, NULL); |
| 296 |
return -1; |
| 297 |
} |
| 298 |
for (i = 0; i < info->num_hloswind; i++) |
| 299 |
{ |
| 300 |
info->geolocation_cursor[i] = cursor; |
| 301 |
if (i < info->num_hloswind - 1) |
| 302 |
{ |
| 303 |
if (coda_cursor_goto_next_array_element(&cursor) != 0) |
| 304 |
{ |
| 305 |
harp_set_error(HARP_ERROR_CODA, NULL); |
| 306 |
return -1; |
| 307 |
} |
| 308 |
} |
| 309 |
} |
| 310 |
|
| 311 |
return 0; |
| 312 |
} |
| 313 |
|
| 314 |
static int read_datetime(void *user_data, long index, harp_array data) |
| 315 |
{ |
| 316 |
return get_double_value(((ingest_info *)user_data)->profile_cursor[index], "profile_datetime_average", data); |
| 317 |
} |
| 318 |
|
| 319 |
static int read_datetime_start(void *user_data, long index, harp_array data) |
| 320 |
{ |
| 321 |
return get_double_value(((ingest_info *)user_data)->profile_cursor[index], "profile_datetime_start", data); |
| 322 |
} |
| 323 |
|
| 324 |
static int read_datetime_stop(void *user_data, long index, harp_array data) |
| 325 |
{ |
| 326 |
return get_double_value(((ingest_info *)user_data)->profile_cursor[index], "profile_datetime_stop", data); |
| 327 |
} |
| 328 |
|
| 329 |
static int read_orbit_index(void *user_data, harp_array data) |
| 330 |
{ |
| 331 |
ingest_info *info = (ingest_info *)user_data; |
| 332 |
coda_cursor cursor; |
| 333 |
|
| 334 |
if (coda_cursor_set_product(&cursor, info->product) != 0) |
| 335 |
{ |
| 336 |
harp_set_error(HARP_ERROR_CODA, NULL); |
| 337 |
return -1; |
| 338 |
} |
| 339 |
if (coda_cursor_goto(&cursor, "/mph/abs_orbit") != 0) |
| 340 |
{ |
| 341 |
harp_set_error(HARP_ERROR_CODA, NULL); |
| 342 |
return -1; |
| 343 |
} |
| 344 |
|
| 345 |
if (coda_cursor_read_uint32(&cursor, (uint32_t *)data.int32_data) != 0) |
| 346 |
{ |
| 347 |
harp_set_error(HARP_ERROR_CODA, NULL); |
| 348 |
return -1; |
| 349 |
} |
| 350 |
|
| 351 |
return 0; |
| 352 |
} |
| 353 |
|
| 354 |
static int read_latitude(void *user_data, long index, harp_array data) |
| 355 |
{ |
| 356 |
return get_double_value(((ingest_info *)user_data)->profile_cursor[index], "profile_lat_average", data); |
| 357 |
} |
| 358 |
|
| 359 |
static int read_longitude(void *user_data, long index, harp_array data) |
| 360 |
{ |
| 361 |
return get_double_value(((ingest_info *)user_data)->profile_cursor[index], "profile_lon_average", data); |
| 362 |
} |
| 363 |
|
| 364 |
static int read_altitude(void *user_data, long index, harp_array data) |
| 365 |
{ |
| 366 |
return get_double_profile(((ingest_info *)user_data)->profile_cursor[index], |
| 367 |
((ingest_info *)user_data)->geolocation_cursor, "windresult_geolocation/altitude_vcog", |
| 368 |
data); |
| 369 |
} |
| 370 |
|
| 371 |
static int read_altitude_bounds(void *user_data, long index, harp_array data) |
| 372 |
{ |
| 373 |
harp_array top_data; |
| 374 |
double values[24]; |
| 375 |
int i; |
| 376 |
|
| 377 |
if (get_double_profile(((ingest_info *)user_data)->profile_cursor[index], |
| 378 |
((ingest_info *)user_data)->geolocation_cursor, "windresult_geolocation/altitude_bottom", |
| 379 |
data) != 0) |
| 380 |
{ |
| 381 |
return -1; |
| 382 |
} |
| 383 |
top_data.double_data = values; |
| 384 |
if (get_double_profile(((ingest_info *)user_data)->profile_cursor[index], |
| 385 |
((ingest_info *)user_data)->geolocation_cursor, "windresult_geolocation/altitude_top", |
| 386 |
top_data) != 0) |
| 387 |
{ |
| 388 |
return -1; |
| 389 |
} |
| 390 |
for (i = 23; i >= 0; i--) |
| 391 |
{ |
| 392 |
data.double_data[2 * i] = data.double_data[i]; |
| 393 |
data.double_data[2 * i + 1] = top_data.double_data[i]; |
| 394 |
} |
| 395 |
|
| 396 |
return 0; |
| 397 |
} |
| 398 |
|
| 399 |
static int read_sensor_azimuth_angle(void *user_data, long index, harp_array data) |
| 400 |
{ |
| 401 |
return get_double_profile(((ingest_info *)user_data)->profile_cursor[index], |
| 402 |
((ingest_info *)user_data)->geolocation_cursor, "windresult_geolocation/los_azimuth", |
| 403 |
data); |
| 404 |
} |
| 405 |
|
| 406 |
static int read_sensor_elevation_angle(void *user_data, long index, harp_array data) |
| 407 |
{ |
| 408 |
return get_double_profile(((ingest_info *)user_data)->profile_cursor[index], |
| 409 |
((ingest_info *)user_data)->geolocation_cursor, |
| 410 |
"windresult_geolocation/los_elevation_vcog", data); |
| 411 |
} |
| 412 |
|
| 413 |
static int read_wind_velocity(void *user_data, long index, harp_array data) |
| 414 |
{ |
| 415 |
ingest_info *info = (ingest_info *)user_data; |
| 416 |
char path[MAX_PATH_LENGTH]; |
| 417 |
|
| 418 |
snprintf(path, MAX_PATH_LENGTH, "windresult/%s_wind_velocity", info->rayleigh ? "rayleigh" : "mie"); |
| 419 |
return get_double_profile(info->profile_cursor[index], info->hloswind_cursor, path, data); |
| 420 |
} |
| 421 |
|
| 422 |
static int read_wind_velocity_validity(void *user_data, long index, harp_array data) |
| 423 |
{ |
| 424 |
ingest_info *info = (ingest_info *)user_data; |
| 425 |
char path[MAX_PATH_LENGTH]; |
| 426 |
|
| 427 |
snprintf(path, MAX_PATH_LENGTH, "windresult/validity_flag"); |
| 428 |
return get_int8_profile(info->profile_cursor[index], info->hloswind_cursor, path, data); |
| 429 |
} |
| 430 |
|
| 431 |
static void ingestion_done(void *user_data) |
| 432 |
{ |
| 433 |
ingest_info *info = (ingest_info *)user_data; |
| 434 |
|
| 435 |
if (info->geolocation_cursor != NULL) |
| 436 |
{ |
| 437 |
free(info->geolocation_cursor); |
| 438 |
} |
| 439 |
if (info->hloswind_cursor != NULL) |
| 440 |
{ |
| 441 |
free(info->hloswind_cursor); |
| 442 |
} |
| 443 |
if (info->profile_cursor != NULL) |
| 444 |
{ |
| 445 |
free(info->profile_cursor); |
| 446 |
} |
| 447 |
|
| 448 |
free(info); |
| 449 |
} |
| 450 |
|
| 451 |
static int ingestion_init(const harp_ingestion_module *module, coda_product *product, |
| 452 |
const harp_ingestion_options *options, harp_product_definition **definition, void **user_data) |
| 453 |
{ |
| 454 |
const char *option_value; |
| 455 |
ingest_info *info; |
| 456 |
|
| 457 |
info = malloc(sizeof(ingest_info)); |
| 458 |
if (info == NULL) |
| 459 |
{ |
| 460 |
harp_set_error(HARP_ERROR_OUT_OF_MEMORY, "out of memory (could not allocate %lu bytes) (%s:%u)", |
| 461 |
sizeof(ingest_info), __FILE__, __LINE__); |
| 462 |
return -1; |
| 463 |
} |
| 464 |
info->product = product; |
| 465 |
info->rayleigh = 1; |
| 466 |
info->geolocation_cursor = NULL; |
| 467 |
info->hloswind_cursor = NULL; |
| 468 |
info->profile_cursor = NULL; |
| 469 |
*definition = module->product_definition[0]; |
| 470 |
|
| 471 |
if (harp_ingestion_options_has_option(options, "data")) |
| 472 |
{ |
| 473 |
if (harp_ingestion_options_get_option(options, "data", &option_value) != 0) |
| 474 |
{ |
| 475 |
ingestion_done(info); |
| 476 |
return -1; |
| 477 |
} |
| 478 |
if (strcmp(option_value, "mie") == 0) |
| 479 |
{ |
| 480 |
info->rayleigh = 0; |
| 481 |
*definition = module->product_definition[1]; |
| 482 |
} |
| 483 |
|
| 484 |
} |
| 485 |
|
| 486 |
if (init_cursors(info) != 0) |
| 487 |
{ |
| 488 |
ingestion_done(info); |
| 489 |
return -1; |
| 490 |
} |
| 491 |
|
| 492 |
*user_data = info; |
| 493 |
|
| 494 |
return 0; |
| 495 |
} |
| 496 |
|
| 497 |
static void register_common_variables(harp_product_definition *product_definition, int rayleigh) |
| 498 |
{ |
| 499 |
harp_variable_definition *variable_definition; |
| 500 |
harp_dimension_type dimension_type[3]; |
| 501 |
const char *description; |
| 502 |
char path[MAX_PATH_LENGTH]; |
| 503 |
long dimension[3]; |
| 504 |
|
| 505 |
dimension_type[0] = harp_dimension_time; |
| 506 |
dimension_type[1] = harp_dimension_vertical; |
| 507 |
dimension_type[2] = harp_dimension_independent; |
| 508 |
|
| 509 |
|
| 510 |
dimension[0] = -1; |
| 511 |
dimension[1] = -1; |
| 512 |
dimension[2] = 2; |
| 513 |
|
| 514 |
|
| 515 |
description = "datetime of the first measurement used for the wind profile"; |
| 516 |
variable_definition = harp_ingestion_register_variable_block_read(product_definition, "datetime_start", |
| 517 |
harp_type_double, 1, dimension_type, NULL, |
| 518 |
description, "seconds since 2000-01-01", |
| 519 |
NULL, read_datetime_start); |
| 520 |
snprintf(path, MAX_PATH_LENGTH, "/%s_profile[]/profile_datetime_start", rayleigh ? "rayleigh" : "mie"); |
| 521 |
harp_variable_definition_add_mapping(variable_definition, NULL, NULL, path, NULL); |
| 522 |
|
| 523 |
|
| 524 |
description = "average datetime of the measurements used for the wind profile"; |
| 525 |
variable_definition = harp_ingestion_register_variable_block_read(product_definition, "datetime", |
| 526 |
harp_type_double, 1, dimension_type, NULL, |
| 527 |
description, "seconds since 2000-01-01", |
| 528 |
NULL, read_datetime); |
| 529 |
snprintf(path, MAX_PATH_LENGTH, "/%s_profile[]/profile_datetime_average", rayleigh ? "rayleigh" : "mie"); |
| 530 |
harp_variable_definition_add_mapping(variable_definition, NULL, NULL, path, NULL); |
| 531 |
|
| 532 |
|
| 533 |
description = "datetime of the last measurements used for the wind profile"; |
| 534 |
variable_definition = harp_ingestion_register_variable_block_read(product_definition, "datetime_stop", |
| 535 |
harp_type_double, 1, dimension_type, NULL, |
| 536 |
description, "seconds since 2000-01-01", |
| 537 |
NULL, read_datetime_stop); |
| 538 |
snprintf(path, MAX_PATH_LENGTH, "/%s_profile[]/profile_datetime_stop", rayleigh ? "rayleigh" : "mie"); |
| 539 |
harp_variable_definition_add_mapping(variable_definition, NULL, NULL, path, NULL); |
| 540 |
|
| 541 |
|
| 542 |
description = "absolute orbit number"; |
| 543 |
variable_definition = |
| 544 |
harp_ingestion_register_variable_full_read(product_definition, "orbit_index", harp_type_int32, 0, NULL, NULL, |
| 545 |
description, NULL, NULL, read_orbit_index); |
| 546 |
harp_variable_definition_add_mapping(variable_definition, NULL, NULL, "/mph/abs_orbit", NULL); |
| 547 |
|
| 548 |
|
| 549 |
description = "average latitude of the measurements used for the wind profile"; |
| 550 |
variable_definition = harp_ingestion_register_variable_block_read(product_definition, "latitude", |
| 551 |
harp_type_double, 1, dimension_type, NULL, |
| 552 |
description, "degree_north", NULL, read_latitude); |
| 553 |
snprintf(path, MAX_PATH_LENGTH, "/%s_profile[]/profile_lat_average", rayleigh ? "rayleigh" : "mie"); |
| 554 |
harp_variable_definition_add_mapping(variable_definition, NULL, NULL, path, NULL); |
| 555 |
|
| 556 |
|
| 557 |
description = "average longitude of the measurements used for the wind profile"; |
| 558 |
variable_definition = harp_ingestion_register_variable_block_read(product_definition, "longitude", |
| 559 |
harp_type_double, 1, dimension_type, NULL, |
| 560 |
description, "degree_east", NULL, read_longitude); |
| 561 |
snprintf(path, MAX_PATH_LENGTH, "/%s_profile[]/profile_lon_average", rayleigh ? "rayleigh" : "mie"); |
| 562 |
harp_variable_definition_add_mapping(variable_definition, NULL, NULL, path, NULL); |
| 563 |
|
| 564 |
|
| 565 |
description = "vertical COG altitude relative to geoid for each accumulation"; |
| 566 |
variable_definition = harp_ingestion_register_variable_block_read(product_definition, "altitude", |
| 567 |
harp_type_double, 2, dimension_type, dimension, |
| 568 |
description, "m", NULL, read_altitude); |
| 569 |
snprintf(path, MAX_PATH_LENGTH, "/%s_geolocation[/%s_profile/l2b_wind_profies/wind_result_id_number - 1]/" |
| 570 |
"windresult_geolocation/altitude_vcog", rayleigh ? "rayleigh" : "mie", rayleigh ? "rayleigh" : "mie"); |
| 571 |
harp_variable_definition_add_mapping(variable_definition, NULL, NULL, path, NULL); |
| 572 |
|
| 573 |
|
| 574 |
description = "altitude relative to geoid of layer boundaries for each accumulation"; |
| 575 |
variable_definition = harp_ingestion_register_variable_block_read(product_definition, "altitude_bounds", |
| 576 |
harp_type_double, 3, dimension_type, dimension, |
| 577 |
description, "m", NULL, read_altitude_bounds); |
| 578 |
snprintf(path, MAX_PATH_LENGTH, "/%s_geolocation[/%s_profile/l2b_wind_profies/wind_result_id_number - 1]" |
| 579 |
"/windresult_geolocation/altitude_bottom, /%s_geolocation[/%s_profile/l2b_wind_profies/" |
| 580 |
"wind_result_id_number - 1]/windresult_geolocation/altitude_top", rayleigh ? "rayleigh" : "mie", |
| 581 |
rayleigh ? "rayleigh" : "mie", rayleigh ? "rayleigh" : "mie", rayleigh ? "rayleigh" : "mie"); |
| 582 |
harp_variable_definition_add_mapping(variable_definition, NULL, NULL, path, NULL); |
| 583 |
|
| 584 |
|
| 585 |
description = "Topocentric Azimuth of the target-to-satellite pointing vector measured clockwise from north"; |
| 586 |
variable_definition = harp_ingestion_register_variable_block_read(product_definition, "sensor_azimuth_angle", |
| 587 |
harp_type_double, 2, dimension_type, dimension, |
| 588 |
description, "degree", NULL, |
| 589 |
read_sensor_azimuth_angle); |
| 590 |
snprintf(path, MAX_PATH_LENGTH, "/%s_geolocation[/%s_profile/l2b_wind_profies/wind_result_id_number - 1]/" |
| 591 |
"windresult_geolocation/los_azimuth", rayleigh ? "rayleigh" : "mie", rayleigh ? "rayleigh" : "mie"); |
| 592 |
harp_variable_definition_add_mapping(variable_definition, NULL, NULL, path, NULL); |
| 593 |
|
| 594 |
|
| 595 |
description = "Elevation of the target-to-satellite pointing vector to the VCOG of the range bin"; |
| 596 |
variable_definition = harp_ingestion_register_variable_block_read(product_definition, "sensor_elevation_angle", |
| 597 |
harp_type_double, 2, dimension_type, dimension, |
| 598 |
description, "degree", NULL, |
| 599 |
read_sensor_elevation_angle); |
| 600 |
snprintf(path, MAX_PATH_LENGTH, "/%s_geolocation[/%s_profile/l2b_wind_profies/wind_result_id_number - 1]/" |
| 601 |
"windresult_geolocation/los_elevation_vcog", rayleigh ? "rayleigh" : "mie", rayleigh ? "rayleigh" : "mie"); |
| 602 |
harp_variable_definition_add_mapping(variable_definition, NULL, NULL, path, NULL); |
| 603 |
|
| 604 |
|
| 605 |
description = "HLOS wind velocity"; |
| 606 |
variable_definition = harp_ingestion_register_variable_block_read(product_definition, "hlos_wind_velocity", |
| 607 |
harp_type_double, 2, dimension_type, NULL, |
| 608 |
description, "cm/s", NULL, read_wind_velocity); |
| 609 |
snprintf(path, MAX_PATH_LENGTH, "/%s_hloswind[/%s_profile/l2b_wind_profies/wind_result_id_number - 1]" |
| 610 |
"/windresult/%s_wind_velocity", rayleigh ? "rayleigh" : "mie", rayleigh ? "rayleigh" : "mie", |
| 611 |
rayleigh ? "rayleigh" : "mie"); |
| 612 |
harp_variable_definition_add_mapping(variable_definition, NULL, NULL, path, NULL); |
| 613 |
|
| 614 |
|
| 615 |
description = "validity flag of the HLOS wind velocity"; |
| 616 |
variable_definition = harp_ingestion_register_variable_block_read(product_definition, |
| 617 |
"hlos_wind_velocity_validity", harp_type_int8, |
| 618 |
2, dimension_type, NULL, description, NULL, |
| 619 |
NULL, read_wind_velocity_validity); |
| 620 |
snprintf(path, MAX_PATH_LENGTH, "/%s_hloswind[/%s_profile/l2b_wind_profies/wind_result_id_number - 1]" |
| 621 |
"/windresult/validity_flag", rayleigh ? "rayleigh" : "mie", rayleigh ? "rayleigh" : "mie"); |
| 622 |
harp_variable_definition_add_mapping(variable_definition, NULL, NULL, path, NULL); |
| 623 |
} |
| 624 |
|
| 625 |
int harp_ingestion_module_aeolus_l2b_init(void) |
| 626 |
{ |
| 627 |
const char *dataset_options[] = { "rayleigh", "mie" }; |
| 628 |
harp_ingestion_module *module; |
| 629 |
harp_product_definition *product_definition; |
| 630 |
const char *description; |
| 631 |
|
| 632 |
description = "AEOLUS Level 2B Product"; |
| 633 |
module = harp_ingestion_register_module("AEOLUS_L2B", "AEOLUS", "AEOLUS", "ALD_U_N_2B", description, |
| 634 |
ingestion_init, ingestion_done); |
| 635 |
harp_ingestion_register_option(module, "data", "the type of profiles to ingest; option values are 'rayleigh' " |
| 636 |
"(default), 'mie'", 2, dataset_options); |
| 637 |
|
| 638 |
description = "Rayleigh HLOS wind profile"; |
| 639 |
product_definition = harp_ingestion_register_product(module, "AEOLUS_L2B_Rayleigh", description, read_dimensions); |
| 640 |
harp_product_definition_add_mapping(product_definition, NULL, "data=rayleigh or data unset"); |
| 641 |
register_common_variables(product_definition, 1); |
| 642 |
|
| 643 |
description = "Mie HLOS wind profile"; |
| 644 |
product_definition = harp_ingestion_register_product(module, "AEOLUS_L2B_Mie", description, read_dimensions); |
| 645 |
harp_product_definition_add_mapping(product_definition, NULL, "data=mie"); |
| 646 |
register_common_variables(product_definition, 0); |
| 647 |
|
| 648 |
return 0; |
| 649 |
} |