| [2281] | 1 | // ArchTOIPipe           (C)     CEA/DAPNIA/SPP IN2P3/LAL | 
|---|
|  | 2 | //                               Eric Aubourg | 
|---|
|  | 3 | //                               Cecile Renault | 
|---|
|  | 4 | //                               Christophe Magneville | 
|---|
|  | 5 | //                               Reza Ansari | 
|---|
| [2361] | 6 | // $Id: fitsringwtr.cc,v 1.7 2003-04-17 13:47:34 cecile Exp $ | 
|---|
| [2281] | 7 |  | 
|---|
|  | 8 | #include "fitsringwtr.h" | 
|---|
|  | 9 | #include "toimanager.h" | 
|---|
|  | 10 |  | 
|---|
|  | 11 | extern void fits_lock(); | 
|---|
|  | 12 | extern void fits_unlock(); | 
|---|
|  | 13 |  | 
|---|
|  | 14 | FITSRingWriter::FITSRingWriter(string fn) { | 
|---|
|  | 15 | fname = fn; | 
|---|
|  | 16 | fstatus = 0; | 
|---|
|  | 17 | // Open file | 
|---|
|  | 18 | remove(fname.c_str()); | 
|---|
|  | 19 | fits_lock(); | 
|---|
|  | 20 | fits_create_file(&fptr,fname.c_str(),&fstatus); | 
|---|
|  | 21 | fits_unlock(); | 
|---|
|  | 22 | name = "ringwriter"; | 
|---|
| [2320] | 23 | cout << "FITSRINGWriter:: FileName=" << name << endl; | 
|---|
|  | 24 | } | 
|---|
| [2281] | 25 |  | 
|---|
|  | 26 | FITSRingWriter::~FITSRingWriter() { | 
|---|
|  | 27 | } | 
|---|
|  | 28 |  | 
|---|
|  | 29 | void FITSRingWriter::setNSamples(long n) { | 
|---|
|  | 30 | nSamples = n; | 
|---|
|  | 31 | } | 
|---|
|  | 32 |  | 
|---|
|  | 33 | void FITSRingWriter::setNRings(long n) { | 
|---|
|  | 34 | nRings = n; | 
|---|
|  | 35 | } | 
|---|
|  | 36 |  | 
|---|
|  | 37 | void FITSRingWriter::setAperture(double a) { | 
|---|
|  | 38 | aperture = a; | 
|---|
|  | 39 | } | 
|---|
|  | 40 |  | 
|---|
|  | 41 | void FITSRingWriter::init() { | 
|---|
|  | 42 | declareInput("signal"); | 
|---|
|  | 43 | } | 
|---|
|  | 44 |  | 
|---|
|  | 45 | void FITSRingWriter::run() { | 
|---|
|  | 46 | //int snb = getMinIn();   ON IGNORE ICI | 
|---|
|  | 47 | //int sne = getMaxIn();   ON IGNORE ICI | 
|---|
|  | 48 |  | 
|---|
|  | 49 | char buf[100]; | 
|---|
|  | 50 |  | 
|---|
|  | 51 | fits_lock(); | 
|---|
| [2336] | 52 | fits_create_img(fptr,BYTE_IMG,0,NULL,&fstatus); | 
|---|
| [2281] | 53 | fits_write_date(fptr, &fstatus); | 
|---|
|  | 54 | fits_write_comment(fptr,"ArchTOIPipe FITSRingWriter",&fstatus); | 
|---|
|  | 55 | strcpy(buf, "RINGSET"); | 
|---|
|  | 56 | fits_write_key(fptr, TSTRING, "PDMTYPE",  &buf, "Planck Data Model Type", &fstatus); | 
|---|
|  | 57 | fits_write_key(fptr, TLONG,   "NCIRCLES", &nRings, "Number of rings", &fstatus); | 
|---|
|  | 58 | fits_unlock(); | 
|---|
| [2361] | 59 |  | 
|---|
| [2355] | 60 | char* ttype = "DATA"; | 
|---|
|  | 61 | char* tform = "1D"; | 
|---|
|  | 62 | char xname[100]; | 
|---|
|  | 63 |  | 
|---|
| [2281] | 64 | for (int ring = 0; ring<nRings; ring++) { | 
|---|
|  | 65 | sprintf(xname, "CRING_%d", ring); | 
|---|
| [2320] | 66 |  | 
|---|
| [2361] | 67 | wontNeedBefore(ring*(nSamples+2)); | 
|---|
|  | 68 | double theta = getData(0, ring*(nSamples+2)+0); | 
|---|
|  | 69 | double phi   = getData(0, ring*(nSamples+2)+1); | 
|---|
| [2337] | 70 |  | 
|---|
| [2281] | 71 | fits_lock(); | 
|---|
|  | 72 | fits_create_tbl(fptr,BINARY_TBL,nSamples,1,&ttype,&tform,NULL,xname,&fstatus); | 
|---|
|  | 73 | strcpy(buf, "RINGDATA"); | 
|---|
|  | 74 | fits_write_key(fptr, TSTRING, "PDMTYPE",  &buf, "Planck Data Model Type", &fstatus); | 
|---|
|  | 75 | fits_write_key(fptr, TDOUBLE, "CIRTHETA", &theta, "Theta angle in radians", &fstatus); | 
|---|
|  | 76 | fits_write_key(fptr, TDOUBLE, "CIRPHI", &phi, "Phi angle in radians", &fstatus); | 
|---|
|  | 77 | fits_write_key(fptr, TDOUBLE, "CIRAPER", &aperture, "Aperture angle in radians", &fstatus); | 
|---|
|  | 78 | fits_write_key(fptr, TLONG, "NSAMPLES", &nSamples, "Number of samples on the circle", &fstatus); | 
|---|
|  | 79 | fits_unlock(); | 
|---|
| [2320] | 80 |  | 
|---|
| [2361] | 81 | cout << nSamples << " @@@@@@@@@@@@@@@@@@@@@@@@@@@@@" << endl; | 
|---|
|  | 82 |  | 
|---|
| [2281] | 83 | for (int i=0; i<nSamples; i++) { | 
|---|
| [2361] | 84 | double data = getData(0, ring*(nSamples+2)+2+i); | 
|---|
|  | 85 | if (i > 1000) cout << i << " "  << data << endl; | 
|---|
| [2281] | 86 | fits_lock(); | 
|---|
| [2336] | 87 | fits_write_col(fptr, TDOUBLE, 1,i+1,1,1, &data, &fstatus); | 
|---|
| [2355] | 88 | fits_unlock(); | 
|---|
| [2281] | 89 | } | 
|---|
|  | 90 | } | 
|---|
| [2355] | 91 |  | 
|---|
|  | 92 | fits_lock(); | 
|---|
|  | 93 | fits_close_file(fptr, &fstatus); | 
|---|
|  | 94 | fits_report_error(stderr, fstatus); | 
|---|
|  | 95 | fits_unlock(); | 
|---|
|  | 96 | cout << "fitsringwriter done " << endl; | 
|---|
| [2281] | 97 | } | 
|---|