Changeset 40401 for trunk/Ohana/src/opihi/dvo/avperiodogram.c
- Timestamp:
- Apr 19, 2018, 9:41:13 PM (8 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/dvo/avperiodogram.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/dvo/avperiodogram.c
r40400 r40401 20 20 21 21 void PeriodogramResultFree (PeriodogramResult *result); 22 void PeriodogramResultSave (PeriodogramResult *result, char *extname, FILE *foutput, Average *average); 22 23 PeriodogramResult *periodogram_fm_raw (opihi_flt *time, opihi_flt *flux, opihi_flt *dflux, int Npts); 23 24 … … 27 28 int avperiodogram (int argc, char **argv) { 28 29 29 # if (0)30 31 30 int N, next, Nfields; 32 31 … … 73 72 // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results 74 73 if (PARALLEL && !HOST_ID) { 75 // XXX this is not going to work : the measure args will have been stripped off 76 int status = HostTableParallelOps (skylist, argc, argv, RESULT_FILE, TRUE, 0, VERBOSE); 77 78 dbFreeFields (fields, Nfields); 79 dbFreeStack (stack, Nstack); 80 free (stack); 74 int status = HostTableParallelOps (skylist, argc, argv, NULL, TRUE, 0, VERBOSE); 75 SkyListFree (skylist); 81 76 FreeSkyRegionSelection (selection); 82 dvo_catalog_free (&catalog);83 84 77 return status; 85 78 } … … 157 150 } 158 151 152 // command-line is of the form: avperiodogram (output) where (field op value)... 153 if (argc < 2) goto help; 154 char *output = strcreate (argv[1]); 155 156 // **** generate output file **** 157 // we save the results in a single FITS file, one extension per object 158 FILE *foutput = NULL; 159 if (RESULT_FILE) { 160 foutput = fopen (RESULT_FILE, "w"); 161 } else { 162 foutput = fopen (output, "w"); 163 } 164 // generate the PHU and write to disk 165 // XXX add some metadata here? 166 Header header; 167 Matrix matrix; 168 gfits_init_header (&header); 169 gfits_init_matrix (&matrix); 170 header.extend = TRUE; 171 gfits_create_header (&header); 172 gfits_create_matrix (&header, &matrix); 173 gfits_fwrite_header (foutput, &header); 174 gfits_fwrite_matrix (foutput, &matrix); 175 gfits_free_header (&header); 176 gfits_free_matrix (&matrix); 177 159 178 Catalog catalog; 160 179 dvo_catalog_init (&catalog, TRUE); … … 166 185 // init locally static variables (time refs) 167 186 dbExtractAveragesInit (); 168 169 // command-line is of the form: avperiodogram (output) where (field op value)...170 if (argc < 2) goto help;171 char *output = strcreate (argv[1]);172 187 173 188 // examine line for 'where' or 'match to'. 'match to' is forbidden … … 197 212 ALLOCATE (values, dbValue, Nfields); 198 213 214 int Nobject = 0; 215 char extname[80]; 216 199 217 // grab data from all selected sky regions 200 218 struct sigaction *old_sigaction = SetInterrupt(); … … 221 239 } 222 240 dvo_catalog_unlock (&catalog); 223 224 // we save the results in a single FITS file, one extension per object225 FILE *foutput = NULL;226 if (RESULT_FILE) {227 foutput = fopen (RESULT_FILE, "w");228 } else {229 foutput = fopen (output, "w");230 }231 232 // generate the PHU and write to disk233 Header header;234 Matrix matrix;235 gfits_init_header (&header);236 gfits_init_matrix (&matrix);237 header.extend = TRUE;238 gfits_create_header (&header);239 gfits_create_matrix (&header, &matrix);240 gfits_fwrite_header (foutput, &header);241 gfits_fwrite_matrix (foutput, &matrix);242 gfits_free_header (&header);243 gfits_free_matrix (&matrix);244 241 245 242 // Scan the catalog for objects which match the WHERE clause … … 299 296 PeriodogramResult *result = periodogram_fm_raw (time, mag, dmag, Npts); 300 297 301 PeriodogramResultSave (result, extname, foutput); 298 // XXX if we have 1e6 objects, we will have output files with sizes of ~80GB 299 // XXX warn or exit if Nboject > 1e6? 300 snprintf (extname, 80, "OBJ_%06d", Nobject); 301 PeriodogramResultSave (result, extname, foutput, average); 302 302 PeriodogramResultFree (result); 303 Nobject ++; 303 304 } 304 305 … … 330 331 331 332 help: 332 333 # endif334 333 gprint (GP_ERR, "USAGE: avperiodogram (output) where (expression) -where-measure (expression)\n"); 335 334 gprint (GP_ERR, " the where (expression) is a boolean to limit the objects analysed based on average properties\n"); 336 335 gprint (GP_ERR, " NOTE: the optional -where-measure (expression) MUST come after the average where expression\n"); 337 336 return (FALSE); 338 339 340 337 } 341 338 … … 470 467 } 471 468 472 /*473 474 469 // write the period and power vectors to an extension in this output file 475 void PeriodogramResult Free (PeriodogramResult *result, char *extname, FILE *foutput) {470 void PeriodogramResultSave (PeriodogramResult *result, char *extname, FILE *foutput, Average *average) { 476 471 477 472 // generate a binary table … … 482 477 outtable.header = &outheader; 483 478 484 // XXX add some metadata to the header to identify the object485 // extname should be related to the object IDs486 479 gfits_create_table_header (&outheader, "BINTABLE", extname); 480 481 // add some metadata derived from average: 482 gfits_modify (&outheader, "RA_OBJ", "%lf", 1, average->R); 483 gfits_modify (&outheader, "DEC_OBJ", "%lf", 1, average->D); 484 gfits_modify (&outheader, "OBJ_ID", "%d", 1, average->objID); 485 gfits_modify (&outheader, "CAT_ID", "%d", 1, average->catID); 487 486 488 487 gfits_define_bintable_column (&outheader, "D", "PERIOD", NULL, NULL, 1.0, 0.0); 489 488 gfits_define_bintable_column (&outheader, "D", "POWER", NULL, NULL, 1.0, 0.0); 490 489 491 gfits_create_table ( theader, ftable);490 gfits_create_table (&outheader, &outtable); 492 491 493 492 gfits_set_bintable_column (&outheader, &outtable, "PERIOD", result->period, result->Nperiods); … … 501 500 gfits_free_table (&outtable); 502 501 } 503 504 */
Note:
See TracChangeset
for help on using the changeset viewer.
