00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include <stdio.h>
00012 #include <stdlib.h>
00013 #include <time.h>
00014 #include <sys/time.h>
00015 #include <math.h>
00016 #include <string.h>
00017 #include <unistd.h>
00018 #include "jsoc_main.h"
00019 #include "astro.h"
00020 #include "wcs4pdfi.c"
00021
00022
00023
00024 #define PI (M_PI)
00025 #define RADSINDEG (PI/180.)
00026 #define RAD2ARCSEC (648000./M_PI)
00027 #define SECINDAY (86400.)
00028 #define FOURK (4096)
00029 #define FOURK2 (16777216)
00030
00031 #define ARRLENGTH(ARR) (sizeof(ARR) / sizeof(ARR[0]))
00032
00033 #define DIE(msg) {fflush(stdout); fprintf(stderr,"%s, status=%d\n", msg, status); return(status);}
00034 #define SHOW(msg) {printf("%s", msg); fflush(stdout);}
00035
00036 #define kNotSpecified "Not Specified"
00037
00038 #define TESTMODE (1)
00039
00040
00041 #define UPADDING (12)
00042
00043
00044
00045
00046 #ifdef TESTMODE
00047 char *inSegNames[] = {"Bloncoe", "Blatcoe", "Brllcoe",
00048 "Vloncoe", "Vlatcoe", "Vlosllcoe",
00049 "Lloncoe", "Llatcoe", "Lrllcoe"};
00050 char *outSegNames[] = {"Elonpdfi", "Elatpdfi", "Erllpdfi"};
00051 char *outSegBNames[] = {"Blon0", "Blat0", "Brll0",
00052 "Blon1", "Blat1", "Brll1"};
00053 #else
00054 char *inSegNames[] = {"Bx", "By", "Bz",
00055 "Vx", "Vy", "Vz",
00056 "Lx", "Ly", "Lz"};
00057 char *outSegNames[] = {"Expdfi", "Eypdfi", "Ezpdfi"};
00058 char *outSegBNames[] = {"Bx0", "By0", "Bz0",
00059 "Bx1", "By1", "Bz1"};
00060 #endif
00061
00062
00063
00064 struct reqInfo {
00065 int n, m;
00066 int npad0, mpad0;
00067 int npadl, npadr, mpadb, mpadt;
00068 int n_o, m_o;
00069 double a, b, c, d;
00070 TIME t, trec;
00071 };
00072
00073
00074
00075 extern void pdfi_wrapper4jsoc_ss_(int *m, int *n, double *rsun, double *a, double *b, double *c, double *d,
00076 double *bloncoe0, double *blatcoe0, double *brllcoe0,
00077 double *bloncoe1, double *blatcoe1, double *brllcoe1,
00078 double *vloncoe0, double *vlatcoe0, double *vlosllcoe0,
00079 double *vloncoe1, double *vlatcoe1, double *vlosllcoe1,
00080 double *lloncoe0, double *llatcoe0, double *lrllcoe0,
00081 double *lloncoe1, double *llatcoe1, double *lrllcoe1,
00082 double *tjul0, double *tjul1,
00083 double *blon0, double *blat0, double *brll0,
00084 double *blon1, double *blat1, double *brll1,
00085 double *elonpdfi, double *elatpdfi, double *erllpdfi,
00086 double *srll, double *hmll,
00087 double *tjulhalf);
00088
00089
00090
00091
00092 int getInputArr(DRMS_Record_t *inRec, struct reqInfo *rInfo,
00093 double **bloncoe_ptr, double **blatcoe_ptr, double **brllcoe_ptr,
00094 double **vloncoe_ptr, double **vlatcoe_ptr, double **vloscoe_ptr,
00095 double **lloncoe_ptr, double **llatcoe_ptr, double **lrllcoe_ptr);
00096
00097
00098 int writeOutputArr(DRMS_Record_t *inRec0, DRMS_Record_t *inRec1, DRMS_Record_t *outRec,
00099 struct reqInfo *rInfo0, struct reqInfo *rInfo1,
00100 double *elonpdfi, double *elatpdfi, double *erllpdfi,
00101 double *blon0, double *blat0, double *brll0,
00102 double *blon1, double *blat1, double *brll1);
00103
00104
00105 void pad_int_gen_ss(struct reqInfo *rInfo);
00106
00107
00108
00109 char *module_name = "cgem_pdfi";
00110
00111 ModuleArgs_t module_args[] =
00112 {
00113 {ARG_STRING, "in", kNotSpecified, "Input data series."},
00114 {ARG_STRING, "out", kNotSpecified, "Output data series."},
00115 {ARG_INT, "npad", "50", "Initial guess of padding in column."},
00116 {ARG_INT, "mpad", "50", "Initial guess of padding in row."},
00117
00118
00119
00120 {ARG_END}
00121 };
00122
00123 int DoIt(void)
00124 {
00125
00126 int status = DRMS_SUCCESS;
00127
00128
00129
00130 char *inQuery, *outQuery;
00131
00132 inQuery = (char *) params_get_str(&cmdparams, "in");
00133 outQuery = (char *) params_get_str(&cmdparams, "out");
00134 int noPadding = params_isflagset(&cmdparams, "n");
00135 int mpad = params_get_int(&cmdparams, "mpad"); if (mpad < 0) mpad = 0;
00136 int npad = params_get_int(&cmdparams, "npad"); if (npad < 0) npad = 0;
00137
00138
00139
00140
00141
00142
00143 DRMS_RecordSet_t *inRS = drms_open_records(drms_env, inQuery, &status);
00144 int nrecs = inRS->n;
00145 if (status || nrecs <= 1) {
00146 DIE("Input data series error");
00147 }
00148 int cgemnum = drms_getkey_int(inRS->records[0], "CGEMNUM", &status);
00149 for (int irec = 1; irec < nrecs; irec++) {
00150 if (drms_getkey_int(inRS->records[irec], "CGEMNUM", &status) != cgemnum) {
00151 DIE("Input data series error");
00152 }
00153 }
00154
00155
00156
00157 DRMS_RecordSet_t *outRS = drms_create_records(drms_env, nrecs - 1, outQuery, DRMS_PERMANENT, &status);
00158 if (status) {
00159 DIE("Output data series error");
00160 }
00161
00162
00163
00164
00165
00166 double *bloncoe0, *blatcoe0, *brllcoe0;
00167 double *bloncoe1, *blatcoe1, *brllcoe1;
00168
00169 double *vloncoe0, *vlatcoe0, *vlosllcoe0;
00170 double *vloncoe1, *vlatcoe1, *vlosllcoe1;
00171
00172 double *lloncoe0, *llatcoe0, *lrllcoe0;
00173 double *lloncoe1, *llatcoe1, *lrllcoe1;
00174
00175 double *blon0, *blat0, *brll0;
00176 double *blon1, *blat1, *brll1;
00177
00178 double *elonpdfi, *elatpdfi, *erllpdfi;
00179 double *srll, *hmll;
00180
00181 int n, m;
00182 double a, b, c, d;
00183 TIME t0, t1, thalf;
00184 TIME tjul0, tjul1, tjulhalf;
00185 double rsun_ref = 6.96e5;
00186
00187
00188
00189 for (int irec = 0; irec < nrecs - 1; irec++) {
00190
00191
00192
00193 DRMS_Record_t *inRec0 = inRS->records[irec];
00194 DRMS_Record_t *inRec1 = inRS->records[irec+1];
00195
00196 struct reqInfo rInfo0, rInfo1;
00197 rInfo0.npad0 = rInfo1.npad0 = npad;
00198 rInfo0.mpad0 = rInfo1.mpad0 = mpad;
00199
00200 if (getInputArr(inRec0, &rInfo0,
00201 &bloncoe0, &blatcoe0, &brllcoe0,
00202 &vloncoe0, &vlatcoe0, &vlosllcoe0,
00203 &lloncoe0, &llatcoe0, &lrllcoe0)) {
00204 printf("Input array error, record #%d skipped", irec);
00205 continue;
00206 }
00207
00208 if (getInputArr(inRec1, &rInfo1,
00209 &bloncoe1, &blatcoe1, &brllcoe1,
00210 &vloncoe1, &vlatcoe1, &vlosllcoe1,
00211 &lloncoe1, &llatcoe1, &lrllcoe1)
00212 || rInfo0.m != rInfo1.m || rInfo0.n != rInfo1.n) {
00213 printf("Input array error, record #%d skipped", irec);
00214 continue;
00215 }
00216
00217
00218
00219 n = rInfo0.n; m = rInfo0.m;
00220 a = rInfo0.a; b = rInfo0.b; c = rInfo0.c; d = rInfo0.d;
00221 t0 = rInfo0.t; t1 = rInfo1.t;
00222 tjul0 = t0 / SECINDAY; tjul1 = t1 / SECINDAY;
00223
00224 printf("dt=%36.30f\n", t1 - t0);
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237 blon0 = (double *) (malloc((n + 1) * m * sizeof(double)));
00238 blat0 = (double *) (malloc(n * (m + 1) * sizeof(double)));
00239 brll0 = (double *) (malloc(n * m * sizeof(double)));
00240 blon1 = (double *) (malloc((n + 1) * m * sizeof(double)));
00241 blat1 = (double *) (malloc(n * (m + 1) * sizeof(double)));
00242 brll1 = (double *) (malloc(n * m * sizeof(double)));
00243
00244 elonpdfi = (double *) (malloc(n * (m + 1) * sizeof(double)));
00245 elatpdfi = (double *) (malloc((n + 1) * m * sizeof(double)));
00246 erllpdfi = (double *) (malloc((n + 1) * (m + 1) * sizeof(double)));
00247
00248 srll = (double *) (malloc(n * m * sizeof(double)));
00249 hmll = (double *) (malloc(n * m * sizeof(double)));
00250
00251
00252
00253
00254 pdfi_wrapper4jsoc_ss_(&m, &n, &rsun_ref, &a, &b, &c, &d,
00255 bloncoe0, blatcoe0, brllcoe0, bloncoe1, blatcoe1, brllcoe1,
00256 vloncoe0, vlatcoe0, vlosllcoe0, vloncoe1, vlatcoe1, vlosllcoe1,
00257 lloncoe0, llatcoe0, lrllcoe0, lloncoe1, llatcoe1, lrllcoe1,
00258 &tjul0, &tjul1,
00259 blon0, blat0, brll0, blon1, blat1, brll1,
00260 elonpdfi, elatpdfi, erllpdfi, srll, hmll,
00261 &tjulhalf);
00262 thalf = tjulhalf * SECINDAY;
00263 SHOW("Fortran done\n");
00264
00265
00266
00267 DRMS_Record_t *outRec = outRS->records[irec];
00268
00269 if (writeOutputArr(inRec0, inRec1, outRec,
00270 &rInfo0, &rInfo1,
00271 elonpdfi, elatpdfi, erllpdfi,
00272 blon0, blat0, brll0,
00273 blon1, blat1, brll1)) {
00274 printf("Output array error, record #%d skipped", irec);
00275 free(elonpdfi); free(elatpdfi); free(erllpdfi);
00276 free(blon0); free(blat0); free(brll0);
00277 free(blon1); free(blat1); free(brll1);
00278 }
00279 SHOW("here1\n");
00280
00281
00282
00283 free(bloncoe0); free(blatcoe0); free(brllcoe0);
00284 free(bloncoe1); free(blatcoe1); free(brllcoe1);
00285 free(vloncoe0); free(vlatcoe0); free(vlosllcoe0);
00286 free(vloncoe1); free(vlatcoe1); free(vlosllcoe1);
00287 free(lloncoe0); free(llatcoe0); free(lrllcoe0);
00288 free(lloncoe1); free(llatcoe1); free(lrllcoe1);
00289
00290
00291 free(srll); free(hmll);
00292
00293 }
00294
00295 drms_close_records(outRS, DRMS_INSERT_RECORD);
00296 drms_close_records(inRS, DRMS_FREE_RECORD);
00297
00298
00299
00300 return DRMS_SUCCESS;
00301
00302 }
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313 int getInputArr(DRMS_Record_t *inRec, struct reqInfo *rInfo,
00314 double **bloncoe_ptr, double **blatcoe_ptr, double **brllcoe_ptr,
00315 double **vloncoe_ptr, double **vlatcoe_ptr, double **vlosllcoe_ptr,
00316 double **lloncoe_ptr, double **llatcoe_ptr, double **lrllcoe_ptr)
00317 {
00318 int status = 0;
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328 rInfo->t = drms_getkey_time(inRec, "T_OBS", &status); if (status) return 1;
00329 rInfo->trec = drms_getkey_time(inRec, "T_REC", &status); if (status) return 1;
00330
00331
00332
00333 double *data_ptr[9];
00334 DRMS_Segment_t *inSeg[9];
00335
00336 inSeg[0] = drms_segment_lookup(inRec, inSegNames[0]);
00337 rInfo->n_o = inSeg[0]->axis[0] - 1; rInfo->m_o = inSeg[0]->axis[1] - 1;
00338
00339 pad_int_gen_ss(rInfo);
00340
00341 rInfo->n = rInfo->n_o + rInfo->npadl + rInfo->npadr;
00342 rInfo->m = rInfo->m_o + rInfo->mpadb + rInfo->mpadt;
00343
00344 printf("m_o=%d, m=%d, mpadb=%d, mpadt=%d\n", rInfo->m_o, rInfo->m, rInfo->mpadb, rInfo->mpadt);
00345 printf("n_o=%d, n=%d, npadl=%d, npadr=%d\n", rInfo->n_o, rInfo->n, rInfo->npadl, rInfo->npadr);
00346
00347 if (rInfo->n <= 0 || rInfo->m <= 0) {return 1;}
00348 for (int i = 1; i < 9; i++) {
00349 inSeg[i] = drms_segment_lookup(inRec, inSegNames[i]);
00350 if (inSeg[i]->axis[0] != (rInfo->n_o + 1) || inSeg[i]->axis[1] != (rInfo->m_o + 1)) {
00351 return 1;
00352 }
00353 }
00354
00355
00356
00357
00358 double crpix1 = drms_getkey_double(inRec, "CRPIX1", &status); if (status) return 1;
00359 double crpix2 = drms_getkey_double(inRec, "CRPIX2", &status); if (status) return 1;
00360 double crval1 = drms_getkey_double(inRec, "CRVAL1", &status); if (status) return 1;
00361 double crval2 = drms_getkey_double(inRec, "CRVAL2", &status); if (status) return 1;
00362 double cdelt1 = drms_getkey_double(inRec, "CDELT1", &status); if (status) return 1;
00363 double cdelt2 = drms_getkey_double(inRec, "CDELT2", &status); if (status) return 1;
00364
00365 rInfo->c = (crval1 + (1. - rInfo->npadl - crpix1) * cdelt1) * RADSINDEG;
00366 rInfo->d = (crval1 + (rInfo->n_o + rInfo->npadr - crpix1) * cdelt1) * RADSINDEG;
00367 rInfo->a = (90. - (crval2 + (rInfo->m_o + rInfo->mpadt - crpix2) * cdelt2)) * RADSINDEG;
00368 rInfo->b = (90. - (crval2 + (1. - rInfo->mpadb - crpix2) * cdelt2)) * RADSINDEG;
00369
00370 printf("n=%d, m=%d\n", rInfo->n, rInfo->m);
00371 printf("n_o=%d, m_o=%d\n", rInfo->n_o, rInfo->m_o);
00372 printf("a=%36.30f, b=%36.30f\nc=%36.30f, d=%36.30f\n", rInfo->a, rInfo->b, rInfo->c, rInfo->d);
00373
00374
00375
00376 DRMS_Array_t *inArray[9];
00377 double *inData[9];
00378
00379 for (int i = 0; i < 9; i++) {
00380 inArray[i] = drms_segment_read(inSeg[i], DRMS_TYPE_DOUBLE, &status);
00381 if (status) {
00382 for (int j = i - 1; j >=0; j--) {
00383 drms_free_array(inArray[j]);
00384 }
00385 return 1;
00386 }
00387 inData[i] = (double *) inArray[i]->data;
00388 }
00389
00390
00391
00392 int n1m1 = (rInfo->n + 1) * (rInfo->m + 1);
00393
00394 *bloncoe_ptr = (double *) (malloc(n1m1 * sizeof(double)));
00395 *blatcoe_ptr = (double *) (malloc(n1m1 * sizeof(double)));
00396 *brllcoe_ptr = (double *) (malloc(n1m1 * sizeof(double)));
00397
00398 *vloncoe_ptr = (double *) (malloc(n1m1 * sizeof(double)));
00399 *vlatcoe_ptr = (double *) (malloc(n1m1 * sizeof(double)));
00400 *vlosllcoe_ptr = (double *) (malloc(n1m1 * sizeof(double)));
00401
00402 *lloncoe_ptr = (double *) (malloc(n1m1 * sizeof(double)));
00403 *llatcoe_ptr = (double *) (malloc(n1m1 * sizeof(double)));
00404 *lrllcoe_ptr = (double *) (malloc(n1m1 * sizeof(double)));
00405
00406
00407
00408 int col, col_o, row, row_o, lead, lead_o, idx, idx_o;
00409 for (row_o = 0; row_o < rInfo->m_o + 1; row_o++) {
00410 row = row_o + rInfo->mpadb;
00411 lead = row * (rInfo->n + 1);
00412 lead_o = row_o * (rInfo->n_o + 1);
00413 for (col_o = 0; col_o < rInfo->n_o + 1; col_o++) {
00414 col = col_o + rInfo->npadl;
00415 idx = lead + col;
00416 idx_o = lead_o + col_o;
00417 (*bloncoe_ptr)[idx] = (inData[0])[idx_o];
00418 (*blatcoe_ptr)[idx] = (inData[1])[idx_o];
00419 (*brllcoe_ptr)[idx] = (inData[2])[idx_o];
00420 (*vloncoe_ptr)[idx] = (inData[3])[idx_o];
00421 (*vlatcoe_ptr)[idx] = (inData[4])[idx_o];
00422 (*vlosllcoe_ptr)[idx] = (inData[5])[idx_o];
00423 (*lloncoe_ptr)[idx] = (inData[6])[idx_o];
00424 (*llatcoe_ptr)[idx] = (inData[7])[idx_o];
00425 (*lrllcoe_ptr)[idx] = (inData[8])[idx_o];
00426 }
00427 }
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443 for (int i = 0; i < 9; i++) {
00444 drms_free_array(inArray[i]);
00445 }
00446
00447 return 0;
00448
00449 }
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460 int writeOutputArr(DRMS_Record_t *inRec0, DRMS_Record_t *inRec1, DRMS_Record_t *outRec,
00461 struct reqInfo *rInfo0, struct reqInfo *rInfo1,
00462 double *elonpdfi, double *elatpdfi, double *erllpdfi,
00463 double *blon0, double *blat0, double *brll0,
00464 double *blon1, double *blat1, double *brll1)
00465 {
00466 int status = 0;
00467
00468
00469
00470 DRMS_Segment_t *outSeg[3];
00471 for (int i = 0; i < 3; i++) {
00472 outSeg[i] = drms_segment_lookup(outRec, outSegNames[i]);
00473 }
00474
00475 int n = rInfo0->n, m = rInfo0->m;
00476
00477 double *outData[3] = {elonpdfi, elatpdfi, erllpdfi};
00478 DRMS_Array_t *outArray[3];
00479 int dims_arr[3][2] = {{n, m+1}, {n+1, m}, {n+1, m+1}};
00480
00481 for (int i = 0; i < 3; i++) {
00482 int dims[2] = {dims_arr[i][0], dims_arr[i][1]};
00483 outArray[i] = drms_array_create(DRMS_TYPE_DOUBLE, 2, dims, outData[i], &status);
00484 if (status) {
00485 for (int j = i - 1; j >=0; j--) {
00486 drms_free_array(outArray[j]);
00487 }
00488 return 1;
00489 }
00490 outSeg[i]->axis[0] = outArray[i]->axis[0]; outSeg[i]->axis[1] = outArray[i]->axis[1];
00491 status = drms_segment_write(outSeg[i], outArray[i], 0);
00492 }
00493
00494 for (int i = 0; i < 3; i++) {
00495 drms_free_array(outArray[i]);
00496 }
00497
00498
00499
00500 drms_copykeys(outRec, inRec0, 0, kDRMS_KeyClass_Explicit);
00501
00502 drms_setkey_int(outRec, "NPADL", rInfo0->npadl);
00503 drms_setkey_int(outRec, "NPADR", rInfo0->npadr);
00504 drms_setkey_int(outRec, "MPADB", rInfo0->mpadb);
00505 drms_setkey_int(outRec, "MPADT", rInfo0->mpadt);
00506 drms_setkey_time(outRec, "T_REC0", rInfo0->trec);
00507 drms_setkey_time(outRec, "T_REC1", rInfo1->trec);
00508 drms_setkey_time(outRec, "T_REC", (rInfo0->trec + rInfo1->trec) / 2.);
00509 drms_setkey_time(outRec, "T_OBS0", rInfo0->t);
00510 drms_setkey_time(outRec, "T_OBS1", rInfo1->t);
00511 drms_setkey_time(outRec, "T_OBS", (rInfo0->t + rInfo1->t) / 2.);
00512
00513
00514
00515 drms_setkey_double(outRec, "MINCOLAT", (rInfo0->a + rInfo1->a) / 2.);
00516 drms_setkey_double(outRec, "MAXCOLAT", (rInfo0->b + rInfo1->b) / 2.);
00517 drms_setkey_double(outRec, "MINLON", (rInfo0->c + rInfo1->c) / 2.);
00518 drms_setkey_double(outRec, "MAXLON", (rInfo0->d + rInfo1->d) / 2.);
00519
00520
00521
00522 double crval1_0 = drms_getkey_double(inRec0, "CRVAL1", &status);
00523 double crval1_1 = drms_getkey_double(inRec1, "CRVAL1", &status);
00524 double crval2_0 = drms_getkey_double(inRec0, "CRVAL2", &status);
00525 double crval2_1 = drms_getkey_double(inRec1, "CRVAL2", &status);
00526
00527 double cdelt1 = drms_getkey_double(inRec0, "CDELT1", &status);
00528 double cdelt2 = drms_getkey_double(inRec0, "CDELT2", &status);
00529 double crpix1 = drms_getkey_double(inRec0, "CRPIX1", &status);
00530 double crpix2 = drms_getkey_double(inRec0, "CRPIX2", &status);
00531
00532 crval1_0 += ((rInfo0->npadr - rInfo0->npadl) / 2. * cdelt1);
00533 crval1_1 += ((rInfo1->npadr - rInfo1->npadl) / 2. * cdelt1);
00534 crval2_0 += ((rInfo0->mpadt - rInfo0->mpadb) / 2. * cdelt2);
00535 crval2_1 += ((rInfo1->mpadt - rInfo1->mpadb) / 2. * cdelt2);
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553 drms_setkey_double(outRec, "CRVAL1", (crval1_0 + crval1_1) / 2.);
00554 drms_setkey_double(outRec, "CRVAL2", (crval2_0 + crval2_1) / 2.);
00555
00556 drms_setkey_double(outRec, "CRPIX1_000", (1. + n) / 2.);
00557 drms_setkey_double(outRec, "CRPIX2_000", (2. + m) / 2.);
00558
00559 drms_setkey_double(outRec, "CRPIX1_001", (2. + n) / 2.);
00560 drms_setkey_double(outRec, "CRPIX2_001", (1. + m) / 2.);
00561
00562 drms_setkey_double(outRec, "CRPIX1_002", (2. + n) / 2.);
00563 drms_setkey_double(outRec, "CRPIX2_002", (2. + m) / 2.);
00564
00565 drms_setkey_double(outRec, "CRPIX1_003", (2. + n) / 2.);
00566 drms_setkey_double(outRec, "CRPIX2_003", (1. + m) / 2.);
00567
00568 drms_setkey_double(outRec, "CRPIX1_004", (1. + n) / 2.);
00569 drms_setkey_double(outRec, "CRPIX2_004", (2. + m) / 2.);
00570
00571 drms_setkey_double(outRec, "CRPIX1_005", (1. + n) / 2.);
00572 drms_setkey_double(outRec, "CRPIX2_005", (1. + m) / 2.);
00573
00574 drms_setkey_double(outRec, "CRPIX1_006", (2. + n) / 2.);
00575 drms_setkey_double(outRec, "CRPIX2_006", (1. + m) / 2.);
00576
00577 drms_setkey_double(outRec, "CRPIX1_007", (1. + n) / 2.);
00578 drms_setkey_double(outRec, "CRPIX2_007", (2. + m) / 2.);
00579
00580 drms_setkey_double(outRec, "CRPIX1_008", (1. + n) / 2.);
00581 drms_setkey_double(outRec, "CRPIX2_008", (1. + m) / 2.);
00582
00583 SHOW("kk\n");
00584
00585
00586
00587 DRMS_Segment_t *outSegB[6];
00588 for (int i = 0; i < 6; i++) {
00589 outSegB[i] = drms_segment_lookup(outRec, outSegBNames[i]);
00590 }
00591
00592 double *outDataB[6] = {blon0, blat0, brll0, blon1, blat1, brll1};
00593 DRMS_Array_t *outArrayB[6];
00594 int dimsB_arr[6][2] = {{n+1, m}, {n, m+1}, {n, m},
00595 {n+1, m}, {n, m+1}, {n, m}};
00596
00597 for (int i = 0; i < 6; i++) {
00598 int dimsB[2] = {dimsB_arr[i][0], dimsB_arr[i][1]};
00599 outArrayB[i] = drms_array_create(DRMS_TYPE_DOUBLE, 2, dimsB, outDataB[i], &status);
00600 if (status) {
00601 for (int j = i - 1; j >=0; j--) {
00602 drms_free_array(outArrayB[j]);
00603 }
00604 return 1;
00605 }
00606 outSegB[i]->axis[0] = outArrayB[i]->axis[0]; outSegB[i]->axis[1] = outArrayB[i]->axis[1];
00607 status = drms_segment_write(outSegB[i], outArrayB[i], 0);
00608 }
00609
00610 for (int i = 0; i < 6; i++) {
00611 drms_free_array(outArrayB[i]);
00612 }
00613
00614
00615
00616 return 0;
00617 }
00618
00619
00620
00621
00622 void pad_int_gen_ss(struct reqInfo *rInfo)
00623
00624 {
00625
00626 rInfo->mpadb = (((rInfo->m_o + 2 * rInfo->mpad0 + (rInfo->m_o % 2)) / UPADDING) * UPADDING - rInfo->m_o) / 2;
00627 rInfo->mpadt = rInfo->mpadb + (rInfo->m_o % 2);
00628
00629 rInfo->npadl = (((rInfo->n_o + 2 * rInfo->npad0 + (rInfo->n_o % 2)) / UPADDING) * UPADDING - rInfo->n_o) / 2;
00630 rInfo->npadr = rInfo->npadl + (rInfo->n_o % 2);
00631
00632 }