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
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", "MRUNTIME",
00230
00231 NULL, NULL,
00232 };
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242 static const char *mask2harp_shared_keys[] = {
00243
00244 "OFFDISK", NULL,
00245 "QUIET", NULL,
00246 "ACTIVE", NULL,
00247 "NCLASS", NULL,
00248 "ON_PATCH", NULL,
00249 "ON_PATCH", "MASK",
00250
00251 "ARM_QUAL", NULL,
00252 "ARM_NCLN", NULL,
00253
00254 "ARMCODEV", NULL,
00255 "ARMDOCU", NULL,
00256
00257 "ARM_MODL", NULL,
00258 "ARM_BETA", NULL,
00259 "ARM_EDGE", NULL,
00260
00261 NULL, NULL,
00262 };
00263
00264
00265 static const char *mask2harp_hmi_keys[] = {
00266
00267
00268 NULL, NULL,
00269 };
00270
00271
00272 static const char *mask2harp_mdi_keys[] = {
00273
00274
00275 NULL, NULL,
00276 };
00277
00278
00279
00280
00281
00282 static
00283 int
00284 propagate_keys_generic(const char **keys, DRMS_Record_t *inRec, DRMS_Record_t *outRec)
00285 {
00286 int failCount;
00287 int status;
00288 int iKey;
00289 const int verbose = 0;
00290 DRMS_Value_t srcval;
00291
00292
00293 if (inRec == NULL || outRec == NULL)
00294 return -1;
00295
00296
00297 for (failCount = iKey = 0; keys[iKey] != NULL; iKey += 2) {
00298 status = DRMS_SUCCESS;
00299 srcval = drms_getkey_p(inRec, keys[iKey], &status);
00300 if (status == DRMS_SUCCESS) {
00301 status = drms_setkey_p(outRec,
00302 keys[iKey+1] ? keys[iKey+1] : keys[iKey],
00303 &srcval);
00304 }
00305 drms_value_free(&srcval);
00306
00307
00308
00309 failCount += (status == DRMS_SUCCESS) ? 0 : 1;
00310 if (verbose) {
00311 if (status != DRMS_SUCCESS)
00312 printf("prop-keys: error for %s was %d\n", keys[iKey], status);
00313 else
00314 printf("prop-keys: OK for %s\n", keys[iKey]);
00315 }
00316 }
00317 return failCount;
00318 }
00319
00320
00321
00322
00323
00324 static
00325 int
00326 propagate_keys_mag2mask(char *mode, DRMS_Record_t *inRec, DRMS_Record_t *outRec)
00327 {
00328 int s1, s2;
00329
00330 s1 = propagate_keys_generic(mag2mask_shared_keys, inRec, outRec);
00331 if (strcmp(mode, "HMI") == 0)
00332 s2 = propagate_keys_generic(mag2mask_hmi_keys, inRec, outRec);
00333 else if (strcmp(mode, "MDI") == 0)
00334 s2 = propagate_keys_generic(mag2mask_mdi_keys, inRec, outRec);
00335 else
00336 s2 = 0;
00337 if (s1 < 0 || s2 < 0)
00338 return -1;
00339 else
00340 return s1 + s2;
00341 }
00342
00343
00344
00345
00346
00347 static
00348 int
00349 propagate_keys_intensity2mask(char *mode, DRMS_Record_t *inRec, DRMS_Record_t *outRec)
00350 {
00351 int s1, s2;
00352
00353 s1 = propagate_keys_generic(intensity2mask_shared_keys, inRec, outRec);
00354 if (strcmp(mode, "HMI") == 0)
00355 s2 = propagate_keys_generic(intensity2mask_hmi_keys, inRec, outRec);
00356 else if (strcmp(mode, "MDI") == 0)
00357 s2 = propagate_keys_generic(intensity2mask_mdi_keys, inRec, outRec);
00358 else
00359 s2 = 0;
00360 if (s1 < 0 || s2 < 0)
00361 return -1;
00362 else
00363 return s1 + s2;
00364 }
00365
00366
00367
00368
00369
00370
00371 static
00372 int
00373 propagate_keys_mag2harp(char *mode, DRMS_Record_t *inRec, DRMS_Record_t *outRec)
00374 {
00375 int s1, s2;
00376
00377 s1 = propagate_keys_generic(mag2harp_shared_keys, inRec, outRec);
00378 if (strcmp(mode, "HMI") == 0)
00379 s2 = propagate_keys_generic(mag2harp_hmi_keys, inRec, outRec);
00380 else if (strcmp(mode, "MDI") == 0)
00381 s2 = propagate_keys_generic(mag2harp_mdi_keys, inRec, outRec);
00382 else
00383 s2 = 0;
00384 if (s1 < 0 || s2 < 0)
00385 return -1;
00386 else
00387 return s1 + s2;
00388 }
00389
00390
00391
00392
00393
00394
00395 static
00396 int
00397 propagate_keys_mask2harp(char *mode, DRMS_Record_t *inRec, DRMS_Record_t *outRec)
00398 {
00399 int s1, s2;
00400
00401 s1 = propagate_keys_generic(mask2harp_shared_keys, inRec, outRec);
00402 if (strcmp(mode, "HMI") == 0)
00403 s2 = propagate_keys_generic(mask2harp_hmi_keys, inRec, outRec);
00404 else if (strcmp(mode, "MDI") == 0)
00405 s2 = propagate_keys_generic(mask2harp_mdi_keys, inRec, outRec);
00406 else
00407 s2 = 0;
00408 if (s1 < 0 || s2 < 0)
00409 return -1;
00410 else
00411 return s1 + s2;
00412 }
00413
00414
00415
00416
00417
00418
00419
00420 static
00421 int
00422 propagate_keys_harp(char *mode, DRMS_Record_t *magRec, DRMS_Record_t *maskRec, DRMS_Record_t *outRec)
00423 {
00424 int s1, s2;
00425
00426
00427 s1 = propagate_keys_mag2harp( mode, magRec, outRec);
00428
00429 s2 = propagate_keys_mask2harp(mode, maskRec, outRec);
00430
00431 if (s1 < 0 || s2 < 0)
00432 return -1;
00433 else
00434 return s1 + s2;
00435 }
00436