(file) Return to jrebinsmooth.c CVS log (file) (dir) Up to [Development] / JSOC / proj / globalhs / apps

Diff for /JSOC/proj/globalhs/apps/jrebinsmooth.c between version 1.5 and 1.6

version 1.5, 2013/10/17 23:35:13 version 1.6, 2014/01/16 08:13:19
Line 11  this module (optionally) rebins its inpu
Line 11  this module (optionally) rebins its inpu
 #include "jsoc_main.h" #include "jsoc_main.h"
 #include "drms_dsdsapi.h" #include "drms_dsdsapi.h"
 #include "fresize.h" #include "fresize.h"
   #include "fstats.h"
  
 #define ARRLENGTH(ARR)  (sizeof(ARR)/sizeof(ARR[0])) #define ARRLENGTH(ARR)  (sizeof(ARR)/sizeof(ARR[0]))
 #define QUAL_NODATA     (0x80000000) #define QUAL_NODATA     (0x80000000)
Line 62  int DoIt(void)
Line 63  int DoIt(void)
   char trecstr[100];   char trecstr[100];
   struct fresize_struct fress;   struct fresize_struct fress;
   int xpixin, ypixin, xpix1, ypix1, xpix2, ypix2;   int xpixin, ypixin, xpix1, ypix1, xpix2, ypix2;
     float x0in, y0in, xscalein, yscalein, x01, y01, xscale1, yscale1, x02, y02, xscale2, yscale2;
   float *inptr, *outptr;   float *inptr, *outptr;
  
   DRMS_RecordSet_t *inrecset = NULL;   DRMS_RecordSet_t *inrecset = NULL;
