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

Diff for /JSOC/proj/globalhs/apps/jtsslice.c between version 1.4 and 1.5

version 1.4, 2011/11/15 05:24:07 version 1.5, 2012/05/09 03:56:25
Line 17  based on jtsfiddle, but no detrending or
Line 17  based on jtsfiddle, but no detrending or
 #include <math.h> #include <math.h>
 #include <assert.h> #include <assert.h>
 #include <fftw3.h> #include <fftw3.h>
 #include "fahlman_ulrych_C99.h"  //#include "fahlman_ulrych_C99.h"
 #include "detrend_C99.h"  //#include "detrend_C99.h"
  
 #include "jsoc_main.h" #include "jsoc_main.h"
 #include "/home/jsoc/include/fitsio.h" #include "/home/jsoc/include/fitsio.h"
Line 26  based on jtsfiddle, but no detrending or
Line 26  based on jtsfiddle, but no detrending or
 #define ARRLENGTH(ARR)  (sizeof(ARR)/sizeof(ARR[0])) #define ARRLENGTH(ARR)  (sizeof(ARR)/sizeof(ARR[0]))
 #define kNOTSPECIFIED "not specified" #define kNOTSPECIFIED "not specified"
  
 char *module_name = "jtsslice2";  char *module_name = "jtsslice";
  
 /* Command line arguments: */ /* Command line arguments: */
 ModuleArgs_t module_args[] = ModuleArgs_t module_args[] =
Line 237  int DoIt(void)
Line 237  int DoIt(void)
   DRMS_Link_t *histlink = hcon_lookup_lower(&tempoutrec->links, histlinkname);   DRMS_Link_t *histlink = hcon_lookup_lower(&tempoutrec->links, histlinkname);
   DRMS_Link_t *srclink = hcon_lookup_lower(&tempoutrec->links, srclinkname);   DRMS_Link_t *srclink = hcon_lookup_lower(&tempoutrec->links, srclinkname);
  
     char *cvsinfo = strdup("$Header$");
   if (histlink != NULL)   if (histlink != NULL)
   {   {
     histrecnum=set_history(histlink);      histrecnum=set_history(histlink, cvsinfo);
     if (histrecnum < 0)     if (histrecnum < 0)
     {     {
       drms_close_record(tempoutrec, DRMS_FREE_RECORD);       drms_close_record(tempoutrec, DRMS_FREE_RECORD);
Line 252  int DoIt(void)
Line 253  int DoIt(void)
   }   }
  
  // these must be present in the output dataseries and variable, not links or constants  // these must be present in the output dataseries and variable, not links or constants
   char *outchecklist[] = {"T_START", "QUALITY", "LMIN", "LMAX"};    char *outchecklist[] = {"T_START", "QUALITY", "LMIN", "LMAX", "NDT"};
  
   int itest;   int itest;
   for (itest=0; itest < ARRLENGTH(outchecklist); itest++)   for (itest=0; itest < ARRLENGTH(outchecklist); itest++)
Line 275  int DoIt(void)
Line 276  int DoIt(void)
     return 1;     return 1;
   }   }
   int ntimechunks = nseconds/chunksecs;   int ntimechunks = nseconds/chunksecs;
     tsample=tstep;
  
   int mflipout = drms_getkey_int(tempoutrec, "MFLIPPED", &status);   int mflipout = drms_getkey_int(tempoutrec, "MFLIPPED", &status);
   if (status != DRMS_SUCCESS) mflipout=0;   if (status != DRMS_SUCCESS) mflipout=0;
Line 355  int DoIt(void)
Line 357  int DoIt(void)
     return 1;     return 1;
   }   }
  
   if (inrecset->n > 1)  
   {  
     fprintf(stderr, "ERROR: nrecs > 1 not yet supported.\n");  
     return 1;  
   }  
   
   inrec=inrecset->records[0];   inrec=inrecset->records[0];
   char *inchecklist[] = {"T_START", "QUALITY", "LMIN", "LMAX", "T_STEP"};   char *inchecklist[] = {"T_START", "QUALITY", "LMIN", "LMAX", "T_STEP"};
  
