version 1.1, 2012/05/09 03:53:22
|
version 1.4, 2012/09/20 17:33:45
|
Line 75 int jretile_manytofew(void) |
|
Line 75 int jretile_manytofew(void) |
|
sprint_time(tstartstr, tstart, "TAI", 0); | sprint_time(tstartstr, tstart, "TAI", 0); |
ttotal=(char *)cmdparams_save_str(&cmdparams, "TTOTAL", &newstat); | ttotal=(char *)cmdparams_save_str(&cmdparams, "TTOTAL", &newstat); |
status=drms_names_parseduration(&ttotal, &nseconds, 1); | status=drms_names_parseduration(&ttotal, &nseconds, 1); |
if (status) |
if (status != DRMS_SUCCESS) |
{ | { |
// newstat = newstat | CPSAVE_UNKNOWN_ERROR; | // newstat = newstat | CPSAVE_UNKNOWN_ERROR; |
fprintf(stderr, "ERROR: problem parsing TTOTAL, = %s\n", ttotal); | fprintf(stderr, "ERROR: problem parsing TTOTAL, = %s\n", ttotal); |
Line 85 int jretile_manytofew(void) |
|
Line 85 int jretile_manytofew(void) |
|
if (strcmp(kNOTSPECIFIED, tchunk)) | if (strcmp(kNOTSPECIFIED, tchunk)) |
{ | { |
status=drms_names_parseduration(&tchunk, &chunksecs, 1); | status=drms_names_parseduration(&tchunk, &chunksecs, 1); |
if (status) |
if (status != DRMS_SUCCESS) |
newstat = newstat | CPSAVE_UNKNOWN_ERROR; | newstat = newstat | CPSAVE_UNKNOWN_ERROR; |
} | } |
else | else |
Line 287 int jretile_manytofew(void) |
|
Line 287 int jretile_manytofew(void) |
|
return 1; | return 1; |
} | } |
| |
irecout=0; |
long long calversout, calvers; |
for (iset=0; iset < ntimechunks; iset++) |
int calversunset=1; |
{ |
|
tstartout=tstart + iset * chunksecs; |
|
tstopout=tstartout+chunksecs; |
|
|
|
for (lchunk = lchunkfirst; lchunk <= lchunklast; lchunk++) |
|
{ |
|
lminout = lchunk * lchunksize; |
|
lmaxout = lminout + lchunksize - 1; |
|
lminout = MAXIMUM(lminout,lmin); |
|
lmaxout = MINIMUM(lmaxout,lmax); |
|
|
|
outrec = outrecset->records[irecout]; |
|
if (histlink) |
|
drms_setlink_static(outrec, histlinkname, histrecnum); |
|
drms_setkey_int(outrec, "LMIN", lminout); |
|
drms_setkey_int(outrec, "LMAX", lmaxout); |
|
drms_setkey_time(outrec, "T_START", tstartout); |
|
drms_setkey_time(outrec, "T_STOP", tstopout); |
|
drms_setkey_time(outrec, "T_OBS", tstartout+chunksecs/2); |
|
drms_setkey_int(outrec, "NDT", ndt); |
|
/* |
|
if (segoutflag) |
|
segout = drms_segment_lookup(outrec, segnameout); |
|
else |
|
segout = drms_segment_lookupnum(outrec, 0); |
|
segout->axis[0]=2*ndt; |
|
segout->axis[1]=lmaxout*(lmaxout+1)/2+lmaxout - lminout*(lminout+1)/2 + 1; |
|
*/ |
|
irecout++; |
|
} |
|
} |
|
|
|
| |
|
int firsttimethrough=1; |
int *nskiparr=(int *)calloc(nrecsout,sizeof(int)); | int *nskiparr=(int *)calloc(nrecsout,sizeof(int)); |
for (irecin=0; irecin < nrecsin; irecin++) | for (irecin=0; irecin < nrecsin; irecin++) |
{ | { |
Line 348 int jretile_manytofew(void) |
|
Line 317 int jretile_manytofew(void) |
|
// continue; | // continue; |
} | } |
| |
|
if (calversunset) |
|
{ |
|
calversout=drms_getkey_longlong(inrec, "CALVER64", &status); |
|
if (status != DRMS_SUCCESS) |
|
calversout = 0; |
|
calversunset=0; |
|
} |
|
|
|
calvers=drms_getkey_longlong(inrec, "CALVER64", &status); |
|
if (status != DRMS_SUCCESS) |
|
calvers = 0; |
|
|
|
if (calvers != calversout) |
|
{ |
|
fprintf(stderr, "ERROR: input data has mixed CALVER64: %lld and %lld, recnum = %lld, histrecnum = %lld\n", calversout, calvers, inrec->recnum, histrecnum); |
|
return 0; |
|
} |
|
|
if (seginflag) | if (seginflag) |
segin = drms_segment_lookup(inrec, segnamein); | segin = drms_segment_lookup(inrec, segnamein); |
else | else |
segin = drms_segment_lookupnum(inrec, 0); | segin = drms_segment_lookupnum(inrec, 0); |
if (segin) |
if (segin != NULL) |
inarr = drms_segment_read(segin, usetype, &status); | inarr = drms_segment_read(segin, usetype, &status); |
// inarr = drms_segment_readslice(segin, usetype, startind, endind, &status); | // inarr = drms_segment_readslice(segin, usetype, startind, endind, &status); |
if (status != DRMS_SUCCESS || inarr == NULL || segin == NULL) | if (status != DRMS_SUCCESS || inarr == NULL || segin == NULL) |
Line 382 int jretile_manytofew(void) |
|
Line 369 int jretile_manytofew(void) |
|
lmaxout = lminout + lchunksize - 1; | lmaxout = lminout + lchunksize - 1; |
lminout = MAXIMUM(lminout,lmin); | lminout = MAXIMUM(lminout,lmin); |
lmaxout = MINIMUM(lmaxout,lmax); | lmaxout = MINIMUM(lmaxout,lmax); |
|
outrec = outrecset->records[irecout]; |
|
|
|
if (firsttimethrough) |
|
{ |
|
if (histlink != NULL) |
|
drms_setlink_static(outrec, histlinkname, histrecnum); |
|
drms_copykeys(outrec, inrec, 0, kDRMS_KeyClass_Explicit); |
|
// copykeys takes care of MAPMMAX, SINBDIVS, CALVER64, etc. that should be constant across the input |
|
drms_setkey_int(outrec, "LMIN", lminout); |
|
drms_setkey_int(outrec, "LMAX", lmaxout); |
|
drms_setkey_time(outrec, "T_START", tstartout); |
|
drms_setkey_time(outrec, "T_STOP", tstopout); |
|
drms_setkey_time(outrec, "T_OBS", tstartout+chunksecs/2); |
|
drms_setkey_int(outrec, "NDT", ndt); |
|
} |
| |
if (tstartin >= tstopout || tstopin <= tstartout || lminin > lmaxout || lmaxin < lminout) | if (tstartin >= tstopout || tstopin <= tstartout || lminin > lmaxout || lmaxin < lminout) |
{ | { |
Line 389 int jretile_manytofew(void) |
|
Line 391 int jretile_manytofew(void) |
|
continue; | continue; |
} | } |
| |
outrec = outrecset->records[irecout]; |
|
if (segoutflag) | if (segoutflag) |
segout = drms_segment_lookup(outrec, segnameout); | segout = drms_segment_lookup(outrec, segnameout); |
else | else |
Line 422 int jretile_manytofew(void) |
|
Line 423 int jretile_manytofew(void) |
|
outarr = drms_array_create(usetype, 2, length, arrptr, &status); | outarr = drms_array_create(usetype, 2, length, arrptr, &status); |
if (status != DRMS_SUCCESS || outarr == NULL || arrptr == NULL) | if (status != DRMS_SUCCESS || outarr == NULL || arrptr == NULL) |
{ | { |
fprintf(stderr,"ERROR: problem creating output array: T_START = %s, LMIN = %d, LMAX = %d, length = [%d, %d], status = %d, histrecnum = %lld", |
fprintf(stderr,"ERROR: problem creating output array: T_START = %s, LMIN = %d, LMAX = %d, length = [%d, %d], status = %d, histrecnum = %lld\n", |
tstartstr, lminout, lmaxout, length[0], length[1], status, histrecnum); | tstartstr, lminout, lmaxout, length[0], length[1], status, histrecnum); |
drms_close_records(inrecset, DRMS_FREE_RECORD); | drms_close_records(inrecset, DRMS_FREE_RECORD); |
drms_close_records(outrecset, DRMS_FREE_RECORD); | drms_close_records(outrecset, DRMS_FREE_RECORD); |
Line 443 int jretile_manytofew(void) |
|
Line 444 int jretile_manytofew(void) |
|
in_offset+=2*tstepin/cadence; | in_offset+=2*tstepin/cadence; |
} | } |
| |
|
outarr->bzero=segout->bzero; |
|
outarr->bscale=segout->bscale; |
status=drms_segment_writeslice_ext(segout, outarr, startind, endind, totallength, 0); | status=drms_segment_writeslice_ext(segout, outarr, startind, endind, totallength, 0); |
if (status != DRMS_SUCCESS) | if (status != DRMS_SUCCESS) |
{ | { |
Line 459 int jretile_manytofew(void) |
|
Line 462 int jretile_manytofew(void) |
|
} // end loop on lchunk | } // end loop on lchunk |
} // end loop on iset | } // end loop on iset |
| |
|
firsttimethrough=0; |
|
drms_free_array(inarr); |
continue_outer_loop: | continue_outer_loop: |
inrec = drms_recordset_fetchnext(drms_env, inrecset, &fetchstat, &chunkstat, NULL); | inrec = drms_recordset_fetchnext(drms_env, inrecset, &fetchstat, &chunkstat, NULL); |
} // end loop on irecin | } // end loop on irecin |