00001
00007
00008 #include <stdio.h>
00009 #include <stdlib.h>
00010 #include <time.h>
00011 #include "jsoc_main.h"
00012 #include "fstats.h"
00013
00014 char *module_name = "mrmlosdailysynframe_nrt";
00015
00016 #define DIE(msg) {fflush(stdout); fprintf(stderr, "%s, status = %d \n", msg, status); return(status);}
00017 #define PARAMETER_ERROR(PNAME)
00018 #define PI 4.0 * atan(1.0)
00019 #define QUAL_CHECK (0xfffefb00)
00020
00021 void frebinbox(float *image_in, float *image_out, int nx, int ny, int nbinx, int nbiny);
00022
00023 ModuleArgs_t module_args[] =
00024 {
00025 {ARG_STRING, "in", "NOTSPECIFIED", "in"},
00026 {ARG_STRING, "out", "NOTSPECIFIED", "out"},
00027 {ARG_STRING, "synoptic", "NOTSPECIFIED", "synoptic"},
00028 {ARG_STRING, "outMl", "NOTSPECIFIED", ""},
00029 {ARG_STRING, "smallsyn", "NOTSPECIFIED", ""},
00030 {ARG_STRING, "smallMlsyn", "NOTSPECIFIED", ""},
00031 {ARG_STRING, "drmethod", "NOCORRDIFFROT", "drmethod"},
00032 {ARG_INT, "magresoln", "NOTSPECIFIED", "magresoln"},
00033 {ARG_INT, "synresoln", "NOTSPECIFIED", "synresoln"},
00034 {ARG_INT, "xx1", "-1", "xx1"},
00035 {ARG_INT, "yy1", "-1", "yy1"},
00036 {ARG_END}
00037 };
00038
00039 float zgrid(int jph, int ith, int cmp, int rup, int dbl,
00040 float phd[], float thd[], float lad[], float cth[],
00041 float sth[], float csc[], float scs[]);
00042
00043 int DoIt(void)
00044 {
00045 DRMS_RecordSet_t *inRS, *inRSfinal, *outRD, *outMlRD, *smallRD, *smallMlRD;
00046 DRMS_Record_t *inRec, *inRecfinal, *outRec, *outMlRec, *smalloutRec, *smalloutMlRec;
00047 DRMS_Segment_t *inSeg, *inSegfinal, *outSeg, *outMlSeg, *smalloutSeg, *smalloutMlSeg;
00048 DRMS_Array_t *inArray, *inArrayfinal;
00049 TIME t_rec, t_rec0;
00050 TIME halfw = 7200.0;
00051 char *t_window = "240m";
00052 char *inQueryfinal, *trec_str = NULL;
00053 float crlt, crln;
00054
00055 float clog0;
00056 float aa, bb, cc, dd, ee;
00057 int status = DRMS_SUCCESS, nrecs, irec, quality;
00058 int i, j, crn;
00059 int xdim_syn, ydim_syn, xmg, ymg;
00060 char sdatestime[100], sdatetmp[100], timetmp[100], timeprint[100];
00061 memset(sdatetmp, 0, sizeof(sdatetmp));
00062 memset(timetmp, 0, sizeof(timetmp));
00063 memset(timeprint, 0, sizeof(timeprint));
00064 memset(sdatestime, 0, sizeof(sdatestime));
00065
00066 char *sdate, *stime, *inQuery, *outQuery, *outMlQuery, *smallRecQuery, *smallMlRecQuery, *synQuery;
00067 char *drmethod;
00068 int magresoln = params_get_int(&cmdparams, "magresoln");
00069 int synresoln = params_get_int(&cmdparams, "synresoln");
00070 int xx1 = params_get_int(&cmdparams, "xx1");
00071 int yy1 = params_get_int(&cmdparams, "yy1");
00072 int nbin = 5;
00073
00074 inQuery = (char *)params_get_str(&cmdparams, "in");
00075 outQuery = (char *)params_get_str(&cmdparams, "out");
00076 outMlQuery = (char *)params_get_str(&cmdparams, "outMl");
00077 synQuery = (char *)params_get_str(&cmdparams, "synoptic");
00078 smallRecQuery = (char *)cmdparams_get_str(&cmdparams, "smallsyn", &status);
00079 smallMlRecQuery = (char *)cmdparams_get_str(&cmdparams, "smallMlsyn", &status);
00080 drmethod = (char *)params_get_str(&cmdparams, "drmethod");
00081
00082 char historyofthemodule[2048];
00083 char *cvsinfo = strdup("$Id: mrmlosdailysynframe_nrt.c,v 1.2 2016/10/13 00:51:01 yliu Exp $");
00084 cvsinfo = (char *)malloc(2048 * sizeof(char));
00085 sprintf(historyofthemodule,"o2helio.c bug corrected, CRVAL, CRPIX corrected -- Feb. 2014");
00086
00087 aa = 13.1988; bb = 0.0; cc = 0.0;
00088 if (strcmp(drmethod, "Meunier") == 0)
00089 {
00090 aa = 13.562; bb = -2.04; cc = -1.4875;
00091 }
00092
00093 if (strcmp(drmethod, "Phil") == 0)
00094 {
00095 aa = 2.917; bb = -0.40; cc = -0.40;
00096 dd = 0.202006;
00097 aa = aa/dd; bb = bb/dd; cc=cc/dd;
00098 ee = 0.930505;
00099 aa = aa*ee; bb = bb*ee; cc = cc*ee;
00100 }
00101
00102 if (strcmp(drmethod, "Pevtsov") == 0)
00103 {
00104 aa = 13.51; bb = -1.72; cc = -2.31;
00105 }
00106
00107 if (strcmp(drmethod, "Snodgrass") == 0)
00108 {
00109 aa = 2.897; bb = -0.339; cc = -0.485;
00110 dd = 0.202006;
00111 aa = aa/dd; bb=bb/dd; cc=cc/dd;
00112 ee = 0.930505;
00113 aa = aa*ee; bb = bb*ee; cc = cc*ee;
00114 }
00115
00116 outRD = drms_create_records(drms_env, 1, outQuery, DRMS_PERMANENT, &status);
00117 if (status) DIE("Output recordset not created");
00118 outMlRD = drms_create_records(drms_env, 1, outMlQuery, DRMS_PERMANENT, &status);
00119 if (status) DIE("Output recordset not created");
00120 smallRD = drms_create_records(drms_env, 1, smallRecQuery, DRMS_PERMANENT, &status);
00121 if (status) DIE("Output record not created");
00122 smallMlRD = drms_create_records(drms_env, 1, smallMlRecQuery, DRMS_PERMANENT, &status);
00123 if (status) DIE("Output record not created");
00124
00125 outRec = outRD->records[0];
00126 outMlRec = outMlRD->records[0];
00127 smalloutRec = smallRD->records[0];
00128 smalloutMlRec = smallMlRD->records[0];
00129
00130 inRS = drms_open_records(drms_env, inQuery, &status);
00131 if (status || inRS->n == 0)
00132 DIE("No input data found -- no remapped files");
00133 inRec = inRS->records[0];
00134 t_rec = drms_getkey_time(inRec, "T_REC", &status);
00135 t_rec0 = t_rec - halfw;
00136
00137 inQueryfinal = (char *)malloc(100 * sizeof(char));
00138 trec_str = (char *)malloc(30 * sizeof(char));
00139 sprint_time(trec_str, t_rec0, "TAI", 0);
00140 sprintf(inQueryfinal, "%s[%s/%s]", inRec->seriesinfo->seriesname, trec_str, t_window);
00141 printf("%s\n", inQueryfinal);
00142 drms_close_records(inRS, DRMS_FREE_RECORD);
00143 free(trec_str);
00144
00145 inRSfinal = drms_open_records(drms_env, inQueryfinal, &status);
00146 if (status || inRSfinal->n == 0) DIE("No input data found -- files contain no data");
00147 nrecs = inRSfinal->n;
00148
00149
00150
00151 int count = 0;
00152 int *recp;
00153 int nref, rec_cen;
00154 recp = (int *)malloc(nrecs * sizeof(int));
00155 for (i = 0; i < nrecs; i++)
00156 {
00157 inRecfinal = inRSfinal->records[i];
00158 inSeg = drms_segment_lookupnum(inRecfinal, 0);
00159 inArray = drms_segment_read(inSeg, DRMS_TYPE_FLOAT, &status);
00160 if (status)
00161 {
00162 printf(" No data file found, status=%d\n", status);
00163 drms_free_array(inArray);
00164 continue;
00165 }
00166 quality = drms_getkey_int(inRecfinal, "QUALITY", &status);
00167 if (quality & QUAL_CHECK)
00168 {
00169 printf("SKIP: error getting keyword %s: iRec = %d, Bad QUALITY = 0x%08x\n",
00170 "QUALITY", i, quality);
00171 continue;
00172 }
00173
00174 recp[count] = i;
00175 count += 1;
00176 drms_free_array(inArray);
00177 }
00178
00179 if (count==0) DIE("No input remapped data found");
00180 rec_cen = (int)(count/2);
00181 nref = recp[rec_cen];
00182 printf("middle data id=%d\n", nref);
00183 inRecfinal = inRSfinal->records[nref];
00184 inSeg = drms_segment_lookupnum(inRecfinal, 0);
00185 inArray = drms_segment_read(inSeg, DRMS_TYPE_FLOAT, &status);
00186 int naxis = inArray->naxis;
00187 xmg = inArray->axis[0]; ymg = inArray->axis[1];
00188 t_rec = drms_getkey_time(inRecfinal, "T_REC", &status);
00189 t_rec0 = drms_getkey_time(inRecfinal, "T_OBS", &status);
00190 crn = drms_getkey_int(inRecfinal, "CAR_ROT", &status);
00191 crlt = drms_getkey_float(inRecfinal, "CRLT_OBS", &status);
00192 crln = drms_getkey_float(inRecfinal, "CRLN_OBS", &status);
00193 clog0 = drms_getkey_float(inRecfinal, "CRVAL1", &status);
00194
00195 printf("crn=%d, clog0=%f\n", crn, clog0);
00196
00197
00198 drms_copykey(outRec, inRecfinal, "DATASIGN");
00199 drms_copykey(outRec, inRecfinal, "DSUN_OBS");
00200 drms_copykey(outRec, inRecfinal, "OBS_VR");
00201 drms_copykey(outRec, inRecfinal, "OBS_VW");
00202 drms_copykey(outRec, inRecfinal, "OBS_VN");
00203 drms_copykey(outRec, inRecfinal, "QUALITY");
00204 drms_copykey(outRec, inRecfinal, "MAPMMAX");
00205 drms_copykey(outRec, inRecfinal, "MAPLGMAX");
00206 drms_copykey(outRec, inRecfinal, "MAPLGMIN");
00207 drms_copykey(outRec, inRecfinal, "SINBDIVS");
00208 drms_copykey(outRec, inRecfinal, "MAPBMAX");
00209 drms_copykey(outRec, inRecfinal, "MAPRMAX");
00210 drms_copykey(outRec, inRecfinal, "LGSHIFT");
00211 drms_copykey(outRec, inRecfinal, "INTERPO");
00212 drms_copykey(outRec, inRecfinal, "MCORLEV");
00213 drms_copykey(outRec, inRecfinal, "MOFFSET");
00214 drms_copykey(outRec, inRecfinal, "CARSTRCH");
00215 drms_copykey(outRec, inRecfinal, "DIFROT_A");
00216 drms_copykey(outRec, inRecfinal, "DIFROT_B");
00217 drms_copykey(outRec, inRecfinal, "DIFROT_C");
00218 drms_copykey(outRec, inRecfinal, "INSTRUME");
00219
00220 drms_copykey(outRec, inRecfinal, "CALVER64");
00221
00222 drms_copykey(outMlRec, inRecfinal, "DATASIGN");
00223 drms_copykey(outMlRec, inRecfinal, "DSUN_OBS");
00224 drms_copykey(outMlRec, inRecfinal, "OBS_VR");
00225 drms_copykey(outMlRec, inRecfinal, "OBS_VW");
00226 drms_copykey(outMlRec, inRecfinal, "OBS_VN");
00227 drms_copykey(outMlRec, inRecfinal, "QUALITY");
00228 drms_copykey(outMlRec, inRecfinal, "MAPMMAX");
00229 drms_copykey(outMlRec, inRecfinal, "MAPLGMAX");
00230 drms_copykey(outMlRec, inRecfinal, "MAPLGMIN");
00231 drms_copykey(outMlRec, inRecfinal, "SINBDIVS");
00232 drms_copykey(outMlRec, inRecfinal, "MAPBMAX");
00233 drms_copykey(outMlRec, inRecfinal, "MAPRMAX");
00234 drms_copykey(outMlRec, inRecfinal, "LGSHIFT");
00235 drms_copykey(outMlRec, inRecfinal, "INTERPO");
00236 drms_copykey(outMlRec, inRecfinal, "MCORLEV");
00237 drms_copykey(outMlRec, inRecfinal, "MOFFSET");
00238 drms_copykey(outMlRec, inRecfinal, "CARSTRCH");
00239 drms_copykey(outMlRec, inRecfinal, "DIFROT_A");
00240 drms_copykey(outMlRec, inRecfinal, "DIFROT_B");
00241 drms_copykey(outMlRec, inRecfinal, "DIFROT_C");
00242 drms_copykey(outMlRec, inRecfinal, "INSTRUME");
00243
00244 drms_copykey(outMlRec, inRecfinal, "CALVER64");
00245
00246
00247 int itmp;
00248 float ftmp;
00249 double dtmp;
00250
00251 drms_copykey(smalloutRec, inRecfinal, "DATASIGN");
00252 drms_copykey(smalloutRec, inRecfinal, "DSUN_OBS");
00253 drms_copykey(smalloutRec, inRecfinal, "OBS_VR");
00254 drms_copykey(smalloutRec, inRecfinal, "OBS_VW");
00255 drms_copykey(smalloutRec, inRecfinal, "OBS_VN");
00256 drms_copykey(smalloutRec, inRecfinal, "QUALITY");
00257 drms_copykey(smalloutRec, inRecfinal, "MAPMMAX");
00258 drms_copykey(smalloutRec, inRecfinal, "MAPLGMAX");
00259 drms_copykey(smalloutRec, inRecfinal, "MAPLGMIN");
00260 drms_copykey(smalloutRec, inRecfinal, "SINBDIVS");
00261 drms_copykey(smalloutRec, inRecfinal, "MAPBMAX");
00262 drms_copykey(smalloutRec, inRecfinal, "MAPRMAX");
00263 drms_copykey(smalloutRec, inRecfinal, "LGSHIFT");
00264 drms_copykey(smalloutRec, inRecfinal, "INTERPO");
00265 drms_copykey(smalloutRec, inRecfinal, "MCORLEV");
00266 drms_copykey(smalloutRec, inRecfinal, "MOFFSET");
00267 drms_copykey(smalloutRec, inRecfinal, "CARSTRCH");
00268 drms_copykey(smalloutRec, inRecfinal, "DIFROT_A");
00269 drms_copykey(smalloutRec, inRecfinal, "DIFROT_B");
00270 drms_copykey(smalloutRec, inRecfinal, "DIFROT_C");
00271 drms_copykey(smalloutRec, inRecfinal, "INSTRUME");
00272
00273 drms_copykey(smalloutRec, inRecfinal, "CALVER64");
00274
00275 drms_copykey(smalloutMlRec, inRecfinal, "DATASIGN");
00276 drms_copykey(smalloutMlRec, inRecfinal, "DSUN_OBS");
00277 drms_copykey(smalloutMlRec, inRecfinal, "OBS_VR");
00278 drms_copykey(smalloutMlRec, inRecfinal, "OBS_VW");
00279 drms_copykey(smalloutMlRec, inRecfinal, "OBS_VN");
00280 drms_copykey(smalloutMlRec, inRecfinal, "QUALITY");
00281 drms_copykey(smalloutMlRec, inRecfinal, "MAPMMAX");
00282 drms_copykey(smalloutMlRec, inRecfinal, "MAPLGMAX");
00283 drms_copykey(smalloutMlRec, inRecfinal, "MAPLGMIN");
00284 drms_copykey(smalloutMlRec, inRecfinal, "SINBDIVS");
00285 drms_copykey(smalloutMlRec, inRecfinal, "MAPBMAX");
00286 drms_copykey(smalloutMlRec, inRecfinal, "MAPRMAX");
00287 drms_copykey(smalloutMlRec, inRecfinal, "LGSHIFT");
00288 drms_copykey(smalloutMlRec, inRecfinal, "INTERPO");
00289 drms_copykey(smalloutMlRec, inRecfinal, "MCORLEV");
00290 drms_copykey(smalloutMlRec, inRecfinal, "MOFFSET");
00291 drms_copykey(smalloutMlRec, inRecfinal, "CARSTRCH");
00292 drms_copykey(smalloutMlRec, inRecfinal, "DIFROT_A");
00293 drms_copykey(smalloutMlRec, inRecfinal, "DIFROT_B");
00294 drms_copykey(smalloutMlRec, inRecfinal, "DIFROT_C");
00295 drms_copykey(smalloutMlRec, inRecfinal, "INSTRUME");
00296
00297 drms_copykey(smalloutMlRec, inRecfinal, "CALVER64");
00298
00299 drms_free_array(inArray);
00300
00301
00302
00303 float *aveData;
00304 int *countNumber;
00305
00306 xdim_syn = 3600; ydim_syn = 1440;
00307 int inDims[2] = {xmg, ymg};
00308 int dxsz = 2 * inDims[0];
00309 int ith = inDims[1];
00310 int ppd = xdim_syn/360;
00311 int xbeg = 10;
00312 if (xx1 == -1) xx1 = 60;
00313 if (yy1 == -1) yy1 = 0;
00314 int hwd = xx1;
00315 int ii, jj;
00316 int smallDims[2], xout, yout;
00317 double lonppixel = 360.0/xdim_syn;
00318 TIME tobs_total = 0.0, tobs_ave;
00319 xx1 *= ppd;
00320 xbeg *= ppd;
00321 aveData = (float *)malloc(xmg * ymg * sizeof(float));
00322 countNumber = (int *)malloc(xmg * ymg * sizeof(int));
00323 xout = xdim_syn/nbin; yout = ydim_syn/(nbin-1);
00324 smallDims[0] = xout; smallDims[1] = yout;
00325
00326 for (jj = 0; jj < ymg; jj++){
00327 for (ii = 0; ii < xmg; ii++) {
00328 countNumber[jj * xmg + ii] = 0;
00329 aveData[jj * xmg + ii] = 0.0;
00330 }
00331 }
00332
00333 for (i = 0; i < count; i++)
00334 {
00335 inRecfinal = inRSfinal->records[recp[i]];
00336 inSeg = drms_segment_lookupnum(inRecfinal, 0);
00337 inArray = drms_segment_read(inSeg, DRMS_TYPE_FLOAT, &status);
00338 float *inData = (float *)inArray->data;
00339 int crnn = drms_getkey_int(inRecfinal, "CAR_ROT", &status);
00340 float clogn = drms_getkey_float(inRecfinal, "CRVAL1", &status);
00341 int xshift = (rint)(ppd * ((clogn - clog0) - 360.0 * (crnn - crn)));
00342 TIME Tobs = drms_getkey_time(inRecfinal, "T_OBS", &status);
00343 tobs_total += Tobs;
00344
00345
00346 for (jj = 0; jj < ymg; jj++)
00347 {
00348 for (ii = xbeg; ii < xmg - xbeg; ii++)
00349 {
00350 if (isnan(inData[jj * xmg + ii - xshift])) continue;
00351 aveData[jj * xmg + ii] += inData[jj * xmg + ii - xshift];
00352 countNumber[jj * xmg + ii] +=1;
00353 }
00354 }
00355 drms_free_array(inArray);
00356 }
00357
00358 tobs_ave = tobs_total/count;
00359
00360 for (jj = 0; jj < ymg; jj++){
00361 for (ii = 0; ii < xmg; ii++){
00362 if (countNumber[jj * xmg + ii] == 0)
00363 {
00364 aveData[jj * xmg + ii] = DRMS_MISSING_FLOAT;
00365 continue;
00366 }
00367 aveData[jj * xmg + ii] /= countNumber[jj * xmg + ii];
00368 }
00369 }
00370 drms_close_records(inRSfinal, DRMS_FREE_RECORD);
00371
00372
00373 float thd[ith], csc[ith], phd[dxsz];
00374 float lad[ith], sth[ith], cth[ith], scs[dxsz];
00375 double dtor = PI/180.;
00376 float constrate = 13.1988;
00377 float ratelow, sinlat;
00378 DRMS_RecordSet_t *synRS = NULL;
00379 DRMS_Record_t *synRec;
00380 DRMS_Segment_t *synSeg;
00381 DRMS_Array_t *synArray, *supsynArray, *outArray, *smalloutArray;
00382 float *synData, *supsynData, *outDataBr, *outDataBlos, *smalloutDataBr, *smalloutDataBlos;
00383 int i1, j1;
00384 int synleftst = ppd * hwd;
00385 double supleftst = ppd * (clog0 - lonppixel);
00386
00387
00388 zgrid(dxsz, ith, 0, 0, 0, phd, thd, lad, cth, sth, csc, scs);
00389
00390 snprintf(timetmp, sizeof(timetmp), "%s[%d/2]", synQuery, crn-2);
00391 snprintf(timeprint, sizeof(timeprint), "%s", synQuery);
00392 synQuery = timetmp;
00393 printf("inputname= %s\n", synQuery);
00394 synRS = drms_open_records(drms_env, synQuery, &status);
00395 if (status || synRS->n == 0) DIE("No input data found -- no synoptic charts");
00396
00397 int nds = synRS->n;
00398 int supxDim = (nds + 1) * xdim_syn;
00399 int supsynDim[2] = {supxDim, ydim_syn};
00400 int synDim[2] = {xdim_syn, ydim_syn};
00401 supsynArray = drms_array_create(DRMS_TYPE_FLOAT, 2, supsynDim, NULL, &status);
00402 supsynData = supsynArray->data;
00403
00404 outArray = drms_array_create(DRMS_TYPE_FLOAT, 2, synDim, NULL, &status);
00405 smalloutArray = drms_array_create(DRMS_TYPE_FLOAT, 2, smallDims, NULL, &status);
00406
00407 if (!(outDataBlos = (float *) malloc(synDim[0]*synDim[1]*4)))
00408 DIE("MALLOC_FAILED");
00409 if (!(outDataBr = (float *) malloc(synDim[0]*synDim[1]*4)))
00410 DIE("MALLOC_FAILED");
00411 if (!(smalloutDataBlos = (float *) malloc(smallDims[0]*smallDims[1]*4)))
00412 DIE("MALLOC_FAILED");
00413 if (!(smalloutDataBr = (float *) malloc(smallDims[0]*smallDims[1]*4)))
00414 DIE("MALLOC_FAILED");
00415
00416 printf("synopN=%d\n", nds);
00417 for (i = 0; i < nds; i++)
00418 {
00419 synRec = synRS->records[i];
00420 synSeg = drms_segment_lookupnum(synRec, 0);
00421 synArray = drms_segment_read(synSeg, DRMS_TYPE_FLOAT, &status);
00422 synData = synArray->data;
00423 int ii = ((nds + 1) - 1 - i) * xdim_syn;
00424 for (j1 = 0; j1 < ydim_syn; j1++)
00425 for (i1 = 0; i1 < xdim_syn; i1++)
00426 {
00427 supsynData[supxDim * j1 + ii + i1] = synData[xdim_syn * j1 + i1];
00428 }
00429 }
00430
00431 drms_free_array(synArray);
00432 drms_close_records(synRS, DRMS_FREE_RECORD);
00433
00434 snprintf(timetmp, sizeof(timetmp), "%s[%d]", timeprint, crn);
00435 synQuery = timetmp;
00436 printf("inputname= %s\n", synQuery);
00437
00438 synRS = drms_open_records(drms_env, synQuery, &status);
00439 if (status || synRS->n == 0) DIE("No input data found -- no synoptic data files");
00440
00441 synRec = synRS->records[0];
00442 synSeg = drms_segment_lookupnum(synRec, 0);
00443 synArray = drms_segment_read(synSeg, DRMS_TYPE_FLOAT, &status);
00444 synData = synArray->data;
00445 ii = 0;
00446 for (j1 = 0; j1 < ydim_syn; j1++)
00447 for (i1 = 0; i1 < xdim_syn; i1++)
00448 {
00449 supsynData[supxDim * j1 + ii + i1] = synData[xdim_syn * j1 + i1];
00450 }
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479 for (j = 0; j < ydim_syn; j++)
00480 {
00481 for (i = synleftst; i < xdim_syn; i++)
00482 {
00483 float lon = i - synleftst;
00484 int lonpixel = (rint)(supleftst + lon);
00485 outDataBr[j*xdim_syn + i] = supsynData[j * supxDim + lonpixel];
00486 }
00487 }
00488
00489 int magleft = (rint)(ppd * (90 - hwd));
00490 for (j = 0; j < ydim_syn; j++)
00491 for (i = 0; i < 2*synleftst + 1; i++)
00492 {
00493 outDataBr[j * xdim_syn + i] = aveData[j * inDims[0] + magleft + i];
00494 }
00495
00496 frebinbox(outDataBr, smalloutDataBr, xdim_syn, ydim_syn, nbin, nbin-1);
00497
00498
00499 int icol, jrow, rowoffset;
00500 float sinB, sinB2, cosB, sinBbase;
00501 double sinBdelta;
00502
00503
00504 sinBbase = 0.5 - synDim[1]/2.0;
00505 sinBdelta = 2.0/synDim[1];
00506
00507 for (jrow = 0; jrow < synDim[1]; jrow++) {
00508 rowoffset = jrow * synDim[0];
00509 sinB = sinBdelta * (sinBbase + jrow);
00510 sinB2 = sinB * sinB;
00511 cosB = sqrt(1.0 - sinB2);
00512
00513 for (icol = 0; icol < synDim[0]; icol++) {
00514 if (isnan(outDataBr[rowoffset + icol]))
00515 {
00516 outDataBlos[rowoffset + icol] = DRMS_MISSING_FLOAT;
00517 continue;
00518 }
00519 outDataBlos[rowoffset + icol] = outDataBr[rowoffset + icol] * cosB;
00520 }
00521 }
00522
00523
00524
00525 sinBbase = 0.5 - smallDims[1]/2.0;
00526 sinBdelta = 2.0/smallDims[1];
00527
00528 for (jrow = 0; jrow < smallDims[1]; jrow++) {
00529 rowoffset = jrow * smallDims[0];
00530 sinB = sinBdelta * (sinBbase + jrow);
00531 sinB2 = sinB * sinB;
00532 cosB = sqrt(1.0 - sinB2);
00533
00534 for (icol = 0; icol < smallDims[0]; icol++) {
00535 if (isnan(smalloutDataBr[rowoffset + icol]))
00536 {
00537 smalloutDataBlos[rowoffset + icol] = DRMS_MISSING_FLOAT;
00538 continue;
00539 }
00540 smalloutDataBlos[rowoffset + icol] = smalloutDataBr[rowoffset + icol] * cosB;
00541 }
00542 }
00543
00544
00545
00546
00547 double statMin, statMax, statMedn, statMean, statSig, statSkew, statKurt;
00548 int statNgood;
00549 if (fstats(xdim_syn*ydim_syn, outDataBr, &statMin, &statMax, &statMedn, &statMean, &statSig,
00550 &statSkew, &statKurt, &statNgood)) printf("\n Statistics computation failed\n");
00551
00552
00553 i = xdim_syn*ydim_syn;
00554 drms_setkey_int(outRec, "TOTVALS", i);
00555 drms_setkey_int(outRec, "DATAVALS", statNgood);
00556 i = xdim_syn*ydim_syn-statNgood;
00557 drms_setkey_int(outRec, "MISSVALS", i);
00558 drms_setkey_double(outRec, "DATAMIN", statMin);
00559 drms_setkey_double(outRec, "DATAMAX", statMax);
00560 drms_setkey_double(outRec, "DATAMEDN", statMedn);
00561 drms_setkey_double(outRec, "DATAMEAN", statMean);
00562 drms_setkey_double(outRec, "DATARMS", statSig);
00563 drms_setkey_double(outRec, "DATASKEW", statSkew);
00564 drms_setkey_double(outRec, "DATAKURT", statKurt);
00565
00566 if (fstats(xdim_syn*ydim_syn, outDataBlos, &statMin, &statMax, &statMedn, &statMean, &statSig,
00567 &statSkew, &statKurt, &statNgood)) printf("\n Statistics computation failed\n");
00568
00569 i = xdim_syn*ydim_syn;
00570 drms_setkey_int(outMlRec, "TOTVALS", i);
00571 drms_setkey_int(outMlRec, "DATAVALS", statNgood);
00572 i = xdim_syn*ydim_syn-statNgood;
00573 drms_setkey_int(outMlRec, "MISSVALS", i);
00574 drms_setkey_double(outMlRec, "DATAMIN", statMin);
00575 drms_setkey_double(outMlRec, "DATAMAX", statMax);
00576 drms_setkey_double(outMlRec, "DATAMEDN", statMedn);
00577 drms_setkey_double(outMlRec, "DATAMEAN", statMean);
00578 drms_setkey_double(outMlRec, "DATARMS", statSig);
00579 drms_setkey_double(outMlRec, "DATASKEW", statSkew);
00580 drms_setkey_double(outMlRec, "DATAKURT", statKurt);
00581
00582
00583
00584 double smallstatMin, smallstatMax, smallstatMedn, smallstatMean, smallstatSig, smallstatSkew, smallstatKurt;
00585 int smallstatNgood;
00586 if (fstats(xout*yout, smalloutDataBr, &smallstatMin, &smallstatMax, &smallstatMedn, &smallstatMean, &smallstatSig,
00587 &smallstatSkew, &smallstatKurt, &smallstatNgood)) printf("\n Statistics computation failed\n");
00588
00589
00590 i = xout*yout;
00591 drms_setkey_int(smalloutRec, "TOTVALS", i);
00592 drms_setkey_int(smalloutRec, "DATAVALS", smallstatNgood);
00593 i = xout*yout-smallstatNgood;
00594 drms_setkey_int(smalloutRec, "MISSVALS", i);
00595 drms_setkey_double(smalloutRec, "DATAMIN", smallstatMin);
00596 drms_setkey_double(smalloutRec, "DATAMAX", smallstatMax);
00597 drms_setkey_double(smalloutRec, "DATAMEDN", smallstatMedn);
00598 drms_setkey_double(smalloutRec, "DATAMEAN", smallstatMean);
00599 drms_setkey_double(smalloutRec, "DATARMS", smallstatSig);
00600 drms_setkey_double(smalloutRec, "DATASKEW", smallstatSkew);
00601 drms_setkey_double(smalloutRec, "DATAKURT", smallstatKurt);
00602
00603 if (fstats(xout*yout, smalloutDataBlos, &smallstatMin, &smallstatMax, &smallstatMedn, &smallstatMean, &smallstatSig,
00604 &smallstatSkew, &smallstatKurt, &smallstatNgood)) printf("\n Statistics computation failed\n");
00605
00606 i = xout*yout;
00607 drms_setkey_int(smalloutMlRec, "TOTVALS", i);
00608 drms_setkey_int(smalloutMlRec, "DATAVALS", smallstatNgood);
00609 i = xout*yout-smallstatNgood;
00610 drms_setkey_int(smalloutMlRec, "MISSVALS", i);
00611 drms_setkey_double(smalloutMlRec, "DATAMIN", smallstatMin);
00612 drms_setkey_double(smalloutMlRec, "DATAMAX", smallstatMax);
00613 drms_setkey_double(smalloutMlRec, "DATAMEDN", smallstatMedn);
00614 drms_setkey_double(smalloutMlRec, "DATAMEAN", smallstatMean);
00615 drms_setkey_double(smalloutMlRec, "DATARMS", smallstatSig);
00616 drms_setkey_double(smalloutMlRec, "DATASKEW", smallstatSkew);
00617 drms_setkey_double(smalloutMlRec, "DATAKURT", smallstatKurt);
00618
00619
00620
00621
00622
00623
00624 drms_setkey_time(outRec, "T_REC", t_rec);
00625 trec_str = (char *)malloc(30 * sizeof(char));
00626 sprint_time(trec_str, tobs_ave, "TAI", 0);
00627 drms_setkey_time(outRec, "T_OBS", tobs_ave);
00628 drms_setkey_int(outRec, "CAR_ROT", crn);
00629 drms_setkey_float(outRec, "CRLT_OBS", crlt);
00630 drms_setkey_float(outRec, "CRLN_OBS", crln);
00631 drms_setkey_float(outRec, "CADENCE", 24.0*60.0*60.0);
00632 drms_setkey_float(outRec, "CROTA2", 0.0);
00633 drms_setkey_string(outRec, "WCSNAME", "Carrington Heliographic");
00634 drms_setkey_string(outRec, "HISTORY", historyofthemodule);
00635 drms_setkey_string(outRec, "BLD_VERS", jsoc_version);
00636 status = drms_setkey_string(outRec, "CODEVER", cvsinfo);
00637
00638 drms_setkey_time(outMlRec, "T_REC", t_rec);
00639 drms_setkey_time(outMlRec, "T_OBS", tobs_ave);
00640 drms_setkey_int(outMlRec, "CAR_ROT", crn);
00641 drms_setkey_float(outMlRec, "CRLT_OBS", crlt);
00642 drms_setkey_float(outMlRec, "CRLN_OBS", crln);
00643 drms_setkey_float(outMlRec, "CADENCE", 24.0*60.0*60.0);
00644 drms_setkey_float(outMlRec, "CROTA2", 0.0);
00645 drms_setkey_string(outMlRec, "WCSNAME", "Carrington Heliographic");
00646 drms_setkey_string(outMlRec, "HISTORY", historyofthemodule);
00647 drms_setkey_string(outMlRec, "BLD_VERS", jsoc_version);
00648 status = drms_setkey_string(outMlRec, "CODEVER", cvsinfo);
00649
00650 double loncen = xdim_syn-(xdim_syn/2 + 1.0)+1.0;
00651
00652
00653
00654
00655
00656 drms_setkey_double(outRec, "CRPIX1", loncen);
00657 drms_setkey_double(outMlRec, "CRPIX1", loncen);
00658
00659 double latcen = (ydim_syn+1.0)/2;
00660 drms_setkey_double(outRec, "CRPIX2", latcen);
00661 drms_setkey_double(outMlRec, "CRPIX2", latcen);
00662
00663 double lonstep = -360.0/xdim_syn;
00664 drms_setkey_double(outRec, "CDELT1", lonstep);
00665 drms_setkey_double(outMlRec, "CDELT1", lonstep);
00666 double latstep = 2.0/ydim_syn;
00667 drms_setkey_double(outRec, "CDELT2", latstep);
00668 drms_setkey_double(outMlRec, "CDELT2", latstep);
00669
00670 double lonfirst = 360.0 * (crn - 1) - clog0 + hwd + 360.0/xdim_syn;
00671
00672 drms_setkey_double(outRec, "LON_FRST", lonfirst);
00673 drms_setkey_double(outMlRec, "LON_FRST", lonfirst);
00674
00675 double lonlast = 360.0 * crn - clog0 + hwd;
00676
00677 drms_setkey_double(outRec, "LON_LAST", lonlast);
00678 drms_setkey_double(outMlRec, "LON_LAST", lonlast);
00679
00680 double loncenter = lonfirst + 180.0;
00681
00682
00683 drms_setkey_double(outRec, "CRVAL1", loncenter);
00684 drms_setkey_double(outRec, "CARRTIME", loncenter);
00685 drms_setkey_double(outRec, "LON_STEP", lonstep);
00686 drms_setkey_double(outMlRec, "CRVAL1", loncenter);
00687 drms_setkey_double(outMlRec, "CARRTIME", loncenter);
00688 drms_setkey_double(outMlRec, "LON_STEP", lonstep);
00689
00690
00691 float hwnwidth = drms_getkey_float(synRec, "HWNWIDTH", &status);
00692 drms_setkey_float(outRec, "HWNWIDTH", hwnwidth);
00693 drms_setkey_float(outMlRec, "HWNWIDTH", hwnwidth);
00694 float eqpoints = drms_getkey_float(synRec, "EQPOINTS", &status);
00695 drms_setkey_float(outRec, "EQPOINTS", eqpoints);
00696 drms_setkey_float(outMlRec, "EQPOINTS", eqpoints);
00697 float syndro_a = drms_getkey_float(synRec, "DIFROT_A", &status);
00698 drms_setkey_float(outRec, "OSYNDR_A", syndro_a);
00699 drms_setkey_float(outMlRec, "OSYNDR_A", syndro_a);
00700 float syndro_b = drms_getkey_float(synRec, "DIFROT_B", &status);
00701 drms_setkey_float(outRec, "OSYNDR_B", syndro_b);
00702 drms_setkey_float(outMlRec, "OSYNDR_B", syndro_b);
00703 float syndro_c = drms_getkey_float(synRec, "DIFROT_C", &status);
00704 drms_setkey_float(outRec, "OSYNDR_C", syndro_c);
00705 drms_setkey_float(outMlRec, "OSYNDR_C", syndro_c);
00706
00707
00708 drms_setkey_string(outRec, "FRTIMWDN", t_window);
00709 drms_setkey_string(outRec, "SYNDRORA", drmethod);
00710 drms_setkey_int(outRec, "FRAVEPNT", count);
00711 drms_setkey_float(outRec, "FRWINDOW", 2.0 * hwd);
00712 drms_setkey_float(outRec, "SYNDRO_A", aa);
00713 drms_setkey_float(outRec, "SYNDRO_B", bb);
00714 drms_setkey_float(outRec, "SYNDRO_C", cc);
00715 drms_keyword_setdate(outRec);
00716
00717 drms_setkey_string(outMlRec, "FRTIMWDN", t_window);
00718 drms_setkey_string(outMlRec, "SYNDRORA", drmethod);
00719 drms_setkey_int(outMlRec, "FRAVEPNT", count);
00720 drms_setkey_float(outMlRec, "FRWINDOW", 2.0 * hwd);
00721 drms_setkey_float(outMlRec, "SYNDRO_A", aa);
00722 drms_setkey_float(outMlRec, "SYNDRO_B", bb);
00723 drms_setkey_float(outMlRec, "SYNDRO_C", cc);
00724 drms_keyword_setdate(outMlRec);
00725
00726 printf(" WRITING OUTPUT\n");
00727
00728
00729 outSeg = drms_segment_lookupnum(outRec, 0);
00730 outArray = drms_array_create(DRMS_TYPE_FLOAT, 2, synDim, outDataBr, &status);
00731 status = drms_segment_write(outSeg, outArray, 0);
00732 if (status) DIE("problem writing file");
00733 drms_free_array(outArray);
00734
00735
00736 outSeg = drms_segment_lookupnum(outMlRec, 0);
00737 outArray = drms_array_create(DRMS_TYPE_FLOAT, 2, synDim, outDataBlos, &status);
00738 status = drms_segment_write(outSeg, outArray, 0);
00739 if (status) DIE("problem writing file");
00740 drms_free_array(outArray);
00741
00742
00743 drms_setkey_time(smalloutRec, "T_REC", t_rec);
00744 drms_setkey_time(smalloutRec, "T_REC_step", 720.0);
00745 drms_setkey_time(smalloutRec, "T_OBS", tobs_ave);
00746 drms_setkey_int(smalloutRec, "CAR_ROT", crn);
00747 drms_setkey_float(smalloutRec, "CRLT_OBS", crlt);
00748 drms_setkey_float(smalloutRec, "CRLN_OBS", crln);
00749 drms_setkey_float(smalloutRec, "CADENCE", 24.0*60.0*60.0);
00750 drms_setkey_float(smalloutRec, "CROTA2", 0.0);
00751 drms_setkey_string(smalloutRec, "WCSNAME", "Carrington Heliographic");
00752 drms_setkey_string(smalloutRec, "HISTORY", historyofthemodule);
00753 drms_setkey_string(smalloutRec, "BLD_VERS", jsoc_version);
00754 status = drms_setkey_string(smalloutRec, "CODEVER", cvsinfo);
00755
00756 drms_setkey_time(smalloutMlRec, "T_REC", t_rec);
00757 drms_setkey_time(smalloutMlRec, "T_OBS", tobs_ave);
00758 drms_setkey_int(smalloutMlRec, "CAR_ROT", crn);
00759 drms_setkey_float(smalloutMlRec, "CRLT_OBS", crlt);
00760 drms_setkey_float(smalloutMlRec, "CRLN_OBS", crln);
00761 drms_setkey_float(smalloutMlRec, "CADENCE", 24.0*60.0*60.0);
00762 drms_setkey_float(smalloutMlRec, "CROTA2", 0.0);
00763 drms_setkey_string(smalloutMlRec, "WCSNAME", "Carrington Heliographic");
00764 drms_setkey_string(smalloutMlRec, "HISTORY", historyofthemodule);
00765 drms_setkey_string(smalloutMlRec, "BLD_VERS", jsoc_version);
00766 status = drms_setkey_string(smalloutMlRec, "CODEVER", cvsinfo);
00767
00768 loncen = xout - ((180.0-((nbin+1)/2.0-1.0)*(360.0/xdim_syn))/(360.0/xout)+1.0) + 1.0;
00769
00770
00771
00772 drms_setkey_double(smalloutRec, "CRPIX1", loncen);
00773 drms_setkey_double(smalloutMlRec, "CRPIX1", loncen);
00774 latcen = (yout+1.0)/2;
00775 drms_setkey_double(smalloutRec, "CRPIX2", latcen);
00776 drms_setkey_double(smalloutMlRec, "CRPIX2", latcen);
00777 lonstep = -360.0/xout;
00778 drms_setkey_double(smalloutRec, "CDELT1", lonstep);
00779 drms_setkey_double(smalloutMlRec, "CDELT1", lonstep);
00780 latstep = 2.0/yout;
00781 drms_setkey_double(smalloutRec, "CDELT2", latstep);
00782 drms_setkey_double(smalloutMlRec, "CDELT2", latstep);
00783
00784 lonfirst = 360.0 * (crn - 1) - clog0 + hwd + 360.0/xdim_syn + ((nbin+1)/2.0-1.0)*(360.0/xdim_syn);
00785 drms_setkey_double(smalloutRec, "LON_FRST", lonfirst);
00786 drms_setkey_double(smalloutMlRec, "LON_FRST", lonfirst);
00787
00788 lonlast = 360.0 * crn - clog0 + hwd - ((nbin+1)/2.0-1.0)*(360.0/xdim_syn);
00789 drms_setkey_double(smalloutRec, "LON_LAST", lonlast);
00790 drms_setkey_double(smalloutMlRec, "LON_LAST", lonlast);
00791
00792 loncenter = 360.0 * (crn - 1) - clog0 + hwd + 360.0/xdim_syn + 180.0;
00793
00794
00795 drms_setkey_double(smalloutRec, "CRVAL1", loncenter);
00796 drms_setkey_double(smalloutRec, "CARRTIME", loncenter);
00797 drms_setkey_double(smalloutRec, "LON_STEP", lonstep);
00798 drms_setkey_double(smalloutMlRec, "CRVAL1", loncenter);
00799 drms_setkey_double(smalloutMlRec, "CARRTIME", loncenter);
00800 drms_setkey_double(smalloutMlRec, "LON_STEP", lonstep);
00801
00802
00803 hwnwidth = drms_getkey_float(synRec, "HWNWIDTH", &status);
00804 drms_setkey_float(smalloutRec, "HWNWIDTH", hwnwidth);
00805 drms_setkey_float(smalloutMlRec, "HWNWIDTH", hwnwidth);
00806 eqpoints = drms_getkey_float(synRec, "EQPOINTS", &status);
00807 drms_setkey_float(smalloutRec, "EQPOINTS", eqpoints);
00808 drms_setkey_float(smalloutMlRec, "EQPOINTS", eqpoints);
00809 syndro_a = drms_getkey_float(synRec, "DIFROT_A", &status);
00810 drms_setkey_float(smalloutRec, "OSYNDR_A", syndro_a);
00811 drms_setkey_float(smalloutMlRec, "OSYNDR_A", syndro_a);
00812 syndro_b = drms_getkey_float(synRec, "DIFROT_B", &status);
00813 drms_setkey_float(smalloutRec, "OSYNDR_B", syndro_b);
00814 drms_setkey_float(smalloutMlRec, "OSYNDR_B", syndro_b);
00815 syndro_c = drms_getkey_float(synRec, "DIFROT_C", &status);
00816 drms_setkey_float(smalloutRec, "OSYNDR_C", syndro_c);
00817 drms_setkey_float(smalloutMlRec, "OSYNDR_C", syndro_c);
00818
00819
00820 drms_setkey_string(smalloutRec, "FRTIMWDN", t_window);
00821 drms_setkey_string(smalloutRec, "SYNDRORA", drmethod);
00822 drms_setkey_int(smalloutRec, "FRAVEPNT", count);
00823 drms_setkey_float(smalloutRec, "FRWINDOW", 2.0 * hwd);
00824 drms_setkey_float(smalloutRec, "SYNDRO_A", aa);
00825 drms_setkey_float(smalloutRec, "SYNDRO_B", bb);
00826 drms_setkey_float(smalloutRec, "SYNDRO_C", cc);
00827 drms_keyword_setdate(smalloutRec);
00828
00829 drms_setkey_string(smalloutMlRec, "FRTIMWDN", t_window);
00830 drms_setkey_string(smalloutMlRec, "SYNDRORA", drmethod);
00831 drms_setkey_int(smalloutMlRec, "FRAVEPNT", count);
00832 drms_setkey_float(smalloutMlRec, "FRWINDOW", 2.0 * hwd);
00833 drms_setkey_float(smalloutMlRec, "SYNDRO_A", aa);
00834 drms_setkey_float(smalloutMlRec, "SYNDRO_B", bb);
00835 drms_setkey_float(smalloutMlRec, "SYNDRO_C", cc);
00836 drms_keyword_setdate(smalloutMlRec);
00837
00838 printf(" WRITING OUTPUT--small-size version\n");
00839
00840
00841 smalloutSeg = drms_segment_lookupnum(smalloutRec, 0);
00842 smalloutArray = drms_array_create(DRMS_TYPE_FLOAT, 2, smallDims, smalloutDataBr, &status);
00843 status = drms_segment_write(smalloutSeg, smalloutArray, 0);
00844 if (status) DIE("problem writing file");
00845 drms_free_array(smalloutArray);
00846
00847
00848 smalloutSeg = drms_segment_lookupnum(smalloutMlRec, 0);
00849 smalloutArray = drms_array_create(DRMS_TYPE_FLOAT, 2, smallDims, smalloutDataBlos, &status);
00850 status = drms_segment_write(smalloutSeg, smalloutArray, 0);
00851 if (status) DIE("problem writing file");
00852 drms_free_array(smalloutArray);
00853
00854 free(trec_str); free(recp); free(aveData); free(countNumber);
00855 drms_free_array(supsynArray);
00856 drms_free_array(synArray);
00857
00858 drms_close_records(smallRD, DRMS_INSERT_RECORD);
00859 drms_close_records(smallMlRD, DRMS_INSERT_RECORD);
00860 drms_close_records(outRD, DRMS_INSERT_RECORD);
00861 drms_close_records(outMlRD, DRMS_INSERT_RECORD);
00862 drms_close_records(synRS, DRMS_FREE_RECORD);
00863
00864 return 0;
00865
00866 }
00867
00868
00869
00870
00871
00872 float zgrid(int jph, int ith, int cmp, int rup, int dbl,
00873 float phd[], float thd[], float lad[], float cth[],
00874 float sth[], float csc[], float scs[])
00875 {
00876
00877 double dtor = PI/180.;
00878 int i, j;
00879
00880 float dcth = 2.0/ith;
00881 float dph = 360./jph;
00882 float cpc[jph], thr, dphr;
00883 float lthd[ith], lphd[jph], lscs[jph];
00884 float llad[ith], lsth[ith], lcth[ith];
00885
00886 #if 0
00887 if (dbl == 1)
00888 {
00889 double thd[ith], phd[jph], csc[ith], cpc[jph];
00890 double dph = 360./jph;
00891 double dcth = 2.0/ith;
00892 double lad[ith], sth[ith], cth[ith], thr;
00893 double lthd[ith], lphd[jph], lscs[jph];
00894 double llad[ith], lsth[ith], lcth[ith];
00895 double dphr;
00896 float scs[jph];
00897 }
00898 #endif
00899
00900 for (i =0; i < ith; i++)
00901 {
00902 cth[i] = (i + 0.5) * dcth - 1.0;
00903 thr = acos(cth[i]);
00904 sth[i] = sin(thr);
00905 thd[i] = thr/dtor;
00906 lad[i] = 90-thd[i];
00907 }
00908
00909 for (j = 0; j < jph; j++)
00910 phd[j] = (j + 0.5) * dph;
00911
00912 if (cmp == 1)
00913 {
00914 for (i = 0; i < ith; i++)
00915 csc[i] = 1/sth[i];
00916 for (j = 0; j < jph; j++)
00917 {
00918 dphr = (phd[j] - cmp) * dtor;
00919 cpc[j] = cos(dphr);
00920 scs[j] = 1/cpc[j];
00921 }
00922 }
00923
00924 if (rup == 1)
00925 {
00926 for (i = 0; i < ith; i++)
00927 {
00928 thd[i] = lthd[ith - i];
00929 lad[i] = llad[ith - 1];
00930 cth[i] = lcth[ith - i];
00931 sth[i] = lsth[ith - 1];
00932 }
00933 for (j = 0; j < jph; j++)
00934 {
00935 phd[j] = lphd[jph-j];
00936 scs[j] = lscs[jph-j];
00937 }
00938 }
00939 return 0;
00940 }
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959 void frebinbox(float *image_in, float *image_out, int nx, int ny, int nbinx, int nbiny)
00960 {
00961 int nxout, nyout;
00962 int ii, jj, i, j;
00963 nxout = nx / nbinx; nyout = ny / nbiny;
00964 for (j = 0; j < nyout; j++) {
00965 int yOff, jy;
00966 jy = j * nbiny;
00967 for (i = 0; i < nxout; i++) {
00968 int ix;
00969 ix = i * nbinx;
00970 float aveval = 0.0;
00971 int number = 0;
00972 for (jj = 0; jj < nbiny; jj++) {
00973 yOff = (jy + jj) * nx;
00974 for (ii = 0; ii < nbinx; ii++) {
00975 int iData = yOff + ix + ii;
00976 if (!(isnan(image_in[iData]))) {
00977 aveval += image_in[iData];
00978 number += 1;
00979 }
00980 }
00981 }
00982 image_out[j*nxout+i] = aveval/number;
00983 }
00984 }
00985 }
00986
00987