Line 383  int DoIt(void)
Line 379  int DoIt(void)
   else   else
     flipm=0;     flipm=0;
  
     // changed n_in to gapsize in following call
     if (extract_gaps(gapsize, agaps, &n_sampled_in, gaps, tsample, &tsamplex, &num_sections, sections))
     {
       fprintf(stderr, "ERROR: problem in extract_gaps\n");
       return 0;
     }
   
     if (n_sampled_out == -1)
       n_sampled_out = n_sampled_in;
     df1 = tsamplex*n_sampled_out;
   
     if (fftout || fft1out || powout || mavgout)
       plan = fftwf_plan_dft_1d(n_sampled_out, (fftwf_complex *)data,
                               (fftwf_complex *)data, FFTW_BACKWARD, FFTW_MEASURE);
   
     /* Set sum to zero before starting */
     if (mavgout)
       msum = (float *)calloc(n_sampled_out/2,sizeof(float));
   
     if (fft1out || powout || mavgout)
     {
       /* Set first and last output index if not set as a parameter. */
       if (imax < imin)
       {
         imin=0;
         imax=n_sampled_out/2-1;
       }
       npow=imax-imin+1;
       pow=(float *)(malloc(n_sampled_out*sizeof(float)));
     }
   
   
   status=drms_stage_records(inrecset, 1, 0);   status=drms_stage_records(inrecset, 1, 0);
   if (status != DRMS_SUCCESS)   if (status != DRMS_SUCCESS)
   {   {
Line 390  int DoIt(void)
Line 418  int DoIt(void)
     return 1;     return 1;
   }   }
  
     int nrecsout = ntimechunks * inrecset->n;
     DRMS_RecordSet_t *outrecset = drms_create_records(drms_env, nrecsout, outseries, DRMS_PERMANENT, &status);
     if (status != DRMS_SUCCESS || outrecset == NULL)
     {
      fprintf(stderr,"ERROR: couldn't open a record in output dataseries %s, status = %d\n", outseries, status);
      return 1;
     }
   
 // insert loop over input here // insert loop over input here
 int irec=0; int irec=0;
     for (irec=0;irec<inrecset->n;irec++)
     {
   
   inrec = inrecset->records[irec];   inrec = inrecset->records[irec];
  
   int lmin=drms_getkey_int(inrec, "LMIN", NULL);   int lmin=drms_getkey_int(inrec, "LMIN", NULL);
Line 405  int irec=0;
Line 444  int irec=0;
  
   tstart=tstartsave=drms_getkey_time(inrec, "T_START", NULL);   tstart=tstartsave=drms_getkey_time(inrec, "T_START", NULL);
   tstop =tstopsave =drms_getkey_time(inrec, "T_STOP", NULL);   tstop =tstopsave =drms_getkey_time(inrec, "T_STOP", NULL);
 //  tstep=drms_getkey_float(inrec, "T_STEP", NULL);  
  
   n_in=(tstop-tstart)/tstep;   n_in=(tstop-tstart)/tstep;
   if (n_in != gapsize)   if (n_in != gapsize)
Line 414  int irec=0;
Line 452  int irec=0;
     return 0;     return 0;
   }   }
  
   tsample=tstep;  
   
   // changed n_in to gapsize in following call  
   if (extract_gaps(gapsize, agaps, &n_sampled_in, gaps, tsample, &tsamplex, &num_sections, sections))  
   {  
     fprintf(stderr, "ERROR: problem in extract_gaps\n");  
     return 0;  
   }  
   
   if (n_sampled_out == -1)  
     n_sampled_out = n_sampled_in;  
   df1 = tsamplex*n_sampled_out;  
   
   if (fftout || fft1out || powout || mavgout)  
     plan = fftwf_plan_dft_1d(n_sampled_out, (fftwf_complex *)data,  
                             (fftwf_complex *)data, FFTW_BACKWARD, FFTW_MEASURE);  
   
   /* Set sum to zero before starting */  
   if (mavgout)  
     msum = (float *)calloc(n_sampled_out/2,sizeof(float));  
   
   /* Create output data set. */   /* Create output data set. */
   if (tsout || fftout)   if (tsout || fftout)
   {   {
Line 443  int irec=0;
Line 460  int irec=0;
   }   }
   else   else
   {   {
     /* Set first and last output index if not set as a parameter. */  
     if (imax < imin)  
     {  
       imin=0;  
       imax=n_sampled_out/2-1;  
     }  
     npow=imax-imin+1;  
     pow=(float *)(malloc(n_sampled_out*sizeof(float)));  
     if (fft1out)     if (fft1out)
       length[0]=2*npow;       length[0]=2*npow;
     else     else
Line 501  int irec=0;
Line 510  int irec=0;
     }     }
     datarr=(float *)(inarr->data);     datarr=(float *)(inarr->data);
  
     outrec = drms_create_record(drms_env,  /*
                               outseries,        outrec = drms_create_record(drms_env, outseries, lifetime, &status);
                               lifetime,  
                               &status);  
   
     if (status != DRMS_SUCCESS || outrec==NULL)     if (status != DRMS_SUCCESS || outrec==NULL)
     {     {
        fprintf(stderr,"ERROR: unable to open record in output dataseries, status = %d\n", status);        fprintf(stderr,"ERROR: unable to open record in output dataseries, status = %d\n", status);
        return 0;        return 0;
     }     }
   */
         outrec = outrecset->records[ntimechunks*irec+iset];
  
     if (histlink)     if (histlink)
        drms_setlink_static(outrec, histlinkname,  histrecnum);        drms_setlink_static(outrec, histlinkname,  histrecnum);
Line 644  int irec=0;
Line 652  int irec=0;
       return 0;       return 0;
     }     }
  
     drms_close_record(outrec, DRMS_INSERT_RECORD);  //    drms_close_record(outrec, DRMS_INSERT_RECORD);
  
   }   }
  
   drms_free_array(inarr);  
   if (inrecset)  
   {  
     drms_close_records(inrecset, DRMS_FREE_RECORD);  
   }   }
  
     drms_free_array(inarr);
     drms_close_records(inrecset,  DRMS_FREE_RECORD);
     drms_close_records(outrecset, DRMS_INSERT_RECORD);
  
   if (fftout || fft1out || powout || mavgout)   if (fftout || fft1out || powout || mavgout)
     fftwf_destroy_plan(plan);     fftwf_destroy_plan(plan);
Line 662  int irec=0;
Line 669  int irec=0;
   ct=getcputime(&ut, &st);   ct=getcputime(&ut, &st);
   if (verbflag)   if (verbflag)
   {   {
 //    printf("number of records created = %d\n", nsuccess);  
     fprintf(stdout, "total time spent: %.2f ms wall time, %.2f ms cpu time\n",     fprintf(stdout, "total time spent: %.2f ms wall time, %.2f ms cpu time\n",
             wt-wt0, ct-ct0);             wt-wt0, ct-ct0);
   }   }


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

Karen Tian
Powered by
ViewCVS 0.9.4