void __fastcall TRotWireDlg::RotWire(double &X, double &Y, double &Z, double deg) { double WL; switch(BSel->ItemIndex){ case 0: // ‚wŽ² WL = sqrt(Y*Y + Z*Z); deg += GetDeg(Y, Z); Y = WL * cos(deg*PAI/180.0); Z = WL * sin(deg*PAI/180.0); break; case 1: // ‚xŽ² WL = sqrt(X*X + Z*Z); deg += GetDeg(X, Z); X = WL * cos(deg*PAI/180.0); Z = WL * sin(deg*PAI/180.0); break; case 2: // ‚yŽ² WL = sqrt(X*X + Y*Y); deg += GetDeg(X, Y); X = WL * cos(deg*PAI/180.0); Y = WL * sin(deg*PAI/180.0); break; } }
/*----------------------------------------------------------------------- */ olong doMovie (ObitInfoList* myInput, ObitUV* inData, ObitImage *outImage, ObitErr* err) { olong iplane = 0; ObitInfoType type; gint32 dim[MAXINFOELEMDIM] = {1,1,1,1,1}; olong SNver, ANver, highVer, loop; olong itemp, xcell, ycell, subA, iif, refAnt, numif, numpol; olong bif, eif; odouble antX, antY, timeEnd=-9999.0; ofloat solInt, fblank = ObitMagicF(), *realP, *imagP; gboolean doImage, doRCP, doLCP, wanted; ObitFArray *accReal=NULL, *accImag=NULL, *outPlane=NULL; ObitTableSN *SNTable=NULL; ObitTableSNRow *SNRow=NULL; ObitTableAN *ANTable=NULL; ObitAntennaList *antList=NULL; ObitImageDesc *imdesc=NULL; ObitUVSel *sel=NULL; ObitIOSize IOBy = OBIT_IO_byPlane; gchar Stokes[6]; olong blc[IM_MAXDIM] = {1,1,1,1,1,1,1}; olong trc[IM_MAXDIM] = {0,0,0,0,0,0,0}; gchar *dataParms[] = { /* Source selection*/ "Sources", "Qual", "timeRange", "Antennas", "FreqID", NULL }; gchar *routine = "doMovie"; /* error checks */ if (err->error) return iplane; g_assert (ObitInfoListIsA(myInput)); g_assert (ObitUVIsA(inData)); /* Get input parameters from myInput, copy to inData */ ObitInfoListCopyList (myInput, inData->info, dataParms); if (err->error) Obit_traceback_val (err, routine, inData->name, iplane ); /* Make sure selector set on inData */ ObitUVOpen (inData, OBIT_IO_ReadCal, err); ObitUVClose (inData, err); /* local pointers for structures */ sel = inData->mySel; /* Get AN table info */ subA = 0; ObitInfoListGetTest(myInput, "subA", &type, dim, &subA); ANver = MAX (1, subA); ANTable = newObitTableANValue (inData->name, (ObitData*)inData, &ANver, OBIT_IO_ReadOnly, 0, 0, err); antList = ObitTableANGetList (ANTable, err); if (err->error) Obit_traceback_val (err, routine, inData->name, iplane); ANTable = ObitTableANUnref (ANTable); /* Get SN table */ itemp = 0; ObitInfoListGetTest(myInput, "solnVer", &type, dim, &itemp); SNver = itemp; /* Which SN table? */ highVer = ObitTableListGetHigh (inData->tableList, "AIPS SN"); if (SNver==0) SNver = highVer; SNTable = newObitTableSNValue (inData->name, (ObitData*)inData, &SNver, OBIT_IO_ReadOnly, 0, 0, err); /* Get descriptive info - IFs */ numif = SNTable->numIF; bif = 1; ObitInfoListGetTest(myInput, "BIF", &type, dim, &bif); bif = MAX (0, bif-1); /* 0-rel */ eif = numif; ObitInfoListGetTest(myInput, "EIF", &type, dim, &eif); if (eif<=0) eif = numif; eif = MIN (numif-1, eif-1); /* 0-rel */ /* Polarization */ numpol = SNTable->numPol; Stokes[0] = Stokes[1] = Stokes[2] = Stokes[3] = ' '; Stokes[4] = 0; ObitInfoListGetTest(myInput, "Stokes", &type, dim, Stokes); /* Do RCP or only poln? */ doRCP = (Stokes[0]=='R') || (Stokes[0]==' ') || (numpol==1); doLCP = (Stokes[0]=='L') && (numpol>1); /* LCP? */ /* averaging time */ solInt = 10.0 / 60.0; ObitInfoListGetTest(myInput, "solInt", &type, dim, &solInt); if (solInt<1.0e-3) solInt = 10.0 / 60.0; solInt /= 1440.0; /* to days */ /* Reference table if needed - once */ refAnt = 0; ObitInfoListGetTest(myInput, "refAnt", &type, dim, &refAnt); if ((refAnt>0) && (outImage==NULL)) { ObitUVSolnRefAnt (SNTable, subA, &refAnt, err); if (err->error) Obit_traceback_val (err, routine, SNTable->name, iplane); } /* Open table */ ObitTableSNOpen (SNTable, OBIT_IO_ReadOnly, err); if (err->error) Obit_traceback_val (err, routine, SNTable->name, iplane); /* row to read SN table */ SNRow = newObitTableSNRow(SNTable); /* Output image? */ doImage = ObitImageIsA(outImage); if (doImage) { IOBy = OBIT_IO_byPlane; /* Do I/O by plane */ dim[0] = 1; ObitInfoListPut (outImage->info, "IOBy", OBIT_long, dim, &IOBy, err); dim[0] = 7; ObitInfoListPut (outImage->info, "BLC", OBIT_long, dim, blc, err); ObitInfoListPut (outImage->info, "TRC", OBIT_long, dim, trc, err); outImage->extBuffer = FALSE; /* Make sure it has buffer */ /* Open Image, image on member image, an ObitFArray */ ObitImageOpen (outImage, OBIT_IO_WriteOnly, err); if (err->error) Obit_traceback_val (err, routine, outImage->name, iplane); imdesc = outImage->myDesc; /* Clone accumulators */ outPlane = outImage->image; accReal = ObitFArrayCreate("accReal", outPlane->ndim, outPlane->naxis); accImag = ObitFArrayCreate("accImag", outPlane->ndim, outPlane->naxis); } /* end initialize image */ /* Loop over table */ iplane = 0; for (loop=1; loop<=SNTable->myDesc->nrow; loop++) { ObitTableSNReadRow (SNTable, loop, SNRow, err); if (err->error) Obit_traceback_val (err, routine, SNTable->name, iplane); if (SNRow->status<0) continue; /* Skip deselected record */ /* Initial time to header */ if (doImage && (loop==1)) imdesc->crval[2] = SNRow->Time; /* Check if this record wanted */ wanted = (SNRow->Time>=sel->timeRange[0]) && (SNRow->Time<=sel->timeRange[1]); wanted = wanted && ObitUVSelWantSour (sel, SNRow->SourID); wanted = wanted && ObitUVSelWantAnt (sel, SNRow->antNo); wanted = wanted && ((SNRow->FreqID==sel->FreqID) || (sel->FreqID<=0)); wanted = wanted && ((SNRow->SubA==sel->SubA) || (sel->SubA<=0)); if (!wanted) continue; /* End of this accumulation*/ if (timeEnd<-1000.0) timeEnd = SNRow->Time + solInt; /* Accumulation finished? */ if (SNRow->Time>timeEnd) { /* Write or count plane */ iplane++; if (doImage) { GetDeg (accReal, accImag, outPlane); /* Add end time in pixel 0 */ outPlane->array[0] = (ofloat)timeEnd; ObitImageWrite (outImage, NULL, err); if (err->error) Obit_traceback_val (err, routine, outImage->name, iplane); } /* If gap bigger than 2 solInt add 2 empty planes */ if ((SNRow->Time-timeEnd)>=2.0*solInt) { iplane +=2; if (doImage) { ObitFArrayFill (outPlane, fblank); ObitImageWrite (outImage, NULL, err); ObitImageWrite (outImage, NULL, err); if (err->error) Obit_traceback_val (err, routine, outImage->name, iplane); } } timeEnd = SNRow->Time + solInt; /* reset for next integration */ } /* end accumumation done */ /* Accumulate if writing image */ if (doImage) { /* If VLA */ if ( antList->isVLA) { /* Reproject Array onto Plains of San Augustin (lat=34.07874889 deg) new X=E, Y=N */ antX = antList->ANlist[(SNRow->antNo)-1]->AntXYZ[1]; antY = antList->ANlist[(SNRow->antNo)-1]->AntXYZ[2] * 0.828268220 - antList->ANlist[(SNRow->antNo)-1]->AntXYZ[0] * 0.560331827; } else { /* don't know how to project */ antX = antList->ANlist[(SNRow->antNo)-1]->AntXYZ[0]; antY = antList->ANlist[(SNRow->antNo)-1]->AntXYZ[1]; } /* Which cell (0-rel) */ xcell = (olong)(-0.5 + imdesc->crpix[0] + (antX / imdesc->cdelt[0])); xcell = MAX (0, MIN (xcell, imdesc->inaxes[0]-1)); ycell = (olong)(-0.5 + imdesc->crpix[1] + (antY / imdesc->cdelt[1])); ycell = MAX (0, MIN (ycell, imdesc->inaxes[1]-1)); /* Pointers in accumulators */ realP = accReal->array + xcell + ycell * imdesc->inaxes[0]; imagP = accImag->array + xcell + ycell * imdesc->inaxes[0]; /* Loop over selected IFs/poln */ for (iif=bif; iif<=eif; iif++) { if (doRCP && (SNRow->Weight1[iif]>0.0) && (SNRow->Real1[iif]!=fblank)) { *realP += SNRow->Real1[iif]; *imagP += SNRow->Imag1[iif]; } if (doLCP && (SNRow->Weight2[iif]>0.0) && (SNRow->Real2[iif]!=fblank)) { *realP += SNRow->Real2[iif]; *imagP += SNRow->Imag2[iif]; } } } /* end writing image */ } /* end loop over table */ /* final accumulation */ if (timeEnd>-1000.0) { iplane++; if (doImage) { GetDeg (accReal, accImag, outPlane); /* Add end time in pixel 0 */ outPlane->array[0] = (ofloat)timeEnd; ObitImageWrite (outImage, NULL, err); if (err->error) Obit_traceback_val (err, routine, outImage->name, iplane); } } /* Close output image if writing */ if (doImage) { ObitImageClose (outImage, err); /* Close */ if (err->error) Obit_traceback_val (err, routine, outImage->name, iplane); /* Cleanup */ outPlane = outImage->image = ObitFArrayUnref(outImage->image); accReal = ObitFArrayUnref(accReal); accImag = ObitFArrayUnref(accImag); } /* Cleanup */ ObitTableSNClose (SNTable, err); if (err->error) Obit_traceback_val (err, routine, SNTable->name, iplane); antList = ObitAntennaListUnref( antList); SNTable = ObitTableSNUnref(SNTable); SNRow = ObitTableSNRowUnref(SNRow); return iplane; } /* end doMovie */