Line 221  int DoIt(void)
Line 223  int DoIt(void)
   init_fresize_gaussian(&fress, sigma, hwidth, nsub);   init_fresize_gaussian(&fress, sigma, hwidth, nsub);
 //  init_fresize_gaussian_fft(&fress, sigma, hwidth, nsub, nxin, nyin); //  init_fresize_gaussian_fft(&fress, sigma, hwidth, nsub, nxin, nyin);
  
     DRMS_RecordSet_t *outrecset = drms_create_records(drms_env, nrecs, outseries, lifetime, &status);
     if (status != DRMS_SUCCESS || outrecset == NULL)
     {
       fprintf(stderr,"ERROR: unable to create record in output dataseries, status = %d\n", status);
       return 1;
     }
   
     DRMS_RecordSet_t *interoutrecset;
     if (interflag)
     {
       interoutrecset = drms_create_records(drms_env, nrecs, interout, lifetime, &status);
       if (status != DRMS_SUCCESS || interoutrecset == NULL)
       {
         fprintf(stderr,"ERROR: unable to create record in intermediate output dataseries, status = %d\n", status);
         return 1;
       }
     }
   
   error=0;   error=0;
     int nodata=0;
   for (irec=0; irec<nrecs; irec++)   for (irec=0; irec<nrecs; irec++)
   {   {
  
     inrec = inrecset->records[irec];     inrec = inrecset->records[irec];
     outrec = drms_create_record(drms_env, outseries, lifetime, &status);      outrec = outrecset->records[irec];
   
     if (status != DRMS_SUCCESS || outrec == NULL)  
     {  
       fprintf(stderr,"ERROR: unable to create record in output dataseries, status = %d\n", status);  
       error=2;  
       break;  
     }  
  
     if (histlink)     if (histlink)
       drms_setlink_static(outrec, histlinkname,  histrecnum);       drms_setlink_static(outrec, histlinkname,  histrecnum);
Line 257  int DoIt(void)
Line 271  int DoIt(void)
  
     if (quality & QUAL_NODATA)     if (quality & QUAL_NODATA)
     {     {
         nodata=1;
         if (verbflag > 1)
       fprintf(stderr,"SKIP: record rejected based on quality = %d: irec = %d, T_REC = %s, recnum = %lld\n", quality, irec, trecstr, inrec->recnum);       fprintf(stderr,"SKIP: record rejected based on quality = %d: irec = %d, T_REC = %s, recnum = %lld\n", quality, irec, trecstr, inrec->recnum);
       continue;  //      continue;
     }     }
       else
       {
         nodata=0;
  
     if (seginflag)     if (seginflag)
       segin = drms_segment_lookup(inrec, segnamein);       segin = drms_segment_lookup(inrec, segnamein);
Line 285  int DoIt(void)
Line 304  int DoIt(void)
     xpix2=xpix1/nsub;     xpix2=xpix1/nsub;
     ypix2=ypix1/nsub;     ypix2=ypix1/nsub;
  
     float x0in = drms_getkey_float(inrec, "CRPIX1", &status) - 1;        x0in = drms_getkey_float(inrec, "CRPIX1", &status) - 1;
     float y0in = drms_getkey_float(inrec, "CRPIX2", &status) - 1;        y0in = drms_getkey_float(inrec, "CRPIX2", &status) - 1;
     float xscalein = drms_getkey_float(inrec, "CDELT1", &status);        xscalein = drms_getkey_float(inrec, "CDELT1", &status);
     float yscalein = drms_getkey_float(inrec, "CDELT2", &status);        yscalein = drms_getkey_float(inrec, "CDELT2", &status);
   
     float x01 = (x0in - bxoff + 0.5)/nbin - 0.5;        x01 = (x0in - bxoff + 0.5)/nbin - 0.5;
     float y01 = (y0in - byoff + 0.5)/nbin - 0.5;        y01 = (y0in - byoff + 0.5)/nbin - 0.5;
     float xscale1=xscalein*nbin;        xscale1=xscalein*nbin;
     float yscale1=yscalein*nbin;        yscale1=yscalein*nbin;
  
     if (ibin)     if (ibin)
     {     {
Line 310  int DoIt(void)
Line 329  int DoIt(void)
            nbin,            nbin,
            bxoff,            bxoff,
            byoff,            byoff,
            bfill             bfill);
           );        }
     }     }
  
     if (interflag)      if (interflag && nodata)
       {
         DRMS_Record_t *outrec = interoutrecset->records[irec];
         DRMS_Link_t *histlink = hcon_lookup_lower(&outrec->links, histlinkname);
         DRMS_Link_t *srclink = hcon_lookup_lower(&outrec->links, srclinkname);
         if (histlink)
           drms_setlink_static(outrec, histlinkname,  histrecnum);
         if (srclink)
           drms_setlink_static(outrec, srclinkname,  inrec->recnum);
         drms_copykeys(outrec, inrec, 0, kDRMS_KeyClass_Explicit);
         tnow = (double)time(NULL);
         tnow += UNIX_epoch;
         drms_setkey_time(outrec, "DATE", tnow);
   
       }
       else if (interflag)
     {     {
       DRMS_Record_t *outrec = drms_create_record(drms_env, interout, lifetime, &status);  //      DRMS_Record_t *outrec = drms_create_record(drms_env, interout, lifetime, &status);
         DRMS_Record_t *outrec = interoutrecset->records[irec];
       DRMS_Link_t *histlink = hcon_lookup_lower(&outrec->links, histlinkname);       DRMS_Link_t *histlink = hcon_lookup_lower(&outrec->links, histlinkname);
       DRMS_Link_t *srclink = hcon_lookup_lower(&outrec->links, srclinkname);       DRMS_Link_t *srclink = hcon_lookup_lower(&outrec->links, srclinkname);
       if (histlink)       if (histlink)
Line 332  int DoIt(void)
Line 367  int DoIt(void)
       outarr = drms_array_create(usetype, 2, length, interptr, &status);       outarr = drms_array_create(usetype, 2, length, interptr, &status);
       outarr->bzero=segout->bzero;       outarr->bzero=segout->bzero;
       outarr->bscale=segout->bscale;       outarr->bscale=segout->bscale;
       drms_segment_write(segout, outarr, 0);        status=drms_segment_write(segout, outarr, 0);
       drms_copykeys(outrec, inrec, 0, kDRMS_KeyClass_Explicit);       drms_copykeys(outrec, inrec, 0, kDRMS_KeyClass_Explicit);
       drms_setkey_int(outrec, "TOTVALS", xpix1*ypix1);       drms_setkey_int(outrec, "TOTVALS", xpix1*ypix1);
       set_statistics(segout, outarr, 1);       set_statistics(segout, outarr, 1);
Line 345  int DoIt(void)
Line 380  int DoIt(void)
       tnow = (double)time(NULL);       tnow = (double)time(NULL);
       tnow += UNIX_epoch;       tnow += UNIX_epoch;
       drms_setkey_time(outrec, "DATE", tnow);       drms_setkey_time(outrec, "DATE", tnow);
       drms_close_record(outrec, DRMS_INSERT_RECORD);  //      drms_close_record(outrec, DRMS_INSERT_RECORD);
       }
   
       if (nodata)
       {
         drms_copykeys(outrec, inrec, 0, kDRMS_KeyClass_Explicit);
         tnow = (double)time(NULL);
         tnow += UNIX_epoch;
         drms_setkey_time(outrec, "DATE", tnow);
         continue;
     }     }
  
     length[0]=xpix2;     length[0]=xpix2;
