00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 static const char *mag2mask_shared_keys[] = {
00043
00044 "T_OBS", NULL,
00045 "DATE__OBS",NULL,
00046
00047 "DSUN_OBS", NULL,
00048 "RSUN_OBS", NULL,
00049 "CRLN_OBS", NULL,
00050 "CRLT_OBS", NULL,
00051 "CAR_ROT", NULL,
00052 "OBS_VR", NULL,
00053 "OBS_VW", NULL,
00054 "OBS_VN", NULL,
00055 "RSUN_OBS", NULL,
00056
00057 "CRPIX1", NULL,
00058 "CRPIX2", NULL,
00059 "CRVAL1", NULL,
00060 "CRVAL2", NULL,
00061 "CDELT1", NULL,
00062 "CDELT2", NULL,
00063 "CROTA2", NULL,
00064
00065 NULL, NULL,
00066 };
00067
00068
00069 static const char *mag2mask_hmi_keys[] = {
00070 "INSTRUME", NULL,
00071 "CAMERA", NULL,
00072
00073 "QUALITY", NULL,
00074
00075 "QUALLEV1", NULL,
00076 "SATVALS", NULL,
00077
00078 "CRDER1", NULL,
00079 "CRDER2", NULL,
00080 "CSYSER1", NULL,
00081 "CSYSER2", NULL,
00082
00083 "HFLID", NULL,
00084 "HCFTID", NULL,
00085 "QLOOK", NULL,
00086 "TINTNUM", NULL,
00087 "SINTNUM", NULL,
00088 "DISTCOEF", NULL,
00089 "ROTCOEF", NULL,
00090 "POLCALM", NULL,
00091 "CALVER64", NULL,
00092
00093
00094 "CODEVER0", NULL,
00095 "CODEVER1", NULL,
00096 "CODEVER2", NULL,
00097 "CODEVER3", NULL,
00098
00099
00100
00101 NULL, NULL,
00102 };
00103
00104
00105 static const char *mag2mask_mdi_keys[] = {
00106 "QUALITY", NULL,
00107 "R_SUN", NULL,
00108 "X0", NULL,
00109 "Y0", NULL,
00110 "EARTH_DT", NULL,
00111 "RUNTIME", "MRUNTIME",
00112
00113 NULL, NULL,
00114 };
00115
00116
00117 static const char *intensity2mask_shared_keys[] = {
00118
00119 NULL, NULL,
00120 };
00121
00122
00123 static const char *intensity2mask_hmi_keys[] = {
00124
00125 "CODEVER0", "ICCODEV0",
00126 "CODEVER1", "ICCODEV1",
00127 "CODEVER2", "ICCODEV2",
00128 "CODEVER3", "ICCODEV3",
00129 "CODEVER4", "ICCODEV4",
00130
00131 "NORMALIZE",NULL,
00132 "COEF_VER", NULL,
00133 "LDCoef0", NULL,
00134 "LDCoef1", NULL,
00135 "LDCoef2", NULL,
00136 "LDCoef3", NULL,
00137 "LDCoef4", NULL,
00138 "LDCoef5", NULL,
00139
00140 NULL, NULL,
00141 };
00142
00143
00144
00145
00146 static const char *intensity2mask_mdi_keys[] = {
00147
00148 NULL, NULL,
00149 };
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160 static const char *mag2harp_shared_keys[] = {
00161
00162 "T_OBS", NULL,
00163 "DATE__OBS",NULL,
00164
00165 "DSUN_OBS", NULL,
00166 "RSUN_OBS", NULL,
00167 "CRLN_OBS", NULL,
00168 "CRLT_OBS", NULL,
00169 "CAR_ROT", NULL,
00170 "OBS_VR", NULL,
00171 "OBS_VW", NULL,
00172 "OBS_VN", NULL,
00173 "RSUN_OBS", NULL,
00174
00175
00176
00177 "CRVAL1", NULL,
00178 "CRVAL2", NULL,
00179 "CDELT1", NULL,
00180 "CDELT2", NULL,
00181 "CROTA2", NULL,
00182
00183 "CRPIX1", "IMCRPIX1",
00184 "CRPIX2", "IMCRPIX2",
00185 "CRVAL1", "IMCRVAL1",
00186 "CRVAL2", "IMCRVAL2",
00187
00188 NULL, NULL,
00189 };
00190
00191
00192 static const char *mag2harp_hmi_keys[] = {
00193 "INSTRUME", NULL,
00194 "CAMERA", NULL,
00195
00196 "QUALITY", NULL,
00197
00198 "QUALLEV1", NULL,
00199
00200 "CRDER1", NULL,
00201 "CRDER2", NULL,
00202 "CSYSER1", NULL,
00203 "CSYSER2", NULL,
00204
00205 "HFLID", NULL,
00206 "HCFTID", NULL,
00207 "QLOOK", NULL,
00208 "TINTNUM", NULL,
00209 "SINTNUM", NULL,
00210 "DISTCOEF", NULL,
00211 "ROTCOEF", NULL,
00212 "POLCALM", NULL,
00213 "CALVER64", NULL,
00214
00215
00216 "CODEVER0", NULL,
00217 "CODEVER1", NULL,
00218 "CODEVER2", NULL,
00219 "CODEVER3", NULL,
00220
00221
00222
00223 NULL, NULL,
00224 };
00225
00226
00227 static const char *mag2harp_mdi_keys[] = {
00228 "EARTH_DT", NULL,
00229 "RUNTIME", "MAG_RUNT",
00230 "DATE", "MAG_DATE",
00231
00232 NULL, NULL,
00233 };
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243 static const char *mask2harp_shared_keys[] = {
00244
00245 "OFFDISK", NULL,
00246 "QUIET", NULL,
00247 "ACTIVE", NULL,
00248 "NCLASS", NULL,
00249 "ON_PATCH", NULL,
00250 "ON_PATCH", "MASK",
00251
00252 "ARM_QUAL", NULL,
00253 "ARM_NCLN", NULL,
00254
00255 "ARMCODEV", NULL,
00256 "ARMDOCU", NULL,
00257
00258 "ARM_MODL", NULL,
00259 "ARM_BETA", NULL,
00260 "ARM_EDGE", NULL,
00261
00262 NULL, NULL,
00263 };
00264
00265
00266 static const char *mask2harp_hmi_keys[] = {
00267
00268
00269 NULL, NULL,
00270 };
00271
00272
00273 static const char *mask2harp_mdi_keys[] = {
00274
00275
00276 NULL, NULL,
00277 };
00278
00279
00280
00281
00282
00283 static
00284 int
00285 propagate_keys_generic(const char **keys, DRMS_Record_t *inRec, DRMS_Record_t *outRec)
00286 {
00287 int failCount;
00288 int status;
00289 int iKey;
00290 const int verbose = 0;
00291 DRMS_Value_t srcval;
00292
00293
00294 if (inRec == NULL || outRec == NULL)
00295 return -1;
00296
00297
00298 for (failCount = iKey = 0; keys[iKey] != NULL; iKey += 2) {
00299 status = DRMS_SUCCESS;
00300 srcval = drms_getkey_p(inRec, keys[iKey], &status);
00301 if (status == DRMS_SUCCESS) {
00302 status = drms_setkey_p(outRec,
00303 keys[iKey+1] ? keys[iKey+1] : keys[iKey],
00304 &srcval);
00305 }
00306 drms_value_free(&srcval);
00307
00308
00309
00310 failCount += (status == DRMS_SUCCESS) ? 0 : 1;
00311 if (verbose) {
00312 if (status != DRMS_SUCCESS)
00313 printf("prop-keys: error for %s was %d\n", keys[iKey], status);
00314 else
00315 printf("prop-keys: OK for %s\n", keys[iKey]);
00316 }
00317 }
00318 return failCount;
00319 }
00320
00321
00322
00323
00324
00325 static
00326 int
00327 propagate_keys_mag2mask(char *mode, DRMS_Record_t *inRec, DRMS_Record_t *outRec)
00328 {
00329 int s1, s2;
00330
00331 s1 = propagate_keys_generic(mag2mask_shared_keys, inRec, outRec);
00332 if (strcmp(mode, "HMI") == 0)
00333 s2 = propagate_keys_generic(mag2mask_hmi_keys, inRec, outRec);
00334 else if (strcmp(mode, "MDI") == 0)
00335 s2 = propagate_keys_generic(mag2mask_mdi_keys, inRec, outRec);
00336 else
00337 s2 = 0;
00338 if (s1 < 0 || s2 < 0)
00339 return -1;
00340 else
00341 return s1 + s2;
00342 }
00343
00344
00345
00346
00347
00348 static
00349 int
00350 propagate_keys_intensity2mask(char *mode, DRMS_Record_t *inRec, DRMS_Record_t *outRec)
00351 {
00352 int s1, s2;
00353
00354 s1 = propagate_keys_generic(intensity2mask_shared_keys, inRec, outRec);
00355 if (strcmp(mode, "HMI") == 0)
00356 s2 = propagate_keys_generic(intensity2mask_hmi_keys, inRec, outRec);
00357 else if (strcmp(mode, "MDI") == 0)
00358 s2 = propagate_keys_generic(intensity2mask_mdi_keys, inRec, outRec);
00359 else
00360 s2 = 0;
00361 if (s1 < 0 || s2 < 0)
00362 return -1;
00363 else
00364 return s1 + s2;
00365 }
00366
00367
00368
00369
00370
00371
00372 static
00373 int
00374 propagate_keys_mag2harp(char *mode, DRMS_Record_t *inRec, DRMS_Record_t *outRec)
00375 {
00376 int s1, s2;
00377
00378 s1 = propagate_keys_generic(mag2harp_shared_keys, inRec, outRec);
00379 if (strcmp(mode, "HMI") == 0)
00380 s2 = propagate_keys_generic(mag2harp_hmi_keys, inRec, outRec);
00381 else if (strcmp(mode, "MDI") == 0)
00382 s2 = propagate_keys_generic(mag2harp_mdi_keys, inRec, outRec);
00383 else
00384 s2 = 0;
00385 if (s1 < 0 || s2 < 0)
00386 return -1;
00387 else
00388 return s1 + s2;
00389 }
00390
00391
00392
00393
00394
00395
00396 static
00397 int
00398 propagate_keys_mask2harp(char *mode, DRMS_Record_t *inRec, DRMS_Record_t *outRec)
00399 {
00400 int s1, s2;
00401
00402 s1 = propagate_keys_generic(mask2harp_shared_keys, inRec, outRec);
00403 if (strcmp(mode, "HMI") == 0)
00404 s2 = propagate_keys_generic(mask2harp_hmi_keys, inRec, outRec);
00405 else if (strcmp(mode, "MDI") == 0)
00406 s2 = propagate_keys_generic(mask2harp_mdi_keys, inRec, outRec);
00407 else
00408 s2 = 0;
00409 if (s1 < 0 || s2 < 0)
00410 return -1;
00411 else
00412 return s1 + s2;
00413 }
00414
00415
00416
00417
00418
00419
00420
00421 static
00422 int
00423 propagate_keys_harp(char *mode, DRMS_Record_t *magRec, DRMS_Record_t *maskRec, DRMS_Record_t *outRec)
00424 {
00425 int s1, s2;
00426
00427
00428 s1 = propagate_keys_mag2harp( mode, magRec, outRec);
00429
00430 s2 = propagate_keys_mask2harp(mode, maskRec, outRec);
00431
00432 if (s1 < 0 || s2 < 0)
00433 return -1;
00434 else
00435 return s1 + s2;
00436 }
00437