Line 394  int DoIt(void)
Line 438  int DoIt(void)
              );              );
     }     }
  
     float x02 = (x01 - gxoff)/nsub;      x02 = (x01 - gxoff)/nsub;
     float y02 = (y01 - gyoff)/nsub;      y02 = (y01 - gyoff)/nsub;
     float xscale2=xscale1*nsub;      xscale2=xscale1*nsub;
     float yscale2=yscale1*nsub;      yscale2=yscale1*nsub;
  
     outarr->bzero=segout->bzero;     outarr->bzero=segout->bzero;
     outarr->bscale=segout->bscale;     outarr->bscale=segout->bscale;
     drms_segment_write(segout, outarr, 0);      status=drms_segment_write(segout, outarr, 0);
     drms_copykeys(outrec, inrec, 0, kDRMS_KeyClass_Explicit);     drms_copykeys(outrec, inrec, 0, kDRMS_KeyClass_Explicit);
     drms_setkey_int(outrec, "TOTVALS", xpix2*ypix2);     drms_setkey_int(outrec, "TOTVALS", xpix2*ypix2);
     set_statistics(segout, outarr, 1);     set_statistics(segout, outarr, 1);
Line 415  int DoIt(void)
Line 459  int DoIt(void)
     tnow += UNIX_epoch;     tnow += UNIX_epoch;
     drms_setkey_time(outrec, "DATE", tnow);     drms_setkey_time(outrec, "DATE", tnow);
  
     drms_close_record(outrec, DRMS_INSERT_RECORD);  //    drms_close_record(outrec, DRMS_INSERT_RECORD);
     drms_free_array(inarr);     drms_free_array(inarr);
     drms_free_array(outarr);     drms_free_array(outarr);
     if (interptr != NULL)     if (interptr != NULL)
Line 424  int DoIt(void)
Line 468  int DoIt(void)
   }   }
  
   drms_close_records(inrecset, DRMS_FREE_RECORD);   drms_close_records(inrecset, DRMS_FREE_RECORD);
     if (error)
   if (error == 1)    {
     drms_close_record(outrec, DRMS_FREE_RECORD);      drms_close_records(outrecset, DRMS_FREE_RECORD);
       if (interflag)
         drms_close_records(interoutrecset, DRMS_FREE_RECORD);
     }
     else
     {
       drms_close_records(outrecset, DRMS_INSERT_RECORD);
       if (interflag)
         drms_close_records(interoutrecset, DRMS_INSERT_RECORD);
     }
  
   free_fresize(&fress);   free_fresize(&fress);
  


Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

Karen Tian
Powered by
ViewCVS 0.9.4