/////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_CalcParam_McuFramerate.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to translate user input in Hz for MCU framrates into nearest // commanded values // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/03/31 V0.1: Initial version adapted from // SpireProc_CalcParam_BsmFramerate (2009/02/15 V0.1) // /////////////////////////////////////////////////////////////////////////// int procedure SpireProc_CalcParam_McuFramerate { double frateHz = 0.0; // Input MCU (==BSM,SMEC) framerate [Hz] bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Convert from Hz to RAW values: // int frateInt = iround(1000000.0 / (frateHz * 420.0)); // // // // // Debug printout: // if(debug) { debug_print("Input Hz value for MCU(==BSM,SMEC) framerate: " + frateHz); debug_print("Output Dec(Hex) values for MCU(==BSM,SMEC) framerate: " + frateInt); } // // // // // Return required values: // return frateInt; } // SpireBbPOF2End // // $Id:$ // // Building Block to reconfigure the instrument to PHOT_STBY mode from POF2 (7-point jiggle) mode // // 26 Jan 2008: KK removed resetting of OBSID and BBISD as they are now // done in SpireBb_EndObsAll // 14 Feb 2009: MP peplace calls to SpireProc_Set_PhotPhase/Bias with // call to SpireProc_Set_PhotBright // 02/07/2009 KJK: // - Replaced version input parameter with photVersion and comVersion // - Replaced call to Proc_SetPhotBRight with Proc_SetPhotMode to reset the // detectors if bright setting has been used // block SpireBbPOF2End SPIRE 8226 { string obsMode = "PHTSTBY"; bool isBright = false in [true,false]; string photVersion = "v00"; string comVersion = "v00"; bool debug = false in [true,false]; }{ int t = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB POF2 Reconfiguration started"); SpireMsg(2," $Id:$"); // // ..... configuration ..... // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // set STEP to zero tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP_RAW(0x0000)"); Spire_SET_OBS_STEP_RAW(0x0); // // Move BSM to HOLD int bsmHoldChopPosn = ilookup("BSM.txt","Hold","ChopPosn"); int bsmHoldJiggPosn = ilookup("BSM.txt","Hold","JiggPosn"); SpireBsmMove(bsmHoldChopPosn,bsmHoldJiggPosn); // // // reset bright-source biases and phases - if needed // if(isBright) { SpireProc_Set_PhotMode(obsMode,isBright,photVersion,comVersion,debug); } // // ..... completion ..... // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB POF2 Reconfiguration ended"); SpireMsg(1," ..POF2 Reconfiguration (" + (time() - t) + " seconds)"); } // SpireBbSOF1Init // // $Id: SpireBbSOF1Init.txt,v 1.1 2006/08/10 09:38:58 kking Exp $ // // Building Block to initialise the instrument for SOF1 operation // // The complete instrument setup operation is divided into two parts: // Configuration: actions that can be executed during the slew to the start // position of the S/C pointing mode. // Initialisation: actions that must be carried out at the S/C intial pointing // position before any observational operations are executed. // // This building Block implements the second part of the setup // // 04 November 2008: // added data_rate commands // added commands to setup the detector sampling // // block SpireBbSOF1Init SPIRE 8369 { }{ int t = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SOF1 Initialisation started"); SpireMsg(2," $Id: SpireBbSOF1Init.txt,v 1.1 2006/08/10 09:38:58 kking Exp $"); // // ..... configuration ..... // int cmd = 0x0; // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // set STEP to On Target tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP_RAW(0x8000)"); Spire_SET_OBS_STEP_RAW(0x8000); // // set detector offsets // set DCU data mode to Auto Offset cmd = 0x843c0014; SpireSendDrcuCmd(cmd,0); // start auto offset generation cmd = 0x843e0001; SpireSendDrcuCmd(cmd,0); delay(15); // // dump detector offsets // stop auto offset generation cmd = 0x843e0000; SpireSendDrcuCmd(cmd,0); // set DCU data mode to get offset data cmd = 0x843c001c; SpireSendDrcuCmd(cmd,0); // start offset data dump cmd = 0x843e0001; SpireSendDrcuCmd(cmd,0); // set datarate double rate = 0.0; rate = dlookup("Datarates.txt","SOffsets","DCU"); data_rate(rate); delay(5); // stop offset data dump cmd = 0x843e0000; SpireSendDrcuCmd(cmd,0); data_rate(0.0); // // flush data tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_FLUSH_FIFO_RAW(0x1000)"); Spire_FLUSH_FIFO_RAW(0x1000); delay(2); // // set up detectors for operations // SpireConfigDcuData("Scan"); sync(); // // ..... completion ..... // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SOF1 Initialisation ended"); SpireMsg(1," ..SOF1 Initialisation (" + (time() - t) + " seconds)"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireSpectro_CalGCO_ScannedSmecBeamProfile.txt // /////////////////////////////////////////////////////////////////////////// // // CUS script for: 'Spec Scanned SMEC Beam Profile' // // in *custom_map_pointing* mode // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/11/06 V0.1: Initial version adapted from // SpireSpectro_CalGCO_FixedSmecBeamProfile (2008/11/03 V0.2) // 2008/11/12 V0.2: Implement mode setting; Add isBright // 2009/03/30 V0.3: Add debug_print as input abd pass to low level scripts. // Set default gcp_time to 20 (desired value for SOVT2). // Use new SpireBb_EndObsAll and SpireBb_StartObsAll. Read // nominal bias frequency and bias dividerfrom new // SpireTable_SpecModeParams. Implemented setting of // datarates. Implemented isBright setting. Change call to // SpireBb_StartDcuData. Use SpireBb_SpecSetMode to set // to SPECSTBY during SLEW and FINAL_HOLD. Set first obsstep // to 1. Add isSerendipity, isPcal, and 8 more dummy parameters // to the script for future use. Add additional resolution // setting 'C' (see SCR-1114). Added header line. // 2009/03/31 V0.4: Move order of SpireBb_SmecMove and SpireBb_SetupSmecScan. // Add new SpireBb_SmecHold to account for the fact that // SpireBb_SmecMove does not stop SMEC (desired inside script // but not at the very end). Added start/stop of DCU+MCU data. // Added setting of MCU framerates as input and reset to // default values at end. // /////////////////////////////////////////////////////////////////////////// // Script assumes that: // // 1) Instrument is in SPECSTBY // (i.e. bias amplitude, phase, frequency [mclkdiv,biasdiv] are nominal) // // 2) Bias frequency (mclkdiv) and sampling rate (biasdiv) are the same // for all three arrays and could be taken from following cal table: // SpireTable_SpecModeParams.txt // // 3) That currently the gyro reconstruction is only available for // non-SSO targets. // // 4) SMEC scan parameters can be read from calibration table: // SpireTable_Spectrometer.txt // // 5) SMEC move parameters can be read from calibration table: // SpireTable_SpecSmecNominalSettings.txt // /////////////////////////////////////////////////////////////////////////// // obs SpireSpectro_CalGCO_ScannedSmecBeamProfile { /* ****************************************************** */ /* USER PARAMETER DEFINITION, CUS SIGNATURE for EX-HSpot */ /* ****************************************************** */ double ra = 0.0 in [0.0,360.0]; // RA of target double dec = 0.0 in [-90.0,90.0]; // DEC of target int naifid = 0; //NAIF identifier: put '0' to use RA/DEC, or correct 'NAIFID' bool isBright = false; // Use settings for bright source (==tick) /* */ double raoff = 0.0 in [0.0,360.0]; // RA of GCP position double decoff = 0.0 in [-90.0,90.0]; // DEC of GCP position string ib = "S14_0"; // Central aperture (defined in SIAM) of raster double d1 = 2.0; // Angular stepsize between raster pts [arcsec] string resolution = "M" in ["L","M","H","C"]; // Resolution (low, medium, high,calibration) int nscans = 1; // Number of SMEC scans (back+forth==1) int gcp_time = 20; // Time spend at GCP (gyro calibration position) [s] int gcp_period = 600; // Maximum time between successiv GCP visits [s] double bsmFrateInput = 15.98; // Specifies the BSM framerate [Hz] (Careful, don't exceed number of data packages to be transferred from spacecraft!) double smecFrateInput = 238.08; // Specifies the SMEC framerate [Hz] (Careful, don't exceed number of data packages to be transferred from spacecraft!) string version01 = "v00"; // Version in cal table SpireTable_SpecModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParam string version05 = "v00"; // Version in cal table SpireTable_Spectrometer string version06 = "v00"; // Version in cal table SpireTable_SmecNominalSettings bool debug = false; // Allow (==tick) or suppress cus debug_print statements bool isSerendipity = true; // Allow (==tick) serendipity mode to be activated or prohibit (==untick) it (currently not in use)? bool isPcal = true; // Allow (==tick) regular PcalFlash in script or prohibit (==untick) it (currently not in use)?. bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ // ****************************************************** */ // CALCULATE DURATIONS for POINTING STATES */ // ****************************************************** */ // // // // // Current restrictions: // if(naifid != 0) { error("Currently no SSO objects are allowed as input!"); } // // // // // Declare some variable: // // Photometer or FTS: bool phot = false; bool fts = !phot; // // Add interlaced cross or use a simple 11x11 raster? bool cross = false; // // Start timing of script: int start = time(); // // First obsstep (start at 1): int obsstep = 1; // // Count raster points (needs to start at 0): int raster_counter = 0; // // GCP counter (start at 1): int gcpcounter = 1; // // DCU data mode (0 == Full photometer; 4 == Full spectrometer) int dcumode = 4; // // Angular stepsize along Z axis [arcsec]: double d2 = d1; // NOTE: Script works only for equidistant raster points in both axes: // string tabName = ""; string selCol = ""; string selVal = ""; string tarCol = ""; string version = ""; double scirate = 0.0; double chkrate = 0.0; double nhkrate = 0.0; // // Hardcoded calibration tables: // string tabName01 = "SpireTable_SpecModeParams.txt"; string tabName02 = "SpireTable_CommonModeParams.txt"; string tabName05 = "SpireTable_Spectrometer.txt"; string tabName06 = "SpireTable_SmecNominalSettings.txt"; // // Currently hardcoded parameter: // Is (==tick) the DCU currently sampled? bool dcuData = false; // // // // // Setup mode: // // Set obsMode for QLA: string obsModeQla = "ENG_CAL_OBS35"; // Note: this needs entry in MIB table and in SpireTableInstConfigs.txt // // Set obsMode for datarates: string obsMode = "SEngCalObs"; // Note: this is currently only a maximum value // // // // // Read SMEC home position from calibration file: // tarCol = "Home"; tabName = tabName06; selVal = version06; int smecHomePosn = ilookup(tabName,selVal,tarCol); // // // // // Retrieve SMEC scanStart parameters from calibration table: // tarCol = "ScanStart"; selVal = "ResChar"; tabName = tabName05; version = version05; int scanStart = SpireProc_GetTableEntryInt("SpireTable_Spectrometer.txt",selVal,resolution,tarCol,version,debug); // // // // // Retrieve BSM SPECSTBY framerate from calibration table: // version = version02; tabName = tabName02; selCol = "mode"; selVal = obsMode; tarCol = "bsmFrameRate"; int bsmFrameRate = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); double bsmFrameRateHz = 0.0; if(bsmFrameRate != 0) { bsmFrameRateHz = 1000000.0 / (double(bsmFrameRate) * 420.0); } // // // // // Retrieve SMEC SPECSTBY framerate from calibration table: // version = version01; tabName = tabName01; selCol = "mode"; selVal = obsMode; tarCol = "smecFrameRate"; int smecFrameRate = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); double smecFrameRateHz = 0.0; if(smecFrameRate != 0) { smecFrameRateHz = 1000000.0 / (double(smecFrameRate) * 420.0); } if(debug) { debug_print("Nominal SMEC sampling rate is: " + smecFrameRateHz + " [Hz]"); } // // // // // Calculate commanded framerates for SMEC+BSM from user input: int bsmFrate = SpireProc_CalcParam_McuFramerate(bsmFrateInput,debug); int smecFrate = SpireProc_CalcParam_McuFramerate(smecFrateInput,debug); // // ****************************************************** */ // CALCULATE DURATIONS for POINTING STATES */ // ****************************************************** */ // // // // // Calculate timing for the pointing request: // // BBs called during slew: // int tslewmin = duration(SpireBb_StartObsAll(obsModeQla)) + duration(SpireBb_SpecSetMode(obsMode,isBright,version01,version02,debug)) + duration(SpireBb_SetupSmecScan(resolution,version05,debug)) + duration(SpireBb_SmecMove(smecHomePosn,scanStart,debug)) + duration(SpireBb_SetBsmFramerate(0,debug)) + duration(SpireBb_SetSmecFramerate(0,debug)); // // BBs carried out when the pointing is reached: // int tinithold = 0; // // BB carried out during pointing: // int tp_np = duration(SpireBb_SmecScan(resolution,nscans,version05,debug)) + duration(SpireBb_SpecOffsetAuto(dcuData,debug)) + duration(SpireBb_SetObsStep(9999,debug)) + duration(SpireBb_StartDcuMcuData()) + duration(SpireBb_StopDcuMcuData()); // // Activities at normal raster point: int tp_gp = gcp_time; // Note, this means 'just wait at GCP' // if(gcp_time > tp_np) { // Scan at GCP + extra delay: int extra_delay = gcp_time - tp_np; } // BB carried out at the end: // int tfinalhold = duration(SpireBb_EndObsAll(phot)) + duration(SpireBb_StopDcuData()) + duration(SpireBb_SpecSetMode("SPECSTBY",isBright,version01,version02,debug)) + duration(SpireBb_SmecMove(scanStart,smecHomePosn,debug)) + duration(SpireBb_SmecHold(debug)) + duration(SpireBb_SetBsmFramerate(0,debug)) + duration(SpireBb_SetSmecFramerate(0,debug)); // // // // // Debug printing: if(debug) { debug_print("tslewmin = " + tslewmin); debug_print("tinithold = " + tinithold); debug_print("tpointing normal= " + tp_np); debug_print("tpointing @GCP= " + tp_gp); debug_print("tfinalhold = " + tfinalhold); } // // ****************************************************** */ // POINTING MODE DECLARATION */ // ****************************************************** */ // // // // // Fixed parameters for pointing mode: // bool fixed = false; // Pattern orientation (true==sky; false==array) double patt = 90.0; // Rotation angle of the pattern double yoffset = 0.0; // Offset of pattern in the direction of the +Y double zoffset = 0.0; // Offset of pattern in the direction of the +Z int thold = 0; // The duration of the hold when nhold>0. int nhold = 0; // Number of nods or raster points or scan lines before // // performing a hold. double pattnod = 0.0; // double chopthrow = 2.0; // int nnod = 1; // int knod = 0; // int nload = 0; // int tloadmin = 0; // // // // // // Calculate array of points: // {double[],double[]} array = SpireProc_CalcParam_RasterCross(d1,d2,cross,debug); double[] zarray_org = array{0}; double[] yarray_org = array{1}; int numpixel = length(yarray_org); int nump_org = length(yarray_org); // // // // // Add GCP visit after every raster point (except first which is GCP) // and create tp (duration of fine pointing) vector new raster: // double[] yarray = [0.0]; double[] zarray = [0.0]; int run = 1; int aindex = 1; int fin = length(yarray_org); yarray[0] = yarray_org[0]; zarray[0] = zarray_org[0]; bool gcpp = false; int[] tpv = [0]; // First GCP visit is normal raster position (assuming gcp_time (nslew + 1) * 11 * 11) { nslew = nslew + 1; if(debug) { debug_print("nslew: " + nslew); } } // // Calculate approximate(!) time between off visits : // [Problem: slews are not 100% predictable with single dummy run] // ktime = tp_gp + kgcp * tp_np + (kgcp - nslew) * tppn + nslew * maxslew + 2 * maxslew; // // Add safety time: // [to account for possible longer slews than in dummy run] ktime = ktime + 0; int kdiff = ktime - ktime_old; // // Print out error if gcp_period < ktime for first case // (== having a GCP after each point): if(kgcp == 1) { if(gcp_period < ktime) { if(debug) { debug_print("gcp_period < ktime: " + gcp_period + " < " + ktime); } error("gcp_period smaller than expected times between GCP visits! Change input parameters!"); } } // if(debug) { debug_print("tpv[0]: " + tpv[0]); debug_print("tp_np: " + tp_np); debug_print("tp_gp: " + tp_gp); debug_print("tppn: " + tppn); debug_print("maxslew: " + maxslew); debug_print("nslew: " + nslew); debug_print("ktime-ktime_old: " + kdiff); debug_print("ktime loop kgcp/ktime: " + kgcp + "/" + ktime); } // // // Increment kgcp (i.e delay visit to GCP by one more raster point): if(debug) { debug_print("increment kgcp by 1"); } kgcp = kgcp + 1; if(debug) { debug_print("new kgcp: " + kgcp); } // } while (ktime < gcp_period); // // Select last kgcp for which condition was fulfilled: int kgcp_old = 1; if(kgcp > 2) { kgcp_old = kgcp - 2; } message("Return to GCP after every " + kgcp_old + " normal raster point(s)!"); // if(debug) { debug_print("values after kgcp selection loop:"); debug_print("nump: " + nump); debug_print("nslews: " + nslews); debug_print("tslews: " + tslews); debug_print("maxslew: " + maxslew); debug_print("ktime loop end: " + ktime); debug_print("kgcp loop end:" + kgcp); debug_print("ktime_old: " + ktime_old); debug_print("kgcp_old:" + kgcp_old); } // // // // // Add visits to the GCP tp raster array: // int counter = 0; double[] yarray_new = [0.0]; double[] zarray_new = [0.0]; double ygcp = yarray[0]; double zgcp = zarray[0]; if(debug) { debug_print("ygcp/zgcp: " + ygcp + "/" + zgcp); debug_print("zarray: " + zarray); } // // Start loop: int end = nump_org; int ln = 0; int stop = 0; int index = 0; bool[] raster = [true]; do { if(debug) { debug_print("stop : " + stop); debug_print("end : " + end); debug_print("index : " + index); debug_print("counter: " + counter); } if(counter > kgcp_old - 1) { yarray_new[index] = ygcp; zarray_new[index] = zgcp; ln = ln + 1; counter = 0; raster[index] = false; } else { yarray_new[index] = yarray_org[index - ln]; zarray_new[index] = zarray_org[index - ln]; if(debug) { debug_print("index -ln : " + (index - ln)); } stop = stop + 1; counter = counter + 1; raster[index] = true; } index = index + 1; } while (stop < end); // // Define first point always as regular raster point: raster[0] = true; // assuming gcp_time < tp_np // // Add additional visit to GCP at end: // (could give unsymmetric GCP visits but ensures a GCP at start AND end) if(debug) { debug_print("index : " + index); } if(yarray_new[index - 1] != ygcp) { yarray_new[index] = ygcp; zarray_new[index] = zgcp; raster[index] = false; } // if(debug) { debug_print("# pts without GCPs: " + length(yarray_org)); debug_print("# pts with GCPs: " + length(yarray_new)); debug_print("yarray_org: " + yarray_org); debug_print("zarray_org: " + zarray_org); debug_print("yarray_new = " + yarray_new); debug_print("zarray_new = " + zarray_new); } // // Adapt tp vector to new number of points: int[] tpv_new = [0]; for(int ind = 0 .. length(yarray_new) - 1) { if(ind == 0) { tpv_new[0] = tpv[0]; } else { if(yarray_new[ind] == ygcp) { if(zarray_new[ind] == zgcp) { tpv_new[ind] = tp_gp; } else { tpv_new[ind] = tp_np; } } else { tpv_new[ind] = tp_np; } } } if(debug) { debug_print("raster vector = " + raster); debug_print("new timing vector = " + tpv_new); debug_print("length(raster): " + length(raster)); debug_print("length(yarray_new): " + length(yarray_new)); debug_print("length(tpv_new): " + length(tpv_new)); } // // // // // Set pointing mode: // //custom_map_pointing(true, tslewmin, tinithold, tfinalhold, ib, naifid, //ra,dec,fixed,patt,yoffset,zoffset,yarray,zarray,tpv, pattnod,chopthrow, //nnod,knod,tloadmin,nload, thold, nhold); // int[] ts = custom_map_pointing(true,tslewmin,tinithold,tfinalhold,ib,naifid,ra,dec,fixed,patt,yoffset,zoffset,yarray_new,zarray_new,tpv_new,pattnod,chopthrow,nnod,knod,tloadmin,nload,thold,nhold); // if(debug) { debug_print("Output timing vector from the pointing request: " + ts); } // }{ // ****************************************************** */ // POINTING STATES WITH OBSERVING MODE LOGIC */ // ****************************************************** */ // // // // // Set datarates: // string rateType = "chk"; chkrate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); ess_hk_data_rate(chkrate); // rateType = "nhk"; // nhkrate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); non_ess_hk_data_rate(nhkrate); // rateType = "sci"; scirate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); data_rate(scirate); // if(debug) { debug_print("Set CHK datarate to: " + chkrate); debug_print("Set NHK datarate to: " + nhkrate); debug_print("Set SCI datarate to: " + scirate); } // // // Start the state_machine: // int[] state = [0]; // while(state[0] >= 0) { if(debug) { debug_print("Current state: " + state); } state = next_state(); if(debug) { debug_print("Next state: " + state); } // if(state[0] == 1) { // STATE = SLEW ( Spacecraft is slewing ) // // // // // Startup observation: // SpireBb_StartObsAll(obsModeQla); // // // // // Move SMEC to ScanStart position: // SpireBb_SmecMove(smecHomePosn,scanStart,debug); // // // // // Initialise instrument (in case for isBright): // SpireBb_SpecSetMode(obsMode,isBright,version01,version02,debug); // // // // // Set MCU framerates (==BSM/SMEC sampling rates): // SpireBb_SetBsmFramerate(bsmFrate,debug); SpireBb_SetSmecFramerate(smecFrate,debug); // // // // // Setup SMEC Scan: // SpireBb_SetupSmecScan(resolution,version05,debug); // //delay(timeSlewCal); } if(state[0] == 2) { // STATE = INIT_HOLD ( spacecraft is idling at source ) // // //delay(tinithold); } if(state[0] == 3) { // STATE = POINT (spacecraft is at nominal RA,DEC (staring, raster)) // //delay(tp); // // // // // Different timings for different raster points (normal vs. GCP): // if(raster[raster_counter] == false) { // // // // // Show time elapsed between visits to GCP: int t = time() - start; message("Time elapsed since last visit to GCP: " + t); if(debug) { debug_print("Time elapsed since last visit to GCP: " + t); } // if(t > gcp_period) { error("Elapsed time between GCP visits larger than gcp_period! Change script."); } // // Reset timer: start = time(); // // // // // Wait for gcp_time at GCP if gcp_time < tp_np // otherwise add in an additional scan at the GCP // if(gcp_time < tp_np) { // // // // // Set Obs step at GCP to fff: // SpireBb_SetObsStep(4095,debug); // // // // // Wait at GCP: // delay(gcp_time - duration(SpireBb_SetObsStep(9999,debug))); // } else { // // // // // Set Obs step at GCP to fff: // SpireBb_SetObsStep(4095,debug); // // // // // Set offsets at raster point: // SpireBb_SpecOffsetAuto(dcuData,debug); // // // // // Start DCU+MCU data generation: // SpireBb_StartDcuMcuData(); // // // // // Perform SMEC scan: // SpireBb_SmecScan(resolution,nscans,version05,debug); // // // // // Add extra time to account for gcp_time > tp_np: // delay(extra_delay); // // // // // Stop DCU+MCU data generation: // SpireBb_StopDcuMcuData(); } // } else { // // // // // Reset timing at first raster point: if(obsstep == 1) { start = time(); } // // // // // Set Obs step: // SpireBb_SetObsStep(obsstep,debug); // // // // // Set offsets at raster point: // SpireBb_SpecOffsetAuto(dcuData,debug); // // // // // Start DCU+MCU data generation: // SpireBb_StartDcuMcuData(); // // // // // Perform SMEC scan: // SpireBb_SmecScan(resolution,nscans,version05,debug); // // // // // Allow extra time at first raster point if gcp_time > tp_np: // if(obsstep == 1) { if(gcp_time > tp_np) { delay(extra_delay); } } // // // // // Stop DCU+MCU data generation: // SpireBb_StopDcuMcuData(); // // // // // Increase obsstep parameter for next point: // obsstep = obsstep + 1; // } raster_counter = raster_counter + 1; // } if(state[0] == 5) { // STATE = FINAL_HOLD ("sky" observation ends, performing final activities ) // // // // // Set scientific datarate back to zero: // data_rate(0.0); // // // // // Move SMEC back to home position: // SpireBb_SmecMove(scanStart,smecHomePosn,debug); // // // // // Set detectors back to SPECSTBY: // SpireBb_SpecSetMode("SPECSTBY",isBright,version01,version02,debug); // // // // // Set MCU framerates (==BSM/SMEC sampling rates): // SpireBb_SetBsmFramerate(bsmFrameRate,debug); SpireBb_SetSmecFramerate(smecFrameRate,debug); // // // // // Stop any remaining SMEC movement: // SpireBb_SmecHold(debug); // // // // // Reset OBSID and BBIB: // SpireBb_EndObsAll(phot); // } if(state[0] == -1) { // STATE = END (end of the pointing/commanding part of the code) // } } } /////////////////////////////////////////////////////////////////////////// // // SpireSpectro_CalGCO_FovMapCrossRaster.txt // /////////////////////////////////////////////////////////////////////////// // // CUS script for: 'Spec FOV Mapping Cross Raster' // // in *custom_map_pointing* mode // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/09/17 V0.1: Initial version adapted from // SpirePhoto_CalGCO_FovMapCrossRaster (2009/03/16 V1.0) // 2009/05/05 V0.2: Add in move BSM/SMEC to hold/home at start. Add new // SpireBb_SmecHold to account for the fact that // SpireBb_SmecMove2Home does not stop SMEC. // Gather procedures at start and end in separate BB. // Remove isSerendipity approach. // /////////////////////////////////////////////////////////////////////////// // Script assumes that: // // 1) Instrument is in SPECSTBY // (i.e. bias amplitude, phase, frequency [mclkdiv,biasdiv] are nominal) // // 2) Bias frequency (mclkdiv) and sampling rate (biasdiv) are the same // for all three arrays and could be taken from following cal table: // SpireTable_SpecModeParams.txt // // 3) Home position of BSM can be read from SpireTable_BsmNominalSettings.txt // // 4) Some VM parameters for chopping are read from following cal table: // SpireTable_CommandLists.txt // /////////////////////////////////////////////////////////////////////////// // obs SpireSpectro_CalGCO_FovMapCrossRaster { /* ****************************************************** */ /* USER PARAMETER DEFINITION, CUS SIGNATURE for EX-HSpot */ /* ****************************************************** */ double ra = 0.0 in [0.0,360.0]; // RA of target double dec = 0.0 in [-90.0,90.0]; // DEC of target int naifid = 0; //NAIF identifier: put '0' to use RA/DEC, or correct 'NAIFID' /* */ bool isBright = false; // Use settings for bright source (==tick) string ib = "S24_0"; // Central aperture (defined in SIAM) of raster double d1 = 4.0; // Angular stepsize along Y axis [arcsec] double d2 = 4.0; // Angular stepsize along Z axis [arcsec] int m = 9 in [3,2997]; // Total number of points in Y/Z [odd number, symmetric!] int k = 0; // Additional visits to GCP on each arm of the cross int ftime = 60; // Read-out time [s] double chopf = 2.0 in [0.1,4.0]; // Chop frequency [Hz] int offChopfh = 9600; // off-source chop position (+ or - relative to hold) [Dec(Hex)] double framerate = 125.0; // Specifies the MCU framerate [Hz] int gcp_time = 20; // Time spend at GCP (gyro calibration position) [s] int gcp_period = 600; // Maximum time between successiv GCP visits [s] string version01 = "v00"; // Version in cal table SpireTable_SpecModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParas string version03 = "v00"; // Version in cal table SpireTable_BsmNominalSettings string model = "initial"; // Model in cal table SpireTable_BsmNominalSettings bool debug = false; // Allow (==tick) or suppress cus debug_print statements bool isSerendipity = true; // Allow (==tick) serendipity mode to be activated or prohibit (==untick) it? bool isPcal = true; // Allow (==tick) regular PcalFlash in script or prohibit (==untick) it (currently not in use)?. bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ // // // // // Current restrictions: // if(naifid != 0) { error("Currently no SSO objects are allowed as input!"); } // // // // // Declare some variable: // // Spectrometer or FTS: bool phot = false; bool fts = !phot; // // Start timing of script: int start = time(); // // Keep track of actual visits to GCP: double maxgcp_period = 0.0; // // First obsstep [HEX]: int obsstep = 0x0; // // Count raster points: int raster_counter = 0; // int obsStep = 0; int tslewminadd = 0; bool setFramerate = true; string version = ""; string tabName = ""; double scirate = 0.0; double chkrate = 0.0; double nhkrate = 0.0; // // DCU data mode (0 == Full spectrometer; 4 == Full spectrometer): int dcumode = 4; // // Hardcoded calibration tables: // string tabName01 = "SpireTable_SpecModeParams.txt"; string tabName02 = "SpireTable_CommonModeParams.txt"; string tabName03 = "SpireTable_BsmNominalSettings.txt"; string tabName04 = "SpireTable_CommandLists.txt"; string tabName06 = "SpireTable_SmecNominalSettings.txt"; // // Currently hardcoded version: // string version06 = "v00"; // Version in cal table SpireTable_SmecNominalSettings // // Currently hardcoded parameter: // Is (==tick) the DCU currently sampled? bool dcuData = false; // // Currently hardcoded parameter: // Useful length of serendipity observation int limit = 20; // // // // // Setup mode: // // Set obsMode for QLA: string obsModeQla = "ENG_CAL_OBS43"; // Note: this needs entry in MIB table and in SpireTableInstConfigs.txt // // Set obsMode for setup and datarates: string obsMode = "SEngCalObs"; // Note: datarates are currently only maximum values // // // // // Setup parameters for BSM chopping movement: // // Select version flag and set GetTableEntry parameters: // version = version03; tabName = tabName03; string selCol = "model"; // Name of column for selecting string selVal = model; // Value of 'string' selector // // Read hold position from calibration table: // string tarCol = "chop_0_I"; int hold_chop = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "jigg_0_I"; int hold_jigg = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // Set chop/jigg positions: // // on-source Chop position [Dec(Hex)]: int onChop = hold_chop; // // on-source Jiggle position: int onJigg = hold_jigg; // // off-source Chop position: int offChop = hold_chop + offChopfh; // // off-source Jiggle position: int offJigg = hold_jigg; // // Read VM parameters from calibration table: // tabName = tabName04; selVal = "Chop"; int vmId = ilookup(tabName,selVal,"Id"); int vmIndex = ilookup(tabName,selVal,"Index"); int nParms = ilookup(tabName,selVal,"Nparms"); // // // // // Read SMEC home position from calibration file: // tarCol = "Home"; tabName = tabName06; selVal = version06; int smecHomePosn = ilookup(tabName,selVal,tarCol); // // // // // Read nominal bias frequency and bias divider: // // Select version flag and set GetTableEntry parameters: version = version01; tabName = tabName01; selCol = "mode"; // Name of column for selecting selVal = obsMode; // Value of 'string' selector // tarCol = "mclkDiv"; int mclkdiv = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // tarCol = "biasDiv"; int biasdiv = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // // // // Calculate nominal sampling rate from mclkdiv and biasdiv: // double mclkdivHz = 1.0E7 / (512.0 * double(mclkdiv + 1)); double biasdivHz = 1.0 / (double(biasdiv) + 1.0) * mclkdivHz; if(debug) { debug_print("Nominal sampling rate is: " + biasdivHz + " [Hz]"); } // // // // // // Compare read-out time and dwell time on GCP: // int dtime = 0; // time to be spend on GCP position if(gcp_time < ftime) { dtime = ftime; } else { dtime = gcp_time; } if(debug) { debug_print("ftime: " + ftime); debug_print("gcp_time: " + gcp_time); debug_print("dtime: " + dtime); } // // // // // Calculate BSM chop parameters: // int[] chopparam1 = SpireProc_CalcParam_BsmSetup(ftime,chopf,biasdivHz,framerate,debug); int ncycles = chopparam1[0]; int chop_period = chopparam1[1]; int dcusample = chopparam1[2]; int dcudelay = chopparam1[3]; int bsmsample = chopparam1[4]; // int[] chopparam2 = SpireProc_CalcParam_BsmSetup(dtime,chopf,biasdivHz,framerate,debug); int ncycles_2 = chopparam2[0]; int chop_period_2 = chopparam2[1]; int dcusample_2 = chopparam2[2]; int dcudelay_2 = chopparam2[3]; int bsmsample_2 = chopparam2[4]; // // // // // Compare user input of BSM framerate with default value: // version = version02; tabName = tabName02; tarCol = "bsmFrameRate"; int bsmFrameRate = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); double bsmFrameRateHz = 1000000.0 / (double(bsmFrameRate) * 420.0); if(debug) { debug_print("Nominal BSM sampling rate is: " + bsmFrameRateHz + " [Hz]"); } // // Compare nominal with input BSM framerate: // int frate = SpireProc_CalcParam_BsmFramerate(framerate,debug); if(frate == bsmFrameRate) { setFramerate = false; } // // ****************************************************** */ // CALCULATE DURATIONS for POINTING STATES */ // ****************************************************** */ // // // // // Calculate timing for the pointing request: // // BBs called during slew: // int tslewmin = duration(SpireBb_StartFovMapCrossRaster(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,setFramerate,frate,smecHomePosn,debug)); // //BBs carried out when the pointing is reached: // int tinithold = 0; // // BB carried out during pointing: // int tp_np = duration(SpireBb_Chop(vmId,vmIndex,nParms,onChop,onJigg,offChop,offJigg,ncycles,chop_period,dcumode,dcusample,dcudelay,bsmsample,9999,debug)) + duration(SpireBb_SpecOffsetAuto(dcuData,debug)); int tp_gp = duration(SpireBb_Chop(vmId,vmIndex,nParms,onChop,onJigg,offChop,offJigg,ncycles_2,chop_period_2,dcumode,dcusample_2,dcudelay_2,bsmsample_2,9999,debug)) + duration(SpireBb_SpecOffsetAuto(dcuData,debug)); // // BB carried out at the end: // int tfinalhold = duration(SpireBb_EndFovMapCrossRaster(phot,hold_chop,hold_jigg,isBright,version01,version02,debug)); // // // // // Debug printing: // if(debug) { debug_print("tslewmin = " + tslewmin); debug_print("tinithold = " + tinithold); debug_print("tpointing normal= " + tp_np); debug_print("tpointing @GCP= " + tp_gp); debug_print("tfinalhold = " + tfinalhold); } // // ****************************************************** */ // POINTING MODE DECLARATION */ // ****************************************************** */ // // // // // Fixed parameters for pointing mode: // // Pattern orientation (true==sky; false==array): bool fixed = false; // // Rotation angle of the pattern: double patt = 90.0; // // Offset of pattern in the direction of the +Y: double yoffset = 0.0; // // Offset of pattern in the direction of the +Z: double zoffset = 0.0; // // The duration of the hold when nhold>0: int thold = 0; // // Number of nods or raster points or scan lines before // performing a hold. int nhold = 0; // double pattnod = 0.0; // double chopthrow = 2.0; // int nnod = 1; // int knod = 0; // int nload = 0; // int tloadmin = 0; // // // // // // Calculate array of points: // {double[],double[],bool[]} array = SpireProc_CalcParam_FovMapCrossRaster(d1,d2,m,k,debug); double[] zarray = array{0}; double[] yarray = array{1}; bool[] raster = array{2}; int nump = length(yarray); // // // // // Set pointing vector: // int[] tpv = [0]; for(int index = 0 .. nump - 1) { if(raster[index]) { tpv[index] = tp_np; } else { tpv[index] = tp_gp; } index = index + 1; } if(debug) { debug_print("tpv = " + tpv); } // // // // // Set pointing mode: // //custom_map_pointing(true, tslewmin, tinithold, tfinalhold, ib, naifid, //ra,dec,fixed,patt,yoffset,zoffset,yarray,zarray,tpv, pattnod,chopthrow, //nnod,knod,tloadmin,nload, thold, nhold); // int[] ts = custom_map_pointing(true,tslewmin,tinithold,tfinalhold,ib,naifid,ra,dec,fixed,patt,yoffset,zoffset,yarray,zarray,tpv,pattnod,chopthrow,nnod,knod,tloadmin,nload,thold,nhold); // if(debug) { debug_print("Output timing vector from the pointing request: " + ts); } // }{ // ****************************************************** */ // POINTING STATES WITH OBSERVING MODE LOGIC */ // ****************************************************** */ // // // // // Set datarates: // string rateType = "chk"; chkrate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); ess_hk_data_rate(chkrate); // rateType = "nhk"; // nhkrate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); non_ess_hk_data_rate(nhkrate); // rateType = "sci"; scirate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); data_rate(scirate); // if(debug) { debug_print("Set CHK datarate to: " + chkrate); debug_print("Set NHK datarate to: " + nhkrate); debug_print("Set SCI datarate to: " + scirate); } // // // Start the state_machine: // int[] state = [0]; // while(state[0] >= 0) { if(debug) { debug_print("Current state: " + state); } state = next_state(); if(debug) { debug_print("Next state: " + state); } // if(state[0] == 1) { // STATE = SLEW ( Spacecraft is slewing ) // // // // // Startup observation: // SpireBb_StartFovMapCrossRaster(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,setFramerate,frate,smecHomePosn,debug); // // // // // Perform serendipity operation if possible: // // Read slew time from pointing mode: //int tslew = ts[1]; // Slew time // // Minimum time for a serendipity observation: //int tSerendipity = duration(SpireProc_Exec_Serendipity(0,debug)); //if(debug) { // debug_print("Minimum time for a serendipity observation: " + tSerendipity); //} //// //// //if(tslew > tSerendipity + tslewmin + 20) { // // Time remaining for serendipity observation: // int stime = tslew - tslewmin; // // // // Execute observation: // if(isSerendipity) { // SpireProc_Exec_Serendipity(stime,debug); // } //} // //delay(timeSlewCal); } if(state[0] == 2) { // STATE = INIT_HOLD ( spacecraft is idling at source ) // // //delay(tinithold); } if(state[0] == 3) { // STATE = POINT (spacecraft is at nominal RA,DEC (staring, raster)) // // // // // Set offsets at each raster point: // SpireBb_SpecOffsetAuto(dcuData,debug); // // // // // Different timings for different raster points (normal vs. GCP): // if(raster[raster_counter] == false) { // // // // // Show time elapsed between visits to GCP: // if(raster_counter == 0) { // Reset timer: start = time(); } else { int t = time() - start; // Check elapsed time and give out error: maxgcp_period = max(maxgcp_period,double(t)); if(maxgcp_period > double(gcp_period)) { error("gcp_period constraint violated!! Increase k parameter by 1"); } message("Time elapsed since last visit to GCP: " + t); if(debug) { debug_print("Time elapsed since last visit to GCP: " + t); debug_print("Maximum time between two GCPs: " + maxgcp_period); } // // Reset timer: start = time(); } // // // // // Run chop VM (includes data taking) and set obs step parameter: // if(debug) { debug_print("Chop on GCP raster point!"); } SpireBb_Chop(vmId,vmIndex,nParms,onChop,onJigg,offChop,offJigg,ncycles_2,chop_period_2,dcumode,dcusample_2,dcudelay_2,bsmsample_2,65535,debug); // } else { // // // // // Run chop VM (includes data taking) and set obs step parameter: // if(debug) { debug_print("Chop on regular raster point!"); } SpireBb_Chop(vmId,vmIndex,nParms,onChop,onJigg,offChop,offJigg,ncycles,chop_period,dcumode,dcusample,dcudelay,bsmsample,obsstep,debug); obsstep = obsstep + 1; // } raster_counter = raster_counter + 1; // } if(state[0] == 5) { // STATE = FINAL_HOLD ("sky" observation ends, performing final activities ) // // // // // Set scientific datarate back to zero: // data_rate(0.0); // // // // // Reconfigure at the end (incl. resetting of OBSID and BBIB): // SpireBb_EndFovMapCrossRaster(phot,hold_chop,hold_jigg,isBright,version01,version02,debug); // } if(state[0] == -1) { // STATE = END (end of the pointing/commanding part of the code) // } } } // SpireEngPHOT_STBYtoREDY // // $id$ // // This observation puts the instrument into the REDY mode // // The instrument should be in the PHOT_STBY mode before execution of this observation // // 08/11/2007 KJK: explicitly run StartObs and EndObs building blocks around the engineering procedure // obs SpireEngPHOT_STBYtoREDY { string bsmVersion = "v00"; string detVersion = "v00"; string ptcVersion = "v00"; bool debug = false; bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ int t = duration(SpireBbStartObs()) + duration(SpirePHOT_STBYtoREDY(bsmVersion,detVersion,ptcVersion,debug)) + duration(SpireBbEndObs()); int[] ts = no_pointing(true,0,0,t); }{ int[] state = [0]; while(state[0] >= 0) { state = next_state(); if(state[0] == 3) { SpireBbStartObs(); SpirePHOT_STBYtoREDY(bsmVersion,detVersion,ptcVersion,debug); SpireBbEndObs(); } } } // Missionphase : // // Purpose : Send the appropriate TC to set a determined bias voltage // for a group 1 matrix. The bias voltage is expressed in // volts // Author : Diego A. Cesarsky // CUS script : Diego A. Cesarsky // CVS file : PHOT_bias_group_1.txt // // Arguments : // string biasName The bias name in accordance with the MIB convention // float bias The corresponding bias voltage [volts] // // Description : Extremely unsatisfactory code to find the bias name and // issue the corresponding TC. If bias name is not found, // the procedure sets an error condition // // Dependencies : // // Preconditions : // // Comments : The code is awful since it has to use dedicated TCs for // each bias of each group, namely 20 different TCs. There // are similar CUS procedures for each of the other 5 groups. // There are two "sanity checks": // 1- group number has to agree with procedure name // 2- bias number has to agree with bias name // // Version : 0.1 07-aug-2006 Creation by DAC // History : // : procedure PHOT_bias_group_3 { int grpNb = 3 in [3,3]; // The group number (sort of sanity check) int biasNb = 1; // The bias number (sort of sanity check) string biasName = "VH"; // The corresponding bias name as per MIB double bias = 1.62312; // The bias voltage to be set for biasName }{ // // Assume failure bool sentTC = false; // Start stupid "if" code // Bias name Pacs_BOLC_SET_VH if(biasName == "VH" && biasNb == 1) { Pacs_BOLC_SET_VH_G3(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VL if(biasName == "VL" && biasNb == 2) { Pacs_BOLC_SET_VL_G3(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VRL if(biasName == "VRL" && biasNb == 3) { Pacs_BOLC_SET_VRL_G3(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VINJ if(biasName == "VINJ" && biasNb == 4) { Pacs_BOLC_SET_VINJ_G3(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VCH if(biasName == "VCH" && biasNb == 5) { Pacs_BOLC_SET_VCH_G3(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VDL if(biasName == "VDL" && biasNb == 6) { Pacs_BOLC_SET_VDL_G3(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VSS if(biasName == "VSS" && biasNb == 7) { Pacs_BOLC_SET_VSS_G3(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VGL if(biasName == "VGL" && biasNb == 8) { Pacs_BOLC_SET_VGL_G3(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_CKRLH if(biasName == "CKRLH" && biasNb == 9) { Pacs_BOLC_SET_CKRLH_G3(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_CKRLL if(biasName == "CKRLL" && biasNb == 10) { Pacs_BOLC_SET_CKRLL_G3(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VDECX_H if(biasName == "VDECX-H" && biasNb == 11) { Pacs_BOLC_SET_VDECX_H_G3(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VDECX_L if(biasName == "VDECX-L" && biasNb == 12) { Pacs_BOLC_SET_VDECX_L_G3(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VSMS_H if(biasName == "VSMS-H" && biasNb == 13) { Pacs_BOLC_SET_VSMS_H_G3(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VSMS_L if(biasName == "VSMS-L" && biasNb == 14) { Pacs_BOLC_SET_VSMS_L_G3(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VGG if(biasName == "VGG" && biasNb == 15) { Pacs_BOLC_SET_VGG_G3(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VDD if(biasName == "VDD" && biasNb == 16) { Pacs_BOLC_SET_VDD_G3(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VSS_BU if(biasName == "VSS-BU" && biasNb == 17) { Pacs_BOLC_SET_VSS_BU_G3(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VDL_BU if(biasName == "VDL-BU" && biasNb == 18) { Pacs_BOLC_SET_VDL_BU_G3(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VGL_BU if(biasName == "VGL-BU" && biasNb == 19) { Pacs_BOLC_SET_VGL_BU_G3(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VH_BLIND if(biasName == "VH-BLIND" && biasNb == 20) { Pacs_BOLC_SET_VH_BLIND_G3(bias); sentTC = true; } // Error condition if no bias was set if(!sentTC) { error("The combination " + biasName + "/" + biasNb + " is not correct"); } } // Missionphase : // // Purpose : Send the appropriate TC to set a determined bias voltage // for a group 1 matrix. The bias voltage is expressed in // volts // Author : Diego A. Cesarsky // CUS script : Diego A. Cesarsky // CVS file : PHOT_bias_group_2.txt // // Arguments : // string biasName The bias name in accordance with the MIB convention // float bias The corresponding bias voltage [volts] // // Description : Extremely unsatisfactory code to find the bias name and // issue the corresponding TC. If bias name is not found, // the procedure sets an error condition // // Dependencies : // // Preconditions : // // Comments : The code is awful since it has to use dedicated TCs for // each bias of each group, namely 20 different TCs. There // are similar CUS procedures for each of the other 5 groups. // There are two "sanity checks": // 1- group number has to agree with procedure name // 2- bias number has to agree with bias name // // Version : 0.1 07-aug-2006 Creation by DAC // History : // : procedure PHOT_bias_group_2 { int grpNb = 2 in [2,2]; // The group number (sort of sanity check) int biasNb = 1; // The bias number (sort of sanity check) string biasName = "VH"; // The corresponding bias name as per MIB double bias = 1.62312; // The bias voltage to be set for biasName }{ // // Assume failure bool sentTC = false; // Start stupid "if" code // Bias name Pacs_BOLC_SET_VH if(biasName == "VH" && biasNb == 1) { Pacs_BOLC_SET_VH_G2(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VL if(biasName == "VL" && biasNb == 2) { Pacs_BOLC_SET_VL_G2(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VRL if(biasName == "VRL" && biasNb == 3) { Pacs_BOLC_SET_VRL_G2(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VINJ if(biasName == "VINJ" && biasNb == 4) { Pacs_BOLC_SET_VINJ_G2(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VCH if(biasName == "VCH" && biasNb == 5) { Pacs_BOLC_SET_VCH_G2(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VDL if(biasName == "VDL" && biasNb == 6) { Pacs_BOLC_SET_VDL_G2(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VSS if(biasName == "VSS" && biasNb == 7) { Pacs_BOLC_SET_VSS_G2(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VGL if(biasName == "VGL" && biasNb == 8) { Pacs_BOLC_SET_VGL_G2(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_CKRLH if(biasName == "CKRLH" && biasNb == 9) { Pacs_BOLC_SET_CKRLH_G2(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_CKRLL if(biasName == "CKRLL" && biasNb == 10) { Pacs_BOLC_SET_CKRLL_G2(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VDECX_H if(biasName == "VDECX-H" && biasNb == 11) { Pacs_BOLC_SET_VDECX_H_G2(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VDECX_L if(biasName == "VDECX-L" && biasNb == 12) { Pacs_BOLC_SET_VDECX_L_G2(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VSMS_H if(biasName == "VSMS-H" && biasNb == 13) { Pacs_BOLC_SET_VSMS_H_G2(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VSMS_L if(biasName == "VSMS-L" && biasNb == 14) { Pacs_BOLC_SET_VSMS_L_G2(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VGG if(biasName == "VGG" && biasNb == 15) { Pacs_BOLC_SET_VGG_G2(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VDD if(biasName == "VDD" && biasNb == 16) { Pacs_BOLC_SET_VDD_G2(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VSS_BU if(biasName == "VSS-BU" && biasNb == 17) { Pacs_BOLC_SET_VSS_BU_G2(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VDL_BU if(biasName == "VDL-BU" && biasNb == 18) { Pacs_BOLC_SET_VDL_BU_G2(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VGL_BU if(biasName == "VGL-BU" && biasNb == 19) { Pacs_BOLC_SET_VGL_BU_G2(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VH_BLIND if(biasName == "VH-BLIND" && biasNb == 20) { Pacs_BOLC_SET_VH_BLIND_G2(bias); sentTC = true; } // Error condition if no bias was set if(!sentTC) { error("The combination " + biasName + "/" + biasNb + " is not correct"); } } // Missionphase : // // Purpose : Send the appropriate TC to set a determined bias voltage // for a group 1 matrix. The bias voltage is expressed in // volts // Author : Diego A. Cesarsky // CUS script : Diego A. Cesarsky // CVS file : PHOT_bias_group_1.txt // // Arguments : // string biasName The bias name in accordance with the MIB convention // float bias The corresponding bias voltage [volts] // // Description : Extremely unsatisfactory code to find the bias name and // issue the corresponding TC. If bias name is not found, // the procedure sets an error condition // // Dependencies : // // Preconditions : // // Comments : The code is awful since it has to use dedicated TCs for // each bias of each group, namely 20 different TCs. There // are similar CUS procedures for each of the other 5 groups. // There are two "sanity checks": // 1- group number has to agree with procedure name // 2- bias number has to agree with bias name // // Version : 0.1 07-aug-2006 Creation by DAC // History : // : procedure PHOT_bias_group_1 { int grpNb = 1 in [1,1]; // The group number (sort of sanity check) int biasNb = 1; // The bias number (sort of sanity check) string biasName = "VH"; // The corresponding bias name as per MIB double bias = 1.62312; // The bias voltage to be set for biasName }{ // // Assume failure bool sentTC = false; // Start stupid "if" code // Bias name Pacs_BOLC_SET_VH if(biasName == "VH" && biasNb == 1) { Pacs_BOLC_SET_VH_G1(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VL if(biasName == "VL" && biasNb == 2) { Pacs_BOLC_SET_VL_G1(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VRL if(biasName == "VRL" && biasNb == 3) { Pacs_BOLC_SET_VRL_G1(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VINJ if(biasName == "VINJ" && biasNb == 4) { Pacs_BOLC_SET_VINJ_G1(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VCH if(biasName == "VCH" && biasNb == 5) { Pacs_BOLC_SET_VCH_G1(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VDL if(biasName == "VDL" && biasNb == 6) { Pacs_BOLC_SET_VDL_G1(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VSS if(biasName == "VSS" && biasNb == 7) { Pacs_BOLC_SET_VSS_G1(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VGL if(biasName == "VGL" && biasNb == 8) { Pacs_BOLC_SET_VGL_G1(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_CKRLH if(biasName == "CKRLH" && biasNb == 9) { Pacs_BOLC_SET_CKRLH_G1(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_CKRLL if(biasName == "CKRLL" && biasNb == 10) { Pacs_BOLC_SET_CKRLL_G1(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VDECX_H if(biasName == "VDECX-H" && biasNb == 11) { Pacs_BOLC_SET_VDECX_H_G1(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VDECX_L if(biasName == "VDECX-L" && biasNb == 12) { Pacs_BOLC_SET_VDECX_L_G1(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VSMS_H if(biasName == "VSMS-H" && biasNb == 13) { Pacs_BOLC_SET_VSMS_H_G1(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VSMS_L if(biasName == "VSMS-L" && biasNb == 14) { Pacs_BOLC_SET_VSMS_L_G1(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VGG if(biasName == "VGG" && biasNb == 15) { Pacs_BOLC_SET_VGG_G1(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VDD if(biasName == "VDD" && biasNb == 16) { Pacs_BOLC_SET_VDD_G1(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VSS_BU if(biasName == "VSS-BU" && biasNb == 17) { Pacs_BOLC_SET_VSS_BU_G1(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VDL_BU if(biasName == "VDL-BU" && biasNb == 18) { Pacs_BOLC_SET_VDL_BU_G1(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VGL_BU if(biasName == "VGL-BU" && biasNb == 19) { Pacs_BOLC_SET_VGL_BU_G1(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VH_BLIND if(biasName == "VH-BLIND" && biasNb == 20) { Pacs_BOLC_SET_VH_BLIND_G1(bias); sentTC = true; } // Error condition if no bias was set if(!sentTC) { error("The combination " + biasName + "/" + biasNb + " is not correct"); } } // Missionphase : // // Purpose : Send the appropriate TC to set a determined bias voltage // for a group 1 matrix. The bias voltage is expressed in // volts // Author : Diego A. Cesarsky // CUS script : Diego A. Cesarsky // CVS file : PHOT_bias_group_1.txt // // Arguments : // string biasName The bias name in accordance with the MIB convention // float bias The corresponding bias voltage [volts] // // Description : Extremely unsatisfactory code to find the bias name and // issue the corresponding TC. If bias name is not found, // the procedure sets an error condition // // Dependencies : // // Preconditions : // // Comments : The code is awful since it has to use dedicated TCs for // each bias of each group, namely 20 different TCs. There // are similar CUS procedures for each of the other 5 groups. // There are two "sanity checks": // 1- group number has to agree with procedure name // 2- bias number has to agree with bias name // // Version : 0.1 07-aug-2006 Creation by DAC // History : // : procedure PHOT_bias_group_6 { int grpNb = 6 in [6,6]; // The group number (sort of sanity check) int biasNb = 1; // The bias number (sort of sanity check) string biasName = "VH"; // The corresponding bias name as per MIB double bias = 1.62312; // The bias voltage to be set for biasName }{ // // Assume failure bool sentTC = false; // Start stupid "if" code // Bias name Pacs_BOLC_SET_VH if(biasName == "VH" && biasNb == 1) { Pacs_BOLC_SET_VH_G6(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VL if(biasName == "VL" && biasNb == 2) { Pacs_BOLC_SET_VL_G6(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VRL if(biasName == "VRL" && biasNb == 3) { Pacs_BOLC_SET_VRL_G6(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VINJ if(biasName == "VINJ" && biasNb == 4) { Pacs_BOLC_SET_VINJ_G6(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VCH if(biasName == "VCH" && biasNb == 5) { Pacs_BOLC_SET_VCH_G6(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VDL if(biasName == "VDL" && biasNb == 6) { Pacs_BOLC_SET_VDL_G6(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VSS if(biasName == "VSS" && biasNb == 7) { Pacs_BOLC_SET_VSS_G6(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VGL if(biasName == "VGL" && biasNb == 8) { Pacs_BOLC_SET_VGL_G6(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_CKRLH if(biasName == "CKRLH" && biasNb == 9) { Pacs_BOLC_SET_CKRLH_G6(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_CKRLL if(biasName == "CKRLL" && biasNb == 10) { Pacs_BOLC_SET_CKRLL_G6(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VDECX_H if(biasName == "VDECX-H" && biasNb == 11) { Pacs_BOLC_SET_VDECX_H_G6(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VDECX_L if(biasName == "VDECX-L" && biasNb == 12) { Pacs_BOLC_SET_VDECX_L_G6(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VSMS_H if(biasName == "VSMS-H" && biasNb == 13) { Pacs_BOLC_SET_VSMS_H_G6(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VSMS_L if(biasName == "VSMS-L" && biasNb == 14) { Pacs_BOLC_SET_VSMS_L_G6(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VGG if(biasName == "VGG" && biasNb == 15) { Pacs_BOLC_SET_VGG_G6(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VDD if(biasName == "VDD" && biasNb == 16) { Pacs_BOLC_SET_VDD_G6(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VSS_BU if(biasName == "VSS-BU" && biasNb == 17) { Pacs_BOLC_SET_VSS_BU_G6(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VDL_BU if(biasName == "VDL-BU" && biasNb == 18) { Pacs_BOLC_SET_VDL_BU_G6(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VGL_BU if(biasName == "VGL-BU" && biasNb == 19) { Pacs_BOLC_SET_VGL_BU_G6(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VH_BLIND if(biasName == "VH-BLIND" && biasNb == 20) { Pacs_BOLC_SET_VH_BLIND_G6(bias); sentTC = true; } // Error condition if no bias was set if(!sentTC) { error("The combination " + biasName + "/" + biasNb + " is not correct"); } } // Missionphase : // // Purpose : Send the appropriate TC to set a determined bias voltage // for a group 1 matrix. The bias voltage is expressed in // volts // Author : Diego A. Cesarsky // CUS script : Diego A. Cesarsky // CVS file : PHOT_bias_group_1.txt // // Arguments : // string biasName The bias name in accordance with the MIB convention // float bias The corresponding bias voltage [volts] // // Description : Extremely unsatisfactory code to find the bias name and // issue the corresponding TC. If bias name is not found, // the procedure sets an error condition // // Dependencies : // // Preconditions : // // Comments : The code is awful since it has to use dedicated TCs for // each bias of each group, namely 20 different TCs. There // are similar CUS procedures for each of the other 5 groups. // There are two "sanity checks": // 1- group number has to agree with procedure name // 2- bias number has to agree with bias name // // Version : 0.1 07-aug-2006 Creation by DAC // History : // : procedure PHOT_bias_group_4 { int grpNb = 4 in [4,4]; // The group number (sort of sanity check) int biasNb = 1; // The bias number (sort of sanity check) string biasName = "VH"; // The corresponding bias name as per MIB double bias = 1.62312; // The bias voltage to be set for biasName }{ // // Assume failure bool sentTC = false; // Start stupid "if" code // Bias name Pacs_BOLC_SET_VH if(biasName == "VH" && biasNb == 1) { Pacs_BOLC_SET_VH_G4(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VL if(biasName == "VL" && biasNb == 2) { Pacs_BOLC_SET_VL_G4(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VRL if(biasName == "VRL" && biasNb == 3) { Pacs_BOLC_SET_VRL_G4(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VINJ if(biasName == "VINJ" && biasNb == 4) { Pacs_BOLC_SET_VINJ_G4(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VCH if(biasName == "VCH" && biasNb == 5) { Pacs_BOLC_SET_VCH_G4(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VDL if(biasName == "VDL" && biasNb == 6) { Pacs_BOLC_SET_VDL_G4(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VSS if(biasName == "VSS" && biasNb == 7) { Pacs_BOLC_SET_VSS_G4(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VGL if(biasName == "VGL" && biasNb == 8) { Pacs_BOLC_SET_VGL_G4(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_CKRLH if(biasName == "CKRLH" && biasNb == 9) { Pacs_BOLC_SET_CKRLH_G4(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_CKRLL if(biasName == "CKRLL" && biasNb == 10) { Pacs_BOLC_SET_CKRLL_G4(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VDECX_H if(biasName == "VDECX-H" && biasNb == 11) { Pacs_BOLC_SET_VDECX_H_G4(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VDECX_L if(biasName == "VDECX-L" && biasNb == 12) { Pacs_BOLC_SET_VDECX_L_G4(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VSMS_H if(biasName == "VSMS-H" && biasNb == 13) { Pacs_BOLC_SET_VSMS_H_G4(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VSMS_L if(biasName == "VSMS-L" && biasNb == 14) { Pacs_BOLC_SET_VSMS_L_G4(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VGG if(biasName == "VGG" && biasNb == 15) { Pacs_BOLC_SET_VGG_G4(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VDD if(biasName == "VDD" && biasNb == 16) { Pacs_BOLC_SET_VDD_G4(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VSS_BU if(biasName == "VSS-BU" && biasNb == 17) { Pacs_BOLC_SET_VSS_BU_G4(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VDL_BU if(biasName == "VDL-BU" && biasNb == 18) { Pacs_BOLC_SET_VDL_BU_G4(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VGL_BU if(biasName == "VGL-BU" && biasNb == 19) { Pacs_BOLC_SET_VGL_BU_G4(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VH_BLIND if(biasName == "VH-BLIND" && biasNb == 20) { Pacs_BOLC_SET_VH_BLIND_G4(bias); sentTC = true; } // Error condition if no bias was set if(!sentTC) { error("The combination " + biasName + "/" + biasNb + " is not correct"); } } // Missionphase : // // Purpose : Send the appropriate TC to set a determined bias voltage // for a group 1 matrix. The bias voltage is expressed in // volts // Author : Diego A. Cesarsky // CUS script : Diego A. Cesarsky // CVS file : PHOT_bias_group_1.txt // // Arguments : // string biasName The bias name in accordance with the MIB convention // float bias The corresponding bias voltage [volts] // // Description : Extremely unsatisfactory code to find the bias name and // issue the corresponding TC. If bias name is not found, // the procedure sets an error condition // // Dependencies : // // Preconditions : // // Comments : The code is awful since it has to use dedicated TCs for // each bias of each group, namely 20 different TCs. There // are similar CUS procedures for each of the other 5 groups. // There are two "sanity checks": // 1- group number has to agree with procedure name // 2- bias number has to agree with bias name // // Version : 0.1 07-aug-2006 Creation by DAC // History : // : procedure PHOT_bias_group_5 { int grpNb = 5 in [5,5]; // The group number (sort of sanity check) int biasNb = 1; // The bias number (sort of sanity check) string biasName = "VH"; // The corresponding bias name as per MIB double bias = 1.62312; // The bias voltage to be set for biasName }{ // // Assume failure bool sentTC = false; // Start stupid "if" code // Bias name Pacs_BOLC_SET_VH if(biasName == "VH" && biasNb == 1) { Pacs_BOLC_SET_VH_G5(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VL if(biasName == "VL" && biasNb == 2) { Pacs_BOLC_SET_VL_G5(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VRL if(biasName == "VRL" && biasNb == 3) { Pacs_BOLC_SET_VRL_G5(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VINJ if(biasName == "VINJ" && biasNb == 4) { Pacs_BOLC_SET_VINJ_G5(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VCH if(biasName == "VCH" && biasNb == 5) { Pacs_BOLC_SET_VCH_G5(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VDL if(biasName == "VDL" && biasNb == 6) { Pacs_BOLC_SET_VDL_G5(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VSS if(biasName == "VSS" && biasNb == 7) { Pacs_BOLC_SET_VSS_G5(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VGL if(biasName == "VGL" && biasNb == 8) { Pacs_BOLC_SET_VGL_G5(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_CKRLH if(biasName == "CKRLH" && biasNb == 9) { Pacs_BOLC_SET_CKRLH_G5(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_CKRLL if(biasName == "CKRLL" && biasNb == 10) { Pacs_BOLC_SET_CKRLL_G5(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VDECX_H if(biasName == "VDECX-H" && biasNb == 11) { Pacs_BOLC_SET_VDECX_H_G5(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VDECX_L if(biasName == "VDECX-L" && biasNb == 12) { Pacs_BOLC_SET_VDECX_L_G5(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VSMS_H if(biasName == "VSMS-H" && biasNb == 13) { Pacs_BOLC_SET_VSMS_H_G5(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VSMS_L if(biasName == "VSMS-L" && biasNb == 14) { Pacs_BOLC_SET_VSMS_L_G5(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VGG if(biasName == "VGG" && biasNb == 15) { Pacs_BOLC_SET_VGG_G5(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VDD if(biasName == "VDD" && biasNb == 16) { Pacs_BOLC_SET_VDD_G5(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VSS_BU if(biasName == "VSS-BU" && biasNb == 17) { Pacs_BOLC_SET_VSS_BU_G5(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VDL_BU if(biasName == "VDL-BU" && biasNb == 18) { Pacs_BOLC_SET_VDL_BU_G5(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VGL_BU if(biasName == "VGL-BU" && biasNb == 19) { Pacs_BOLC_SET_VGL_BU_G5(bias); sentTC = true; } // Bias name Pacs_BOLC_SET_VH_BLIND if(biasName == "VH-BLIND" && biasNb == 20) { Pacs_BOLC_SET_VH_BLIND_G5(bias); sentTC = true; } // Error condition if no bias was set if(!sentTC) { error("The combination " + biasName + "/" + biasNb + " is not correct"); } } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_StartLoadCurvePcalOn.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to configure at the start of // SpirePhoto/Spectro_Cal_LoadCurvePcalOn. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // // 2009/05/06 V0.1: Initial version adapted from // SpireBb_StartBsmAngleCal (2009/05/05 V0.1) and // SpirePhoto_Cal_LoadCurvePcalOn (2009/04/01 V0.1). // BB includes now to move BSM/SMEC to hold/home. // 2009/07/07 V1.0: Fix bug to allow spectrometer to use script too. // 2009/07/10 V1.1: Fix bug SPR-SPIRE-1612 // // Notes: // 1) Scripts assumes that SpireBb_SpecOffsetAuto is run // during INITHOLD or at first POINTING. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_StartLoadCurvePcalOn SPIRE 14060 { bool phot = true; // Photometer (==tick) or FTS (==untick)? string obsModeQla = "ENG_CAL_OBS15"; string obsMode = "PEngCalObs"; bool isBright = false; // Use settings for bright source (==tick) string version01 = "v00"; // Version in cal table SpireTable_Phot/SpecModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams int hold_chop = 37632; // Chop hold position int hold_jigg = 39520; // Jiggle hold position int smecHomePosn = 3500; // SMEC home position int mclkdiv = 149; // mclkdiv (spec ==~ 121) int biasdiv = 6; // biasdiv (spec ==~ 1) int psw_bias = 62; // int pmw_bias = 62; // int plw_bias = 62; // int ptc_bias = 62; // int psw_phase = 127; // int pmw_phase = 127; // int plw_phase = 127; // int ptc_phase = 127; // int ssw_bias = 45; // int slw_bias = 45; // int ssw_phase = 128; // int slw_phase = 128; // bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // int mode_id = 0; string obsmode = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB StartLoadCurvePcalOn configuration started"); SpireMsg(2," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Startup observation: // SpireProc_Set_StartObsAll(obsModeQla); // // // // // In case move SMEC to home: // if(!phot) { // // Calculate available time for possible movement: // int tmove = duration(SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug)) + duration(SpireProc_Set_SpecMode(obsMode,isBright,version01,version02,debug)) + duration(SpireProc_Set_DcuFreqSamp(mclkdiv,biasdiv,phot,debug)) + duration(SpireProc_Set_PhotPhase(psw_phase,pmw_phase,plw_phase,ptc_phase,debug)) + duration(SpireProc_Set_PhotBias(psw_bias,pmw_bias,plw_bias,ptc_bias,debug)) + duration(SpireBb_SpecOffsetAuto(false,debug)); // // Calculate max offset for which time is available: // int smecMaxOff = tmove * 500; // Note, 500 is maximum possible SMEC speed. int smecStart = smecHomePosn + smecMaxOff; // Note, formula above only reasonable // when smecHomePosn small compared to 39500 // Safety check: if(smecStart > 39500) { smecStart = 39500; } if(debug) { debug_print("smecStart: " + smecStart); debug_print("smecHomePosn: " + smecHomePosn); debug_print("tmove: " + tmove); } // // Move from maximal offset to home: // SpireProc_SmecMove2Home(smecHomePosn,smecHomePosn + smecMaxOff,debug); } // // // // // Move BSM back to hold: // SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug); // // // // // Initialise instrument (in case to isBright): // if(phot) { SpireProc_Set_PhotMode(obsMode,isBright,version01,version02,debug); } else { SpireProc_Set_SpecMode(obsMode,isBright,version01,version02,debug); } //delay(timeSlewCal); // // // // // Set requested frequency and phase plus first bias level: // SpireProc_Set_DcuFreqSamp(mclkdiv,biasdiv,phot,debug); if(phot) { SpireProc_Set_PhotPhase(psw_phase,pmw_phase,plw_phase,ptc_phase,debug); SpireProc_Set_PhotBias(psw_bias,pmw_bias,plw_bias,ptc_bias,debug); } else { SpireProc_Set_SpecBias(ssw_bias,slw_bias,debug); SpireProc_Set_SpecPhase(ssw_phase,slw_phase,debug); } // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB StartLoadCurvePcalOn configuration ended"); SpireMsg(1," ..StartLoadCurvePcalOn took " + (time() - t) + " seconds)"); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_PhotFSetupData.txt // /////////////////////////////////////////////////////////////////////////// // // BB to set bias frequency, amplitude, and phase of photometer arrays // // Note: Script does also set biasmode to 255 (sine) and frames to 0 (continous) // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/05/02 V0.1: Initial version adapted from old Setup_PF_Data // 2008/07/03 V0.2: Renumber version; reduce maximal allowed sampling // rate to ensure data rate does not exceed limit; // allow to set PTC bolometer phase/bias // 2009/01/31 V1.0: Add debug_print as input. Change some comments. // Replace last delay(1) with sync(). Remove unsetting // off BBID at end. // 2009/06/05 V1.1: Replace Spire_SEND_DRCU_COMMAND with SpireSendDrcuCmd // as requested in SPR-1482. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_PhotFSetupData SPIRE 14005 { int mclkdiv = 0x95; //Default (IST) bias freq (== 130.20833 Hz) int biasdiv = 0x6; //Default (IST) sampling freq (== 18.60119 Hz) int psw_bias = 0x3e; //Default (IST) bias amplitud (==31.0761 mV) int pmw_bias = 0x3e; //Default (IST) bias amplitud (==31.2735 mV) int plw_bias = 0x3e; //Default (IST) bias amplitud (==31.4033 mV) int ptc_bias = 0x80; //Default (IST) bias amplitud (==127.6311 mV) int psw_phase = 0x80; //Default phase (IST) (== 180.7 deg) int pmw_phase = 0x80; //Default phase (IST) (== 180.7 deg) int plw_phase = 0x80; //Default phase (IST) (== 180.7 deg) int ptc_phase = 0x80; //Default phase (IST) (== 180.7 deg) bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Set fixed (for flight) parameters: // // Default (IST) sine bias mode generation: int biasmode = 0xff; // // Default (IST) number of frames to request // (do not use frames, but only ftime to select time) int frames = 0; // // // // // Safety checks // if(biasdiv < 2) { biasdiv = 2; } if(biasdiv > 255) { biasdiv = 255; } if(mclkdiv < 64) { mclkdiv = 64; } if(mclkdiv > 511) { mclkdiv = 511; } // // // // // Calculate bias and sampling frequencies based on mclkdiv and biasdiv: // // Calculate bias frequency Hz: double bias_f = 1.0E7 / (512.0 * double(mclkdiv + 1)); // // Calculate sampling rate Hz: double s_rate = bias_f / (1.0 + double(biasdiv)); // // // // // Verify sampling rate does not exceed 20Hz for Full Photometer: // if(s_rate > 20.0) { do { biasdiv = biasdiv + 1; s_rate = bias_f / (1.0 + double(biasdiv)); if(debug) { debug_print("New bias divisor is: " + biasdiv); debug_print("New sampling rate is: " + s_rate); } } while (s_rate > 20.0); } // // // // // Calculate frametime (time between successive frames = 1/sampling rate): // //Frametime difference in ms: double framerate = 1.0 / s_rate * 1000.0; // // // // // Debug printout: // if(debug) { debug_print(" BIAS FREQUENCY IS : " + bias_f + " [Hz]"); debug_print("SAMPLING FREQUENCY IS : " + s_rate + " [Hz]"); debug_print(" FRAMETIME DIFF IS : " + framerate + " [ms]"); } // // // // // Set the BBs to SPIRE bbid: // Spire_SET_BBID($BBID); // // // // // Set bias mode: // SpireSendDrcuCmd(0x84000000 + biasmode,0); delay(1); // // // // // Set data mode to nominal: // SpireSendDrcuCmd(0x843c0000,0); //delay(1); // // // // // Set number of frames to continuous: // SpireSendDrcuCmd(0x843d0000 + frames,0); delay(1); // // // // // Set mclkdiv and biasdiv: // SpireSendDrcuCmd(0x84190000 + mclkdiv,0); //delay(1); SpireSendDrcuCmd(0x84180000 + biasdiv,0); delay(1); // // // // // Set bias amplitude: // SpireSendDrcuCmd(0x84010000 + psw_bias,0); //delay(1); SpireSendDrcuCmd(0x84020000 + pmw_bias,0); delay(1); SpireSendDrcuCmd(0x84030000 + plw_bias,0); //delay(1); // // // // // Set phase: // SpireSendDrcuCmd(0x841a0000 + psw_phase,0); delay(1); SpireSendDrcuCmd(0x841b0000 + pmw_phase,0); //delay(1); SpireSendDrcuCmd(0x841c0000 + plw_phase,0); delay(1); // // // // // Set also the bias and phase for the TC to input values: // SpireSendDrcuCmd(0x84040000 + ptc_bias,0); //delay(1); SpireSendDrcuCmd(0x841d0000 + ptc_phase,0); sync(); // } /////////////////////////////////////////////////////////////////////////// // // SpirePhotoPeakup.txt // /////////////////////////////////////////////////////////////////////////// // // This observation executes a Peakup observation // // The instrument should be in the PHOTSTBY mode before execution // of this procedure. // // The peakup offset generated takes effect with the next observation // so this observation should be concatenated with a following observation // that requires peaking up // // 11/11/2008 KJK first version // 14/11/2008 MP: renamed script to 'Photo' to conform to naming convention; // Transformed into a *basic_fine_pointing* version // 17/11/2008 MP: add offset setting at start // 01/02/2009 MP: add debug_print as input and pass to low level script // 10/03/2009 KJK: // SCR 1274, add additional dummy parameters // Update input API to include versions for all cal tables // 17/03/2009 KJK: // Updated to use SpireTable_OpsParms cal table // Added possibility to input boresight // /////////////////////////////////////////////////////////////////////////// // obs SpirePhotoPeakup { /* ****************************************************** */ /* USER PARAMETER DEFINITION, CUS SIGNATURE for EX-HSpot */ /* ****************************************************** */ /* */ double ra = 0.0 in [0.0,360.0]; // RA of target double dec = 0.0 in [-90.0,90.0]; // DEC of target int naifid = 0; // NAIF identifier string boresight = ""; // Instrument Boresight bool isBright = false; // Use settings for bright source (==tick) string opsVersion = "v00"; // Version in Table_OpsParms cal table bool debug = false; // debug messages flag bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ // ****************************************************** */ // CALCULATE DURATIONS for POINTING STATES */ // ****************************************************** */ // // Calculate timing for the pointing request: // // BBs called during slew: int tslewmin = duration(SpireBbStartObs()); // // BBs carried out when the pointing is reached: int tinithold = duration(SpireBb_PhotOffsetAuto(debug)); //int tinithold = 0; // // BB carried out during pointing: int tp = duration(SpirePeakup("PPeakup")); // // BB carried out at the end: int tfinalhold = duration(SpireBbEndObs()); // // Debug_printing? // if(debug) { debug_print("tslewmin = " + tslewmin); debug_print("tinithold = " + tinithold); debug_print("tpointing = " + tp); debug_print("tfinalhold = " + tfinalhold); } // // ****************************************************** */ // POINTING MODE DECLARATION */ // ****************************************************** */ // // Lookup boresight, if not provided string ib = boresight; if(boresight == "") { ib = SpireProc_GetTableEntryString("SpireTable_OpsParms.txt","mode","POF1","Boresight",opsVersion,debug); } // // Set pointing mode: // int[] ts = basic_fine_pointing(true,tslewmin,tinithold,tfinalhold,ib,naifid,ra,dec,0.0,0.0,tp); // if(debug) { debug_print("Output timing vector from the pointing request: " + ts); debug_print("Boresight: " + ib); } // }{ // ****************************************************** */ // POINTING STATES WITH OBSERVING MODE LOGIC */ // ****************************************************** */ // // Start the state_machine: // int[] state = [0]; // while(state[0] >= 0) { if(debug) { debug_print("Current state: " + state); } state = next_state(); if(debug) { debug_print("Next state: " + state); } // if(state[0] == 1) { // STATE = SLEW ( Spacecraft is slewing ) // // // // // Startup observation: // SpireBbStartObs(); // } if(state[0] == 2) { // STATE = INIT_HOLD ( spacecraft is idling at source ) // // // // // Set offsets: // SpireBb_PhotOffsetAuto(debug); // // //delay(tinithold); // } if(state[0] == 3) { // STATE = POINT ( spacecraft is at nominal RA,DEC (staring, raster) ) // // // // // Execute Peakup // SpirePeakup("PPeakup"); } if(state[0] == 5) { // STATE = FINAL_HOLD ( "sky" observation ends, performing final activities ) // // // // // Reset OBSID and BBID: // SpireBbEndObs(); // } if(state[0] == -1) { // STATE = END ( end of the pointing/commanding part of the code ) // } } } // SpireBbPcalFlash // // execute PCAL calibration // // K.J. King // // 04 November 2008: // added data_rate commands // added commands to setup detector sampling for flash, in case it is set differently (e.g. for parallel mode) // 12 December 2008: SPR-1088: Modified flashMode input to allow ParPFlash // 05/07/2009 KJK: // SPR-1593 - Added flashVersion and debug to input parameters // 03/08/2009 SDS: // SCR-1768 - Added flash modes "PFlashEng","SFlashEng" for the input flashMode parameter // SCR-1587 - Set the DCU sampling to continuous after PCAL flash // block SpireBbPcalFlash SPIRE 10241 { string flashMode = "PFlash" in ["PFlash","ParPFlash","SFlash","PFlashEng","SFlashEng"]; string flashVersion = "v00"; int step = 0; bool debug = false; }{ int t = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB PCAL Flash started"); SpireMsg(2," $Id:$"); // // ..... configuration ..... // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // set STEP hstr = SpireHexStr(step,4); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP_RAW(" + hstr + ")"); Spire_SET_OBS_STEP_RAW(step); // // Time synchronisation tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_RESET_DRCU_COUNTERS_RAW()"); Spire_RESET_DRCU_COUNTERS_RAW(); delay(2); // // position SMEC, if necessary // if(flashMode == "SFlash") { // Move SMEC to HOME position int home = ilookup("SMEC.txt","HOME","ivalue"); SpireSendDrcuCmd(0x90450000 + home,0); // set position SpireSendDrcuCmd(0x90490001,0); // move SpireSendDrcuCmd(0x90490000,0); // hold position delay(2); } // // Set up detector sampling // // SpireConfigDcuData(flashMode); // // execute flash // int tableId = ilookup("SpireTable_CommandLists.txt","Flash","TableId"); // number of table containing the flash command list int startIndex = ilookup("SpireTable_CommandLists.txt","Flash","Index"); // istart point in table containing the flash command list int nParams = ilookup("SpireTable_CommandLists.txt","Flash","NParms"); // number of parameters to the flash command list int lowBias = SpireProc_GetTableEntryInt("SpireTable_Flash.txt","Mode",flashMode,"LowBias",flashVersion,debug); int highBias = SpireProc_GetTableEntryInt("SpireTable_Flash.txt","Mode",flashMode,"HighBias",flashVersion,debug); int cycles = SpireProc_GetTableEntryInt("SpireTable_Flash.txt","Mode",flashMode,"Cycles",flashVersion,debug); int period = SpireProc_GetTableEntryInt("SpireTable_Flash.txt","Mode",flashMode,"Period",flashVersion,debug); int dcuFrame = SpireProc_GetTableEntryInt("SpireTable_Flash.txt","Mode",flashMode,"DcuFrame",flashVersion,debug); int dcuSamples = SpireProc_GetTableEntryInt("SpireTable_Flash.txt","Mode",flashMode,"DcuSamples",flashVersion,debug); int dcuDelay = SpireProc_GetTableEntryInt("SpireTable_Flash.txt","Mode",flashMode,"DcuDelay",flashVersion,debug); int scuMode = SpireProc_GetTableEntryInt("SpireTable_Flash.txt","Mode",flashMode,"ScuMode",flashVersion,debug); int scuSamples = SpireProc_GetTableEntryInt("SpireTable_Flash.txt","Mode",flashMode,"ScuSamples",flashVersion,debug); {int}[] parms = [{lowBias},{highBias},{cycles},{period},{dcuFrame},{dcuSamples},{dcuDelay},{scuMode},{scuSamples}]; tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_RUN_VM_RAW(" + tableId + "," + startIndex + "," + nParams + "," + parms + ")"); Spire_RUN_VM_RAW(tableId,startIndex,nParams,parms); // set datarate double rate = 0.0; rate = dlookup("Datarates.txt",flashMode,"DCU"); rate = rate + dlookup("Datarates.txt",flashMode,"SCU"); data_rate(rate); delay(period * cycles / 1000000 + 2); data_rate(0.0); // // // ..... completion ..... // // flush data tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_FLUSH_FIFO_RAW(0x5000)"); Spire_FLUSH_FIFO_RAW(0x5000); delay(2); // // Set DCU sampling back to continuous SpireSendDrcuCmd(0x843d0000,0); delay(1); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB PCAL Flash ended"); SpireMsg(1," ..PCAL Flash (" + (time() - t) + " seconds)"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_SetSmecFramerate.txt // /////////////////////////////////////////////////////////////////////////// // // BB to set SMEC framerate // // Note: Script calls the procedure SpireProc_Set_SmecFramerate.txt // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/03/31 V1.0: Initial version adapted from // SpireBb_SetBsmFramerate (2009/02/15 V1.1) // /////////////////////////////////////////////////////////////////////////// // block SpireBb_SetSmecFramerate SPIRE 14039 { int frate = 149; // Specifies the frame rate [Dec(Hex)] bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // // // // // Start BB: // message("4 " + time() + ": SpireBb_SetSmecFramerate started"); message("4 $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); delay(1); // // // // // Set framerate: // SpireProc_Set_SmecFramerate(frate,debug); // // // // // End BB: // SpireMsg(4," " + time() + ": BB SpireBb_SetSmecFramerate ended"); // } // SpireBbJiggleId55 // // execute jiggle operations with VM table 55 // // returns the actual time on-source // // 10/12/2008 V0.1: MP First version, adapted from Ken's SpireBbJiggle // (04 November 2008) // double block SpireBbJiggleId55 SPIRE 14022 { string opsMode = "" in ["POF2","POF3","POF4"]; int jiggleTable = 0; // number of jiggle table int itableID = 0x37; // Table ID to be uploaded int startPosn = 0; // starting position in jiggle map int nPosns = 1; // number of jiggle positions to execute int nRepeats = 1; // number of times to repeat this jiggle operation int step = 0; // step number }{ int t = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB Jiggle started"); SpireMsg(2," $Id: SpireBbJiggle.txt,v 1.3 2006/12/05 14:16:57 kking Exp $"); // // ..... configuration ..... // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // set STEP hstr = SpireHexStr(step,4); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP_RAW(" + hstr + ")"); Spire_SET_OBS_STEP_RAW(step); // // set up detectors for operations // SpireConfigDcuData(opsMode); // // execute jiggle // // // New setup of VM table Id: // // int id = ilookup("CommandLists.txt","JiggleMap","Id"); // number of table containing the jiggle command list int id = itableID; // // Original setup: // int index = ilookup("CommandLists.txt","JiggleMap","Index"); // istart point in table containing the jiggle command list int nParms = ilookup("CommandLists.txt","JiggleMap","Nparms"); // number of parameters to the jiggle command list int nChops = ilookup("OpsParms.txt",opsMode,"NChops"); // number of chop cycles per jiggle position int tChop = ilookup("Chopping.txt",opsMode,"Period"); // period of chop cycle int dcuFrame = ilookup("Chopping.txt",opsMode,"DcuFrame"); // DCU Sample Mode int nDcu = ilookup("Chopping.txt",opsMode,"DcuSamples"); // number of DCU Samples per chop position int tDelay = ilookup("Chopping.txt",opsMode,"DcuDelay"); // delay to start of DCU sampling int nBsm = ilookup("Chopping.txt",opsMode,"BsmSamples"); // number of BSM samples per chop position // // issue VM command // {int}[] parms = [{jiggleTable},{startPosn * 2},{nPosns * 2},{nChops},{tChop},{dcuFrame},{nDcu},{tDelay},{nBsm},{nRepeats}]; tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_RUN_VM_RAW(" + id + "," + index + "," + nParms + "," + parms + ")"); Spire_RUN_VM_RAW(id,index,nParms,parms); // set datarate double rate = 0.0; rate = dlookup("Datarates.txt",opsMode,"DCU"); rate = rate + dlookup("Datarates.txt",opsMode,"BSM"); data_rate(rate); // calc time to perform a jiggle operation int nOps = nPosns * nChops * nRepeats; double opsTime = double(nOps) * double(tChop) / 1000000.0; // wait to end of jiggle operation delay(iceil(opsTime)); data_rate(0.0); // // flush data tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_FLUSH_FIFO_RAW(0x3000)"); Spire_FLUSH_FIFO_RAW(0x3000); delay(2); double srcTime = double(nOps) * double(tChop) / 1000000.0; // // effective integration time per jiggle operation // // ..... completion ..... // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB Jiggle ended"); SpireMsg(1," ..Jiggle (" + (time() - t) + " seconds)"); // return srcTime; } // SpireConfigDcuData // // $Id:$ // // Procedure to configure the DCU to generate detector data TM packets for a particular operating mode // // 04 November 2008: first version // procedure SpireConfigDcuData { string opsMode = ""; }{ message("4 " + time() + ": SpireConfigDcuData started"); message("4 $Id:$"); // // fetch sampling values int biasmode = ilookup("Datarates.txt",opsMode,"BiasMode"); int mclkdiv = ilookup("Datarates.txt",opsMode,"MclkDiv"); int biasdiv = ilookup("Datarates.txt",opsMode,"BiasDiv"); string datamode = slookup("Datarates.txt",opsMode,"DataMode"); // stop DCU data generation, just to make sure SpireSendDrcuCmd(0x843e0000,0); // select data mode if(datamode == "PF") { SpireSendDrcuCmd(0x843c0000,0); } if(datamode == "PSW") { SpireSendDrcuCmd(0x843c0001,0); } if(datamode == "PMW") { SpireSendDrcuCmd(0x843c0002,0); } if(datamode == "PLW") { SpireSendDrcuCmd(0x843c0003,0); } if(datamode == "SF") { SpireSendDrcuCmd(0x843c0004,0); } if(datamode == "SSW") { SpireSendDrcuCmd(0x843c0005,0); } if(datamode == "SLW") { SpireSendDrcuCmd(0x843c0006,0); } if(datamode == "Parallel") { SpireSendDrcuCmd(0x843c0000,0); } // setup sampling SpireSendDrcuCmd(0x84000000 + biasmode,0); SpireSendDrcuCmd(0x84190000 + mclkdiv,0); delay(1); SpireSendDrcuCmd(0x84180000 + biasdiv,0); // Set sampling to continuous SpireSendDrcuCmd(0x843d0000,0); // delay(1); message("4 " + time() + ": SpireConfigDcuData ended"); // } // SpireSOF12Pointing // // $id$ // // This procedure calculates and returns the pointing parameters for the SOF1 and SOF2 observing modes // // 03/02/2009: KJK // changed input interface to accept 2 sets of scan info in order to call SpirePointSpectrum correctly // now calls SpireProc_SFlash to get PCAL flash duration (including SMEC movement times) // {int,int,int,int,int,int} procedure SpireSOF12Pointing { string opsMode = "SOF1" in ["SOF1","SOF2","SOF2_int"]; // operations mode string res1 = "H" in ["H","M","C","L"]; // resolution for set 1 int nCycles1 = 0; // number of cycles to execute in set 1 double tCycle1 = 0.0; // time for a cycle in set 1 int scansPerCycle1 = 0; // number of scans in a cycle for set 1 string res2 = "L" in ["H","M","C","L"]; // resolution for set 2 int nCycles2 = 0; // number of cycles to execute in set 2 double tCycle2 = 0.0; // time for a cycle in set 2 int scansPerCycle2 = 0; // number of scans in a cycle for set 2 int nMaps = 1; // total number of number of maps to perform int nFlashes = 0; // number of flashes per point double tFlashInterval = 0.0; // time between flashes string specVersion = "v00"; string flashVersion = "v00"; bool debug = false; }{ string version = "v00"; bool initFlash = blookup("SpireParms.txt",opsMode,"InitFlash"); // initial flash flag bool endFlash = blookup("SpireParms.txt",opsMode,"EndFlash"); // final flash flag int jiggleTable = ilookup("OpsParms.txt",opsMode,"TableId"); // Jiggle Table ID int jiggleSize = ilookup("OpsParms.txt",opsMode,"TableSize"); // Jiggle Table length int hScansPerCycle = ilookup("OpsParms.txt",opsMode,"NHScans"); int mScansPerCycle = ilookup("OpsParms.txt",opsMode,"NMScans"); int lScansPerCycle = ilookup("OpsParms.txt",opsMode,"NLScans"); // int scanStart1 = SpireProc_GetTableEntryInt("SpireTable_Spectrometer.txt","ResChar",res1,"ScanStart",specVersion,debug); int smecHome = ilookup("SpireTable_SmecNominalSettings.txt",version,"Home"); int tFlash = duration(SpireProc_SFlash("SFlash",scanStart1,scanStart1,0,flashVersion,debug)); // // total time pointing int tp = 2; int nPoints = 0; for(int i = 0 .. jiggleSize - 1) { // move to jiggle point i tp = tp + duration(SpireBbBsmMove(jiggleTable,i,0)); // insert flashes between points if flashes are required inside each point if(i > 0) { if(nFlashes > 0 || i % nPoints == 0) { tp = tp + tFlash; initFlash = true; endFlash = true; } } // observe jiggle point i tp = tp + duration(SpirePointSpectrum(res1,nCycles1,tCycle1,scansPerCycle1,res2,nCycles2,tCycle2,scansPerCycle2,tFlashInterval,0,specVersion,flashVersion,debug)); // insert flashes every n points if(i == 0) { nPoints = ifloor(tFlashInterval / double(tp)); if(nPoints == 0) { nPoints = jiggleSize; } } if(debug) { debug_print("tp=" + tp); } } // // minimum slew time int tSlewMin = duration(SpireBbObsConfig(0)) + duration(SpireBbSOF1Config(res1,specVersion,debug)) + 2; // // time for Initial Hold int tInitHold = duration(SpireBbSOF1Init()) + 2; if(initFlash) { tInitHold = tInitHold + duration(SpireProc_SFlash("SFlash",smecHome,scanStart1,0,flashVersion,debug)); } // // time for Final Hold int tFinalHold = duration(SpireBbSOF1End(res1,specVersion,debug)) + 2; if(endFlash) { tFinalHold = tFinalHold + duration(SpireProc_SFlash("SFlash",scanStart1,smecHome,0,flashVersion,debug)); } // // raster variables // int nFlash = 0; if(nFlashes > 0 || ifloor(tFlashInterval / double(tp)) == 0) { // flashes within a jiggle point or raster point nFlash = 1; } else { nFlash = ifloor(tFlashInterval / double(tp)); } return {tSlewMin,tInitHold,tFinalHold,tp,tFlash,nFlash}; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_EndObsAll.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to reconfigure at the end of all AOTs // (i.e. astronomer, engineering, and calibration ones) // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/01/21 V1.0: Merged BB using SpireBb_EndObs (2008/11/12 V0.2) and // SpireBbEndObs (17/11/2008 KJK). This will also replace // part of the EndObs stuff done currently in // SpireBbPOF2End (v 1.1 2006/08/10) and // SpireBbPOF3End (v 1.3 2007/08/02) and // SpireBbPOF5End (v 1.1 2006/08/10) // Script includes HSPOT messages and has an // added sync() statement to round up total duration (SxR?). // 2009/01/30 V1.1: Changed entries in messages related to 'RAW'. Changed // some comments. Removed last delay(1) before new sync(). // 2009/05/05 V1.2: Move commands into low level procedure // SpireProc_Set_EndObsAl which will be called here. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_EndObsAll SPIRE 14023 { bool phot = true; // Photometer (==tick) or FTS (==untick)? }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // int mode_id = 0; string obsmode = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB Reconfiguration started"); SpireMsg(2," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // End observations: // SpireProc_Set_EndObsAll(phot); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB Reconfiguration ended"); SpireMsg(1," ..Reconfiguration to " + obsmode + "mode (" + (time() - t) + " seconds)"); // } block Pacs_CcuMonitorStartRecycle PACS 2102 { }{ PacsCcuMonitorPeriodRecycle(); sync(); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_StartDcuMcuData.txt // /////////////////////////////////////////////////////////////////////////// // // BB to start generation of detector data (TM packets) plus MCU // (here only BSM and SMEC) data. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/03/31 V0.1: Initial version adapted from // SpireBb_StartDcuData (2009/02/18 V1.0) // /////////////////////////////////////////////////////////////////////////// // block SpireBb_StartDcuMcuData SPIRE 14037 { }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SpireBb_StartDcuMcuData started"); SpireMsg(2," $Id:$"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Start DCU data: // SpireProc_Set_StartDcuData(); SpireProc_Set_StartMcuData(); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SpireBb_StartDcuMcuData ended"); SpireMsg(1," ..StartDcuMcuData (" + (time() - t) + " seconds)"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_EndLoadCurvePcalOn.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to reconfigure at the end of // SpirePhoto/Spectro_Cal_LoadCurvePcalOn. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // // 2009/05/05 V1.0: Initial version adapted from // SpireBb_EndBsmAngleCal (2009/05/05 V1.2) and // SpirePhoto_Cal_LoadCurvePcalOn (2009/04/01 V0.1). // /////////////////////////////////////////////////////////////////////////// // block SpireBb_EndLoadCurvePcalOn SPIRE 14061 { bool phot = true; // Photometer (==tick) or FTS (==untick)? bool isBright = false in [true,false]; // IsBright (==tick) flag string version01 = "v00"; // Version in cal.tab. SpireTable_PhotModeParams string version02 = "v00"; // Version in cal.tab. SpireTable_CommonModeParams bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // int mode_id = 0; string obsmode = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB EndLoadCurvePcalOn reconfiguration started"); SpireMsg(2," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Set instrument back to Phot/Spec-STBY: // if(phot) { SpireProc_Set_PhotMode("PHTSTBY",isBright,version01,version02,debug); } else { SpireProc_Set_SpecMode("SPECSTBY",isBright,version01,version02,debug); } // // // // // End observation: // SpireProc_Set_EndObsAll(phot); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB EndLoadCurvePcalOn reconfiguration ended"); SpireMsg(1," ..Reconfiguration to " + obsmode + "mode (" + (time() - t) + " seconds)"); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_CalcParam_BiasFreqSampFreq.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to translate user input in Hz for bias frequency and // sampling rate into nearest Hex values for mclkdiv and biasdiv // // Adapted from: Proc_SetBias.txt (v1.4 2008/01/31 20:24:35) // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/05/02 V0.1: Initial version // 2008/06/09 V0.2: Changes to output printing and input values // 2008/06/10 V0.3: Change formula to calculate mclkdiv according to // S060719_SAp-SPIRE-CCa-076-02_I1.3_DRCU-DPU-ICD.pdf // 2008/08/15 V0.4: Add extra parameter to keep track of different // boundary for biasdiv for photometer and FTS // 2009/01/31 V1.0: Add debug_print option. // /////////////////////////////////////////////////////////////////////////// // int[] procedure SpireProc_CalcParam_BiasFreqSampFreq { double freq0 = 130.2; // Bias frequency (Hz) double freq1 = 18.6; // Sampling frequency bool fts = false; // FTS or photometer limits? bool debug = false; // Allow (==tick) or suppress cus debug_print statement }{ // // // // // Calculate mclkdiv and biasdiv based on user input in Hz: // // Master clock divisor, which specifies bias freq: // int mclkdiv = iround(1.0E7 / (512.0 * (freq0 + 1.0))); int mclkdiv = iround(1.0E7 / (512.0 * freq0)) - 1; // // Check boundaries: // if(mclkdiv < 64) { mclkdiv = 64; } if(mclkdiv > 511) { mclkdiv = 511; } // // Sampling divisor, which specifies sampling rate: int biasdiv = iround(freq0 / freq1) - 1; // // // // // Check boundaries: // int biasdiv_lim = 2; if(fts) { biasdiv_lim = 1; } // if(biasdiv < biasdiv_lim) { biasdiv = biasdiv_lim; } if(biasdiv > 255) { biasdiv = 255; } // // // // // Calculate Hz values of commanded frequencies: // double mclkdivHz = 1.0E7 / (512.0 * double(mclkdiv + 1)); double biasdivHz = 1.0 / (double(biasdiv) + 1.0) * mclkdivHz; // // // // // Printout: // if(debug) { debug_print("Input values bias/samp. frequency: " + freq0 + " " + freq1); debug_print("Output values mclkdiv/biasdiv [raw]: " + mclkdiv + " " + biasdiv); debug_print("Output values mclkdiv/biasdiv [Hz]: " + mclkdivHz + " " + biasdivHz); } // // // // // Return required values: // return [mclkdiv,biasdiv]; } // SpireStartDcuData // // $Id:$ // // Procedure to start generation of detector data TM packets appropriate to the operating mode // // 04 November 2008: // added command to set DCU mode to continuous sampling // added data_rate command // changed to receive operating mode rather than data mode as a parameter // now calls SpireConfigDcuData to set up detectors // // procedure SpireStartDcuData { string opsMode = ""; }{ message("4 " + time() + ": SpireStartDcuData started"); message("4 $Id:$"); // setup detectors SpireConfigDcuData(opsMode); // start data collection SpireSendDrcuCmd(0x843e0001,0); // set datarate double rate = 0.0; rate = dlookup("Datarates.txt",opsMode,"DCU"); data_rate(rate); // delay(1); message("4 " + time() + ": SpireStartDcuData ended"); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_EndBsmPcalFlash.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to reconfigure at the end of SpireProc_Exec_BsmPcalFlash // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // // 2009/05/05 V1.0: Initial version adapted from // SpireBb_EndBsmAngleCal (2009/05/05 V1.2), // SpirePhoto_Cal_BsmPcalFlash (2009/03/04 V1.3), and // SpireSpectro_Cal_BsmPcalFlash (2009/03/04 V0.1) // 2009/05/07 V1.1: Set dcuFrameNumber and scuFrameNumber back to continuous // to unset setting passed to VM. // 2009/06/05 V1.2: Replace Spire_SEND_DRCU_COMMAND with SpireSendDrcuCmd // as requested in SPR-1482. // 2009/07/12 V1.3: Set SMEC framerate back to nominal. (SPR-SPIRE-1551). // /////////////////////////////////////////////////////////////////////////// // block SpireBb_EndBsmPcalFlash SPIRE 14043 { bool phot = true; // Photometer (==tick) or FTS (==untick)? int hold_chop = 37632; // Chop hold position [Dec(Hex)] int hold_jigg = 39520; // Jiggle hod position [Dec(Hex)] bool isBright = false in [true,false]; // IsBright (==tick) flag string version01 = "v00"; // Version in cal.tab. SpireTable_PhotModeParams string version02 = "v00"; // Version in cal.tab. SpireTable_CommonModeParams bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // int mode_id = 0; string obsmode = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB EndBsmPcalFlash reconfiguration started"); SpireMsg(2," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Set obsstep back to 0: // tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP(0)"); Spire_SET_OBS_STEP(0); // // // // // Set instrument back to Phot/Spec-STBY: // if(phot) { SpireProc_Set_PhotMode("PHTSTBY",isBright,version01,version02,debug); } else { SpireProc_Set_SpecMode("SPECSTBY",isBright,version01,version02,debug); } // // // // // Move BSM back to hold: // SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug); // // // // // Set number of DCU frames to continuous: // int dcuFrameNumber = 0; if(phot) { dcuFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","PHTSTBY","dcuFrameNumber","v00",debug); } else { dcuFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","SPECSTBY","dcuFrameNumber","v00",debug); } // SpireSendDrcuCmd(0x843d0000 + dcuFrameNumber,0); // // // // // Set number of SCU frames to continuous: // int scuFrameNumber = 0; if(phot) { scuFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","PHTSTBY","scuFrameNumber","v00",debug); } else { scuFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","SPECSTBY","scuFrameNumber","v00",debug); } SpireSendDrcuCmd(0xa0840000 + scuFrameNumber,0); delay(1); // // // // // Set SMEC framerate (== SMEC sampling rate) back to SPEC_STBY: // (Note, hardcoded version to go back to STBY) // if(!phot) { int smecFrameRate = SpireProc_GetTableEntryInt("SpireTable_SpecModeParams.txt","mode","SPECSTBY","smecFrameRate","v00",debug); SpireProc_Set_SmecFramerate(smecFrameRate,debug); } // // // // // End observation: // SpireProc_Set_EndObsAll(phot); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB EndBsmPcalFlash reconfiguration ended"); SpireMsg(1," ..Reconfiguration to " + obsmode + "mode (" + (time() - t) + " seconds)"); // } // SpireProc_SFlash // // Execute a PCAL: flash for spectrometer modes // This procedure ensures the SMEC is located at the Home position for the duration of the flash // It moves the SMEC to the Home position from the current position and returns it to the end position // The SMEC scan speed may also be changed // // The BSM is assumed to be at its Hold position // // K.J. King // // 27/01/2009: (KJK) First Version // 18/02/2009: (MP) Changed call to updated SpireBb_PcalFlash which does // no longer set the data_rate. // procedure SpireProc_SFlash { string flashMode = "SFlash"; int smecCurrPosn = 1000; // Current SMEC position int smecEndPosn = 1000; // End SMEC position int step = 0; string flashVersion = "v00"; // flash parameters version bool debug = false; }{ string version = "v00"; int t = time(); string hstr = ""; // hex string string tstr = ""; // time string // // Start tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": Proc SFlash started"); SpireMsg(2," $Id: $"); // // move to Home position // SpireBb_SmecMove2Home(smecCurrPosn,debug); // // execute flash // // fetch flash parameters int id = ilookup("CommandLists.txt","Flash","Id"); // number of table containing the flash command list int index = ilookup("CommandLists.txt","Flash","Index"); // istart point in table containing the flash command list int nParms = ilookup("CommandLists.txt","Flash","Nparms"); // number of parameters to the flash command list int lowBias = SpireProc_GetTableEntryInt("SpireTable_Flash.txt","Mode",flashMode,"LowBias",flashVersion,debug); int highBias = SpireProc_GetTableEntryInt("SpireTable_Flash.txt","Mode",flashMode,"HighBias",flashVersion,debug); int cycles = SpireProc_GetTableEntryInt("SpireTable_Flash.txt","Mode",flashMode,"Cycles",flashVersion,debug); int period = SpireProc_GetTableEntryInt("SpireTable_Flash.txt","Mode",flashMode,"Period",flashVersion,debug); int dcuMode = SpireProc_GetTableEntryInt("SpireTable_Flash.txt","Mode",flashMode,"DcuFrame",flashVersion,debug); int dcuSamples = SpireProc_GetTableEntryInt("SpireTable_Flash.txt","Mode",flashMode,"DcuSamples",flashVersion,debug); int dcuDelay = SpireProc_GetTableEntryInt("SpireTable_Flash.txt","Mode",flashMode,"DcuDelay",flashVersion,debug); int scuMode = SpireProc_GetTableEntryInt("SpireTable_Flash.txt","Mode",flashMode,"ScuMode",flashVersion,debug); int scuSamples = SpireProc_GetTableEntryInt("SpireTable_Flash.txt","Mode",flashMode,"ScuSamples",flashVersion,debug); // // calculate datarate during flash double rate = 0.0; rate = dlookup("Datarates.txt",flashMode,"DCU"); rate = rate + dlookup("Datarates.txt",flashMode,"SCU"); rate = rate + dlookup("Datarates.txt",flashMode,"BSM"); // // make flash SpireBb_PcalFlash(id,index,nParms,lowBias,highBias,cycles,period,dcuMode,dcuSamples,dcuDelay,scuMode,scuSamples,step,debug); // // set datarate after flash rate = dlookup("Datarates.txt",flashMode,"BSM"); data_rate(rate); // // move to End posn int smecHomePosn = ilookup("SpireTable_SmecNominalSettings.txt",version,"Home"); SpireBb_SmecMove(smecEndPosn,smecHomePosn,debug); // // finish tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": Proc SFlash ended"); SpireMsg(1," Proc SFlash (" + (time() - t) + " seconds)"); } // Missionphase : // // Purpose : Set gain "HIGH" or "LOW" for the BOLO electronics // // // // TCL author : // TCL file : tm_phot_set_gain.tcl // CUS author : // Script file : PHOT_set_gain.txt // // Input arguments // type name description // // Return values // Type Name Default Description // // Description : This script will activate the LOW or HIGH gain modes // // Dependencies : // // Preconditions : // // Comments : // // History : 0.1 19-apr-2005 DAC. // int[] procedure PHOT_set_gain { string set_gain = "LOW" in ["LOW","HIGH"]; // Set electronics gain }{ // Define variables to communicate various durations to HSPOT. // NOTE: all time variables in units of number of ramps (SPEC) or // number of readouts (BOLO). The calling program must convert this // count into actual duration in true time units [seconds]. // SRC, REF, CAL, OVR stand for time spent on SRC, REF (on sky), // CAL source, and overheads (wait for something). Total // duration is given by duree_num. If no error, this duration // must be equal to the sum of all others int duree_num = 0; int duree_SRC = 0; int duree_REF = 0; int duree_CAL = 0; int duree_OVR = 0; int time_start = time(); Pacs_BOLC_SET_GAIN(set_gain); // Time spent int duree_TCs = time() - time_start; duree_OVR = duree_TCs; duree_num = duree_OVR; // Return the array of times int[] time_array = [duree_num,duree_SRC,duree_REF,duree_CAL,duree_OVR]; sync(); return time_array; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_Set_PhotOffsetAuto.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to set the detector offset for the photometer arrays // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/02/19 V0.1: Initial version adapted from // SpireBb_PhotOffsetAuto (2009/01/31 V1.0) // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Set_PhotOffsetAuto { bool dcuData = false; // Is (==tick) the DCU currently sampled? bool debug = false; // Allow (==tick) or suppress cus debug_print statement }{ // // // // // Define some variables: // // a time string: string tstr = ""; // // // // // Start procedure: // message("4 " + time() + ": SpireProc_Set_PhotOffsetAuto started"); message("4 $Id: $"); // // // // // In case stop data: // if(dcuData) { SpireSendDrcuCmd(0x843e0000,0); } // // // // // Reset DCU (x1000) fifo: // tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_RESET_FIFOS(0x1000)"); Spire_RESET_FIFOS(0x1000); sync(); // // // // // Set data mode to 'Set automatic offset': // SpireSendDrcuCmd(0x843c0010,0); // // // // // Start data collection: // SpireSendDrcuCmd(0x843e0001,0); delay(3); // // // // // Stop data collection: // SpireSendDrcuCmd(0x843e0000,0); // // // // // Set data mode to 'Get offset data': // SpireSendDrcuCmd(0x843c0018,0); delay(1); // // // // // Start data collection: // SpireSendDrcuCmd(0x843e0001,0); delay(3); // // // // // Stop data collection: // SpireSendDrcuCmd(0x843e0000,0); // // // // // Flush DCU fifo: // tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_FLUSH_FIFO(0x1000)"); Spire_FLUSH_FIFO(0x1000); delay(2); // // // // // Set data mode back to nominal: // SpireSendDrcuCmd(0x843c0000,0); // // // // // In case start data collection: // if(dcuData) { SpireSendDrcuCmd(0x843e0001,0); } sync(); // } // SpirePhotoLargeLogic // // $id$ // // This procedure selectes the SPIRE observing mode and calculates its instrument parameters // for large map observations // // This type of observation may be executed using either the POF4 or POF5 observing modes // // 18/01/07: v1.9: updated call to SpirePOF5Estimate to pass obsMode // 13/04/07: v1.10: SPR 3010 - added option to select between two scan rates // SPR 3043 - added option to select scan direction(s) // 20/04/07: v1.11: SPR 3125 - corrected nHold for scanab // 26/04/07: v1.12: SPR 3146 - swapped rate and tau paramaters in call to SpirePOF5Estimates // 26/04/07: v1.13: SPR 3148 - calculate patt correctly for each mode // 27/04/07: v1.14: SPR 3150 // 10/03/2009 KJK: // SCR 1274, add additional dummy parameters // Update input API to include versions for all cal tables // 02/07/2009 KJK: // Added configuration input parameters to pass to SpirePOF5Config, SpirePOF5Pointing and SpirePOF5End// // 05/07/2009 KJK: // SPR-1593 - Updated call to SpirePOF5Pointing // {{string,double,double,double,double,bool,double,double,double}[],bool,int,int,int,int,int,int,int,int,int,int,int} obs SpirePhotoLargeLogic { double ra = 0.0 in [0.0,360.0]; // RA of Target double dec = 0.0 in [-90.0,90.0]; // DEC of Target int naifid = 0; // NAIF identifier string source = "large" in ["point","small","large"]; // source type string scanDirection = "scanab" in ["scana","scanb","scanab"]; double mapSize1 = 4.0 in [4.0,1200.0]; // arc minutes double mapSize2 = 0.0 in [0.0,240.0]; // arc minutes double mapOffsetY = 0.0 in [-300.0,300.0]; // offset to observation position from target in Y direction (arcmins) double mapOffsetZ = 0.0 in [-300.0,300.0]; // offset to observation position from target in Z direction (arcmins) string mapScanRate = "nominal" in ["nominal","fast"]; // selected scan rate bool mapOrientationArray = true; // is the map orientation an array (rather than array with constraints) double mapOrientationConFrom = 0.0 in [0.0,360.0]; double mapOrientationConTo = 360.0 in [0.0,360.0]; int nRepetitions = 1 in [1,100]; // number of repeats of a map sequence (nominal + orthoganal scans) double sourceFluxPSW = -1.0; double sourceFluxPMW = -1.0; double sourceFluxPLW = -1.0; double sourceBrightPSW = -1.0; double sourceBrightPMW = -1.0; double sourceBrightPLW = -1.0; bool isBright = false; string bsmModel = "initial"; string bsmVersion = "v00"; // Version in cal table SpireTable_BsmNominalSettings.txt string spireVersion = "v00"; // Version in cal table SpireTable_SpireParms string opsVersion = "v00"; // Version in cal table SpireTable_OpsParms string flashVersion = "v00"; // Version in cal table SpireTable_FlashParms string photVersion = "v00"; // Version in cal table SpireTable_PhotModeParams.txt string comVersion = "v00"; // Version in cal table SpireTable_CommonModeParams.txt bool debug = false; // debug messages flag bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ // check inputs if(source != "large") { error("SpirePhotoLargeLogic: Source is not a large map"); } if(scanDirection == "scanab" && mapSize1 > 240.0) { error("SpirePhotoLargeLogic: Scan length too big (>240.0 arcmin) "); } SpireMsg(0,"Photometric Large Map Observation"); int nRasters = nRepetitions; int nPoints = 1; int nMaps = 1; int nCycles = 1; int nNodInts = 1; int nLines = 1; int nCal = 99999; int nFlash = 99999; int nLinesx = 1; int nCalx = 99999; int nFlashx = 99999; // // ************************************************************* // calculate parameters for POF4 observation // ************************************************************* // SpireMsg(1," POF4 (Raster map) mode parameters"); // // !!! THIS IS NOT IMPLEMENTED YET !!! // // ************************************************************* // calculate parameters for POF5 observation // ************************************************************* SpireMsg(1," POF5 (Non-chopped Scan Map) mode parameters"); // string obsMode = "POF5"; if(mapScanRate == "fast") { obsMode = obsMode + "_F"; } else { obsMode = obsMode + "_S"; } // // ***** first scan parameters ***** {double,double,int,int,int,int} pof5Obs = {0.0,0.0,0,0,0,0}; double patt = dlookup("OpsParms.txt",obsMode + "_N","Patt"); // direction of scan // observing mode parameters if(scanDirection == "scana") { nMaps = ilookup("OpsParms.txt",obsMode + "_N","NMaps"); pof5Obs = SpirePOF5Observing(obsMode + "_N",nRepetitions * nMaps,mapSize1,mapSize2); } if(scanDirection == "scanb") { nMaps = ilookup("OpsParms.txt",obsMode + "_O","NMaps"); patt = dlookup("OpsParms.txt",obsMode + "_O","Patt"); // direction of scan pof5Obs = SpirePOF5Observing(obsMode + "_O",nRepetitions * nMaps,mapSize1,mapSize2); } if(scanDirection == "scanab") { nMaps = ilookup("OpsParms.txt",obsMode + "_N","NMaps"); pof5Obs = SpirePOF5Observing(obsMode + "_N",nMaps,mapSize1,mapSize2); } double mapOsit = pof5Obs{0}; double d1 = pof5Obs{1}; int nRepeats = pof5Obs{2}; nLines = pof5Obs{3}; nCal = pof5Obs{4}; nFlash = pof5Obs{5}; // // pointing mode input parameters: {int,int,int,int,int,double,double} pof5Point = {0,0,0,0,0,0.0,0.0}; if(scanDirection == "scanb") { pof5Point = SpirePOF5Pointing(obsMode + "_O",nRepeats,nLines,nCal,nFlash,isBright,bsmModel,bsmVersion,flashVersion,photVersion,comVersion,debug); } else { pof5Point = SpirePOF5Pointing(obsMode + "_N",nRepeats,nLines,nCal,nFlash,isBright,bsmModel,bsmVersion,flashVersion,photVersion,comVersion,debug); } int tSlewMin = pof5Point{0}; int tInitHold = pof5Point{1}; int tFinalHold = pof5Point{2}; int tHold = pof5Point{3}; int nHold = pof5Point{4}; double d2 = pof5Point{5}; double rate = pof5Point{6}; // // ***** cross scan parameters ***** if(scanDirection == "scanab") { nMaps = ilookup("OpsParms.txt",obsMode + "_O","NMaps"); // observing mode parameters {double,double,int,int,int,int} pof5Obsx = {0.0,0.0,0,0,0,0}; pof5Obsx = SpirePOF5Observing(obsMode + "_O",nMaps,mapSize2,mapSize1); double mapOsitx = pof5Obsx{0}; double d1x = pof5Obsx{1}; int nRepeatsx = pof5Obsx{2}; nLinesx = pof5Obsx{3}; nCalx = pof5Obsx{4}; nFlashx = pof5Obsx{5}; // // pointing mode input parameters: {int,int,int,int,int,double,double} pof5Pointx = {0,0,0,0,0,0.0,0.0}; pof5Pointx = SpirePOF5Pointing(obsMode + "_O",nRepeatsx,nLinesx,nCalx,nFlashx,isBright,bsmModel,bsmVersion,flashVersion,photVersion,comVersion,debug); int nHoldx = pof5Pointx{4}; double d2x = pof5Pointx{5}; // } // // ***** pointing mode pointing parameters ***** string ib = slookup("OpsParms.txt",obsMode + "_N","Boresight"); // instrument boresight double deltaY = dlookup("OpsParms.txt",obsMode + "_N","DeltaY"); // offset to pixel centre from boresight in Y direction (arcsecs) double deltaZ = dlookup("OpsParms.txt",obsMode + "_N","DeltaZ"); // offset to pixel centre from boresight in Z direction (arcsecs) bool fixed = blookup("OpsParms.txt",obsMode + "_N","Fixed"); // pattern angle definition double pattx = dlookup("OpsParms.txt",obsMode + "_O","Patt"); // direction of cross scan double yOffset = mapOffsetY * 60.0 + deltaY; // offset to observation position from target in Y direction (arcsecs) double zOffset = mapOffsetZ * 60.0 + deltaZ; // offset to observation position from target in Z direction (arcsecs) // int[] ts = []; if(scanDirection == "scanab") { // correct nHold and nFlash if(nFlash < nLines) { int nFlashes = nLines / nFlash; nHold = nLines / (nFlashes + 1); nFlash = nHold; } ts = cross_scan_pointing(true,tSlewMin,tInitHold,tFinalHold,ib,naifid,ra,dec,fixed,patt,yOffset,zOffset,nLines,d1,d2,rate,tHold,nHold,nRepetitions,nMaps,pattx,nLinesx,d1x,d2x,nHoldx); } else { ts = line_scan_pointing(true,tSlewMin,tInitHold,tFinalHold,ib,naifid,ra,dec,fixed,patt,yOffset,zOffset,nLines,d1,d2,rate,tHold,nHold,nRepeats); } // // ***** choose observing mode ***** // bool isRasterMap = false; SpireMsg(1," Using POF5 (Scan Map) Observing Mode"); }{ // ******************************* // return instrument parameters // ******************************* // {string,double,double,double,double,bool,double,double,double}[] estimates = []; // if(isRasterMap) { } else { double tau = double(nRepetitions); estimates = SpirePOF5Estimate(obsMode + "_" + scanDirection,tau,rate,sourceFluxPSW,sourceFluxPMW,sourceFluxPLW,sourceBrightPSW,sourceBrightPMW,sourceBrightPLW,isBright); } // SpireMsg(3," Spire Photometry Large Map Mode parameters:"); SpireMsg(3," ..estimates: " + estimates); SpireMsg(3," ..isRasterMap: " + isRasterMap); SpireMsg(3," ..nRasters: " + nRasters + "(# map repeats)"); SpireMsg(3," ..nPoints: " + nPoints); SpireMsg(3," ..nMaps: " + nMaps); SpireMsg(3," ..nCycles: " + nCycles); SpireMsg(3," ..nNodInts: " + nNodInts); SpireMsg(3," ..nLines: " + nLines); SpireMsg(3," ..nCal: " + nCal); SpireMsg(3," ..nFlash: " + nFlash); SpireMsg(3," ..nLinesx: " + nLinesx); SpireMsg(3," ..nCalx: " + nCalx); SpireMsg(3," ..nFlashx: " + nFlashx); // return {estimates,isRasterMap,nRasters,nPoints,nMaps,nCycles,nNodInts,nLines,nCal,nFlash,nLinesx,nCalx,nFlashx}; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_SmecHold.txt // /////////////////////////////////////////////////////////////////////////// // // BB to stop SMEC trajectory generation. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/03/31 V0.1: Initial version // /////////////////////////////////////////////////////////////////////////// // block SpireBb_SmecHold SPIRE 14036 { bool debug = false; }{ // // // // // Define some variables: // int t = time(); // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // // // // // Start BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SmecHold started"); SpireMsg(2," $Id: $"); // // // // // Set the BBID: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // // // // Set SMEC to stop: // SpireProc_SmecHold(debug); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SmecHold ended"); SpireMsg(1," ..BB SmecHold (" + (time() - t) + " seconds)"); // } // SpireSOF12Estimate // // $Id:$ // // This procedure calculates the estimated noise and signal/noise // for the given observing time for all spectrometer modes. // // for input values, a value less than 0 indicates value unknown // // 20/04/07: v1.5: SCR3054 // 07/02/09: v1.6: Updated to select sensitivity tables depending on value of isBright // {{double,double,double,double,double,double}[],{double,double,double,double,double,double}[]} procedure SpireSOF12Estimate { string resolution = "H" in ["H","M","L","H+L"]; double osit1 = 0.0; // set 1 on-source integration time double osit2 = 0.0; // set 2 on-source integration time double wavelength1 = -1.0; double wavelength2 = -1.0; double wavelength3 = -1.0; double wavelength4 = -1.0; double wavelength5 = -1.0; double wavelength6 = -1.0; double wavelength7 = -1.0; double wavelength8 = -1.0; double lineFlux1 = -1.0; double lineFlux2 = -1.0; double lineFlux3 = -1.0; double lineFlux4 = -1.0; double lineFlux5 = -1.0; double lineFlux6 = -1.0; double lineFlux7 = -1.0; double lineFlux8 = -1.0; bool isJyContinuum = true; double contFlux1 = -1.0; double contFlux2 = -1.0; double contFlux3 = -1.0; double contFlux4 = -1.0; double contFlux5 = -1.0; double contFlux6 = -1.0; double contFlux7 = -1.0; double contFlux8 = -1.0; bool isBright = false; string version = "v00"; bool debug = false; }{ SpireMsg(3," Calculating SOF noise estimates"); SpireMsg(3," $Id:$"); SpireMsg(3," Input:"); SpireMsg(3," Resolution:" + resolution); SpireMsg(3," osit1: " + osit1); SpireMsg(3," osit2: " + osit2); SpireMsg(3," Wavelength1: " + wavelength1); SpireMsg(3," Wavelength2: " + wavelength2); SpireMsg(3," Wavelength3: " + wavelength3); SpireMsg(3," Wavelength4: " + wavelength4); SpireMsg(3," Wavelength5: " + wavelength5); SpireMsg(3," Wavelength6: " + wavelength6); SpireMsg(3," Wavelength7: " + wavelength7); SpireMsg(3," Wavelength8: " + wavelength8); SpireMsg(3," Line 1 Flux density: " + lineFlux1); SpireMsg(3," Line 2 Flux density: " + lineFlux2); SpireMsg(3," Line 3 Flux density: " + lineFlux3); SpireMsg(3," Line 4 Flux density: " + lineFlux4); SpireMsg(3," Line 5 Flux density: " + lineFlux5); SpireMsg(3," Line 6 Flux density: " + lineFlux6); SpireMsg(3," Line 7 Flux density: " + lineFlux7); SpireMsg(3," Line 8 Flux density: " + lineFlux8); SpireMsg(3," Continuum 1 Flux density: " + contFlux1); SpireMsg(3," Continuum 2 Flux density: " + contFlux2); SpireMsg(3," Continuum 3 Flux density: " + contFlux3); SpireMsg(3," Continuum 4 Flux density: " + contFlux4); SpireMsg(3," Continuum 5 Flux density: " + contFlux5); SpireMsg(3," Continuum 6 Flux density: " + contFlux6); SpireMsg(3," Continuum 7 Flux density: " + contFlux7); SpireMsg(3," Continuum 8 Flux density: " + contFlux8); SpireMsg(3," Continuum in Jy: " + isJyContinuum); // double[] wave = []; // // calculate sensitivities // string tabName = "Spec_Sensitivities.txt"; if(isBright) { tabName = "Spec_BrightSensitivities.txt"; } double hLineSensitivity = 0.0; double hContSensitivity = 0.0; double hResPower = 0.0; double lContSensitivity = 0.0; double lResPower = 0.0; double hres = SpireProc_GetTableEntryDouble("SpireTable_Spectrometer.txt","ResChar","H","Resolution",version,debug); double mres = SpireProc_GetTableEntryDouble("SpireTable_Spectrometer.txt","ResChar","M","Resolution",version,debug); double lres = SpireProc_GetTableEntryDouble("SpireTable_Spectrometer.txt","ResChar","L","Resolution",version,debug); {double,double,double,double,double,double}[] sensitivities = []; // wave = [194.0,200.0,250.0,300.0,320.0,400.0,550.0,672.0]; SpireMsg(3," Output Sensitivities:"); SpireMsg(3," Wavelength HR Sensitivity HR Cont Sensitivity HR Res Pwr LR Cont Sensitivity LR Res Pwr"); for(int w1 = 0 .. length(wave) - 1) { hLineSensitivity = 0.0; hContSensitivity = 0.0; lContSensitivity = 0.0; hResPower = 0.0; lResPower = 0.0; if(resolution == "H" || resolution == "H+L") { hLineSensitivity = interpolate(tabName,"HLineUnc",wave[w1]) / sqrt(osit1); if(isJyContinuum) { hContSensitivity = interpolate(tabName,"HContUncJ",wave[w1]) / sqrt(osit1); } else { hContSensitivity = interpolate(tabName,"HContUncW",wave[w1]) / sqrt(osit1); } hResPower = 10000.0 / (wave[w1] * hres); } if(resolution == "M") { hLineSensitivity = interpolate(tabName,"MLineUnc",wave[w1]) / sqrt(osit1); if(isJyContinuum) { hContSensitivity = interpolate(tabName,"MContUncJ",wave[w1]) / sqrt(osit1); } else { hContSensitivity = interpolate(tabName,"MContUncW",wave[w1]) / sqrt(osit1); } hResPower = 10000.0 / (wave[w1] * mres); } if(resolution == "L") { if(isJyContinuum) { lContSensitivity = interpolate(tabName,"LContUncJ",wave[w1]) / sqrt(osit1); } else { lContSensitivity = interpolate(tabName,"LContUncW",wave[w1]) / sqrt(osit1); } lResPower = 10000.0 / (wave[w1] * lres); } if(resolution == "H+L") { if(isJyContinuum) { lContSensitivity = interpolate(tabName,"LContUncJ",wave[w1]) / sqrt(osit2); } else { lContSensitivity = interpolate(tabName,"LContUncW",wave[w1]) / sqrt(osit2); } lResPower = 10000.0 / (wave[w1] * lres); } sensitivities[w1] = {wave[w1],hLineSensitivity,hContSensitivity,hResPower,lContSensitivity,lResPower}; SpireMsg(3," " + wave[w1] + " " + hLineSensitivity + " " + hContSensitivity + " " + hResPower + " " + lContSensitivity + " " + lResPower); } // // calculate signal/noise estimates // double hLineSN = 0.0; double hContSN = 0.0; double lContSN = 0.0; {double,double,double,double,double,double}[] estimates = []; // wave = [wavelength1,wavelength2,wavelength3,wavelength4,wavelength5,wavelength6,wavelength7,wavelength8]; double[] lineFlux = [lineFlux1,lineFlux2,lineFlux3,lineFlux4,lineFlux5,lineFlux6,lineFlux7,lineFlux8]; double[] contFlux = [contFlux1,contFlux2,contFlux3,contFlux4,contFlux5,contFlux6,contFlux7,contFlux8]; // SpireMsg(3," Output Estimates:"); SpireMsg(3," Wavelength Line Flux High Res S/N on Line Continuum Flux High Res S/N on Continuum Low Res S/N on Continuum"); for(int w2 = 0 .. length(wave) - 1) { hLineSN = -1.0; hContSN = -1.0; lContSN = -1.0; if(wave[w2] > 0.0) { if(resolution == "H" || resolution == "H+L") { if(lineFlux[w2] >= 0.0) { hLineSN = lineFlux[w2] * sqrt(osit1) / interpolate(tabName,"HLineUnc",wave[w2]); if(hLineSN > 200.0) { hLineSN = 200.0; } } if(contFlux[w2] >= 0.0) { if(isJyContinuum) { hContSN = contFlux[w2] * sqrt(osit1) / interpolate(tabName,"HContUncJ",wave[w2]); } else { hContSN = contFlux[w2] * sqrt(osit1) / interpolate(tabName,"HContUncW",wave[w2]); } if(hContSN > 200.0) { hContSN = 200.0; } } } if(resolution == "M") { if(lineFlux[w2] >= 0.0) { hLineSN = lineFlux[w2] * sqrt(osit1) / interpolate(tabName,"MLineUnc",wave[w2]); if(hLineSN > 200.0) { hLineSN = 200.0; } } if(contFlux[w2] >= 0.0) { if(isJyContinuum) { hContSN = contFlux[w2] * sqrt(osit1) / interpolate(tabName,"MContUncJ",wave[w2]); } else { hContSN = contFlux[w2] * sqrt(osit1) / interpolate(tabName,"MContUncW",wave[w2]); } if(hContSN > 200.0) { hContSN = 200.0; } } } if(resolution == "L") { if(contFlux[w2] >= 0.0) { if(isJyContinuum) { lContSN = contFlux[w2] * sqrt(osit1) / interpolate(tabName,"LContUncJ",wave[w2]); } else { lContSN = contFlux[w2] * sqrt(osit1) / interpolate(tabName,"LContUncW",wave[w2]); } if(lContSN > 200.0) { lContSN = 200.0; } } } if(resolution == "H+L") { if(contFlux[w2] >= 0.0) { if(isJyContinuum) { lContSN = contFlux[w2] * sqrt(osit2) / interpolate(tabName,"LContUncJ",wave[w2]); } else { lContSN = contFlux[w2] * sqrt(osit2) / interpolate(tabName,"LContUncW",wave[w2]); } if(lContSN > 200.0) { lContSN = 200.0; } } } estimates[w2] = {wave[w2],lineFlux[w2],contFlux[w2],hLineSN,hContSN,lContSN}; SpireMsg(3," " + wave[w2] + " " + lineFlux[w2] + " " + hLineSN + " " + contFlux[w2] + " " + hContSN + " " + lContSN); } } // return {sensitivities,estimates}; } // SpireSetObsStep // // $id$ // // This building block sets the Observing Step parameter // procedure SpireSetObsStep { int step = 0; // step value }{ string hstr = ""; // hex string string tstr = ""; // time string // hstr = SpireHexStr(step,4); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP_RAW(" + hstr + ")"); Spire_SET_OBS_STEP_RAW(step); } // SpirePOF5Observing // // $Id: SpirePOF5Observing.txt,v 1.8 2007/04/20 12:29:27 kking Exp $ // // This is the procedure to calculate // instrument observing parameters for the Scan Map observing mode // // Note: // This procedure assumes that 2 seconds are required at the start of the scan to allow // setting of the BB and STEP. // It also assumes that 2 seconds are required at the end of the scan to // reset the STEP parameter // // 13/04/07: SCR3010 - changed default obsMode // {double,double,int,int,int,int} procedure SpirePOF5Observing { string obsMode = "POF5_S_N"; int nRepeats = 1; // requested number of map repeats double mapWidth = 0.0; // requested map width (arcmins) double mapHeight = 0.0; // requested map height (arcmin) }{ SpireMsg(2," Observing mode POF5 Observing Parameters "); SpireMsg(2," $Id: SpirePOF5Observing.txt,v 1.8 2007/04/20 12:29:27 kking Exp $"); // // fetch operating parameters double flashTime = double(ilookup("SpireParms.txt",obsMode,"FlashTime")); // Optimum time between flashes double calTime = double(ilookup("SpireParms.txt",obsMode,"CalTime")); // Minimum time between gyro calibrations string ib = slookup("OpsParms.txt",obsMode,"Boresight"); // instrument boresight double patt = dlookup("OpsParms.txt",obsMode,"Patt"); // direction of nod double d2 = dlookup("OpsParms.txt",obsMode,"D2"); // line separation double hLoss = dlookup("OpsParms.txt",obsMode,"HLoss"); // map height loss double lLoss = dlookup("OpsParms.txt",obsMode,"LLoss"); // map length loss double scanRate = dlookup("OpsParms.txt",obsMode,"ScanRate"); // line scan rate bool initFlash = blookup("SpireParms.txt",obsMode,"InitFlash"); // initial flash flag bool endFlash = blookup("SpireParms.txt",obsMode,"EndFlash"); // final flash flag // // ***************************************** // Display input parameters // ***************************************** SpireMsg(3," POF5 Observing Input values:"); SpireMsg(3," ..nRepeats: " + nRepeats); SpireMsg(3," ..mapWidth: " + mapWidth); SpireMsg(3," ..mapHeight: " + mapHeight); SpireMsg(3," POF5 Fixed values:"); SpireMsg(3," ..ib: " + ib); SpireMsg(3," ..patt: " + patt); SpireMsg(3," ..d2: " + d2); SpireMsg(3," ..hLoss: " + hLoss); SpireMsg(3," ..lLoss: " + lLoss); SpireMsg(3," ..scanRate: " + scanRate); SpireMsg(3," ..flashTime: " + flashTime); SpireMsg(3," ..calTime: " + calTime); SpireMsg(3," ..initFlash: " + initFlash); SpireMsg(3," ..endFlash: " + endFlash); // // calculate observing parameters SpireMsg(2," Calculated Parameters:"); // // number of lines in a map int nLines = iceil((mapHeight * 60.0 - hLoss) / d2) + 1; SpireMsg(3," Required number of scan lines in map: " + nLines); // // observing scanLength double scanLength = mapWidth * 60.0 + lLoss; // // integration time per line (covering user requested length) double lineOsit = scanLength / scanRate; SpireMsg(3," Integration time per scan line: " + lineOsit); // // increase scan length to allow time to start the scan int tStart = 2; int tEnd = 2; scanLength = scanLength + double(tStart + tEnd) * scanRate; SpireMsg(3," Required scan length: " + scanLength); // // time per line double lineTime = scanLength / scanRate; // // total observing time int d = duration(SpireBbScanLine(iceil(lineTime),0)); double totalTime = double(nRepeats) * double(nLines) * double(d); SpireMsg(3," Total observing time: " + totalTime); // // number of lines per Gyro calibration // Note: this only takes into account on source observing time, not movement between lines, // which is assumed to be a small fraction of the observing time, and so the value obtained is approximate int nCals = ifloor(totalTime / calTime); // SpireMsg(3," Number of Gyro Calibrations: " + nCals); int nCal = iceil(totalTime / lineTime); // default is no gyro calibrations during observation if(nCals > 0) { nCal = iceil(double(nLines) * double(nRepeats) / double(nCals + 1)); } if(nLines % nCal == 0) { nCal = nCal + 1; } // SpireMsg(3," Number of Gyro Calibrations(adjusted): " + nCals); // SpireMsg(3," Number of nod lines per Gyro calibration: " + nCal); // // number of lines per PCAL calibration // Note: this only takes into account on source observing time, not movement between lines, // which is assumed to be a small fraction of the observing time, and so the value obtained is approximate int nFlashes = ifloor(totalTime / flashTime); SpireMsg(3," Number of Flashes: " + nFlashes); int nFlash = iceil(totalTime / lineTime); // default is no flashes during observation if(nFlashes > 0) { nFlash = iceil(double(nLines) * double(nRepeats) / double(nFlashes + 1)); } if(nLines % nFlash == 0) { nFlash = nFlash + 1; } SpireMsg(3," Number of Flashes(adjusted): " + nFlashes); SpireMsg(3," Number of nod lines per PCAL calibration: " + nFlash); return {lineOsit * double(nLines),scanLength,nRepeats,nLines,nCal,nFlash}; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireSpectro_Cal_StdLoadCurve.txt // /////////////////////////////////////////////////////////////////////////// // // CUS script for: 'Spec Standard Load Curve' // // in *basic_fine_pointing* or *no_pointing* mode // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/08/15 V0.1: Initial version adapted from // SpirePhoto_Cal_StdLoadCurve (2008/07/21 V0.4) // based on // Mode_ILT_PERF_DAB_S_Levels.txt (v 1.3 2008/01/31 23:35:17) // 2008/11/11 V0.2: Allow 'no pointing' as input option; Adapt debug printing // 2008/11/12 V0.3: Implement mode setting; Add isBright // Change 'no pointing' implementation // 2009/02/19 V0.4: Add debug_print as input and pass it to low level // scripts. Use new SpireBb_EndObsAll and SpireBb_StartObsAll. // Read nominal bias frequency and bias divider from new // SpireTable_SpecModeParms. Implemented message // if activating isBright setting. Implemented setting // of datarates. Bias levels used for the load curve are // now calculated in SpireProc_CalcParam_LoadCurve. // Use SpireBb_SpecSetMode to set to SPECSTBY during // SLEW and FINAL_HOLD. Read boresight from // SpireTable_OpsParms. Remove cal. table name from input. // Replace call to SpireBb_SpecFSetupData with call to // SpireBb_SpecFSetPhase and SpireBb_SpecFSetBiasAmpl to // set user requested frequency, phase, and first BiasAmpl. // 2009/03/04 V0.5: Add isSerendipity, isPcal, and 8 more dummy parameters // to the script for future use. Replace 'message' by // 'error' if isBright is selected. // 2009/05/06 V0.6: Add in move BSM/SMEC to hold/home at start. Add new // SpireBb_SmecHold to account for the fact that // SpireBb_SmecMove2Home does not stop SMEC. // Gather procedures at start and end in separate BB. // /////////////////////////////////////////////////////////////////////////// // // Script assumes that: // // 1) Instrument is in SPECSTBY at beginning // (i.e. bias amplitude, phase, frequency [mclkdiv,biasdiv] are nominal) // // 2) Phase is kept constant (from input) during this test, i.e no // adjustment of the phase with changing bias amplitude and frequency // // 3) Bias frequency and sampling rate are input parameters // // 4) Boresight of array can be read from following cal table: // SpireTable_OpsParms.txt // /////////////////////////////////////////////////////////////////////////// // obs SpireSpectro_Cal_StdLoadCurve { /* ****************************************************** */ /* USER PARAMETER DEFINITION, CUS SIGNATURE for EX-HSpot */ /* ****************************************************** */ /* */ double ra = 0.0 in [0.0,360.0]; // RA of target double dec = 0.0 in [-90.0,90.0]; // DEC of target int naifid = 0; // NAIF identifier bool isBright = false; // Use settings for bright source (==tick) bool pointing = true; // Should telescope 'point' (==tick) or do a 'no pointing' (==untick)? /* */ double biasfreq = 160.1 in [80.0,240.0]; // Bias frequency [Hz] double samplerate = 80.0 in [1.0,80.5]; // Sampling rate [Hz] (Careful, don't exceed number of data packages to be transferred from spacecraft!) double phasedeg_ssw = 184.9 in [0.0,360.0]; // SSW Bias phase [deg] double phasedeg_slw = 190.6 in [0.0,360.0]; // SLW Bias phase [deg] int ftime = 10; // Readout time at each bias level [s] string version01 = "v00"; // Version in cal table SpireTable_SpecModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams string version03 = "v00"; // Version in cal table SpireTable_StdLoadCurveLevels string version05 = "v00"; // Version in cal table SpireTable_OpsParms.txt bool debug = false; // Allow (==tick) or suppress cus debug_print statements bool isSerendipity = true; // Allow (==tick) serendipity mode to be activated or prohibit (==untick) it (currently not in use)? bool isPcal = true; // Allow (==tick) regular PcalFlash in script or prohibit (==untick) it (currently not in use)?. bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ // // // // // Check for is bright setting: // if(isBright) { isBright = false; error("IsBright does not make sense here. Try again (e.g. subtract the phase shift manually from the input)!"); } // // // // // Declare some variable: // // Photometer or FTS: bool phot = false; bool fts = !phot; // string tabName = ""; string selCol = ""; string selVal = ""; string tarCol = ""; string version = ""; double scirate = 0.0; double chkrate = 0.0; double nhkrate = 0.0; // int obsStep = 0; // // Hardcoded calibration tables: // string tabName01 = "SpireTable_SpecModeParams.txt"; string tabName02 = "SpireTable_CommonModeParams.txt"; string tabName03 = "SpireTable_StdLoadCurveLevels.txt"; string tabName04 = "SpireTable_BsmNominalSettings.txt"; string tabName05 = "SpireTable_OpsParms.txt"; string tabName06 = "SpireTable_SmecNominalSettings.txt"; // Currently hardcoded version and model parameter: // string version06 = "v00"; // Version in cal table SpireTable_SmecNominalSettings string version04 = "v00"; // Version in cal table SpireTable_BsmNominalSettings string model = "initial"; // Model in cal table SpireTable_BsmNominalSettings // // Dummy value for Phot script: // (needed but not used in spec script!) // int psw_bias = 62; // int pmw_bias = 62; // int plw_bias = 62; // int ptc_bias = 62; // int psw_phase = 127; // int pmw_phase = 127; // int plw_phase = 127; // int ptc_phase = 127; // // // // Currently hardcoded parameter: // Is (==tick) the DCU currently sampled? bool dcuData = false; // // // // // Setup mode: // // Set obsMode for QLA: string obsModeQla = "ENG_CAL_OBS41"; // Note: this needs entry in MIB table and in SpireTableInstConfigs.txt // // Set obsMode for datarates: string obsMode = "SEngCalObs"; // Note: this is currently only a maximum value // // // // // Retrieve bias levels used for the load curve: // tabName = tabName03; version = version03; int[] nbiaslist = SpireProc_CalcParam_LoadCurve(tabName,version,debug); // // Lookup first bias level: int ssw_bias = nbiaslist[0]; int slw_bias = nbiaslist[0]; // // // // // Convert user input to Hex values: // // for bias frequency and sample rate: // int[] hexvalues = SpireProc_CalcParam_BiasFreqSampFreq(biasfreq,samplerate,fts,debug); int mclkdiv = hexvalues[0]; int biasdiv = hexvalues[1]; if(debug) { debug_print("Hex values of mclkdiv/biasdiv are: " + mclkdiv + " " + biasdiv); } // // for bias phase: // int[] phasehex = SpireProc_CalcParam_SpecPhaseConvert(phasedeg_ssw,phasedeg_slw,debug); int ssw_phase = phasehex[0]; int slw_phase = phasehex[1]; // // // // // Read BSM home parameters: // // Select version flag and set GetTableEntry parameters: // version = version04; tabName = tabName04; selCol = "model"; // Name of column for selecting selVal = model; // Value of 'string' selector // // Read hold position from calibration table: // tarCol = "chop_0_I"; int hold_chop = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "jigg_0_I"; int hold_jigg = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // // // // Read SMEC home position from calibration file: // tarCol = "Home"; tabName = tabName06; selVal = version06; int smecHomePosn = ilookup(tabName,selVal,tarCol); // // ****************************************************** */ // CALCULATE DURATIONS for POINTING STATES */ // ****************************************************** */ // // // // // Calculate timing for the pointing request: // // BBs called during slew: int tslewmin = duration(SpireBb_StartStdLoadCurve(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,mclkdiv,biasdiv,psw_bias,pmw_bias,plw_bias,ptc_bias,psw_phase,pmw_phase,plw_phase,ptc_phase,ssw_bias,slw_bias,ssw_phase,slw_phase,debug)); // // BBs carried out when the pointing is reached: if(pointing) { int tinithold = 0; } else { tinithold = tslewmin; } // // BB carried out during pointing: int tp = duration(SpireProc_Exec_SpecStdLoadCurve(nbiaslist,ftime,dcuData,debug)); // // BB carried out at the end: int tfinalhold = duration(SpireBb_EndStdLoadCurve(phot,isBright,version01,version02,debug)); // if(debug) { debug_print("tslewmin = " + tslewmin); debug_print("tinithold = " + tinithold); debug_print("tpointing = " + tp); debug_print("tfinalhold = " + tfinalhold); } // // ****************************************************** */ // POINTING MODE DECLARATION */ // ****************************************************** */ // // // // // Lookup boresight: // tabName = tabName05; selCol = "mode"; selVal = obsMode; tarCol = "Boresight"; version = version05; string ib = SpireProc_GetTableEntryString(tabName,selCol,selVal,tarCol,version,debug); // // Set pointing mode: // if(pointing) { int[] ts = basic_fine_pointing(true,tslewmin,tinithold,tfinalhold,ib,naifid,ra,dec,0.0,0.0,tp); } else { ts = no_pointing(true,tinithold,tfinalhold,tp); } // if(debug) { debug_print("Output timing vector from the pointing request: " + ts); } // }{ // ****************************************************** */ // POINTING STATES WITH OBSERVING MODE LOGIC */ // ****************************************************** */ // // // // // Set datarates: // string rateType = "chk"; chkrate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); ess_hk_data_rate(chkrate); // rateType = "nhk"; // nhkrate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); non_ess_hk_data_rate(nhkrate); // rateType = "sci"; scirate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); data_rate(scirate); // if(debug) { debug_print("Set CHK datarate to: " + chkrate); debug_print("Set NHK datarate to: " + nhkrate); debug_print("Set SCI datarate to: " + scirate); } // // Start the state_machine: // int[] state = [0]; // while(state[0] >= 0) { if(debug) { debug_print("Current state: " + state); } state = next_state(); if(debug) { debug_print("Next state: " + state); } // if(state[0] == 1) { // STATE = SLEW ( Spacecraft is slewing ) // // // // // Startup observation: // SpireBb_StartStdLoadCurve(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,mclkdiv,biasdiv,psw_bias,pmw_bias,plw_bias,ptc_bias,psw_phase,pmw_phase,plw_phase,ptc_phase,ssw_bias,slw_bias,ssw_phase,slw_phase,debug); // //delay(timeSlewCal); } if(state[0] == 2) { // STATE = INIT_HOLD ( spacecraft is idling at source ) // // // // // // If no pointing observation do stuff here which is // done nominally during SLEW: // if(!pointing) { // // // // // Startup observation: // SpireBb_StartStdLoadCurve(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,mclkdiv,biasdiv,psw_bias,pmw_bias,plw_bias,ptc_bias,psw_phase,pmw_phase,plw_phase,ptc_phase,ssw_bias,slw_bias,ssw_phase,slw_phase,debug); // } // //delay(tinithold); // } if(state[0] == 3) { // STATE = POINT ( spacecraft is at nominal RA,DEC (staring, raster) ) // // // // // // Execute load curve: // SpireProc_Exec_SpecStdLoadCurve(nbiaslist,ftime,dcuData,debug); // //delay(tp); // } if(state[0] == 5) { // STATE = FINAL_HOLD ( "sky" observation ends, performing final activ.) // // // // // Set scientific datarate back to zero: // data_rate(0.0); // // // // // Reconfigure at the end (incl. resetting of OBSID and BBIB): // SpireBb_EndStdLoadCurve(phot,isBright,version01,version02,debug); // } if(state[0] == -1) { // STATE = END ( end of the pointing/commanding part of the code ) // } } } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpirePhoto_Cal_IltPcalFlash.txt // /////////////////////////////////////////////////////////////////////////// // // CUS script for: 'Phot ILT PCAL Flash' // // in *basic_fine_pointing* or *no_pointing* mode // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/05/05 V0.1: Initial version adapted from // Mode_ILT_PERF_DAB_P_CPS.txt (v1.3 2008/01/31 23:35:17) // 2008/06/09 V0.2: Changed name to be conform with new naming convention // 2008/07/21 V0.3: Allow nafid as input parameter // 2008/08/12 V0.4: Remove test number; change name of low level script in // description; Remove calculation of ILT flash parameters // and use new Exec script with fixed ILT parameters // 2008/08/15 V0.5: Adapt new input to improved Exec script which properly // allows to recover the erroneous calculated parameters // during ILT; allow detector settings as input; Adapt to // change in call to low level script // SpireProc_CalcParam_BiasFreqSampFreq.txt // 2008/11/11 V0.6: Allow 'no pointing' as input option; Adapt debug printing // 2008/11/12 V0.7: Implement mode setting; Add isBright // Change 'no pointing' implementation // 2009/02/02 V1.0: Add debug_print as input and pass it to some low // level scripts. Add setting of NHK STEP parameter // in SpireProc_Exec_IltPcalFlash and unset at end. // Use new SpireBb_EndObsAll and SpireBb_StartObsAll. // Read nominal bias frequency and bias divider from new // SpireTable_DetectorSettings.txt. Implemented setting // of datarates. Replace SpireProc_Set_PhotNominal by // SpireProc_Set_FreqSampAmpPhasNominal. Implemented message // if activating isBright setting. // 2009/02/17 V1.1: Remove cal table name from input and hardcode. Replace call // to SpireBb_PhotFSetupData by call to SpireBb_DcuSetFreqSamp // SpireBb_PhotFSetPhase and SpireBb_PhotFSetBiasAmpl. // New setting of datarates. Use SpireBb_PhotSetMode to set // to PHOTSTBY during SLEW and FINAL_HOLD. Unset isBright // if set. Read boresight from SpireTable_OpsParms. // 2009/02/18 V1.2: Adapt to change in call to SpireProc_Exec_IltPcalFlash // 2009/02/19 V1.3: Elevate version05 to input. Update call to // SpireProc_Exec_IltPcalFlash to allow for proper setting // of FTS ILT Pcal highbias levels (bug detected at SDAG#19). // 2009/03/04 V1.4: Add isSerendipity, isPcal, and 8 more dummy parameters // to the script for future use. Change isBright behaviour. // Use maxbias for amplitude and subtract isBright phase // shift read from calibration file from the user input phase. // 2009/05/06 V1.5: Add in move BSM to hold at start. Gather procedures at // start and end in separate BB. // 2009/05/26 V1.6: Change default input phases from 180.7 (all) to the values // given in SCR 1441. // 2009/06/05 V1.7: Hardcode STBY 'v00' in EndBB (SPR-1477). Changed peak2peak // in input description with correct zero2peak. // // Caveat: isBright bias amplitude is hardcoded in script! // /////////////////////////////////////////////////////////////////////////// // Script assumes that: // // 1) Instrument is in PHOTSTBY // (i.e. bias amplitude, phase, frequency [mclkdiv,biasdiv] are nominal) // // 2) Boresight of array can be read from following cal table: // SpireTable_OpsParms.txt // // 3) Phase shift for isBright setting can be read from following // cal table: SpireTable_IsBrightPhaseShift.txt // // 4) Needs additional procedure SpireProc_Exec_IltPcalFlash.txt and // SpireProc_CalcParam_IltPcalFlash to execute ILT PCAL flash. // /////////////////////////////////////////////////////////////////////////// // obs SpirePhoto_Cal_IltPcalFlash { /* ****************************************************** */ /* USER PARAMETER DEFINITION, CUS SIGNATURE for EX-HSpot */ /* ****************************************************** */ /* */ double ra = 0.0 in [0.0,360.0]; // RA of target double dec = 0.0 in [-90.0,90.0]; // DEC of target int naifid = 0; // NAIF identifier bool isBright = false; // Use settings for bright source (==tick) bool pointing = true; // Should telescope 'point' (==tick) or do a 'no pointing' (==untick)? /* */ double biasfreq = 130.2 in [70.0,200.0]; // Bias frequency [Hz] double samplerate = 18.6 in [1.0,20.0]; // Sampling rate [Hz] (Careful, don't exceed number of data packages to be transferred from spacecraft!) double biasmV_psw = 31.2 in [0.0,127.813]; // PSW Bias amplitude (zero2peak) [mV] double biasmV_pmw = 31.2 in [0.0,128.625]; // PMW Bias amplitude (zero2peak) [mV] double biasmV_plw = 31.2 in [0.0,129.159]; // PLW Bias amplitude (zero2peak) [mV] double biasmV_ptc = 127.6 in [0.0,254.265]; // PTC Bias amplitude (zero2peak) [mV] double phasedeg_psw = 179.29 in [0.0,360.0]; // PSW Bias phase [deg] double phasedeg_pmw = 179.29 in [0.0,360.0]; // PMW Bias phase [deg] double phasedeg_plw = 182.11 in [0.0,360.0]; // PLW Bias phase [deg] double phasedeg_ptc = 208.0 in [0.0,360.0]; // PTC Bias phase [deg] string version01 = "v00"; // Version in cal table SpireTable_PhotModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams string version05 = "v00"; // Version in cal table SpireTable_OpsParms string version06 = "v00"; // Version in cal table SpireTable_IsBrightPhaseShift bool debug = false; // Allow (==tick) or suppress cus debug_print statements bool isSerendipity = true; // Allow (==tick) serendipity mode to be activated or prohibit (==untick) it (currently not in use)? bool isPcal = true; // Allow (==tick) regular PcalFlash in script or prohibit (==untick) it (currently not in use)?. bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ // // // // // Check for is bright setting: // if(isBright) { message("IsBright selected! PxW bia amplitude is set to 255 and isBright phase-shift is subtracted."); } // // // // // Declare some variable: // // Photometer or FTS: bool phot = true; bool fts = !phot; // string tabName = ""; string selCol = ""; string tarCol = ""; string selVal = ""; string version = ""; double scirate = 0.0; double chkrate = 0.0; double nhkrate = 0.0; // // Hardcoded calibration tables: // string tabName01 = "SpireTable_PhotModeParams.txt"; string tabName02 = "SpireTable_CommonModeParams.txt"; string tabName03 = "SpireTable_BsmNominalSettings.txt"; string tabName05 = "SpireTable_OpsParms.txt"; string tabName06 = "SpireTable_IsBrightPhaseShift.txt"; // // Currently hardcoded version and model parameter: // string version03 = "v00"; // Version in cal table SpireTable_BsmNominalSettings string model = "initial"; // Model in cal table SpireTable_BsmNominalSettings // // Dummy value for Spec script: // (needed but not used in phot script!) // int smecHomePosn = 3500; // SMEC home position int bias_ssw = 45; // int bias_slw = 45; // int phase_ssw = 128; // int phase_slw = 128; // // // // // // Setup mode: // // Set obsMode for QLA: string obsModeQla = "ENG_CAL_OBS07"; // Note: this needs entry in MIB table and in SpireTableInstConfigs.txt // // Set obsMode for datarates: string obsMode = "PEngCalObs"; // Note: this is currently only a maximum value // // // // // Read isBright phase shift from calibration table: // int photPhaseShift = ilookup(tabName06,version06,"photPhaseShift"); // // // // // Convert user input to Hex values: // // for bias frequency and sample rate: // int[] hexvalues = SpireProc_CalcParam_BiasFreqSampFreq(biasfreq,samplerate,fts,debug); int mclkdiv = hexvalues[0]; int biasdiv = hexvalues[1]; if(debug) { debug_print("Hex values of mclkdiv/biasdiv are: " + mclkdiv + " " + biasdiv); } // // for bias phase: // int[] phasehex = SpireProc_CalcParam_PhotPhaseConvert(phasedeg_psw,phasedeg_pmw,phasedeg_plw,phasedeg_ptc,debug); int phase_psw = phasehex[0]; int phase_pmw = phasehex[1]; int phase_plw = phasehex[2]; if(isBright) { phase_psw = SpireProc_CalcParam_IsBrightPhaseShift(phase_psw,photPhaseShift,debug); phase_pmw = SpireProc_CalcParam_IsBrightPhaseShift(phase_pmw,photPhaseShift,debug); phase_plw = SpireProc_CalcParam_IsBrightPhaseShift(phase_plw,photPhaseShift,debug); } int phase_ptc = phasehex[3]; // // for bias amplitude: // int[] biashex = SpireProc_CalcParam_PhotBiasConvert(biasmV_psw,biasmV_pmw,biasmV_plw,biasmV_ptc,debug); int bias_psw = biashex[0]; int bias_pmw = biashex[1]; int bias_plw = biashex[2]; if(isBright) { bias_psw = 255; bias_pmw = 255; bias_plw = 255; } int bias_ptc = biashex[3]; // // // // // Set PCAL Flash values to the once fixed used during ILT: // //PCAL Flash FULL period (high and low bias) [microsec]: int period = 4000000; // // DCU data mode (0 == PF; 4 == SF): int ndcumode = 0; // // // // // Read BSM home parameters: // // Select version flag and set GetTableEntry parameters: // version = version03; tabName = tabName03; selCol = "model"; // Name of column for selecting selVal = model; // Value of 'string' selector // // Read hold position from calibration table: // tarCol = "chop_0_I"; int hold_chop = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "jigg_0_I"; int hold_jigg = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // ****************************************************** */ // CALCULATE DURATIONS for POINTING STATES */ // ****************************************************** */ // // // // // Calculate timing for the pointing request: // // BBs called during slew: // int tslewmin = duration(SpireBb_StartIltPcalFlash(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,mclkdiv,biasdiv,bias_psw,bias_pmw,bias_plw,bias_ptc,phase_psw,phase_pmw,phase_plw,phase_ptc,bias_ssw,bias_slw,phase_ssw,phase_slw,debug)); // // BBs carried out when the pointing is reached: // if(pointing) { int tinithold = duration(SpireBb_PhotOffsetAuto(debug)); } else { tinithold = duration(SpireBb_PhotOffsetAuto(debug)) + tslewmin; } // // BB carried out during pointing: // int tp = duration(SpireProc_Exec_IltPcalFlash(period,mclkdiv,biasdiv,ndcumode,phot,debug)); // // BB carried out at the end: // int tfinalhold = duration(SpireBb_EndIltPcalFlash(phot,isBright,version01,version02,debug)); // // Debug printing: // if(debug) { debug_print("tslewmin = " + tslewmin); debug_print("tinithold = " + tinithold); debug_print("tpointing = " + tp); debug_print("tfinalhold = " + tfinalhold); } // // ****************************************************** */ // POINTING MODE DECLARATION */ // ****************************************************** */ // // Lookup boresight: tabName = tabName05; selCol = "mode"; selVal = obsMode; tarCol = "Boresight"; version = version05; string ib = SpireProc_GetTableEntryString(tabName,selCol,selVal,tarCol,version,debug); // // Set pointing mode: // if(pointing) { int[] ts = basic_fine_pointing(true,tslewmin,tinithold,tfinalhold,ib,naifid,ra,dec,0.0,0.0,tp); } else { ts = no_pointing(true,tinithold,tfinalhold,tp); } // if(debug) { debug_print("Output timing vector from the pointing request: " + ts); } // }{ // ****************************************************** */ // POINTING STATES WITH OBSERVING MODE LOGIC */ // ****************************************************** */ // // // // // Set datarates: // string rateType = "chk"; chkrate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); ess_hk_data_rate(chkrate); // rateType = "nhk"; // nhkrate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); non_ess_hk_data_rate(nhkrate); // rateType = "sci"; scirate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); data_rate(scirate); // if(debug) { debug_print("Set CHK datarate to: " + chkrate); debug_print("Set NHK datarate to: " + nhkrate); debug_print("Set SCI datarate to: " + scirate); } // // Start the state_machine: // int[] state = [0]; // while(state[0] >= 0) { if(debug) { debug_print("Current state: " + state); } state = next_state(); if(debug) { debug_print("Next state: " + state); } // if(state[0] == 1) { // STATE = SLEW ( Spacecraft is slewing ) // // // // // Startup observation: // SpireBb_StartIltPcalFlash(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,mclkdiv,biasdiv,bias_psw,bias_pmw,bias_plw,bias_ptc,phase_psw,phase_pmw,phase_plw,phase_ptc,bias_ssw,bias_slw,phase_ssw,phase_slw,debug); // //delay(timeSlewCal); } if(state[0] == 2) { // STATE = INIT_HOLD ( spacecraft is idling at source ) // // // // // // If no pointing observation do stuff here which is // done nominally during SLEW: // if(!pointing) { // // // // // Startup observation: // SpireBb_StartIltPcalFlash(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,mclkdiv,biasdiv,bias_psw,bias_pmw,bias_plw,bias_ptc,phase_psw,phase_pmw,phase_plw,phase_ptc,bias_ssw,bias_slw,phase_ssw,phase_slw,debug); // } // // // // // Set offsets: // SpireBb_PhotOffsetAuto(debug); // //delay(tinithold); } if(state[0] == 3) { // STATE = POINT ( spacecraft is at nominal RA,DEC (staring, raster) ) // //delay(tp); // // // // // Execute ILT PCAL flashes: // SpireProc_Exec_IltPcalFlash(period,mclkdiv,biasdiv,ndcumode,phot,debug); // } if(state[0] == 5) { // STATE = FINAL_HOLD ( "sky" observation ends, performing final activities ) // // // // // Set scientific datarate back to zero: // data_rate(0.0); // // // // // Reconfigure at the end (incl. resetting of OBSID and BBIB): // // Hardcode STBY values for resetting (SPR-1477): // version01 = "v00"; version02 = "v00"; // SpireBb_EndIltPcalFlash(phot,isBright,version01,version02,debug); // } if(state[0] == -1) { // STATE = END ( end of the pointing/commanding part of the code ) // } } } // CVS comments : $Id: WriteEndID.txt,v 1.9 2007/08/22 10:21:52 dcesarsk Exp $ // Purpose : Set the BBID and OBSID to the predefined values shown // in FIRST-FSC-DOC-0200 // // CUS script : Diego A. Cesarsky (diego.cesarsky@mpe.mpg.de) // Original TCL : N/A // CVS file : WriteEndID.txt // // Input arguments // Type Name DefVal Description // // Description : Equivalent of WriteOBSID and WriteBBID but using preset // values for $OBSID and $BBID // // Dependencies : Pacs_DMC_SET_BBID and Pacs_DMC_SET_OBSID // // Comments : // // Version : 0.1 12-Oct-2004 First creation // History : 0.2 21-Oct-2004 Added write to CDMS // 1.0 24-Mar-2005 DAC Removed all writes except to DMC (ASTRIUM environment) // 1.1 20-oct-2005 BBID and then OBSID; do not sync() before leaving as this // is the last TC ever. // 1.2 19-apr-2006 Do sync so duration() will give time for next TC // 1.2.1 22-nov-2006 Removed debug_print // 2.0 21-aug-2007 According to HERSCHEL SCIENCE GROUND SEGMENT // TO INSTRUMENTS INTERFACE CONTROL DOCUMENT // r�ference FIRST-FSC-DOC-0200; OBSID should be set // to zero when no observing (in OBS phase) // Removed write to BBID as all blocks now end by setting // their BBIDs to the default value (SCR-3507) // procedure WriteEndID { }{ // int iBBID = 0x40000000; // // Write BBID to DEC/MEC // Pacs_DMC_SET_BBID(iBBID); int iOBSID = 0x0; // Write OBSID to DEC/MEC Pacs_DMC_SET_OBSID(iOBSID); sync(); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_StartBsmAngleCal.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to configure at the start of // SpirePhoto/Spectro_Cal_BsmAngleCal. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // // 2009/05/05 V0.1: Initial version adapted from // SpireBb_EndBsmAngleCal (2009/02/14 V1.1) and // SpirePhoto_Cal_BsmAngleCal (2009/04/01 V1.6) // BB includes now to move BSM to hold. // 2009/07/12 V0.2: Fix bug in passing of SMEC home position (SPR-SPIRE-1612) // Set SMEC framerate to zero to get all BSM samples // (SPR-SPIRE-1551). // // Notes: // 1) Scripts assumes that SpireBb_SpecOffsetAuto is run // during INITHOLD or at first POINTING. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_StartBsmAngleCal SPIRE 14041 { bool phot = true; // Photometer (==tick) or FTS (==untick)? string obsModeQla = "ENG_CAL_OBS01"; string obsMode = "PEngCalObs"; bool isBright = false; // Use settings for bright source (==tick) string version01 = "v00"; // Version in cal table SpireTable_Phot/SpecModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams int hold_chop = 37632; // Chop hold position int hold_jigg = 39520; // Jiggle hold position double framerate = 125.0; // Specifies the MCU framerate [Hz] int smecHomePosn = 3500; // SMEC home position bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // int mode_id = 0; string obsmode = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB StartBsmAngleCal configuration started"); SpireMsg(2," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Startup observation: // SpireProc_Set_StartObsAll(obsModeQla); // // // // // In case move SMEC to home: // if(!phot) { // // Calculate available time for possible movement: // int tmove = duration(SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug)) + duration(SpireProc_Set_SpecMode(obsMode,isBright,version01,version02,debug)) + duration(SpireProc_Set_BsmFramerate(19,debug)) + duration(SpireBb_SpecOffsetAuto(false,debug)); // // Calculate max offset for which time is available: // int smecMaxOff = tmove * 500; // Note, 500 is maximum possible SMEC speed. int smecStart = smecHomePosn + smecMaxOff; // Note, formula above only reasonable // when smecHomePosn small compared to 39500 // Safety check: if(smecStart > 39500) { smecStart = 39500; } if(debug) { debug_print("smecStart: " + smecStart); debug_print("smecHomePosn: " + smecHomePosn); debug_print("tmove: " + tmove); } // // Move from maximal offset to home: // SpireProc_SmecMove2Home(smecHomePosn,smecHomePosn + smecMaxOff,debug); } // // // // // Move BSM back to hold: // SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug); // // // // // Initialise instrument (in case to isBright): // if(phot) { SpireProc_Set_PhotMode(obsMode,isBright,version01,version02,debug); } else { SpireProc_Set_SpecMode(obsMode,isBright,version01,version02,debug); } //delay(timeSlewCal); // // // // // Set user requested framerate: // int frate = SpireProc_CalcParam_BsmFramerate(framerate,debug); SpireProc_Set_BsmFramerate(frate,debug); // // // // // Set SMEC framerate (== SMEC sampling rate) to zero: // if(!phot) { SpireProc_Set_SmecFramerate(0,debug); } // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB StartBsmAngleCal configuration ended"); SpireMsg(1," ..StartBsmAngleCal took " + (time() - t) + " seconds)"); // } // SpireREDYtoPHOT_STBY // // $id$ // // This procedure configures the instrument into the PHOT_STBY mode // // The instrument should be in the REDY mode before execution of this observation // // // 08/11/2007 KJK: removed StartObs and EndObs building blocks from the engineering procedure // 27/04/2009 KJK: bsmModel, bsmVersion and debug passed as parameters // 09/06/2009 KJK: added parameter and commands to switch on PTC PID, if required // 02/07/2009 MP: Added report of tables and memory checksums (SPIRE-SCR-1527) // 12/07/2009 MP: Changed default stabilisationTime (SCR-SPIRE-1632) // procedure SpireREDYtoPHOT_STBY { int jfet_heater_V = 0; // Default jfet heater voltage at switch on string ptc = "Default" in ["Default","On","Off"]; // PTC status int ptcHold = 0; // time to wait for detectors to settle before starting PTC int stabilisationTime = 120; // time (secs) to allow Detectors to stabilise before starting observations bool sampleDetectors = false; // sample detectors during the stabilisation periods string bsmModel = "initial"; string bsmVersion = "v00"; string detVersion = "v00"; string vssVersion = "v00"; string ptcVersion = "v00"; bool debug = false; }{ // set nominal housekeeping rate SpireBbSetNhkSampling("PHTSTBY","v00",debug); // // // // // Report tables and do memory checksums: // SpireBb_RepTabAndMemChecksum(); // // // ----------- // configure BSM // ----------- // // switch on BSM mois_comment("Procedure SPIRE_BSM_ON: to switch on the SPIRE BSM"); mois_spacon("Select the TM Display for FUNCTIONAL TEST PARAMETERS"); mois_tmcheck("Check that parameter CHOPSENSPWR is set to 0"); mois_tmcheck("Check that parameter JIGGSENSPWR is set to 0"); SpireBbBsmOn("PHTSTBY",bsmModel,bsmVersion,debug); mois_comment("SPIRE SPIRE_BSM_ON Procedure Completed"); mois_tmcheck("Check that parameter CHOPSENSPWR is set to 1"); mois_tmcheck("Check that parameter JIGGSENSPWR is set to 1"); mois_tmcheck("Check that parameter MODE is set to BSM_ON"); // // initialise BSM mois_comment("Procedure SPIRE_BSM_INIT: to initialise the SPIRE BSM"); mois_spacon("Select the TM Display for FUNCTIONAL TEST PARAMETERS"); mois_spacon("Ensure that SPIRE_BSM_ON procedure has been run before continuing"); mois_tmcheck("Ensure that parameter MODE is set to BSM_ON"); SpireBbBsmChopInit("PHTSTBY",bsmModel,bsmVersion,debug); SpireBbBsmJiggInit("PHTSTBY",bsmModel,bsmVersion,debug); // Setup BSM sampling SpireBbSetBsmSampling("PHTSTBY",bsmVersion,debug); mois_comment("SPIRE SPIRE_BSM_INIT Procedure Completed"); mois_tmcheck("Check that parameter MODE is set to BSM_INIT"); // // ---------------- // configure Detectors // ---------------- // mois_comment("Procedure SPIRE_PDET_ON: to switch on the SPIRE Photometer"); mois_spacon("Select the TM Display for FUNCTIONAL TEST PARAMETERS"); mois_tmcheck("Ensure that parameter MODE is set to BSM_INIT"); mois_tmcheck("Ensure PLIABITSTAT is set to 0"); mois_tmcheck("Ensure PSWJFETSTAT is set to 0"); mois_tmcheck("Ensure PMLWJFETSTAT is set to 0"); mois_tmcheck("Ensure parameters PSWJFET1V to PSWJFET6V are all set to 0"); mois_tmcheck("Ensure parameters PMWJFET1V to PSWJFET4V are all set to 0"); mois_tmcheck("Ensure parameters PLWJFET1V to PSWJFET2V are all set to 0"); mois_spacon("Select the TM Display for SFT PARAMETERS"); mois_tmcheck("PLIAP5V, PLIAP9V and PLIAM9V should all be set to 0"); SpireBbPdetOn(jfet_heater_V,detVersion,vssVersion,debug); mois_comment("SPIRE SPIRE_PDET_ON Procedure Completed"); mois_tmcheck("Ensure PLIABITSTAT is set to 1"); mois_tmcheck("PLIAP5V should be ~5V"); mois_tmcheck("PLIAP9V should be ~11.5V"); mois_tmcheck("PLIAM9V should be ~-11.5V"); mois_spacon("Select the TM Display for FUNCTIONAL TEST PARAMETERS"); mois_tmcheck("Ensure PSWJFETSTAT is set to 0x3F"); mois_tmcheck("Ensure PMLWJFETSTAT is set to 0x7F"); mois_tmcheck("Ensure parameters PSWJFET1V to PSWJFET6V are all < 0 - nominally within ~ -1V and -3V"); mois_tmcheck("Ensure parameters PMWJFET1V to PSWJFET4V are all < 0 - nominally within ~ -1V and -3V"); mois_tmcheck("Ensure parameters PLWJFET1V & PSWJFET2V are all < 0 - nominally within ~ -1V and -3V"); mois_tmcheck("Ensure that parameter MODE is set to PHOTSTBY"); if(sampleDetectors) { SpireBbSetDetSampling("PHTSTBY",true,detVersion,sampleDetectors,debug); } // // ---------------- // configure SCU // ---------------- // SpireBbSetScuSampling("PHTSTBY","v00",debug); // // ---------------- // Configure PTC // ---------------- // delay(ptcHold); if(ptc == "Default") { // read default status ptc = SpireProc_GetTableEntryString("SpireTable_DefaultParams.txt","mode","PHTSTBY","ptcVm",ptcVersion,debug); } SpireBbSetPtc(ptc,ptcVersion,debug); // // ---------------- // Stabilisation // ---------------- delay(stabilisationTime); // // ----------------------- // Setup final detector sampling // ----------------------- SpireBbSetDetSampling("PHTSTBY",true,detVersion,false,debug); } // SpirePOF3Pointing // // $id$ // // This procedure calculates and returns the pointing parameters for the POF3 observing mode // // 11/02/09: KJK Updated to reflect changed configuration and reconfiguration stages // 03/07/2009 KJK: // Added configuration input parameters to pass to SpirePOF3Config and SpirePOF3End // 05/07/2009 KJK: // SPR-1593 - added flashVersion to input parameters // - changed call to SpireBbPcalFlash // // 22/07/2009 SDS: // SCR-1670 - Added pBool1 option to load new JM64 table which has +/- 126 arcseconds chop throw // 27/07/2009 SDS: // SCR-1728 - Added chopVersion to be able set Kp/Ki/Kd for JM64 maps // {int,int,int,int,int,int,int} procedure SpirePOF3Pointing { int nMaps = 1; // total number of number of maps to perform int nCycles = 1; // number of nod cycles per map int nNodInts = 1; // number of nod integrations per nod position int nCal = 99999; // number of nod cycles per Gyro calibration int nFlash = 99999; // number of nod cycles per PCAL flash bool isBright = false; string flashVersion = "v00"; string photVersion = "v00"; string comVersion = "v00"; bool debug = false; bool pBool1 = false; // Load 64-Point Jiggle Map Table? string chopVersion = "v00"; // Version of the SpireTable_BsmNominalSettings.txt table }{ // // ***** fetch fixed operating mode parameters ***** // int jiggleTable = ilookup("OpsParms.txt","POF3","TableId"); // Jiggle Table ID int jiggleSize = ilookup("OpsParms.txt","POF3","TableSize"); // Jiggle Table length int nChop = ilookup("OpsParms.txt","POF3","NChops"); // number of chop cycles per jiggle position int nJiggs = ilookup("OpsParms.txt","POF3","NJiggs"); // number of jiggle positions per nod position int nNodPosns = ilookup("OpsParms.txt","POF3","NNodPosns"); // number of nod positions in a nod cycle bool initFlash = blookup("SpireParms.txt","POF3","InitFlash"); // initial flash flag bool endFlash = blookup("SpireParms.txt","POF3","EndFlash"); // final flash flag // // ***** check inputs ***** int nMoves = nMaps * nCycles * nNodPosns / 2; if(nMoves > 1200) { error("POFS3Pointing: number of nod switches is greater than maximum allowed (1200): " + nMoves); } // // ****** calculate parameters for pointing mode ****** // // minimum slew time int tSlewMin = duration(SpireBb_StartObsAll("POF3")) + duration(SpireBbPOF3Config("POF3",isBright,pBool1,photVersion,chopVersion,debug)) + 2; // // time for Initial Hold int tInitHold = duration(SpireBbPOF3Init()) + 2; int tFlash = duration(SpireBbPcalFlash("PFlash",flashVersion,0,debug)); if(endFlash || nFlash < nCycles) { tInitHold = tInitHold + tFlash; } // // time for Final Hold int tFinalHold = duration(SpireBbPOF3End("PHTSTBY",isBright,photVersion,comVersion,chopVersion,debug)) + duration(SpireBb_EndObsAll(true)) + 2; if(endFlash || nFlash < nCycles) { tFinalHold = tFinalHold + tFlash; } // // time at hold position int tHold = tFlash + 2; // // number of nods per hold int nHold = 0; if(nFlash < nMaps * nCycles) { nHold = nFlash * nNodPosns / 2; } // int tp = duration(SpireBbJiggle("POF3",jiggleTable,0,nJiggs,nNodInts,0)) + duration(SpireBbMove(0)) + 2; return {tSlewMin,tInitHold,tFinalHold,nMoves,tp,tHold,nHold}; } // SpireBbPOF5Config // // $Id:$ // // Building Block to configure the instrument for POF5 (scan map) operation // // The complete instrument setup operation is divided into two parts: // Configuration: actions that can be executed during the slew to the start // position of the S/C pointing mode. // Initialisation: actions that must be carried out at the S/C intial pointing // position before any observational operations are executed. // // This building Block implements the first part of the setup // // 02/07/2009 KJK: // - Added bsmModel, isBright, bsmVersion, photVersion and debug input parameters // - Added use of possible bright-source settings // block SpireBbPOF5Config SPIRE 8272 { string obsMode = "POF5"; bool isBright = false in [true,false]; string bsmModel = "initial"; string bsmVersion = "v00"; string photVersion = "v00"; bool debug = false in [true,false]; }{ int t = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB POF5 Configuration started"); SpireMsg(2," $Id:$"); // // ..... configuration ..... // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // Set Mode to POF5 tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_MODE_RAW(0x0350)"); Spire_SET_OBS_MODE_RAW(0x350); // // Move BSM to HOLD int bsmHoldChopPosn = ilookup("BSM.txt","Hold","ChopPosn"); int bsmHoldJiggPosn = ilookup("BSM.txt","Hold","JiggPosn"); SpireBsmMove(bsmHoldChopPosn,bsmHoldJiggPosn); // // set bright-source biases and phases - if needed if(isBright) { SpireProc_Set_PhotBright(obsMode,photVersion,debug); } // // Time synchronisation tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_RESET_DRCU_COUNTERS_RAW()"); Spire_RESET_DRCU_COUNTERS_RAW(); // // ..... completion ..... // delay(2); // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB POF5 Configuration ended"); SpireMsg(1," ..POF5 Configuration (" + (time() - t) + " seconds)"); } // SpireSendDrcuCmd // // $Id: SpireSendDrcuCmd.txt,v 1.1 2006/08/10 09:38:59 kking Exp $ // // Procedure to send a DRCU command // // // procedure SpireSendDrcuCmd { int cmd = 0x0; int override = 0; }{ string hstr = ""; // hex string string tstr = ""; // time string // hstr = SpireHexStr(cmd,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SEND_DRCU_COMMAND_RAW(" + hstr + ")"); Spire_SEND_DRCU_COMMAND_RAW(cmd,override); } // CVS comments : $Id: Array2grp_1.txt,v 1.2 2007/04/25 15:14:03 dcesarsk Exp $ // Missionphase : // // Purpose : Utility to create grp_1 tuples out of 1D arrays. // Many PACS TCs require a grp_1 argument. It appears that grp_1 are // defined as "1 element" tuples, which conceptually is the same as a 1D // array. The checksum function, on the other hand, which is used to checksum // some PACS operands, acts on 1D arrays. So a grp_1 list cannot be checksummed // unless a 1D array is created from the grp_1. This is error prone as the // following construct is needed in many CUS instances: // // // TC operand // {int}[] spu_par = [{ppf},{ppp},{tfp},{tcp}]; // // // Check sum argument array // int aux = [ppf,ppp,tfp,tcp]; // int check_sum = checksum("int",aux); // // The utility Array2grp_1 will create "spu_par " given the array aux as // input: // // {int} [] spu_par = Array2grp_1(aux); // // TCL author : N/A // TCL file : N/A // CUS author : DAC // Script file : Array2grp_1.txt // // Input arguments // type name description // int[] array_in Any 1D array containing elements needed as operand for a TC // // Return values // type Name Description // {int} [] A 1D tuple constructed with all the elements of the input array // // Description : Extract elements from array_in and insert them as "tuples" in tuple_out // // Dependencies : // // Preconditions : // // Comments : // // History : 0.1 creation by XXX {int}[] procedure Array2grp_1 { int[] array_in = [0,1,2,3]; }{ // Get dimension of array_in int nb_elem = length(array_in); // Create output tuple {int}[] tuple_out = [{0}]; {int} aux = {0}; // and fill it with elements from array_in for(int loop = 0 .. nb_elem - 1) { aux = {array_in[loop]}; tuple_out[loop] = aux; } return tuple_out; } // SpirePacsParallel // // Proposed signature for PACS-SPIRE parallel observing mode // // v0.1, Initial version for ICD v1.01, 22-Aug-2006, Roland Vavrek // v0.2, 'mapScanRate' inserted, 24-Aug-2006 (RV) // v0.3 Updated the returned values (AB) // v0.4 Added 'scanDirection' and extra noise display 01-SEP-2006 (SJL/AB) // v0.4.1 DAC, 18-oct-2006 Converted debug_print into SpireMsg // v0.4.2 DAC, 2-mar-2007 New estimate of effective tOBS (SPR-2876) // v0.4.3 DAC, 9-mar-2007 Red/blue RMS are exchanged (SPR-2876) // v0.4.4 DAC, 10-mar-2007 Aclaratory e-mail from AB: return tuple // contains extended sensitivities // v0.4.4.1 22-mar-2007 DAC: Had forgotten to reset verbose=false // // 18/01/07: v1.8: updated call to SpirePOF5Estimate to pass obsMode // 16/02/07: V1.9: SPR2836 - updated to correct calculation of efficiency // 20/04/07: v1.14: Updated to use new interface with SpirePOF5Estimate // v1.15: SCR3012 // 9/10/07: v1.16: SCR3628. Get PACS defaults for parallel mode // // 04 November 2008: added data_rate commands (SCR0953) // 07 November 2008: Added isBright input parameters (SPR4136) // // 19.11.2008: MP added isBrightPacs to call of PacsPhotDefaults // 05/07/2009 KJK: // SPR-1593 - Added flashVersion input parameter // - Updated calls to SpirePOF5Pointing and SpireBbPcalFlash to use flashVersion // {{string,double,double}[],double,double,int} obs SpirePacsParallel { double ra = 0.0 in [0.0,360.0]; // RA of Target double dec = 0.0 in [-90.0,90.0]; // DEC of Target string blue = "blue1" in ["blue1","blue2"]; // PACS blue filter selection double mapSize1 = 30.0 in [30.0,1200.0]; // map length (arcminutes) double mapSize2 = 30.0 in [30.0,1200.0]; // map height (arcminutes) bool mapOrientationArray = true; // The map orientation reference frame is 'array' (rather than array with sky constraints) double mapOrientationConFrom = 0.0 in [0.0,360.0]; double mapOrientationConTo = 360.0 in [0.0,360.0]; string mapScanRate = "fast" in ["fast","slow"]; string scanDirection = "nominal" in ["nominal","orthogonal"]; bool isBrightPacs = false; // Use settings for bright source (==tick) bool isBrightSpire = false; // Use settings for bright source (==tick) string bsmModel = "initial"; string bsmVersion = "v00"; // Version in cal table SpireTable_BsmNominalSettings.txt string flashVersion = "v00"; // Version in cal table SPireTable_Flash.txt string spireVersion = "v00"; // Version in cal table SpireTable_SpireParms.txt string opsVersion = "v00"; // Version in cal table SpireTable_OpsParms.txt string photVersion = "v00"; // Version in cal table SpireTable_PhotModeParams.txt string comVersion = "v00"; // Version in cal table SpireTable_CommonModeParams.txt bool debug = false; bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ bool verbose = false; // Debug print verbosity // // ********************************************* // pointing mode parameters for SPIRE // ********************************************* // // string obsMode = "Par"; if(mapScanRate == "fast") { obsMode = obsMode + "_F"; } else { obsMode = obsMode + "_S"; } if(scanDirection == "nominal") { obsMode = obsMode + "_N"; } else { obsMode = obsMode + "_O"; } SpireMsg(3," Observation Mode:" + obsMode); int nMaps = ilookup("OpsParms.txt",obsMode,"NMaps"); int nRepetitions = 1; // // ***** observing mode parameters ***** {double,double,int,int,int,int} pof5Obs = SpirePOF5Observing(obsMode,nRepetitions * nMaps,mapSize1,mapSize2); double mapOsit = pof5Obs{0}; int nRepeats = pof5Obs{2}; int nLines = pof5Obs{3}; int nCal = pof5Obs{4}; int nFlash = pof5Obs{5}; // // pointing mode input parameters: {int,int,int,int,int,double,double} pof5Point = SpirePOF5Pointing(obsMode,nRepeats,nLines,nCal,nFlash,isBrightSpire,bsmModel,bsmVersion,flashVersion,photVersion,comVersion,debug); // // // ********************************************* // pointing mode parameters for PACS // ********************************************* // Before issue PointReq need to do some nitty-gritty for PACS // NOTE: Re-use as much as possible code from PacsPhoto AOT. // NOTE: the conf arrays are inherited from PacsSpec, where the [0] element // represented the default values, and the [n] element represented values // to be used with the n-th wavelength. For PHOT, [0] still represents // the default values and [1] values corresponding to the chosen filter. // NOTE: In this version BOLOs acquire data all the time, no OBCP is needed // to start data taking {int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int}[] confOBCP = [{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}]; // Define confPHOTblu and confPHOTred {int,int,int,int,int,int,int,int,int}[] confPHOTblu = [{0,0,0,0,0,0,0,0,0}]; {int,int,int,int,int,int,int,int,int}[] confPHOTred = [{0,0,0,0,0,0,0,0,0}]; // Define paramsPHOT, a "tuple of tuples" // Estimator module returns {confPHOTblu,confPHOTred,confOBCP} {{int,int,int,int,int,int,int,int,int},{int,int,int,int,int,int,int,int,int},{int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int}} paramsPHOT = {clone(confPHOTblu[0]),clone(confPHOTred[0]),clone(confOBCP[0])}; // Obtain default values (here for largeSRC) paramsPHOT = PacsPhotDefaults("largeSRC","Parallel",isBrightPacs,verbose); // Array [0] of paramsPHOT contains the default values; array [1] // will contain the values based on HSPOT input. Array [1] is a copy of [0]; // only elements depending on HSPOT will be updated // Copy default values to individual "conf" tuples confPHOTblu[0] = paramsPHOT{0}; confPHOTred[0] = paramsPHOT{1}; confOBCP[0] = paramsPHOT{2}; // Get the durations of each activity: // - AOT prologue // - CAL observation // - Start OBCP (not really needed since BOLO acquires data non-stop) // - Possible CAL during "hold" // - AOT epilogue // Start computations for the "pre-calibration" cycle. This cycle to be // performed during the slew to the source. // First TC is associated with setting OBSID int timeSetOBSID = duration(WriteOBSID($OBSID)); // Next call PacsPhotSlewCal. This script conditions the BOLO if doProlog is // set to true or just performs a calibration using an alredy conditioned BOLO // The time needed to perform these activities during slew is // Calibration alone: bool doProlog = false; int timeSlewCal = duration(PacsPhotSlewCal(verbose,confPHOTblu,confPHOTred,confOBCP,doProlog,blue)); if(verbose) { SpireMsg(3,"Duration of SlewCal: " + timeSlewCal); } // Same but including prologue doProlog = true; int timeSlewCalProlog = duration(PacsPhotSlewCal(verbose,confPHOTblu,confPHOTred,confOBCP,doProlog,blue)); if(verbose) { SpireMsg(3,"Duration of SlewCalProlog: " + timeSlewCalProlog); } // The total PACS time needed during slew is timeSlewCalProlog + timeSetOBSID; // Do not lose time with OBCPs. BOLOs are only stopped with AOT_epilogue // Deal with PHOT_aot_epilogue and WriteEndID int timeEpilogue = duration(PHOT_aot_epilogue()); int timeEndID = duration(WriteEndID()); timeEpilogue = timeEpilogue + timeEndID; if(verbose) { SpireMsg(3,"Duration aot_epilogue: " + timeEpilogue); } // ********************************************* // set up telescope pointing mode // ********************************************* // default values int naifid = 0; // no tracking in this mode double mapOffsetY = 0.0; // no offsetting in this mode double mapOffsetZ = 0.0; // no offsetting in this mode // fixed parameters string ib = slookup("OpsParms.txt",obsMode,"Boresight"); // Use SPIRE instrument boresight double deltaY = dlookup("OpsParms.txt",obsMode,"DeltaY"); // offset to pixel centre from boresight in Y direction (arcsecs) double deltaZ = dlookup("OpsParms.txt",obsMode,"DeltaZ"); // offset to pixel centre from boresight in Z direction (arcsecs) bool fixed = blookup("OpsParms.txt",obsMode,"Fixed"); // pattern angle definition double patt = dlookup("OpsParms.txt",obsMode,"Patt"); // direction of scan lines in instrument coordinates double yOffset = mapOffsetY * 60.0 + deltaY; // offset to observation position from target in Y direction (arcsecs) double zOffset = mapOffsetZ * 60.0 + deltaZ; // offset to observation position from target in Z direction (arcsecs) // calculated parameters int tSlewMin = timeSetOBSID + timeSlewCalProlog + pof5Point{0}; int tih = pof5Point{1}; int tfh = timeEpilogue + pof5Point{2}; int n = nLines; double scanLength = pof5Obs{1}; double d2 = pof5Point{5}; double rate = pof5Point{6}; // int tHold = timeSlewCal + pof5Point{3}; int nHold = pof5Point{4}; int nRepeat = nRepeats; int[] ts = line_scan_pointing(true,tSlewMin,tih,tfh,ib,naifid,ra,dec,fixed,patt,yOffset,zOffset,n,scanLength,d2,rate,tHold,nHold,nRepeat); //Info from API (nomenclature from Jon Br) int tobs = ts[0]; int tslew = ts[1]; int tacc = ts[2]; int tdec = ts[3]; int tl = ts[4]; int tll = ts[5]; int trep = ts[6]; int tend = ts[7]; if(verbose) { SpireMsg(3,"##### line_scan_with_hold"); SpireMsg(3,"##### rate: " + rate + " arcsec/sec"); SpireMsg(3,"##### PntReq: " + ts); SpireMsg(3,"##### tobs : " + tobs); SpireMsg(3,"##### tslew: " + tslew); SpireMsg(3,"##### tacc : " + tacc); SpireMsg(3,"##### tdec : " + tdec); SpireMsg(3,"##### tl : " + tl); SpireMsg(3,"##### tll : " + tll); SpireMsg(3,"##### trep : " + trep); SpireMsg(3,"##### tend : " + tend); } // How long it takes to scan a line [sec] int scanTime = tl; // Gather the overheads int scanOVER = tacc + tdec; // fetch timing information // bool initFlash = blookup("SpireParms.txt",obsMode,"InitFlash"); // initial flash flag bool endFlash = blookup("SpireParms.txt",obsMode,"EndFlash"); // final flash flag int tFlash = duration(SpireBbPcalFlash("PFlash",flashVersion,0,debug)); // time for a PCAL flash int tSerendipity = duration(SpireBbPhotSerendipity(obsMode,0)); // minimum time for a serendipity observation }{ // ***************************************** // Display input parameters // ***************************************** SpireMsg(3," Parallel Mode Input values:"); SpireMsg(3," ..RA: " + ra); SpireMsg(3," ..Dec: " + dec); SpireMsg(3," ..blue: " + blue); SpireMsg(3," ..mapSize1: " + mapSize1); SpireMsg(3," ..mapSize2: " + mapSize2); SpireMsg(3," ..mapOrientationArray: " + mapOrientationArray); SpireMsg(3," ..mapOrientationConFrom: " + mapOrientationConFrom); SpireMsg(3," ..mapOrientationConTo: " + mapOrientationConTo); SpireMsg(3," ..mapScanRate: " + mapScanRate); SpireMsg(3," ..scanDirection: " + scanDirection); SpireMsg(3," Fixed values:"); SpireMsg(3," ..ib: " + ib); SpireMsg(3," ..patt: " + patt); SpireMsg(3," ..d2: " + d2); SpireMsg(3," ..rate: " + rate); SpireMsg(3," PACS Parms:"); SpireMsg(3," SPIRE Parms:"); SpireMsg(3," ..initFlash: " + initFlash); SpireMsg(3," ..endFlash: " + endFlash); SpireMsg(3," Line Scan with Hold Pointing Mode Input values:"); SpireMsg(3," ..tSlewMin: " + tSlewMin); SpireMsg(3," ..tInitHold: " + tih); SpireMsg(3," ..tFInalHold: " + tfh); SpireMsg(3," ..nLines: " + nLines); SpireMsg(3," ..scanLength: " + scanLength); SpireMsg(3," ..tHold: " + tHold); SpireMsg(3," ..nHold: " + nHold); SpireMsg(3," Line Scan Pointing Mode Output values:"); SpireMsg(3," ..tobs: " + tobs); SpireMsg(3," ..tslew: " + tslew); SpireMsg(3," ..tacc: " + tacc); SpireMsg(3," ..tdec: " + tdec); SpireMsg(3," ..tl: " + tl); SpireMsg(3," ..tll: " + tll); SpireMsg(3," ..trep: " + trep); SpireMsg(3," ..tend: " + tend); // ***************************************** // execute observation // ***************************************** SpireMsg(0,"Observation Start"); SpireMsg(0," Uses SPIRE observing mode POF5 (Scan Map)"); SpireMsg(3," $Id: SpirePacsParallel.txt,v 1.16 2007/10/10 07:54:48 dcesarsk Exp $"); data_rate(0.0); double chkrate = dlookup("Datarates.txt","Parallel","CHK"); ess_hk_data_rate(chkrate); double nhkrate = dlookup("Datarates.txt","Parallel","NHK"); non_ess_hk_data_rate(nhkrate); // // State machine ///////////////////////// start of "commanding" section ////////////////////// SpireMsg(3,"++++++++++++++++++++++++ Start Command Section"); SpireMsg(3,"$$$$$$$$$$$$$$$$ State Machine $$$$$$$$$$$$$$$$$$"); // Initialize some "global" variables int totalOBStime = 0; int totalOBSover = 0; int totalCALtime = 0; int totalCALover = 0; int nbSCANlegs = 0; string tstr = ""; // time string int otf = 0x8000; // On Target Flag double srcTime = 0.0; // total on source integration time int nl = 0; // line counter double s = 0.0; // Issue TCs int[] state = [0]; int nbOBS = 0; while(state[0] >= 0) { state = next_state(); if(state[0] == 1) { // *********************** SLEWING tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " Slewing to start position"); if(verbose) { int tNOW = time(); SpireMsg(3,"=== SLEW/CAL starts at: " + tNOW); } // set up observation parameters SpireBbObsConfig(0x500); WriteOBSID($OBSID); // perform serendipity operation if possible if(tslew > tSerendipity + tSlewMin) { SpireBbPhotSerendipity(obsMode,tslew - tSlewMin - 2); } // configure instrument for operations SpirePacsBbParallelConfig(); doProlog = true; int[] calTime = PacsPhotSlewCal(verbose,confPHOTblu,confPHOTred,confOBCP,doProlog,blue); totalCALtime = totalCALtime + calTime[3]; totalCALover = totalCALover + calTime[0]; // if(verbose) { tNOW = time(); SpireMsg(3,"=== SLEW/CAL ends at: " + tNOW); SpireMsg(3," TotalCalTime: " + totalCALtime); } } if(state[0] == 2) { // *********************** INITIAL HOLD tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " Initialising Instrument"); if(verbose) { tNOW = time(); SpireMsg(3,"=== INIT_HOLD starts at: " + tNOW); } // initialise instrument SpirePacsBbParallelInit(); // calibrate if necessary if(initFlash || nFlash < nLines) { tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " PCAL Calibration inserted"); SpireBbPcalFlash("ParPFlash",flashVersion,otf,debug); SpireBbStartDcuData("Parallel"); } // if(verbose) { tNOW = time(); SpireMsg(3,"=== INIT_HOLD ends at: " + tNOW); } } if(state[0] == 3) { // *********************** POINT if(verbose) { tNOW = time(); SpireMsg(3,"=== INIT_HOLD starts at: " + tNOW); } // code for things to do during POINT would come here nbOBS = nbOBS + 1; if(verbose) { SpireMsg(3,"POINT: POINTobs: " + nbOBS); } // if(verbose) { tNOW = time(); SpireMsg(3,"=== INIT_HOLD ends at: " + tNOW); } } if(state[0] == 5) { // *********************** FINAL HOLD tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " Reconfiguring Instrument"); if(verbose) { tNOW = time(); SpireMsg(3,"=== FINAL_HOLD starts at: " + tNOW); } // reconfigure instrument SpireBbStopDcuData(); // calibrate if necessary if(endFlash || nFlash < nLines) { tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " PCAL Calibration inserted"); SpireBbPcalFlash("ParPFlash",flashVersion,otf | nl,debug); } // reconfigure back to PHOT_STBY configuration SpirePacsBbParallelEnd(); // PHOT_aot_epilogue(); WriteEndID(); // if(verbose) { tNOW = time(); SpireMsg(3,"=== FINAL_HOLD ends at: " + tNOW); } } if(state[0] == 6) { // *********************** CAL_HOLD tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " PCAL Calibration inserted"); if(verbose) { tNOW = time(); SpireMsg(3,"=== FINAL_HOLD starts at: " + tNOW); } // Calibrate SPIRE SpireBbStopDcuData(); SpireBbPcalFlash("ParPFlash",flashVersion,otf | nl,debug); SpireBbStartDcuData("Parallel"); // Calibrate PACS doProlog = false; calTime = PacsPhotSlewCal(false,confPHOTblu,confPHOTred,confOBCP,doProlog,blue); totalCALtime = totalCALtime + calTime[3]; totalCALover = totalCALover + calTime[0]; if(verbose) { SpireMsg(3,"Accumulated CALtime: " + totalCALtime); } // if(verbose) { tNOW = time(); SpireMsg(3,"=== FINAL_HOLD ends at: " + tNOW); } } if(state[0] == 7) { // *********************** NOD if(verbose) { tNOW = time(); SpireMsg(3,"=== NOD starts at: " + tNOW); } // code for things to do during POINT would come here nbOBS = nbOBS + 1; if(verbose) { SpireMsg(3,"NOD: NODobs: " + nbOBS); } // if(verbose) { tNOW = time(); SpireMsg(3,"=== NOD ends at: " + tNOW); } } if(state[0] == 8) { // *********************** LINE int line = state[2]; int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " Instrument scanning"); SpireMsg(2," " + tstr + " Line " + nl); if(verbose) { tNOW = time(); SpireMsg(3,"=== LINE starts at: " + tNOW); } s = SpireBbScanLine(tl,otf | nl); wait_until(t + tl); srcTime = srcTime + s; nl = nl + 1; SpireBbMove(0); // // Do we need code to set BBID?? totalOBStime = totalOBStime + scanTime; totalOBSover = totalOBSover + scanTime + scanOVER; nbSCANlegs = nbSCANlegs + 1; if(verbose) { SpireMsg(3,"=== SCAN mode, leg: " + nbSCANlegs); SpireMsg(3," TotalOBSTime: " + totalOBStime); } // if(verbose) { tNOW = time(); SpireMsg(3,"=== LINE ends at: " + tNOW); } } } assert (time() == ts[0] + ts[1]); if(verbose) { tNOW = time(); SpireMsg(3,"=== END state; time now: " + tNOW); } int timeObsEnd = time(); int overOBS = totalOBSover - totalOBStime; int overCAL = totalCALover - totalCALtime; if(verbose) { SpireMsg(3,"+++ OBS ends at " + timeObsEnd + "; NbOBS: " + nbOBS); SpireMsg(3," totalOBStime :" + totalOBStime); SpireMsg(3," totalOBSover :" + overOBS); SpireMsg(3," totalCALtime :" + totalCALtime); SpireMsg(3," totalCALover :" + overCAL); } tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " Observation Finished"); // ***************************************** // time estimation parameters for SPIRE // ***************************************** double sourceFluxPSW = -1.0; double sourceFluxPMW = -1.0; double sourceFluxPLW = -1.0; double sourceBrightPSW = -1.0; double sourceBrightPMW = -1.0; double sourceBrightPLW = -1.0; {string,double,double,double,double,bool,double,double,double}[] estimates = []; estimates = SpirePOF5Estimate(obsMode,double(nRepetitions),rate,sourceFluxPSW,sourceFluxPMW,sourceFluxPLW,sourceBrightPSW,sourceBrightPMW,sourceBrightPLW,isBrightSpire); // ***************************************** // time estimation parameters for PACS // ***************************************** // Slew overheads: nrepeat*[tacc + (numLegs - 1)*tll] int slewOVER = nRepeat * (tacc + (n - 1) * tll); SpireMsg(3,"slewOVER/numLegs/nrep: " + slewOVER + "/" + n + "/" + nRepeat); // Estimate how long a given sky region has been seen // Bolo size: Short Size, i.e. 32 pixels and Long Size [arcsec] double boloSSize = 1.75 * 60.0; double boloLSize = 3.5 * 60.0; double boloArea = boloSSize * boloLSize; // Elementary integration time [sec] will be computed as fraction of bolo area // wrt to total mapped area // The mapped area has dimensions map1 and map2 double map1 = boloSSize + scanLength; double map2 = boloLSize + double(n - 1) * d2; double mapArea = map1 * map2; double auxTIME = double(totalOBStime) * boloArea / mapArea; SpireMsg(3," BoloArea: " + boloArea + " [arcsec2]"); SpireMsg(3," MapArea : " + mapArea + " [arcsec2]"); SpireMsg(3," Total tOBS : " + totalOBStime + " [sec]"); SpireMsg(3," On-SRC tOBS : " + auxTIME + " [sec]"); // Pass the pointing mode to RMS (may need it for SRC,REF considerations) int pointCase = 33; double[] pixRMS = PacsPhotNoiseRMS(pointCase,blue,auxTIME); SpireMsg(3,"RMS noise: " + pixRMS); // // ***************************************** // return time estimation parameters // ***************************************** double hLoss = dlookup("OpsParms.txt",obsMode,"HLoss"); // map height loss int observationOhds = timeObsEnd - iround(srcTime) - tslew; double efficiency = mapSize1 * mapSize2 * 3600.0 / (scanLength * (d2 * double(nLines - 1) - hLoss)); SpireMsg(3," Efficiency: " + efficiency); SpireMsg(3," Overheads: " + observationOhds); // Return: band, point source noise, extended source noise // SPR-2876: red/blue were exchanged // Pnt source sensitivities double pntBLU = pixRMS[1]; double pntRED = pixRMS[0]; // Add extended source sensitivities (there were place holders because // missing "extended" estimate at the time) double extBLU = pixRMS[3]; double extRED = pixRMS[2]; {string,double,double}[] noiseLevels = [{"PACS Blue",pntBLU,extBLU},{"PACS Red",pntRED,extRED},{"SPIRE 250",estimates[0]{2},estimates[0]{7}},{"SPIRE 350",estimates[1]{2},estimates[1]{7}},{"SPIRE 500",estimates[2]{2},estimates[2]{7}}]; return {noiseLevels,efficiency,srcTime,observationOhds}; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_StartJfetVssTestC.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to configure at the start of // SpirePhoto_Cal_JfetVssTestC. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // // 2009/05/21 V0.1: Initial version adapted from // SpireBb_StartFovMapFpgScan (2009/05/05 V0.1) // /////////////////////////////////////////////////////////////////////////// // block SpireBb_StartJfetVssTestC SPIRE 14071 { bool phot = true; // Photometer (==tick) or FTS (==untick)? string obsModeQla = "ENG_CAL_OBS16"; string obsMode = "PEngCalObs"; bool isBright = false; // Use settings for bright source (==tick) string version01 = "v00"; // Version in cal table SpireTable_Phot/SpecModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams int hold_chop = 37632; // Chop hold position int hold_jigg = 39520; // Jiggle hold position int smecHomePosn = 3500; // SMEC home position bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // int mode_id = 0; string obsmode = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB StartJfetVssTestC configuration started"); SpireMsg(2," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Startup observation: // SpireProc_Set_StartObsAll(obsModeQla); // // // // // In case move SMEC to home: // if(!phot) { // // Calculate available time for possible movement: // int tmove = duration(SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug)) + duration(SpireProc_Set_SpecMode(obsMode,isBright,version01,version02,debug)) + duration(SpireProc_Set_ObsStep(999,debug)) + duration(SpireBb_SpecOffsetAuto(false,debug)); // // Calculate max offset for which time is available: // int smecMaxOff = tmove * 500; // Note, 500 is maximum possible SMEC speed. int smecStart = smecHomePosn + smecMaxOff; // Note, formula above only reasonable // when smecHomePosn small compared to 39500 // Safety check: if(smecStart > 39500) { smecStart = 39500; } if(debug) { debug_print("smecStart: " + smecStart); debug_print("smecHomePosn: " + smecHomePosn); debug_print("tmove: " + tmove); } // // Move from maximal offset to home: // SpireProc_SmecMove2Home(smecHomePosn + smecMaxOff,smecHomePosn,debug); } // // // // // Move BSM back to hold: // SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug); // // // // // Initialise instrument (in case to isBright): // if(phot) { SpireProc_Set_PhotMode(obsMode,isBright,version01,version02,debug); } else { SpireProc_Set_SpecMode(obsMode,isBright,version01,version02,debug); } //delay(timeSlewCal); // // // // // Set Obs step at to 1: // int obsStep = 1; SpireProc_Set_ObsStep(obsStep,debug); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB StartJfetVssTestC configuration ended"); SpireMsg(1," ..StartFovMapFpgScan took " + (time() - t) + " seconds)"); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_Set_StartMcuData.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to start generation of MCU science data (TM packets) // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/03/31 V0.1: Initial version adapted // SpireProc_Set_StartDcuData (2009/02/18 V0.1) // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Set_StartMcuData { }{ // // // // // Start procedure: // message("4 " + time() + ": SpireProc_Set_StartMcuData started"); message("4 $Id: $"); // // // // // Reset MCU (x2000) fifo: // message("5 " + time() + "Cmd: Spire_RESET_FIFOS(0x2000)"); Spire_RESET_FIFOS(0x2000); delay(1); // // // // // Start data collection: // SpireSendDrcuCmd(0x91c10001,0); sync(); // // // // // End procedure: // message("4 " + time() + ": SpireProc_Set_StartMcuData ended"); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireSpectro_Cal_BsmPcalFlash.txt // /////////////////////////////////////////////////////////////////////////// // // CUS script for: 'Spec BSM PCAL Flash' // // in *basic_fine_pointing* or *no_pointing* mode // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/03/04 V0.1: Initial version adapted from // SpirePhoto_Cal_BsmPcalFlash (2009/03/04 V1.3) // 2009/05/05 V0.2: Add in move BSM/SMEC to hold/home at start. Add new // SpireBb_SmecHold to account for the fact that // SpireBb_SmecMove2Home does not stop SMEC. // Gather procedures at start and end in separate BB. // /////////////////////////////////////////////////////////////////////////// // Script assumes that: // // 1) Instrument is in SPECSTBY // (i.e. bias amplitude, phase, frequency [mclkdiv,biasdiv] are nominal) // // 2) Bias frequency (mclkdiv) and sampling rate (biasdiv) are the same // for all three arrays and could be taken from following cal table: // SpireTable_SpecModeParams.txt // // 3) Home position of BSM can be read from SpireTable_BsmNominalSettings.txt // /////////////////////////////////////////////////////////////////////////// // obs SpireSpectro_Cal_BsmPcalFlash { /* ****************************************************** */ /* USER PARAMETER DEFINITION, CUS SIGNATURE for EX-HSpot */ /* ****************************************************** */ double ra = 0.0 in [0.0,360.0]; // RA of target double dec = 0.0 in [-90.0,90.0]; // DEC of target int naifid = 0; //NAIF identifier: put '0' to use RA/DEC, or correct 'NAIFID' bool pointing = true; // Should telescope 'point' (==tick) or do a 'no pointing' (==untick)? /* */ bool isBright = false; // Use settings for bright source (==tick) string ib = "S24_0"; // Central aperture (defined in SIAM) of raster int c_start = 0x1000 in [0x1000,0xf000]; // RAW chop target start position int c_end = 0xf000 in [0x1000,0xf000]; // RAW chop target end position int c_step = 0x2000; // RAW chop target step in position string version01 = "v00"; // Version in cal table SpireTable_SpecModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams string version03 = "v00"; // Version in cal table SpireTable_BsmNominalSettings string model = "initial"; // Model in cal table SpireTable_BsmNominalSettings bool debug = false; // Allow (==tick) or suppress cus debug_print statements bool isSerendipity = true; // Allow (==tick) serendipity mode to be activated or prohibit (==untick) it (currently not in use)? bool isPcal = true; // Allow (==tick) regular PcalFlash in script or prohibit (==untick) it (currently not in use)?. bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ // ****************************************************** */ // CALCULATE DURATIONS for POINTING STATES */ // ****************************************************** */ // // // // // Check user input for chop/jiggle parameters : // if(c_end < c_start + c_step) { error("End chop is smaller than start chop plus 1*step. Try again!"); } // // // // // Declare some variable: // // Spectrometer or FTS: bool phot = false; bool fts = !phot; // string tabName = ""; string selCol = ""; string selVal = ""; string tarCol = ""; string version = ""; double scirate = 0.0; double chkrate = 0.0; double nhkrate = 0.0; // int obsStep = 0; // // Hardcoded calibration tables: // string tabName01 = "SpireTable_SpecModeParams.txt"; string tabName02 = "SpireTable_CommonModeParams.txt"; string tabName03 = "SpireTable_BsmNominalSettings.txt"; string tabName04 = "SpireTable_CommandLists.txt"; string tabName06 = "SpireTable_SmecNominalSettings.txt"; // // Currently hardcoded version: // string version06 = "v00"; // Version in cal table SpireTable_SmecNominalSettings // // Currently hardcoded parameter: // Is (==tick) the DCU currently sampled? bool dcuData = false; // // // // // Setup mode: // // Set obsMode for QLA: string obsModeQla = "ENG_CAL_OBS42"; // Note: this needs entry in MIB table and in SpireTableInstConfigs.txt // // Set obsMode for datarates: string obsMode = "SEngCalObs"; // Note: this is currently only a maximum value // // // // // Read nominal bias frequency and bias divider: // // Select version flag and set GetTableEntry parameters: version = version01; tabName = tabName01; selCol = "mode"; // Name of column for selecting selVal = obsMode; // Value of 'string' selector // tarCol = "mclkDiv"; int mclkDiv = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "biasDiv"; int biasDiv = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // Calculate nominal sampling rate from mclkdiv and biasdiv: // double mclkdivHz = 1.0E7 / (512.0 * double(mclkDiv + 1)); double biasdivHz = 1.0 / (double(biasDiv) + 1.0) * mclkdivHz; if(debug) { debug_print("Nominal sampling rate is: " + biasdivHz + " [Hz]"); } // // // // // Read BSM home position: // // Select version flag and set GetTableEntry parameters: // version = version03; tabName = tabName03; selCol = "model"; // Name of column for selecting selVal = model; // Value of 'string' selector // // Read hold position from calibration table: tarCol = "chop_0_I"; int hold_chop = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "jigg_0_I"; int hold_jigg = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // Set jigg position during test to hold_jigg: int jiggPosn = hold_jigg; // // // // // Read VM parameters from calibration table: // tabName = tabName04; selVal = "Flash"; int vmId = ilookup(tabName,selVal,"Id"); int vmIndex = ilookup(tabName,selVal,"Index"); int nParms = ilookup(tabName,selVal,"Nparms"); // // // // // Read SMEC home position from calibration file: // tarCol = "Home"; tabName = tabName06; selVal = version06; int smecHomePosn = ilookup(tabName,selVal,tarCol); // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // Calculate timing for the pointing request: // // BBs called during slew: int tslewmin = duration(SpireBb_StartBsmPcalFlash(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,debug)); // // BBs carried out when the pointing is reached: if(pointing) { int tinithold = duration(SpireBb_SpecOffsetAuto(dcuData,debug)) + duration(SpireBb_SmecHold(debug)); } else { tinithold = tslewmin + duration(SpireBb_SpecOffsetAuto(dcuData,debug)) + duration(SpireBb_SmecHold(debug)); } // // BB carried out during pointing: int tp = duration(SpireProc_Exec_BsmPcalFlash(c_start,c_end,c_step,jiggPosn,mclkDiv,biasDiv,vmId,vmIndex,nParms,fts,debug)); // // BB carried out at the end: int tfinalhold = duration(SpireBb_EndBsmPcalFlash(phot,hold_chop,hold_jigg,isBright,version01,version02,debug)); // // Debug_printing? // if(debug) { debug_print("tslewmin = " + tslewmin); debug_print("tinithold = " + tinithold); debug_print("tpointing = " + tp); debug_print("tfinalhold = " + tfinalhold); } // // ****************************************************** */ // POINTING MODE DECLARATION */ // ****************************************************** */ // // // // // // Set pointing mode: // if(pointing) { int[] ts = basic_fine_pointing(true,tslewmin,tinithold,tfinalhold,ib,naifid,ra,dec,0.0,0.0,tp); } else { ts = no_pointing(true,tinithold,tfinalhold,tp); } // if(debug) { debug_print("Output timing vector from the pointing request: " + ts); } // }{ // ****************************************************** */ // POINTING STATES WITH OBSERVING MODE LOGIC */ // ****************************************************** */ // // // // // Set datarates: // string rateType = "chk"; chkrate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); ess_hk_data_rate(chkrate); // rateType = "nhk"; // nhkrate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); non_ess_hk_data_rate(nhkrate); // rateType = "sci"; scirate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); data_rate(scirate); // if(debug) { debug_print("Set CHK datarate to: " + chkrate); debug_print("Set NHK datarate to: " + nhkrate); debug_print("Set SCI datarate to: " + scirate); } // // Start the state_machine: // int[] state = [0]; // while(state[0] >= 0) { if(debug) { debug_print("Current state: " + state); } state = next_state(); if(debug) { debug_print("Next state: " + state); } // if(state[0] == 1) { // STATE = SLEW (Spacecraft is slewing ) // // // // // Startup observation: // SpireBb_StartBsmPcalFlash(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,debug); // //delay(timeSlewCal); } if(state[0] == 2) { // STATE = INIT_HOLD ( spacecraft is idling at source ) // // // // // If no pointing observation do stuff here which is // done nominally during SLEW: // if(!pointing) { // // // // // Startup observation: // SpireBb_StartBsmPcalFlash(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,debug); } // // // // // Set offsets: // SpireBb_SpecOffsetAuto(dcuData,debug); // // // // // Stop any remaining SMEC movement: // SpireBb_SmecHold(debug); // //delay(tinithold); // } if(state[0] == 3) { // STATE = POINT ( spacecraft is at nominal RA,DEC (staring, raster) ) // // // // // // Execute loop of BSM Pcal flashes: // SpireProc_Exec_BsmPcalFlash(c_start,c_end,c_step,jiggPosn,mclkDiv,biasDiv,vmId,vmIndex,nParms,fts,debug); // //delay(tp); // } if(state[0] == 5) { // STATE = FINAL_HOLD ( "sky" observation ends, performing final activ.) // // // // // Set scientific datarate back to zero: // data_rate(0.0); // // // // // Reconfigure at the end (incl. resetting of OBSID and BBIB): // SpireBb_EndBsmPcalFlash(phot,hold_chop,hold_jigg,isBright,version01,version02,debug); // } if(state[0] == -1) { // STATE = END ( end of the pointing/commanding part of the code ) // } } } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_SpecFSetupData.txt // /////////////////////////////////////////////////////////////////////////// // // BB to set bias frequency, amplitude, and phase of spectrometer arrays // // Note: Script does also set biasmode to 255 (sine) and frames to 0 (continous) // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/08/11 V0.1: Initial version adapted from // SpireBb_PhotFSetupData.txt (2008/07/03 V0.2) // Setup_SF_Data.txt (v1.4 2008/01/31 20:24:36) // 2009/01/31 V1.0: Add debug_print as input. Change some comments. // Replace last delay(1) with sync(). Remove unsetting // off BBID at end. // 2009/06/05 V1.1: Replace Spire_SEND_DRCU_COMMAND with SpireSendDrcuCmd // as requested in SPR-1482. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_SpecFSetupData SPIRE 14013 { int mclkdiv = 0x79; //Default (IST) bias freq (==160.1 Hz) int biasdiv = 0x1; //Default (IST) sampling freq (==80.0 Hz) int ssw_bias = 0x2d; //Default (IST) bias amplitud (==31.1 mV) int slw_bias = 0x2d; //Default (IST) bias amplitud (==31.1 mV) int ssw_phase = 0x83; //Default phase (IST) (== 184.93 deg) int slw_phase = 0x87; //Default phase (IST) (== 190.59 deg) bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Set fixed (for flight) parameters: // // Default (IST) sine bias mode generation: int biasmode = 0xff; // // Default (IST) number of frames to request: // (do not use frames, but only ftime to select time) int frames = 0; // // // // // Safety checks // if(biasdiv < 1) { biasdiv = 1; } if(biasdiv > 255) { biasdiv = 255; } if(mclkdiv < 64) { mclkdiv = 64; } if(mclkdiv > 511) { mclkdiv = 511; } // // // // // Calculate bias and sampling frequencies based on mclkdiv and biasdiv: // // Calculate bias frequency Hz: double bias_f = 1.0E7 / (512.0 * double(mclkdiv + 1)); // Calculate sampling rate Hz: double s_rate = bias_f / (1.0 + double(biasdiv)); // // // // // Verify sampling rate does not exceed 20Hz for full spectrometer array: // if(s_rate > 80.5) { do { biasdiv = biasdiv + 1; s_rate = bias_f / (1.0 + double(biasdiv)); if(debug) { debug_print("New bias divisor is: " + biasdiv); debug_print("New sampling rate is: " + s_rate); } } while (s_rate > 80.5); } // // // // // Calculate frametime (time between successive frames = 1/sampling rate): // // Frametime difference in ms: double framerate = 1.0 / s_rate * 1000.0; // // // // // Debug printout: // if(debug) { debug_print(" BIAS FREQUENCY IS : " + bias_f + " [Hz]"); debug_print("SAMPLING FREQUENCY IS : " + s_rate + " [Hz]"); debug_print(" FRAMETIME DIFF IS : " + framerate + " [ms]"); } // // // // // Set the BBs to SPIRE bbid: // Spire_SET_BBID($BBID); // // // // // Set bias mode: // SpireSendDrcuCmd(0x84300000 + biasmode,0); delay(1); // // // // // Set data mode: // SpireSendDrcuCmd(0x843c0004,0); //delay(1); // // // // // Set number of frames to continuous: // SpireSendDrcuCmd(0x843d0000 + frames,0); delay(1); // // // // // Set mclkdiv and biasdiv: // SpireSendDrcuCmd(0x84390000 + mclkdiv,0); //delay(1); SpireSendDrcuCmd(0x84380000 + biasdiv,0); delay(1); // // // // // Set bias amplitude: // SpireSendDrcuCmd(0x84310000 + ssw_bias,0); //delay(1); SpireSendDrcuCmd(0x84320000 + slw_bias,0); delay(1); // // // // // Set phase: // SpireSendDrcuCmd(0x843a0000 + ssw_phase,0); //delay(1); SpireSendDrcuCmd(0x843b0000 + slw_phase,0); sync(); // } // CVS comments : $Id: Msec2sec.txt,v 1.2 2007/04/25 15:14:03 dcesarsk Exp $ // Missionphase : // // Purpose : Convert [msec] into [sec]. This is needed since CUS // granularity is the second. // // Author CUS : Diego A. Cesarsky (diego.cesarsky@mpe.mpg.de) // // Author TCL : N/A // // Original TCL : N/A // // Input arguments // Type Name DefVal Description // int milisec N/A A duration [msec] to be converted into [sec] // // Description : Convert int msec into float sec (for instance 1230 msec // gets converted to 1.230 [sec] and take next closest integer // (2 in this example) // // Dependencies : None // // Comments : // // Version : 0.1 13-Aug-2004 First creation // History : // : // int procedure Msec2sec { int milisec = 0; }{ double fwait = double(milisec) / 1000.0; int secnds = iceil(fwait); return secnds; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_StartDcuData.txt // /////////////////////////////////////////////////////////////////////////// // // BB to start generation of detector data (TM packets) // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/05/01 V0.1: Initial version adapted from old Start_DCU_Data.txt // templates used in ILT; replaces old // SpireBbStartDcuData.txt script // 2008/07/03 V0.2: Renumber version; add RESET_FIFO at start // 2009/02/18 V1.0: Remove datamode from input. Remove setting of // #frames, remove unsetting of BB at end. Remaining // commands are now move to low level procedure // SpireProc_Set_StartDcuData now called. // 2009/06/05 V1.1: Fix Hspot message at end of script (SPR-1481). // /////////////////////////////////////////////////////////////////////////// // block SpireBb_StartDcuData SPIRE 14002 { }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SpireBb_StartDcuData started"); SpireMsg(2," $Id:$"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Start DCU data: // SpireProc_Set_StartDcuData(); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SpireBb_StartDcuData ended"); SpireMsg(1," ..StartDcuData End (" + (time() - t) + " seconds)"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////// // // SpireProc_Set_DcuFreqSampMode.txt // /////////////////////////////////////////////////////////// // // Procedure to configure the DCU bias frequency, sampling rate, // and dcuDatamode // /////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/02/15 V0.1: Initial version adapted from // SpireProc_Set_PhotPhase (2009/02/14 V0.2) and // SpireBb_PhotFSetupData (2009/01/31 V1.0) // 2009/06/05 V1.0: Replace Spire_SEND_DRCU_COMMAND with SpireSendDrcuCmd // as requested in SPR-1482. // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Set_DcuFreqSampMode { int mclkDiv = 149; // Bias freq. (for photometer == 130.20833 Hz) int biasDiv = 6; // Sampling freq. (for photometer == 18.60119 Hz) int dcuDataMode = 0; // Detector data sampling mode [0==Phot,4==FTS] bool phot = true; // Set for photometer (==tick) or FTS bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Define some variables: // string tstr = ""; // // Photometer or FTS?: bool fts = !phot; // // // // // Start procedure: // tstr = SpireTimeStr(time()); SpireMsg(4," " + tstr + ": SpireProc_Set_DcuFreqSampMode started"); SpireMsg(4," $Id:$"); // // // // // Set the selected bias frequency, sampling frequency, and DCU data mode: // // Set mclkdiv and biasdiv: // if(phot) { SpireSendDrcuCmd(0x84190000 + mclkDiv,0); SpireSendDrcuCmd(0x84180000 + biasDiv,0); } else { SpireSendDrcuCmd(0x84390000 + mclkDiv,0); SpireSendDrcuCmd(0x84380000 + biasDiv,0); } delay(1); // // Set DCU data mode : // SpireSendDrcuCmd(0x843c0000 + dcuDataMode,0); sync(); // // // // // Calculate bias and sampling frequencies based on mclkdiv and biasdiv: // // Calculate bias frequency Hz: double bias_f = 1.0E7 / (512.0 * double(mclkDiv + 1)); // // Calculate sampling rate Hz: double s_rate = bias_f / (1.0 + double(biasDiv)); // // // // // Calculate frametime (time between successive frames = 1/sampling rate): // //Frametime difference in ms: double framerate = 1.0 / s_rate * 1000.0; // // // // // Debug Printing: // // if(debug) { debug_print(" BIAS FREQUENCY IS : " + bias_f + " [Hz]"); debug_print("SAMPLING FREQUENCY IS : " + s_rate + " [Hz]"); debug_print(" FRAMETIME DIFF IS : " + framerate + " [ms]"); debug_print(" DCU DATA MODE IS : " + dcuDataMode); } // // // // // End procedure: // tstr = SpireTimeStr(time()); SpireMsg(4," " + tstr + ": SpireProc_Set_DcuFreqSampMode ended"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_EndBsmAngleCal.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to reconfigure at the end of SpireProc_Exec_BsmAngleCal // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // // 2009/01/30 V1.0: Initial version // 2009/02/14 V1.1: Set instrument back to Phot/Spec-STBY. Move BSM back // to its hold position. // 2009/05/05 V1.2: Include setting of SpireBb_EndObsAll. // 2009/05/07 V1.3: Set dcuFrameNumber and mcuFrameNumber back to continuous // to unset setting passed to VM. // 2009/06/05 V1.4: Replace Spire_SEND_DRCU_COMMAND with SpireSendDrcuCmd // as requested in SPR-1482. // 2009/07/12 V1.5: Set SMEC framerate back to nominal. (SPR-SPIRE-1551). // /////////////////////////////////////////////////////////////////////////// // block SpireBb_EndBsmAngleCal SPIRE 14026 { bool phot = true; // Photometer (==tick) or FTS (==untick)? int hold_chop = 37632; // Chop hold position [Dec(Hex)] int hold_jigg = 39520; // Jiggle hod position [Dec(Hex)] bool isBright = false in [true,false]; // IsBright (==tick) flag string version01 = "v00"; // Version in cal.tab. SpireTable_PhotModeParams string version02 = "v00"; // Version in cal.tab. SpireTable_CommonModeParams bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // int mode_id = 0; string obsmode = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB EndBsmAngleCal reconfiguration started"); SpireMsg(2," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Set obsstep back to 0: // tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP(0)"); Spire_SET_OBS_STEP(0); // // // // // Set instrument back to Phot/Spec-STBY: // if(phot) { SpireProc_Set_PhotMode("PHTSTBY",isBright,version01,version02,debug); } else { SpireProc_Set_SpecMode("SPECSTBY",isBright,version01,version02,debug); } // // // // // Move BSM back to hold: // SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug); // // // // // Set number of DCU frames to continuous: // int dcuFrameNumber = 0; if(phot) { dcuFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","PHTSTBY","dcuFrameNumber","v00",debug); } else { dcuFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","SPECSTBY","dcuFrameNumber","v00",debug); } // SpireSendDrcuCmd(0x843d0000 + dcuFrameNumber,0); // // // // // Set number of MCU frames to continuous: // int mcuFrameNumber = 0; if(phot) { mcuFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","PHTSTBY","mcuFrameNumber","v00",debug); } else { mcuFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","SPECSTBY","mcuFrameNumber","v00",debug); } SpireSendDrcuCmd(0x91c30000 + mcuFrameNumber,0); delay(1); // // // // // Set SMEC framerate (== SMEC sampling rate) back to SPEC_STBY: // (Note, hardcoded version to go back to STBY) // if(!phot) { int smecFrameRate = SpireProc_GetTableEntryInt("SpireTable_SpecModeParams.txt","mode","SPECSTBY","smecFrameRate","v00",debug); SpireProc_Set_SmecFramerate(smecFrameRate,debug); } // // // End observation: // SpireProc_Set_EndObsAll(phot); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB EndBsmAngleCal reconfiguration ended"); SpireMsg(1," ..Reconfiguration to " + obsmode + "mode (" + (time() - t) + " seconds)"); // } // $Id: WriteEndBB.txt,v 1.2 2007/08/22 10:21:52 dcesarsk Exp $ // Purpose : Set BBID to its default value to indicate the end // of current BB execution (see FIRST-FSC-DOC-0200) // // CUS script : Diego A. Cesarsky (diego.cesarsky@mpe.mpg.de) // // Input arguments N/A // // Description : BBID will be set to its default value // // Comments : Needed for SCR-3507 // // Version : 0.1 21-aug-2007 First creation // procedure WriteEndBB { }{ int iBBID = 0x40000000; // Write BBID to DEC/MEC Pacs_DMC_SET_BBID(iBBID); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_CalcParam_SpecBiasConvert.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to translate user input in mV for bias amplitude // into nearest Hex values for ssw_bias,and slw_bias // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/08/11 V0.1: Initial version adapted from // SpireProc_CalcParam_PhotBiasConvert (2008/07/03 V0.4) // Proc_BiasConvertS (v1.4 2008/01/31 20:24:35) // 2009/02/19 V0.2: Add debug_print as input and implement. // /////////////////////////////////////////////////////////////////////////// int[] procedure SpireProc_CalcParam_SpecBiasConvert { double input_bias_ssw = 0.0 in [0.0,176.385]; // Input SSW Bias amplitude [0.0 - 176.385] [mV] double input_bias_slw = 0.0 in [0.0,176.417]; // Input SLW Bias amplitude [0.0 - 176.417] [mV] bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Predefine version: // string ver_ssw = "v01"; string ver_slw = "v01"; if(debug) { debug_print("The nominal/hardcoded version is v01"); } // // // // // Retrieve the maximum bias amplitude: // double maxbias_ssw = dlookup("SpireTable_SpecSswMaxbias.txt",ver_ssw,"maxbias"); double maxbias_slw = dlookup("SpireTable_SpecSlwMaxbias.txt",ver_slw,"maxbias"); // // // // // Convert from mV to RAW values: // double conversion_factor_ssw = 255.0 / maxbias_ssw; double conversion_factor_slw = 255.0 / maxbias_slw; // int raw_bias_ssw = iround(conversion_factor_ssw * input_bias_ssw); int raw_bias_slw = iround(conversion_factor_slw * input_bias_slw); // // Safety check: if(raw_bias_ssw > 255) { raw_bias_ssw = 255; if(debug) { debug_print("SSW exceeded limit!"); } } if(raw_bias_slw > 255) { raw_bias_slw = 255; if(debug) { debug_print("SLW exceeded limit!"); } } // double bias_ssw = double(raw_bias_ssw) / conversion_factor_ssw; double bias_slw = double(raw_bias_slw) / conversion_factor_slw; // // // // // Printout: // if(debug) { debug_print("Input mV value for SSW/SLW bias amplitude: " + input_bias_ssw + "/" + input_bias_slw); debug_print("Output Hex values for SSW/SLW: " + raw_bias_ssw + "/" + raw_bias_slw); debug_print("Commanded mV values for SSW/SLW: " + bias_ssw + "/" + bias_slw); } // // // // // Return required values: // return [raw_bias_ssw,raw_bias_slw]; } /////////////////////////////////////////////////////////////////////////// // // SpireBb_EndObs.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to reconfigure after an engineering observation // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/05/02 V0.1: Initial version adapted from old EndObs.txt // template used in ILT; replaces old // SpireBbEndObs.txt script // 2008/11/12 V0.2: Add re-setting of Obsmode parameter to PHOT/SPEC-STBY // Values fixed for SOVT2 // /////////////////////////////////////////////////////////////////////////// // block SpireBb_EndObs SPIRE 14004 { bool phot = true; // Photometer (==tick) or FTS (==untick)? }{ // // // // // Set the BBs to SPIRE bbid: // Spire_SET_BBID($BBID); //delay(1); // // // // // Reset ObsMODE to PHOT/SPEC-STBY: // // int mode_id = ilookup("InstrumentConfigurations.txt",obsmode,"value"); if(phot) { int mode_id = 768; // Set mode back to PHOTSTBY } else { mode_id = 1024; // Set mode back to SPECSTBY } Spire_SET_OBS_MODE(mode_id); delay(1); // // // // // Set the BBID(s) back to null: // Spire_SET_BBID_RAW(0x80000000); //delay(1); // // // // // // Set the OBSIDs to null: // int null_obsid = SpireNullObsid(); Spire_SET_OBSID(null_obsid); delay(1); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireSpectro_CalGCO_FpgInitialPointing.txt // /////////////////////////////////////////////////////////////////////////// // // CUS script for: 'Spec Focal Plane Geometry (Initial Pointing)' // // in *custom_map_pointing* mode // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/11/07 V0.1: Initial version adapted from // SpirePhoto_CalGCO_FpgInitialPointing (2008/11/06 V0.11) // 2008/11/12 V0.2: Implement mode setting; Add isBright // Implement proper setting of MCU framerate // Change default gyro re-calibration period // 2009/02/19 V0.3: Add debug_print as input abd pass to low level scripts. // Replace call to SpireProc_Set_BsmFramerate with call to // SpireBb_SetBsmFramerate. Set obsStep back to zero at // FINAL_HOLD. Use new SpireBb_EndObsAll and // SpireBb_StartObsAll. Read nominal bias frequency, bias // divider, and BSM sampling rate from new // SpireTable_SpecModeParams. Implemented setting // of datarates. Implemented isBright setting. // Replace SpireBb_BsmMove2Hold with SpireBb_BsmMove. // Add safety check for off chop BSM position. Set limits // for d1 in input. Use SpireBb_SpecSetMode to set to SPECSTBY // during SLEW and FINAL_HOLD, which replaces unsetting of // framerate at end. Remove cal. table from input. // Read some VM parameters from cal. table // SpireTable_CommandLists.txt. Adapt input to updated // SpireBb_Chop. // 2009/03/03 V0.4: Add isSerendipity, isPcal, and 8 more dummy parameters // to the script for future use. // 2009/05/06 V0.5: Add in move BSM/SMEC to hold/home at start. Add new // SpireBb_SmecHold to account for the fact that // SpireBb_SmecMove2Home does not stop SMEC. // Gather procedures at start and end in separate BB. // Properly compare input BSM framerate with SPECSTBY value. // 2009/05/11 V0.6: Allow number of raster points as input. // 2009/07/17 V1.0: Change patt from 90 to 0 (SPR-SPIRE-1673) // Sunil Sidher // 2009/07/28 V1.1: Change patt from 0 to 180 (SPIRE SPR-1746) // /////////////////////////////////////////////////////////////////////////// // Script assumes that: // // 1) Instrument is in SPECSTBY // (i.e. bias amplitude, phase, frequency [mclkdiv,biasdiv] are nominal) // // 2) Bias frequency (mclkdiv) and sampling rate (biasdiv) are the same // for all three arrays and could be taken from following cal table: // SpireTable_SpecModeParams.txt // // 3) Home position of BSM can be read from SpireTable_BsmNominalSettings.txt // // 4) Some VM parameters for chopping are read from following cal table: // SpireTable_CommandLists.txt // /////////////////////////////////////////////////////////////////////////// // obs SpireSpectro_CalGCO_FpgInitialPointing { /* ****************************************************** */ /* USER PARAMETER DEFINITION, CUS SIGNATURE for EX-HSpot */ /* ****************************************************** */ double ra = 0.0 in [0.0,360.0]; // RA of target double dec = 0.0 in [-90.0,90.0]; // DEC of target int naifid = 0; //NAIF identifier: put '0' to use RA/DEC, or correct 'NAIFID' bool isBright = false; // Use settings for bright source (==tick) /* */ double raoff = 0.0 in [0.0,360.0]; // RA of GCP position double decoff = 0.0 in [-90.0,90.0]; // DEC of GCP position string ib = "S24_0"; // Central aperture (defined in SIAM) of raster int m = 5; // Number of points in raster along Y [odd number!] int n = 5; // Number of points in raster along Z [odd number!] double d1 = 4.0; // Angular stepsize between raster pts [arcsec] int ftime = 15; // Read-out time [s] double chopf = 2.0 in [0.1,4.0]; // Chop frequency [Hz] int offChopfh = 9600; // off-source chop position (+ or - relative to hold) [Dec(Hex)] double framerate = 125.0; // Specifies the MCU framerate [Hz] int gcp_time = 20; // Time spend at GCP (gyro calibration position) [s] int gcp_period = 600; // Maximum time between successiv GCP visits [s] string version01 = "v00"; // Version in cal table SpireTable_SpecModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams string version03 = "v00"; // Version in cal table SpireTable_SpecFpgInitialPointing string version05 = "v00"; // Version in cal table SpireTable_BsmNominalSettings string model = "initial"; // Model in cal table SpireTable_BsmNominalSetting bool debug = false; // Allow (==tick) or suppress cus debug_print statements bool isSerendipity = true; // Allow (==tick) serendipity mode to be activated or prohibit (==untick) it (currently not in use)? bool isPcal = true; // Allow (==tick) regular PcalFlash in script or prohibit (==untick) it (currently not in use)?. bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ // // // // // Current restrictions: // if(naifid != 0) { error("Currently no SSO objects are allowed as input!"); } // // // // // Declare some variable: // // Photometer or FTS: bool phot = false; bool fts = !phot; // string tabName = ""; string selCol = ""; string selVal = ""; string tarCol = ""; string version = ""; double scirate = 0.0; double chkrate = 0.0; double nhkrate = 0.0; // // Hardcoded calibration tables: // string tabName01 = "SpireTable_SpecModeParams.txt"; string tabName02 = "SpireTable_CommonModeParams.txt"; string tabName03 = "SpireTable_SpecFpgInitialPointing.txt"; string tabName04 = "SpireTable_CommandLists.txt"; string tabName05 = "SpireTable_BsmNominalSettings.txt"; string tabName06 = "SpireTable_SmecNominalSettings.txt"; // // Currently hardcoded version parameter: // string version06 = "v00"; // Version in cal table SpireTable_SmecNominalSettings // // Currently hardcoded parameter: // Is (==tick) the DCU currently sampled? bool dcuData = false; // bool setFramerate = true; // int tslewminadd = 0; int tfinalholdadd = 0; // int obsStep = 0; // // Start timing of script: int start = time(); // // First obsstep [HEX]: int obsstep = 0x0; // // Count raster points: int raster_counter = 0; // // Angular stepsize along Z axis [arcsec]: double d2 = d1; // NOTE: Script works only for equidistant raster points in both axes: // // DCU data mode (0 == Full photometer; 4 == Full spectrometer): int dcumode = 4; // // // // // Setup mode: // // Set obsMode for QLA: string obsModeQla = "ENG_CAL_OBS34"; // Note: this needs entry in MIB table and in SpireTableInstConfigs.txt // // Set obsMode for datarates: string obsMode = "SEngCalObs"; // Note: this is currently only a maximum value // // // // // Setup parameters for BSM chopping movement: // // Select version flag and set GetTableEntry parameters: // version = version05; tabName = tabName05; selCol = "model"; // Name of column for selecting selVal = model; // Value of 'string' selector // // Read hold position from calibration table: // tarCol = "chop_0_I"; int hold_chop = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "jigg_0_I"; int hold_jigg = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // on-source Chop position [Dec(Hex)]: int onChop = hold_chop; // on-source Jiggle position: int onJigg = hold_jigg; // off-source Chop position: int offChop = hold_chop + offChopfh; // off-source Jiggle position: int offJigg = hold_jigg; // // Check chop off position: // if(offChop > 50000) { error("Off chop is larger than 50000. Reduce offChopfh"); } // // Read VM parameters from calibration table: // tabName = tabName04; selVal = "Chop"; int vmId = ilookup(tabName,selVal,"Id"); int vmIndex = ilookup(tabName,selVal,"Index"); int nParms = ilookup(tabName,selVal,"Nparms"); // // // // // Read nominal bias frequency and bias divider: // (to determine the sampling rate) // // Select version flag and set GetTableEntry parameters: version = version01; tabName = tabName01; selCol = "mode"; // Name of column for selecting selVal = obsMode; // Value of 'string' selector // tarCol = "mclkDiv"; int mclkDiv = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // tarCol = "biasDiv"; int biasDiv = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // Read SPECSTBY framerate: // selVal = "SPECSTBY"; version = version02; tabName = tabName02; tarCol = "bsmFrameRate"; int bsmFrameRate = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); double bsmFrameRateHz = 1000000.0 / (double(bsmFrameRate) * 420.0); if(debug) { debug_print("Nominal BSM sampling rate is: " + bsmFrameRateHz + " [Hz]"); } // // Compare nominal with input BSM framerate: // int frate = SpireProc_CalcParam_BsmFramerate(framerate,debug); if(frate == bsmFrameRate) { setFramerate = false; } // // Calculate nominal sampling rate from mclkdiv and biasdiv: // double mclkDivHz = 1.0E7 / (512.0 * double(mclkDiv + 1)); double biasDivHz = 1.0 / (double(biasDiv) + 1.0) * mclkDivHz; if(debug) { debug_print("Nominal sampling rate is: " + biasDivHz + " [Hz]"); } // // // // // Compare read-out time and dwell time on GCP: // int dtime = 0; // time to be spend on GCP position if(gcp_time < ftime) { dtime = ftime; } else { dtime = gcp_time; } // // Calculate BSM chop parameters: // int[] chopparam1 = SpireProc_CalcParam_BsmSetup(ftime,chopf,biasDivHz,framerate,debug); int ncycles = chopparam1[0]; int chop_period = chopparam1[1]; int dcusample = chopparam1[2]; int dcudelay = chopparam1[3]; int bsmsample = chopparam1[4]; int[] chopparam2 = SpireProc_CalcParam_BsmSetup(dtime,chopf,biasDivHz,framerate,debug); int ncycles_2 = chopparam2[0]; int chop_period_2 = chopparam2[1]; int dcusample_2 = chopparam2[2]; int dcudelay_2 = chopparam2[3]; int bsmsample_2 = chopparam2[4]; // // // // // Read SMEC home position from calibration file: // tarCol = "Home"; tabName = tabName06; selVal = version06; int smecHomePosn = ilookup(tabName,selVal,tarCol); // // ****************************************************** */ // CALCULATE DURATIONS for POINTING STATES */ // ****************************************************** */ // // // // // Calculate timing for the pointing request: // // BBs called during slew: // int tslewmin = duration(SpireBb_StartFpgInitialPointing(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,setFramerate,frate,debug)); // // BBs carried out when the pointing is reached: // int tinithold = 0; // // BB carried out during pointing: // int tp_np = duration(SpireBb_Chop(vmId,vmIndex,nParms,onChop,onJigg,offChop,offJigg,ncycles,chop_period,dcumode,dcusample,dcudelay,bsmsample,obsstep,debug)) + duration(SpireBb_SpecOffsetAuto(dcuData,debug)); int tp_gp = duration(SpireBb_Chop(vmId,vmIndex,nParms,onChop,onJigg,offChop,offJigg,ncycles_2,chop_period_2,dcumode,dcusample_2,dcudelay_2,bsmsample_2,obsstep,debug)) + duration(SpireBb_SpecOffsetAuto(dcuData,debug)); // // BB carried out at the end: // int tfinalhold = duration(SpireBb_EndFpgInitialPointing(phot,hold_chop,hold_jigg,isBright,version01,version02,debug)); // // // // // Debug printing: if(debug) { debug_print("tslewmin = " + tslewmin); debug_print("tinithold = " + tinithold); debug_print("tpointing normal= " + tp_np); debug_print("tpointing @GCP= " + tp_gp); debug_print("tfinalhold = " + tfinalhold); } // // ****************************************************** */ // POINTING MODE DECLARATION */ // ****************************************************** */ // // // // // Fixed parameters for pointing mode: // bool fixed = false; // Pattern orientation (true==sky; false==array) double patt = 180.0; // Rotation angle of the pattern double yoffset = 0.0; // Offset of pattern in the direction of the +Y double zoffset = 0.0; // Offset of pattern in the direction of the +Z int thold = 0; // The duration of the hold when nhold>0. int nhold = 0; // Number of nods or raster points or scan lines before // // performing a hold. double pattnod = 0.0; // double chopthrow = 2.0; // int nnod = 1; // int knod = 0; // int nload = 0; // int tloadmin = 0; // // // // // // Calculate array of points: // {double[],double[],int} array = SpireProc_CalcParam_FpgInitialPointing(d1,d2,m,n,tabName03,version03,debug); double[] zarray_org = array{0}; double[] yarray_org = array{1}; int numpixel = array{2}; int nump_org = length(yarray_org); // // // // // Add GCP visit after every raster point (except first which is GCP) // and create tp (duration of fine pointing) vector new raster: // double[] yarray = [0.0]; double[] zarray = [0.0]; int run = 1; int aindex = 1; int fin = length(yarray_org); yarray[0] = yarray_org[0]; zarray[0] = zarray_org[0]; bool gcpp = false; int[] tpv = [0]; tpv[0] = tp_gp; do { if(gcpp) { yarray[aindex] = yarray_org[0]; zarray[aindex] = zarray_org[0]; tpv[aindex] = tp_gp; gcpp = false; } else { yarray[aindex] = yarray_org[run]; zarray[aindex] = zarray_org[run]; tpv[aindex] = tp_np; run = run + 1; gcpp = true; } aindex = aindex + 1; } while (run < fin); // Add GCP visit at end: yarray[aindex] = yarray_org[0]; zarray[aindex] = zarray_org[0]; tpv[aindex] = tp_gp; // // // // // if(debug) { debug_print("timing vector : " + tpv); debug_print("zarray_org: " + zarray_org); debug_print("zarray: " + zarray); } // // Calculate slew times in pointing mode: // int[] ts_tr = custom_map_pointing(false,tslewmin,tinithold,tfinalhold,ib,naifid,ra,dec,fixed,patt,yoffset,zoffset,yarray,zarray,tpv,pattnod,chopthrow,nnod,knod,tloadmin,nload,thold,nhold); // if(debug) { debug_print("Pointing vector : " + ts_tr); } // // // // // Determine maximal slew to GCP: // int nump = length(yarray); int nslews = nump; int nlslews = numpixel; int tpp = ts_tr[7]; int[] tslews = [0]; tslews[0] = 0; for(int j = 1 .. nslews - 1) { if(debug) { debug_print("entry: " + (j + 6)); } tslews[j] = ts_tr[j + 6]; } // int maxslew = 0; for(int k = 0 .. length(tslews) - 1) { maxslew = iceil(max(double(maxslew),double(tslews[k]))); } if(debug) { debug_print("nlslews: " + nlslews); debug_print("nslews: " + nslews); debug_print("tslews: " + tslews); debug_print("maxslew: " + maxslew); } // // // // // Determine slew time between small raster points: // int tppn = tslews[1]; // == slew beteen first and second raster point // // // // // Decrease frequency of GCP visits until gcp_period matched // // int kgcp = 1; int ktime = 0; int ktime_old = 0; int nslew = 0; do { ktime_old = ktime; // // Count number of slews between the mxn rasters: if(2 * kgcp + 1 > (nslew + 1) * m * n) { nslew = nslew + 1; if(debug) { debug_print("nslew: " + nslew); } } // // Calculate approximate(!) time between off visits : // [Problem: slews are not 100% predictable with single dummy run] // ktime = tp_gp + kgcp * tp_np + (kgcp - nslew) * tppn + nslew * maxslew + 2 * maxslew; // // Add safety time: // [to account for possible longer slews than in dummy run] ktime = ktime + 0; int kdiff = ktime - ktime_old; // // Print out error if gcp_period < ktime for first case // (== having a GCP after each point): if(kgcp == 1) { if(gcp_period < ktime) { if(debug) { debug_print("gcp_period < ktime: " + gcp_period + " < " + ktime); } error("gcp_period smaller than expected times between GCP visits! Change input parameters!"); } } // if(debug) { debug_print("tpv[0]: " + tpv[0]); debug_print("tp_np: " + tp_np); debug_print("tp_gp: " + tp_gp); debug_print("tppn: " + tppn); debug_print("maxslew: " + maxslew); debug_print("nslew: " + nslew); debug_print("ktime-ktime_old: " + kdiff); debug_print("ktime loop kgcp/ktime: " + kgcp + "/" + ktime); } // // // Increment kgcp (i.e delay visit to GCP by one more raster point): if(debug) { debug_print("increment kgcp by 1"); } kgcp = kgcp + 1; if(debug) { debug_print("new kgcp: " + kgcp); } // } while (ktime < gcp_period); // // Select last kgcp for which condition was fulfilled: int kgcp_old = 1; if(kgcp > 2) { kgcp_old = kgcp - 2; } message("Return to GCP after every " + kgcp_old + " normal raster point(s)!"); // if(debug) { debug_print("values after kgcp selection loop:"); debug_print("nump: " + nump); debug_print("nslews: " + nslews); debug_print("tslews: " + tslews); debug_print("maxslew: " + maxslew); debug_print("ktime loop end: " + ktime); debug_print("kgcp loop end:" + kgcp); debug_print("ktime_old: " + ktime_old); debug_print("kgcp_old:" + kgcp_old); } // // // // // Add visits to the GCP tp raster array: // int counter = 0; double[] yarray_new = [0.0]; double[] zarray_new = [0.0]; double ygcp = yarray[0]; double zgcp = zarray[0]; if(debug) { debug_print("ygcp/zgcp: " + ygcp + "/" + zgcp); debug_print("zarray: " + zarray); } // // Start loop: int end = nump_org; int ln = 0; int stop = 0; int index = 0; bool[] raster = [true]; do { if(debug) { debug_print("stop : " + stop); debug_print("end : " + end); debug_print("index : " + index); debug_print("counter: " + counter); } if(counter > kgcp_old - 1) { yarray_new[index] = ygcp; zarray_new[index] = zgcp; ln = ln + 1; counter = 0; raster[index] = false; } else { yarray_new[index] = yarray_org[index - ln]; zarray_new[index] = zarray_org[index - ln]; if(debug) { debug_print("index -ln : " + (index - ln)); } stop = stop + 1; counter = counter + 1; raster[index] = true; } index = index + 1; } while (stop < end); // // Define first point always as regular raster point: raster[0] = true; // // Add additional visit to GCP at end: // (could give unsymmetric GCP visits but ensures a GCP at start AND end) if(debug) { debug_print("index : " + index); } if(yarray_new[index - 1] != ygcp) { yarray_new[index] = ygcp; zarray_new[index] = zgcp; raster[index] = false; } // if(debug) { debug_print("# pts without GCPs: " + length(yarray_org)); debug_print("# pts with GCPs: " + length(yarray_new)); debug_print("yarray_org: " + yarray_org); debug_print("zarray_org: " + zarray_org); debug_print("yarray_new = " + yarray_new); debug_print("zarray_new = " + zarray_new); } // // Adapt tp vector to new number of points: int[] tpv_new = [0]; for(int ind = 0 .. length(yarray_new) - 1) { if(ind == 0) { tpv_new[0] = tpv[0]; } else { if(yarray_new[ind] == ygcp) { if(zarray_new[ind] == zgcp) { tpv_new[ind] = tp_gp; } else { tpv_new[ind] = tp_np; } } else { tpv_new[ind] = tp_np; } } } if(debug) { debug_print("raster vector: " + raster); debug_print("new timing vector : " + tpv_new); debug_print("length(raster): " + length(raster)); debug_print("length(yarray_new): " + length(yarray_new)); debug_print("length(tpv_new): " + length(tpv_new)); } // // // // // Set pointing mode: // //custom_map_pointing(true, tslewmin, tinithold, tfinalhold, ib, naifid, //ra,dec,fixed,patt,yoffset,zoffset,yarray,zarray,tpv, pattnod,chopthrow, //nnod,knod,tloadmin,nload, thold, nhold); // int[] ts = custom_map_pointing(true,tslewmin,tinithold,tfinalhold,ib,naifid,ra,dec,fixed,patt,yoffset,zoffset,yarray_new,zarray_new,tpv_new,pattnod,chopthrow,nnod,knod,tloadmin,nload,thold,nhold); // if(debug) { debug_print("Output timing vector from the pointing request: " + ts); } // }{ // ****************************************************** */ // POINTING STATES WITH OBSERVING MODE LOGIC */ // ****************************************************** */ // // // // // Set datarates: // string rateType = "chk"; chkrate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); ess_hk_data_rate(chkrate); // rateType = "nhk"; // nhkrate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); non_ess_hk_data_rate(nhkrate); // rateType = "sci"; scirate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); data_rate(scirate); // if(debug) { debug_print("Set CHK datarate to: " + chkrate); debug_print("Set NHK datarate to: " + nhkrate); debug_print("Set SCI datarate to: " + scirate); } // // Start the state_machine: // int[] state = [0]; // while(state[0] >= 0) { if(debug) { debug_print("Current state: " + state); } state = next_state(); if(debug) { debug_print("Next state: " + state); } // if(state[0] == 1) { // STATE = SLEW ( Spacecraft is slewing ) // // // // // Startup observation: // SpireBb_StartFpgInitialPointing(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,setFramerate,frate,debug); // //delay(timeSlewCal); } if(state[0] == 2) { // STATE = INIT_HOLD ( spacecraft is idling at source ) // // //delay(tinithold); } if(state[0] == 3) { // STATE = POINT (spacecraft is at nominal RA,DEC (staring, raster)) // //delay(tp); // // // // // Set offsets at each raster point: // SpireBb_SpecOffsetAuto(dcuData,debug); // // // // // Different timings for different raster points (normal vs. GCP): // if(raster[raster_counter] == false) { // // // // // Show time elapsed between visits to GCP: int t = time() - start; message("Time elapsed since last visit to GCP: " + t); if(debug) { debug_print("Time elapsed since last visit to GCP: " + t); } // if(t > gcp_period) { error("Elapsed time between GCP visits larger than gcp_period! Change input parameters."); } // // Reset timer: start = time(); // // // // // Run chop VM (includes data taking) and set obs step parameter: // SpireBb_Chop(vmId,vmIndex,nParms,onChop,onJigg,offChop,offJigg,ncycles_2,chop_period_2,dcumode,dcusample_2,dcudelay_2,bsmsample_2,65535,debug); // } else { // // // // // Reset timing at first raster point: if(obsstep == 0) { start = time(); } // // // // // Run chop VM (includes data taking) and set obs step parameter: // SpireBb_Chop(vmId,vmIndex,nParms,onChop,onJigg,offChop,offJigg,ncycles,chop_period,dcumode,dcusample,dcudelay,bsmsample,obsstep,debug); obsstep = obsstep + 1; // } raster_counter = raster_counter + 1; // } if(state[0] == 5) { // STATE = FINAL_HOLD ("sky" observation ends, performing final activities ) // // // // // Set scientific datarate back to zero: // data_rate(0.0); // // // // // Reconfigure at the end (incl. resetting of OBSID and BBIB): // SpireBb_EndFpgInitialPointing(phot,hold_chop,hold_jigg,isBright,version01,version02,debug); // } if(state[0] == -1) { // STATE = END (end of the pointing/commanding part of the code) // } } } /////////////////////////////////////////////////////////////////////////// // // SpireProc_Exec_Serendipity.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to execute a serendipity observation // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/11/12 V0.1: Initial version // 2009/03/16 V1.0: Adapt to changed in calls to SpireBb_StartDcuData and // SpireBb_Serendipity. Remove datamode from input. // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Exec_Serendipity { int ttime = 0; // Total time available for serendipity bool debug = true; // Print debug information }{ // // // // // Start DCU data before: // SpireBb_StartDcuData(); // // // // // // Start serendipity waiting: // // Calculate remaining time: int dcu1 = duration(SpireBb_StartDcuData()); int dcu2 = duration(SpireBb_StopDcuData()); if(ttime > dcu1 + dcu2) { int wtime = ttime - dcu1 - dcu2; } else { wtime = 0; } SpireBb_Serendipity(wtime,debug); // if(debug) { debug_print("Serendipity observation done, wtime = " + wtime); } // // // // // Stop DCU data before: // SpireBb_StopDcuData(); // } /////////////////////////////////////////////////////////////////////////// // $Id:$ /////////////////////////////////////////////////////////////////////////// // // SpirePhoto_Cal_BsmAngleCal.txt // /////////////////////////////////////////////////////////////////////////// // // CUS script for: 'Phot BSM Angle Calibration' // // in *basic_fine_pointing* mode or *no_pointing* mode // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/09/10 V0.1: Initial version // 2008/10/13 V0.2: Adapt to name change of calibration file. // 2008/11/07 V0.3: Change description of bool input. Adapt to // change in low level script. // 2008/11/12 V0.4: Implement mode setting; Add isBright // 2008/12/10 V0.5: Modify unreasonable default values of ref pos; // Correct pass-on of chop/fts parameter to low level script; // Correct typo in input description // 2009/01/27 V1.0: Change call to SpireBb_BsmMove2Hold. Add fixed ranges for // input chop/jiggle position and add safety check pos1= 0) { if(debug) { debug_print("Current state: " + state); } state = next_state(); if(debug) { debug_print("Next state: " + state); } // if(state[0] == 1) { // STATE = SLEW ( Spacecraft is slewing ) // // // // // Startup observation: // SpireBb_StartBsmAngleCal(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,framerate,smecHomePosn,debug); // } if(state[0] == 2) { // STATE = INIT_HOLD ( spacecraft is idling at source ) // // // // // If no pointing observation do stuff here which is // done nominally during SLEW: // if(!pointing) { // // // // // Startup observation: // SpireBb_StartBsmAngleCal(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,framerate,smecHomePosn,debug); // } // // // // // Set offsets: // SpireBb_PhotOffsetAuto(debug); // //delay(tinithold); // } if(state[0] == 3) { // STATE = POINT ( spacecraft is at nominal RA,DEC (staring, raster) ) // // // // // // Execute BSM angle calibration: // SpireProc_Exec_BsmAngleCal(increment,ref_chop,ref_jigg,hold_chop,hold_jigg,max_chop,max_jigg,min_chop,min_jigg,vmId,vmIndex,nParms,chopf,ftime,framerate,biasdivHz,fts,chop,debug); // //delay(tp); // } if(state[0] == 5) { // STATE = FINAL_HOLD ( "sky" observation ends, performing final activ.) // // // // // Set scientific datarate back to zero: // data_rate(0.0); // // // // // Reconfigure at the end (incl. resetting of OBSID and BBIB): // // Hardcode STBY values for resetting (SPR-1477): // version01 = "v00"; version02 = "v00"; version03 = "v00"; model = "initial"; // SpireBb_EndBsmAngleCal(phot,hold_chop,hold_jigg,isBright,version01,version02,debug); } if(state[0] == -1) { // STATE = END ( end of the pointing/commanding part of the code ) // } } } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_Set_ObsStep.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to set OBS_STEP parameter in observing mode // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/07/04 V0.1: Initial version // 2008/07/24 V0.2: Remove restriction of step value to 0-255 // 2009/01/27 V1.0: Add debug_print option. // 2009/02/02 V1.1: Merge with Ken's SpireSetObsStep, i.e add Hspot messages. // Replace delay(1) at end with sync() // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Set_ObsStep { int obsStep = 0; // Obs step parameter [dec] bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Declare some variable: // // A hex string: string hstr = ""; // // A time string: string tstr = ""; // // // // // Set obsstep: // hstr = SpireHexStr(obsStep,4); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP_RAW(" + hstr + ")"); Spire_SET_OBS_STEP_RAW(obsStep); sync(); if(debug) { debug_print("The obsstep is: " + obsStep); } // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_CalcParam_IsBrightPhaseShift.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to calculate phase shift for isBright and make sure // the phase is wrapped at boundaries in case. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/03/04 V0.1: Initial version adapted from // SpireProc_CalcParam_PhaseUp (2009/02/01 V1.0) // /////////////////////////////////////////////////////////////////////////// // int procedure SpireProc_CalcParam_IsBrightPhaseShift { int inputPhase = 0 in [0,255]; // Input (nominal) phase int phaseShift = -50 in [-255,255]; // Phase shift bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Declare some variable: // int low_limit = 0; int high_limit = 255; int k = 0; // // // // // Calculate shift: // int outputPhase = inputPhase + phaseShift; // // // // // Check if phase is 0 <= phase <= 255: // if(outputPhase < low_limit) { k = 1; } else { if(outputPhase > high_limit) { k = -1; } else { k = 0; } } if(debug) { debug_print("The value of k is :" + k); } // // Adapt raw phase list if outside 0 <= phase <= 255: // outputPhase = outputPhase + k * 255; // if(debug) { debug_print("Input raw phase [Dec(Hex)]: " + inputPhase); debug_print("Applied phase shift [Dec(Hex)]: " + phaseShift); debug_print("Output raw phase [Dec(Hex)]: " + outputPhase); } // return outputPhase; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_CalcParam_SpecDataRates.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to retrive the datarate from the associated calibration table // for a given spectrometer mode. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/02/19 V1.0: Initial version adapted from // SpireProc_CalcParam_PhotDataRates (2009/02/15 V1.0) // 2009/05/05 V1.1: Change calibration table where HK are read. // /////////////////////////////////////////////////////////////////////////// // double procedure SpireProc_CalcParam_SpecDataRates { string rateType = "chk" in ["chk","nhk","sci"]; // Data rate to be read string obsMode = "Scan"; // Parameter to specify the configuration mode string version01 = "v00"; // Version in cal table SpireTable_SpecModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Define some variable: // double rate = 0.0; // Name of column for selecting: string selCol = "mode"; // Value of 'string' selector: string selVal = obsMode; // Target column name: string tarCol = ""; string version = ""; // // Hardcoded calibration tables: // string tabName = ""; string tabName01 = "SpireTable_SpecModeParams.txt"; string tabName02 = "SpireTable_CommonModeParams.txt"; string tabName03 = "SpireTable_DefaultParams.txt"; // // Hardcoded version + mode name: // string version03 = "v00"; // Version in cal table SpireTable_DefaultParams string selValHk = "SPECSTBY"; // // // // // Select and set rate: // if(rateType == "chk") { tabName = tabName03; version = version03; tarCol = "chkDataRate"; double chkrate = SpireProc_GetTableEntryDouble(tabName,selCol,selValHk,tarCol,version,debug); rate = chkrate; } // if(rateType == "nhk") { tabName = tabName03; version = version03; tarCol = "nhkDataRate"; double nhkrate = SpireProc_GetTableEntryDouble(tabName,selCol,selValHk,tarCol,version,debug); rate = nhkrate; } // if(rateType == "sci") { string[] tarColSci = ["dcuDataRate","smecDataRate","bsmDataRate","scuDataRate","dpuDataRate"]; double scirate = 0.0; double scirate2add = 0.0; for(int i = 1 .. 5) { tarCol = tarColSci[i - 1]; if(tarCol == "dcuDataRate") { tabName = tabName01; version = version01; } else { if(tarCol == "smecDataRate") { tabName = tabName01; version = version01; } else { tabName = tabName02; version = version02; } } scirate2add = SpireProc_GetTableEntryDouble(tabName,selCol,selVal,tarCol,version,debug); scirate = scirate + scirate2add; if(debug) { debug_print("Reading target column " + tarCol + " with scirate " + scirate2add); debug_print("The new scirate is: " + scirate); } } rate = scirate; } // // // // // Return required rate: // if(debug) { debug_print("The " + rateType + " rate is: " + rate + " [kbps]"); } return rate; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_CalcParam_FpgInitialPointing.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to calculate the positions of x small mxn point rasters. // The positions of the x pixels are read from a calibration table. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/07/25 V0.1: Initial version // 2008/07/28 V0.2: Change sequence of visiting the raster points // 2008/11/06 V0.3: Move calibration table to input to use same script // for FTS // 2009/02/02 V1.0: Add debug_print as input // /////////////////////////////////////////////////////////////////////////// // {double[],double[],int} procedure SpireProc_CalcParam_FpgInitialPointing { double d1 = 4.0 in [2.0,480.0]; // Angular stepsize along Y axis [arcsec] double d2 = 4.0 in [2.0,480.0]; // Angular stepsize along Z axis [arcsec] int m = 5; // Number of points in a raster line [odd number!] int n = 5; // Number of raster lines or scan lines [odd number!] string pixels = "SpireTable_PhotFpgInitialPointing.txt"; // Table with pixel coordinates relative to boresight string version = "v00"; // Version parameter defined in calibration table bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Read distance pixel2center from calibration table: // // Read in table columns: string tabName = pixels; // Table of pixels string[] versionCol = scolumn(tabName,"version"); double[] y_distCol = dcolumn(tabName,"y_dist"); double[] z_distCol = dcolumn(tabName,"z_dist"); string[] pixelCol = scolumn(tabName,"pixel"); // // Read table size: int nrows = table_size(tabName); // // // // // Cycle through values to get all rows with correct version tag: // // Setup: {double,double,string}[] rows = [{0.0,0.0,""}]; int nindex = 0; bool match = false; // for(int j = 0 .. nrows - 1) { if(debug) { debug_print("versionCol[j]: " + versionCol[j]); } if(versionCol[j] == version) { rows[nindex] = {y_distCol[j],z_distCol[j],pixelCol[j]}; nindex = nindex + 1; match = true; } } // if(!match) { error("Calibration table empty or wrong version selected!"); } // // // Number of pixels to visit: int numpix = length(rows); if(debug) { debug_print("rows: " + rows); } // // // // // Assign pixel to base pointing array: // double[] dpr = [0.0]; double[] dpc = [0.0]; int size = length(rows); for(int jay = 0 .. size - 1) { dpr[jay] = rows[jay]{1}; dpc[jay] = rows[jay]{0}; if(debug) { debug_print("y_dist :" + rows[jay]{0}); debug_print("z_dist :" + rows[jay]{1}); } } // // number of points in small raster: int npoints = size; int cs = -1 * iround(0.5 * (double(m) - 1.0)); int ls = -1 * iround(0.5 * (double(n) - 1.0)); double colu = 0.0; double rowd = 0.0; double basecol = 0.0; double baserow = 0.0; double[] yarray = [0.0]; double[] zarray = [0.0]; int index = 0; // for(int i = 0 .. npoints) { bool odd = true; if(debug) { debug_print("Map point :" + i); } for(int row = ls .. ls + (n - 1)) { row = row * 1; if(debug) { debug_print("row: " + row); } rowd = double(row) * d1 + baserow; for(int col = cs .. cs + (m - 1)) { col = col * -1; if(debug) { debug_print("col: " + col); } if(odd) { colu = double(col) * d2; } else { colu = -1.0 * double(col) * d2; } colu = colu + basecol; if(debug) { debug_print("row: " + rowd + " col: " + colu); } zarray[index] = rowd; yarray[index] = colu; index = index + 1; } if(odd) { odd = false; } else { odd = true; } } if(i < npoints) { baserow = dpr[i]; basecol = dpc[i]; } } if(debug) { debug_print("zarray = " + zarray); debug_print("yarray = " + yarray); debug_print("Number of points: " + length(zarray)); } // return {zarray,yarray,numpix}; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_Exec_PcalLevelCheck.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to execute sequence of PCAL flashes with given input parameters. // Note: Needs correct setting of dcusamples, scusamples, and dcudelay! // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/08/12 V0.1: Initial version copied/renamed from // SpireProc_Exec_PhotPcalLevelCheck.txt (2008/06/11 V0.1) // based on // SpireProc_Exec_PhotIltPcalFlash.txt (2008/05/02 V0.1) // Rename script, remove 'Phot', change default // 2008/11/07 V0.2: Adapt to change in name of low level script // 2009/02/02 V1.0: Add debug_print as input and pass it to low level script. // Adapt input to updated SpireBb_PcalFlash with rate as // input and step set in loop. Add setting of NHK STEP // parameter. // 2009/02/18 V1.1: Adapt to change in call to SpireBb_PcalFlash. // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Exec_PcalLevelCheck { int vmId = 0x46; // Raw VM table number int vmIndex = 0; // Raw VM index int nParms = 9; // Number of parameters passed to VM int[] raw_low_bias = [0,0,0]; // Raw low bias PCAL level list int[] raw_high_bias = [0,1111,2176]; // Raw high bias PCAL level list int ncycles = 15; // Number of cycles int period = 4000; // Period of cycle [millisec] int ndcumode = 0; // DCU data mode (default = PF) int dcusamples = 38; // Number of DCU and SCU samples, and DCU sample delay mclkdiv/biasdivi (149/6) int dcudelay = 10880; // Number of DCU and SCU samples, and DCU sample delay mclkdiv/biasdiv (149/6) int scumode = 0; // SCU sampling rate (f =80Hz/(1+scumode)) int scusamples = 0; // Number of DCU and SCU samples, and DCU sample delay mclkdiv/biasdiv (149/6) bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Loop of PCAL flashes with increasing high bias level: // int microperiod = period * 1000; for(int j = 0 .. length(raw_high_bias) - 1) { // // // // // Set STEP: // int obsStep = j + 1; // NHK Step parameter if(j == 1) { if(debug) { debug_print("First obsStep already set during slew"); } } else { SpireBb_SetObsStep(obsStep,debug); } SpireBb_PcalFlash(vmId,vmIndex,nParms,raw_low_bias[j],raw_high_bias[j],ncycles,microperiod,ndcumode,dcusamples,dcudelay,scumode,scusamples,obsStep,debug); if(debug) { debug_print("PCAL bias level finished: " + raw_high_bias[j]); } } // } // SpireBbObsConfig // // $Id: SpireBbObsConfig.txt,v 1.2 2007/10/26 10:20:21 kking Exp $ // // Building Block to configure an observation // // 22 Oct 2007: // Add delay of 1 sec before setting OBSID to allow time for busconfig to be performed // // block SpireBbObsConfig SPIRE 12033 { int obsMode = 0; }{ int t = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB Obs Config started"); SpireMsg(2," $Id: SpireBbObsConfig.txt,v 1.2 2007/10/26 10:20:21 kking Exp $"); hstr = SpireHexStr($BBID,8); SpireMsg(3," BBID = " + hstr); hstr = SpireHexStr(obsMode,4); SpireMsg(3," MODE = " + hstr); // // Wait for busconfig to be performed delay(1); // // set OBSID hstr = SpireHexStr($OBSID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + " Cmd: Spire_SET_OBSID_RAW(" + hstr + ")"); Spire_SET_OBSID_RAW($OBSID); // // set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // Set Mode hstr = SpireHexStr(obsMode,4); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_MODE_RAW(" + hstr + ")"); Spire_SET_OBS_MODE_RAW(obsMode); // // set STEP to zero tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP_RAW(0x0000)"); Spire_SET_OBS_STEP_RAW(0x0); // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB Obs Config ended"); SpireMsg(1," ..Observation Configuration (" + (time() - t) + " secs)"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_EndStdLoadCurve.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to reconfigure at the end of // SpirePhoto/Spectro_Cal_StdLoadCurve. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // // 2009/05/05 V1.0: Initial version adapted from // SpireBb_EndBsmAngleCal (2009/05/05 V1.2), // SpirePhoto_Cal_StdLoadCurve (2009/03/04 V1.3), and // SpireSpectro_Cal_StdLoadCurve (2009/03/04 V0.5) // /////////////////////////////////////////////////////////////////////////// // block SpireBb_EndStdLoadCurve SPIRE 14051 { bool phot = true; // Photometer (==tick) or FTS (==untick)? bool isBright = false in [true,false]; // IsBright (==tick) flag string version01 = "v00"; // Version in cal.tab. SpireTable_PhotModeParams string version02 = "v00"; // Version in cal.tab. SpireTable_CommonModeParams bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // int mode_id = 0; string obsmode = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB EndStdLoadCurve reconfiguration started"); SpireMsg(2," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Set instrument back to Phot/Spec-STBY: // if(phot) { SpireProc_Set_PhotMode("PHTSTBY",isBright,version01,version02,debug); } else { SpireProc_Set_SpecMode("SPECSTBY",isBright,version01,version02,debug); } // // // // // End observation: // SpireProc_Set_EndObsAll(phot); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB EndStdLoadCurve reconfiguration ended"); SpireMsg(1," ..Reconfiguration to " + obsmode + "mode (" + (time() - t) + " seconds)"); // } // SpireBbPOF3End // // $Id:$ // // Building Block to reconfigure the instrument to PHOT_STBY mode from POF3 (jiggle map) mode // // 11 Feb 2008: KK removed resetting of OBSID and BBISD as they are // now done in SpireBb_EndObsAll // 14 Feb 2009: MP peplace calls to SpireProc_Set_PhotPhase/Bias with // call to SpireProc_Set_PhotBright // 03/07/2009 KJK: // - Replaced version input parameter with photVersion and comVersion // - Replaced call to Proc_SetPhotBRight with Proc_SetPhotMode to reset the // detectors if bright setting has been used // 28/07/2009 SDS: // - Added chopVersion input parameter to allow setting of the Chop PID parameters back // to their nominal values (model = "initial"). // block SpireBbPOF3End SPIRE 8242 { string obsMode = "PHTSTBY"; bool isBright = false in [true,false]; string photVersion = "v00"; string comVersion = "v00"; string chopVersion = "v00"; bool debug = false in [true,false]; }{ int t = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB POF3 Reconfiguration started"); SpireMsg(2," $Id:$"); // // ..... configuration ..... // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // set STEP to zero tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP_RAW(0x0000)"); Spire_SET_OBS_STEP_RAW(0x0); // // Move BSM to HOLD int bsmHoldChopPosn = ilookup("BSM.txt","Hold","ChopPosn"); int bsmHoldJiggPosn = ilookup("BSM.txt","Hold","JiggPosn"); SpireBsmMove(bsmHoldChopPosn,bsmHoldJiggPosn); // string tabName = "SpireTable_BsmNominalSettings.txt"; string tarCol = "chop_kp"; int chopkp = SpireProc_GetTableEntryInt(tabName,"model","initial",tarCol,chopVersion,debug); tarCol = "chop_ki"; int chopki = SpireProc_GetTableEntryInt(tabName,"model","initial",tarCol,chopVersion,debug); tarCol = "chop_kd"; int chopkd = SpireProc_GetTableEntryInt(tabName,"model","initial",tarCol,chopVersion,debug); // // // // // Set PID parameters back to nominal (STBY) values: // SpireProc_Set_BsmChopPid(chopkp,chopki,chopkd,debug); // // // // // // reset bright-source biases and phases - if needed // if(isBright) { SpireProc_Set_PhotMode(obsMode,isBright,photVersion,comVersion,debug); } // // ..... completion ..... // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB POF3 Reconfiguration ended"); SpireMsg(1," ..POF3 Reconfiguration to PHT_STBY mode (" + (time() - t) + " seconds)"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_CalcParam_PhotBiasConvert.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to translate user input in mV for bias amplitude // into nearest Hex values for psw_bias, pmw_bias, plw_bias, and ptc_bias // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/05/07 V0.1: Initial version adapted from // Proc_BiasConvertP (v1.4 2008/01/31 20:24:35) // 2008/05/07 V0.2: Add correct upper bias limit, expand printing // 2008/06/09 V0.3: Calculate conversion for each array seperately // 2008/07/03 V0.4: Renumber version; convert also PTC bias // 2009/02/01 V1.0: Add debug_print as input // /////////////////////////////////////////////////////////////////////////// int[] procedure SpireProc_CalcParam_PhotBiasConvert { double input_bias_psw = 0.0 in [0.0,127.813]; // Input PSW Bias amplitude [0.0 - 129.159] [mV] double input_bias_pmw = 0.0 in [0.0,128.625]; // Input PMW Bias amplitude [0.0 - 129.159] [mV] double input_bias_plw = 0.0 in [0.0,129.159]; // Input PLW Bias amplitude [0.0 - 129.159] [mV] double input_bias_ptc = 0.0 in [0.0,254.265]; // Input PTC Bias amplitude [0.0 - 254.265] [mV] bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Predefine version: // string ver_psw = "v01"; string ver_pmw = "v01"; string ver_plw = "v01"; string ver_ptc = "v01"; //debug_print("The nominal version is v01"); // // // // // Retrieve the maximum bias amplitude: // double maxbias_psw = dlookup("SpireTable_PhotPswMaxbias.txt",ver_psw,"maxbias"); double maxbias_pmw = dlookup("SpireTable_PhotPmwMaxbias.txt",ver_pmw,"maxbias"); double maxbias_plw = dlookup("SpireTable_PhotPlwMaxbias.txt",ver_plw,"maxbias"); double maxbias_ptc = dlookup("SpireTable_PhotPtcMaxbias.txt",ver_ptc,"maxbias"); // // // // // Convert from mV to RAW values: // double conversion_factor_psw = 255.0 / maxbias_psw; double conversion_factor_pmw = 255.0 / maxbias_pmw; double conversion_factor_plw = 255.0 / maxbias_plw; double conversion_factor_ptc = 255.0 / maxbias_ptc; // int raw_bias_psw = iround(conversion_factor_psw * input_bias_psw); int raw_bias_pmw = iround(conversion_factor_pmw * input_bias_pmw); int raw_bias_plw = iround(conversion_factor_plw * input_bias_plw); int raw_bias_ptc = iround(conversion_factor_ptc * input_bias_ptc); // // Safety check: if(raw_bias_psw > 255) { raw_bias_psw = 255; if(debug) { debug_print("PSW exceeded limit!"); } } if(raw_bias_pmw > 255) { raw_bias_pmw = 255; if(debug) { debug_print("PMW exceeded limit!"); } } if(raw_bias_plw > 255) { raw_bias_plw = 255; if(debug) { debug_print("PLW exceeded limit!"); } } if(raw_bias_ptc > 255) { raw_bias_ptc = 255; if(debug) { debug_print("PTC exceeded limit!"); } } // double bias_psw = double(raw_bias_psw) / conversion_factor_psw; double bias_pmw = double(raw_bias_pmw) / conversion_factor_pmw; double bias_plw = double(raw_bias_plw) / conversion_factor_plw; double bias_ptc = double(raw_bias_ptc) / conversion_factor_ptc; // // // // // Debug printout: // if(debug) { debug_print("Input mV value for PSW/PMW/PLW/PTC bias amplitude: " + input_bias_psw + "/" + input_bias_pmw + "/" + input_bias_plw + "/" + input_bias_ptc); debug_print("Output Hex values for PSW/PMW/PLW/PTC: " + raw_bias_psw + "/" + raw_bias_pmw + "/" + raw_bias_plw + "/" + raw_bias_ptc); debug_print("Commanded mV values for PSW/PMW/PLW/PTC: " + bias_psw + "/" + bias_pmw + "/" + bias_plw + "/" + bias_ptc); } // // // // // Return required values: // return [raw_bias_psw,raw_bias_pmw,raw_bias_plw,raw_bias_ptc]; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireSpectro_Cal_PcalLevelCheck.txt // /////////////////////////////////////////////////////////////////////////// // // CUS script for: 'Spec PCAL Level Ceck' // // in *basic_fine_pointing* or *no_pointing* mode // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/08/12 V0.1: Initial version adapted from // SpirePhoto_Cal_PcalLevelCheck (2008/08/12 V0.4) // based on // Mode_ILT_PERF_CPT_S (v 1.4 2008/01/31 20:24:33) // 2008/11/11 V0.2: Allow 'no pointing' as input option; Adapt debug printing // 2008/11/12 V0.3: Implement mode setting; Add isBright // Change 'no pointing' implementation // 2009/02/19 V0.4: Add debug_print as input and pass it to some low // level scripts. Add setting of NHK STEP parameter // in SpireProc_Exec_PcalLevelCheck. Set first STEP // already during SLEW and unset at end during INIT_HOLD. // Use new SpireBb_EndObsAll and SpireBb_StartObsAll. // Read nominal bias frequency and bias divider from new // SpireTable_SpecModeParams. Implemented setting // of datarates. Implemented isBright (+!pointing) setting. // Use SpireBb_SpecSetMode to set to SPECSTBY during // SLEW and FINAL_HOLD. Read boresight/set from // SpireTable_OpsParms. Read Pcal levels from new calibration // table. Read VM table parameters now from a cal. table. // Adapt to change in call to SpireProc_Exec_PcalLevelCheck. // 2009/03/04 V0.5: Add isSerendipity, isPcal, and 8 more dummy parameters // to the script for future use. Allow isBright for no // pointing observation. // 2009/05/07 V0.6: Add in move BSM/SMEC to hold/home at start. Add new // SpireBb_SmecHold to account for the fact that // SpireBb_SmecMove2Home does not stop SMEC. // Gather procedures at start and end in separate BB. // 2009/05/11 V0.7: Elevate Pcal flash period and number of cycles to input. // /////////////////////////////////////////////////////////////////////////// // // Script assumes that: // // 1) Instrument is in SPECSTBY at beginning // (i.e. bias amplitude, phase, frequency [mclkdiv,biasdiv] are nominal) // // 2) Nominal bias frequency and sampling rate are read from // following calibration tables: SpireTable_SpecModeParams.txt // // 3) PCAL bias calibration coefficients are read from following cal table: // SpireTable_PcalCurrentConvCoef.txt // // 4) Boresight of array are read from following cal table: // SpireTable_OpsParms.txt // /////////////////////////////////////////////////////////////////////////// // obs SpireSpectro_Cal_PcalLevelCheck { /* ****************************************************** */ /* USER PARAMETER DEFINITION, CUS SIGNATURE for EX-HSpot */ /* ****************************************************** */ /* */ double ra = 0.0 in [0.0,360.0]; // RA of target double dec = 0.0 in [-90.0,90.0]; // DEC of target bool isBright = false; // Use settings for bright source (==tick) bool pointing = true; // Should telescope 'point' (==tick) or do a 'no pointing' (==untick)? /* */ int period = 4000; // PCAL Flash *FULL* period (high+low bias) [millisec] int ncycles = 15; // PCAL Flash Number of cycles string version01 = "v00"; // Version in cal table SpireTable_PhotModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams string version03 = "v00"; // Version in cal table SpireTable_PcalLevelCheckLevels string version05 = "v00"; // Version in cal table SpireTable_OpsParms.txt bool debug = false; // Allow (==tick) or suppress cus debug_print statements bool isSerendipity = true; // Allow (==tick) serendipity mode to be activated or prohibit (==untick) it (currently not in use)? bool isPcal = true; // Allow (==tick) regular PcalFlash in script or prohibit (==untick) it (currently not in use)?. bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ // // // // // Declare some variable: // // Photometer or FTS: bool phot = false; bool fts = !phot; // string tabName = ""; string selCol = ""; string selVal = ""; string tarCol = ""; string version = ""; double scirate = 0.0; double chkrate = 0.0; double nhkrate = 0.0; // int obsStep = 0; // // Hardcoded calibration tables: // string tabName01 = "SpireTable_SpecModeParams.txt"; string tabName02 = "SpireTable_CommonModeParams.txt"; string tabName03 = "SpireTable_PcalLevelCheckLevels.txt"; string tabName04 = "SpireTable_CommandLists.txt"; string tabName05 = "SpireTable_OpsParms.txt"; string tabName06 = "SpireTable_BsmNominalSettings.txt"; string tabName09 = "SpireTable_SmecNominalSettings.txt"; // // Currently hardcoded version parameter: // string version09 = "v00"; // Version in cal table SpireTable_SmecNominalSettings string version06 = "v00"; // Version in cal table SpireTable_BsmNominalSettings string model = "initial"; // Model in cal table SpireTable_BsmNominalSettings // // Currently hardcoded parameter: // Is (==tick) the DCU currently sampled? bool dcuData = false; // // // // // Setup mode: // // Set obsMode for QLA: string obsModeQla = "ENG_CAL_OBS38"; // Note: this needs entry in MIB table and in SpireTableInstConfigs.txt // // Set obsMode for datarates: string obsMode = "SEngCalObs"; // Note: this is currently only a maximum value // // // // // Read BSM home parameters: // // Select version flag and set GetTableEntry parameters: // version = version06; tabName = tabName06; selCol = "model"; // Name of column for selecting selVal = model; // Value of 'string' selector // // Read hold position from calibration table: // tarCol = "chop_0_I"; int hold_chop = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "jigg_0_I"; int hold_jigg = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // // // // Read SMEC home position from calibration file: // tarCol = "Home"; tabName = tabName09; selVal = version09; int smecHomePosn = ilookup(tabName,selVal,tarCol); // // ****************************************************** */ // CALCULATE DURATIONS for POINTING STATES */ // ****************************************************** */ // // // // // Read nominal bias frequency and bias divider: // // Select version flag and set GetTableEntry parameters: version = version01; tabName = tabName01; selCol = "mode"; // Name of column for selecting selVal = obsMode; // Value of 'string' selector // tarCol = "mclkDiv"; int mclkdiv = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "biasDiv"; int biasdiv = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // Calculate nominal sampling rate from mclkdiv and biasdiv: // double mclkdivHz = 1.0E7 / (512.0 * double(mclkdiv + 1)); double biasdivHz = 1.0 / (double(biasdiv) + 1.0) * mclkdivHz; if(debug) { debug_print("Nominal sampling rate is: " + biasdivHz + " [Hz]"); } // // // // // // Read VM parameters from calibration table: // tabName = tabName04; selVal = "Flash"; int vmId = ilookup(tabName,selVal,"Id"); int vmIndex = ilookup(tabName,selVal,"Index"); int nParms = ilookup(tabName,selVal,"Nparms"); // // // // // Initialize PCAL variables with their default values: // // PCAL Flash FULL period (high and low bias) in millisec: // int period = 4000; // // Number of cycles: // V0.2: int ncycles = 7; // from V0.3 on: // int ncycles = 15; // // --> PCAL setup parameters now in calibration file or input parameters. // // DCU data mode (default = PF == 0; SF == 4) int ndcumode = 4; // // SCU sampling rate (f =80Hz/(1+scumode)) int scumode = 0; // // // // // Define/retrieve the list of PCAL biases for each of the flashes in mA: // double[] low_bias = [0.0]; // V0.2: //double[] high_bias = [1.0,2.0,3.0,4.0,5.0,6.0,7.0]; // V0.3: //double[] high_bias = [0.35,0.7,1.05,1.4,1.75,2.1,2.45,2.8,3.15,3.5,3.85,4.2,4.55,4.9,5.25,5.6,5.95,6.3,6.65,7.0]; // double[] high_bias = []; int index = 0; tabName = tabName03; selCol = "version"; selVal = version03; tarCol = "level"; string[] searchCol = scolumn(tabName,selCol); double[] targetCol = dcolumn(tabName,tarCol); int size = table_size(tabName); // // Loop through table to find matching entries: // for(int j = 0 .. size - 1) { if(searchCol[j] == selVal) { high_bias[index] = targetCol[j]; index = index + 1; } } // // Safety check: // if(length(high_bias) == 0) { error("No PCAL bias level selected! Check version with entries in calibration table SpireTable_PcalLevelCheckLevels.txt"); } // // // // // Predefine version in SpireTable_PcalCurrentConvCoef.txt: // string ver_b = "v01"; if(debug) { debug_print("The nominal version in SpireTable_PcalCurrentConvCoef.txt is v01"); } // // // // // Retrieve PCAL bias calibration coefficients: // double[] coeff = [0.0]; coeff[0] = dlookup("SpireTable_PcalCurrentConvCoef.txt",ver_b,"c_0"); coeff[1] = dlookup("SpireTable_PcalCurrentConvCoef.txt",ver_b,"c_1"); // // // // // Calculate RAW PCAL bias values for each of the flashes from mA list: // int[] raw_low_bias = [0]; int[] raw_high_bias = [0]; for(int i = 0 .. length(high_bias) - 1) { raw_low_bias[i] = 0; raw_high_bias[i] = iround((high_bias[i] * 0.0010 - coeff[0]) / coeff[1]); } if(debug) { debug_print("High bias levels in mA are: " + high_bias); debug_print("Raw high bias levels to check are: " + raw_high_bias); debug_print("Raw low bias level to check is: " + raw_low_bias); } // // // // // Deduce number of DCU samples, SCU samples and DCU sample delay based on mclkdiv and biasdiv: // int[] flash_params = SpireProc_CalcParam_PcalFlash(period,mclkdiv,biasdiv,debug); int dcusamples = flash_params[0]; int scusamples = flash_params[1]; int dcudelay = flash_params[2]; if(debug) { debug_print("//////////////////////////////////////////////////////////////"); debug_print(""); debug_print("CALCULATED DCU SAMPLES : " + dcusamples); debug_print("CALCULATED SCU SAMPLES : " + scusamples); debug_print("CALCULATED SAMP DELAY : " + dcudelay + "microsec"); debug_print(""); debug_print("//////////////////////////////////////////////////////////"); } // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // Calculate timing for the pointing request: // // BBs called during slew: int tslewmin = duration(SpireBb_StartPcalLevelCheck(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,debug)); // // BBs carried out when the pointing is reached: if(pointing) { int tinithold = duration(SpireBb_SpecOffsetAuto(dcuData,debug)); } else { tinithold = duration(SpireBb_SpecOffsetAuto(dcuData,debug)) + tslewmin; } // // BB carried out during pointing: int tp = duration(SpireProc_Exec_PcalLevelCheck(vmId,vmIndex,nParms,raw_low_bias,raw_high_bias,ncycles,period,ndcumode,dcusamples,dcudelay,scumode,scusamples,debug)); // // BB carried out at the end: int tfinalhold = duration(SpireBb_EndPcalLevelCheck(phot,isBright,version01,version02,debug)); // if(debug) { debug_print("tslewmin = " + tslewmin); debug_print("tinithold = " + tinithold); debug_print("tpointing = " + tp); debug_print("tfinalhold = " + tfinalhold); } // // ****************************************************** */ // POINTING MODE DECLARATION */ // ****************************************************** */ // // // // // Lookup boresight: // tabName = tabName05; selCol = "mode"; selVal = obsMode; tarCol = "Boresight"; version = version05; string ib = SpireProc_GetTableEntryString(tabName,selCol,selVal,tarCol,version,debug); // // // // // Set pointing mode: // if(pointing) { int[] ts = basic_fine_pointing(true,tslewmin,tinithold,tfinalhold,ib,0,ra,dec,0.0,0.0,tp); } else { ts = no_pointing(true,tinithold,tfinalhold,tp); } // if(debug) { debug_print("Output timing vector from the pointing request: " + ts); } // }{ // ****************************************************** */ // POINTING STATES WITH OBSERVING MODE LOGIC */ // ****************************************************** */ // // // // // Set datarates: // string rateType = "chk"; chkrate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); ess_hk_data_rate(chkrate); // rateType = "nhk"; // nhkrate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); non_ess_hk_data_rate(nhkrate); // rateType = "sci"; scirate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); data_rate(scirate); // if(debug) { debug_print("Set CHK datarate to: " + chkrate); debug_print("Set NHK datarate to: " + nhkrate); debug_print("Set SCI datarate to: " + scirate); } // // Start the state_machine: // int[] state = [0]; // while(state[0] >= 0) { if(debug) { debug_print("Current state: " + state); } state = next_state(); if(debug) { debug_print("Next state: " + state); } // if(state[0] == 1) { // STATE = SLEW ( Spacecraft is slewing ) // // // // // Startup observation: // SpireBb_StartPcalLevelCheck(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,debug); // //delay(timeSlewCal); } if(state[0] == 2) { // STATE = INIT_HOLD ( spacecraft is idling at source ) // // // // // // If no pointing observation do stuff here which is // done nominally during SLEW: // if(!pointing) { // // // // // Startup observation: // SpireBb_StartPcalLevelCheck(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,debug); } // // // // // // Set offsets: // SpireBb_SpecOffsetAuto(dcuData,debug); // //delay(tinithold); // } if(state[0] == 3) { // STATE = POINT ( spacecraft is at nominal RA,DEC (staring, raster) ) // // // // // Execute sequence of PCAL flashes: // SpireProc_Exec_PcalLevelCheck(vmId,vmIndex,nParms,raw_low_bias,raw_high_bias,ncycles,period,ndcumode,dcusamples,dcudelay,scumode,scusamples,debug); // //delay(tp); // } if(state[0] == 5) { // STATE = FINAL_HOLD ( "sky" observation ends, performing final activ.) // // // // // Set scientific datarate back to zero: // data_rate(0.0); // // // // // Reconfigure at the end (incl. resetting of OBSID and BBIB): // SpireBb_EndPcalLevelCheck(phot,isBright,version01,version02,debug); // } if(state[0] == -1) { // STATE = END ( end of the pointing/commanding part of the code ) // } } } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_EndMultiLevelNoise.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to reconfigure at the end of // SpirePhoto/Spectro_Cal_MultiLevelNoise. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // // 2009/05/05 V1.0: Initial version adapted from // SpireBb_EndBsmAngleCal (2009/05/05 V1.2), // SpirePhoto_Cal_MultiLevelNoise (2009/03/03 V1.3), and // SpireSpectro_Cal_MultiLevelNoise (2009/03/04 V0.5) // /////////////////////////////////////////////////////////////////////////// // block SpireBb_EndMultiLevelNoise SPIRE 14053 { bool phot = true; // Photometer (==tick) or FTS (==untick)? bool isBright = false in [true,false]; // IsBright (==tick) flag string version01 = "v00"; // Version in cal.tab. SpireTable_PhotModeParams string version02 = "v00"; // Version in cal.tab. SpireTable_CommonModeParams bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // int mode_id = 0; string obsmode = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB EndMultiLevelNoise reconfiguration started"); SpireMsg(2," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Set obsstep back to 0: // tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP(0)"); Spire_SET_OBS_STEP(0); // // // // // Set instrument back to Phot/Spec-STBY: // if(phot) { SpireProc_Set_PhotMode("PHTSTBY",isBright,version01,version02,debug); } else { SpireProc_Set_SpecMode("SPECSTBY",isBright,version01,version02,debug); } // // // // // End observation: // SpireProc_Set_EndObsAll(phot); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB EndMultiLevelNoise reconfiguration ended"); SpireMsg(1," ..Reconfiguration to " + obsmode + "mode (" + (time() - t) + " seconds)"); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////// // // SpireProc_Set_SpecMode // /////////////////////////////////////////////////////////// // // Procedure to configure some important instrument parameters // for the spectrometer depending on the mode. The procedure returns // the DCU, SMEC, BSM, DPU, and SCU data rate. // /////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/02/15 V0.1: Initial version adapted from // SpireProc_Set_PhotMode (2009/02/15 V0.1) // 2009/07/10 V1.0: Temporary fix for SPR-SPIRE-1613 (hardcode command) // /////////////////////////////////////////////////////////////////////////// // double[] procedure SpireProc_Set_SpecMode { string obsMode = "Scan"; // Obs mode as defined in calibration files bool isBright = false in [true,false]; // IsBright (==tick) flag string version01 = "v00"; // Version in cal.tab. SpireTable_SpecModeParams string version02 = "v00"; // Version in cal.tab. SpireTable_CommonModeParams bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Define some variables: // string tarCol = ""; string selCol = "mode"; string tabName = ""; string version = ""; string selVal = ""; string tstr = ""; // // Photometer or FTS?: bool phot = false; bool fts = !phot; // // Hardcoded name of calibration tables: // string tabName01 = "SpireTable_SpecModeParams.txt"; string tabName02 = "SpireTable_CommonModeParams.txt"; // // // // // Start procedure: // tstr = SpireTimeStr(time()); SpireMsg(4," " + tstr + ": SpireProc_Set_SpecMode started"); SpireMsg(4," $Id:$"); // // // // // In case select isBright: // if(obsMode != "SPECSTBY") { if(isBright) { selVal = obsMode + "_b"; } else { selVal = obsMode; } } else { selVal = obsMode; } // // // // // Read parameters from calibration tables: // // Table SpireTable_SpecModeParams: // tabName = tabName01; version = version01; // tarCol = "mclkDiv"; int mclkDiv = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // tarCol = "biasDiv"; int biasDiv = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // tarCol = "sswBias"; int ssw_bias = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // tarCol = "slwBias"; int slw_bias = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // tarCol = "sswPhase"; int ssw_phase = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // tarCol = "slwPhase"; int slw_phase = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // tarCol = "dcuDataRate"; double dcuDataRate = SpireProc_GetTableEntryDouble(tabName,selCol,selVal,tarCol,version,debug); // tarCol = "smecFrameRate"; int smecFrameRate = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // tarCol = "smecDataRate"; double smecDataRate = SpireProc_GetTableEntryDouble(tabName,selCol,selVal,tarCol,version,debug); // // Table SpireTable_CommonModeParams: // tabName = tabName02; version = version02; // tarCol = "dcuDataMode"; int dcuDataMode = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // tarCol = "bsmFrameRate"; int bsmFrameRate = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "bsmDataRate"; // double bsmDataRate = SpireProc_GetTableEntryDouble(tabName,selCol,selVal,tarCol,version,debug); // tarCol = "dpuDataRate"; double dpuDataRate = SpireProc_GetTableEntryDouble(tabName,selCol,selVal,tarCol,version,debug); // tarCol = "scuFrameRate"; int scuFrameRate = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // tarCol = "scuDataRate"; double scuDataRate = SpireProc_GetTableEntryDouble(tabName,selCol,selVal,tarCol,version,debug); // // // // // Debug printing of all fetched parameters: // if(debug) { debug_print(" mclkDiv: " + mclkDiv); debug_print(" biasDiv: " + biasDiv); debug_print(" ssw_bias: " + ssw_bias); debug_print(" slw_bias: " + slw_bias); debug_print(" ssw_phase: " + ssw_phase); debug_print(" slw_phase: " + slw_phase); debug_print(" dcuDataRate: " + dcuDataRate); debug_print("smecFrameRate: " + smecFrameRate); debug_print(" smecDataRate: " + smecDataRate); debug_print(" dcuDataMode: " + dcuDataMode); debug_print(" bsmFrameRate: " + bsmFrameRate); debug_print(" bsmDataRate: " + bsmDataRate); debug_print(" dpuDataRate: " + dpuDataRate); debug_print(" scuFrameRate: " + scuFrameRate); debug_print(" scuDataRate: " + scuDataRate); } // // // // // Set the DCU bias frequency, sampling rate, and data mode: // // Safety checks: // if(mclkDiv == -1) { error("mclkDiv is not defined for this mode. Think again or call help!"); } if(biasDiv == -1) { error("biasDiv is not defined for this mode. Think again or call help!"); } if(dcuDataMode == -1) { error("dcuDataMode is not defined for this mode. Think again or call help!"); } // SpireProc_Set_DcuFreqSampMode(mclkDiv,biasDiv,dcuDataMode,phot,debug); // // // // // Set the phases of the photometer array: // // Safety checks: // if(ssw_phase == -1) { error("ssw_phase is not defined for this mode. Think again or call help!"); } if(slw_phase == -1) { error("slw_phase is not defined for this mode. Think again or call help!"); } // SpireProc_Set_SpecPhase(ssw_phase,slw_phase,debug); // // // // // Set the bias amplitud of the spectrometer array: // // Safety checks: // if(ssw_bias == -1) { error("ssw_bias is not defined for this mode. Think again or call help!"); } if(slw_bias == -1) { error("slw_bias is not defined for this mode. Think again or call help!"); } // SpireProc_Set_SpecBias(ssw_bias,slw_bias,debug); // // // // // Set the SMEC framerate: // // Safety checks: // if(smecFrameRate == -1) { error("smecFrameRate is not defined for this mode. Think again or call help!"); } // SpireProc_Set_SmecFramerate(smecFrameRate,debug); // // // // // Set the BSM framerate: // // Safety checks: // if(bsmFrameRate == -1) { error("bsmFrameRate is not defined for this mode. Think again or call help!"); } // SpireProc_Set_BsmFramerate(bsmFrameRate,debug); // // // // // Set the SCU framerate // // Safety checks: // if(scuFrameRate == -1) { error("scuFrameRate is not defined for this mode. Think again or call help!"); } // SpireProc_Set_ScuFramerate(scuFrameRate,debug); // // // // // Temporary fix for SPR-SPIRE-1613 (hardcode command): // // Set sampling to continuous SpireSendDrcuCmd(0x843d0000,0); sync(); // // // // // End procedure: // tstr = SpireTimeStr(time()); SpireMsg(4," " + tstr + ": SpireProc_Set_SpecMode ended"); // // // // // Return data rates: // return [dcuDataRate,smecDataRate,bsmDataRate,dpuDataRate,scuDataRate]; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_EndJfetVssTestC.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to reconfigure at the end of // SpirePhoto/Spectro_Cal_JfetVssTestC // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // // 2009/05/21 V1.0: Initial version adapted from // SpireBb_EndFovMapFpgScan (2009/05/05 V1.0) // /////////////////////////////////////////////////////////////////////////// // block SpireBb_EndJfetVssTestC SPIRE 14072 { bool phot = true; // Photometer (==tick) or FTS (==untick)? int hold_chop = 37632; // Chop hold position [Dec(Hex)] int hold_jigg = 39520; // Jiggle hod position [Dec(Hex)] bool isBright = false in [true,false]; // IsBright (==tick) flag string version01 = "v00"; // Version in cal.tab. SpireTable_PhotModeParams string version02 = "v00"; // Version in cal.tab. SpireTable_CommonModeParams bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // int mode_id = 0; string obsmode = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB EndJfetVssTestC reconfiguration started"); SpireMsg(2," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Set obsstep back to 0: // tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP(0)"); Spire_SET_OBS_STEP(0); // // // // // Set instrument back to Phot/Spec-STBY: // if(phot) { SpireProc_Set_PhotMode("PHTSTBY",isBright,version01,version02,debug); } else { SpireProc_Set_SpecMode("SPECSTBY",isBright,version01,version02,debug); } // // // // // Move BSM back to hold: // SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug); // // // // // End observation: // SpireProc_Set_EndObsAll(phot); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB EndJfetVssTestC reconfiguration ended"); SpireMsg(1," ..Reconfiguration to " + obsmode + "mode (" + (time() - t) + " seconds)"); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_Set_StartObsAll.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to configure observation at the start of all AOTs // (i.e. astronomer, engineering, and calibration ones). // // It sets the OBSIDs for the current observation, sets the BB, // resets the DRCU counter, and sets the MODE. This script includes // HSPOT messages. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/05/05 V1.0: First version adapted from // SpireBb_StartObsAll (2009/01/30 V1.1) // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Set_StartObsAll { string obsmode = "ENG_CAL_OBS"; // Parameter to specify the configuration mode }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // // // // // Start procedure: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(3," " + tstr + ": Proc StartObsAll started"); SpireMsg(3," $Id: $"); // // Wait for busconfig to be performed: // delay(1); // Note, this will be set in SpireBb_StartObsAll // // // // // Set the OBSIDs for the current observation: // hstr = SpireHexStr($OBSID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + " Cmd: Spire_SET_OBSID(" + hstr + ")"); Spire_SET_OBSID($OBSID); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); delay(1); // // // // // Reset DRCU counter: // tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_RESET_DRCU_COUNTERS(" + hstr + ")"); Spire_RESET_DRCU_COUNTERS(); // // // // // Set the MODE using the SET_OBS_MODE Spire command: // int mode_id = ilookup("SpireTableInstConfigs.txt",obsmode,"value"); hstr = SpireHexStr(mode_id,4); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_MODE(" + hstr + ")"); Spire_SET_OBS_MODE(mode_id); // // // // // Round up total duration: // sync(); // // // // // End procedure: // tstr = SpireTimeStr(time()); SpireMsg(3," " + tstr + ": Proc StartObsAll ended"); SpireMsg(2," Proc StartObsAll (" + (time() - t) + " seconds)"); } /////////////////////////////////////////////////////////////////////////// // // SpireProc_Set_VmTable.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to set OBS_STEP parameter in observing mode // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/07/04 V0.1: Initial version // 2008/07/24 V0.2: Remove restriction of step value to 0-255 // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Set_VmTable { int itableID = 0x37; // Table ID to be uploaded string version = "v01"; // Version in calibration file }{ // // // // // Setup: // bool debug = true; //bool debug = false; // // // // // Load values from calibration file: // string calTable = "SpireTable_Pof2VmTables.txt"; // int tableID = ilookup(calTable,version,"tableID"); int tableLength = ilookup(calTable,version,"tableLength"); int pos01 = ilookup(calTable,version,"pos01"); int pos02 = ilookup(calTable,version,"pos02"); int pos03 = ilookup(calTable,version,"pos03"); int pos04 = ilookup(calTable,version,"pos04"); int pos05 = ilookup(calTable,version,"pos05"); int pos06 = ilookup(calTable,version,"pos06"); int pos07 = ilookup(calTable,version,"pos07"); int pos08 = ilookup(calTable,version,"pos08"); int pos09 = ilookup(calTable,version,"pos09"); int pos10 = ilookup(calTable,version,"pos10"); int pos11 = ilookup(calTable,version,"pos11"); int pos12 = ilookup(calTable,version,"pos12"); int pos13 = ilookup(calTable,version,"pos13"); int pos14 = ilookup(calTable,version,"pos14"); int pos15 = ilookup(calTable,version,"pos15"); int pos16 = ilookup(calTable,version,"pos16"); int pos17 = ilookup(calTable,version,"pos17"); // // Glue values together for UPDATE_TABLE input: // {int} p01 = {pos01}; {int} p02 = {pos02}; {int} p03 = {pos03}; {int} p04 = {pos04}; {int} p05 = {pos05}; {int} p06 = {pos06}; {int} p07 = {pos07}; {int} p08 = {pos08}; {int} p09 = {pos09}; {int} p10 = {pos10}; {int} p11 = {pos11}; {int} p12 = {pos12}; {int} p13 = {pos13}; {int} p14 = {pos14}; {int} p15 = {pos15}; {int} p16 = {pos16}; {int} p17 = {pos17}; {int}[] posarray = [p01,p02,p03,p04,p05,p06,p07,p08,p09,p10,p11,p12,p13,p14,p15,p16,p17]; //debug_print("posarray: " + posarray); // // // // // Set new table: // Spire_SET_TABLE(tableID,tableLength); delay(1); // update table command call for table index 0x0000: //Spire_UPDATE_TABLE(0x32,0x0,17,[{0x9a576ae2},{0x9a57b653},{0xa1376ae2},{0xa137b653},{0x9dc76e35},{0x9dc7b8e0},{0x96e66e35},{0x96e6b8e0},{0x93766ae2},{0x9376b653},{0x96e66792},{0x96e6b3b4},{0x9dc76792},{0x9dc7b3b4},{0x9a576ae2},{0x9a57b653},{0x7f000000}]); //Spire_UPDATE_TABLE(tinput); Spire_UPDATE_TABLE(tableID,0x0,tableLength,posarray); delay(1); } block Pacs_CcuMonitorDefaultRecycle PACS 2101 { }{ PacsCcuMonitorPeriodDefault(); sync(); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_SmecMove2Home.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to move SMEC to an input home position from a unsecure start // position while not allowing for the necessary delay in time to reach // position but allowing the movement to continue beyond the end of // the procedure! // /////////////////////////////////////////////////////////////////////////// // // KJK: // 2009/05/05 V0.1: Initial version adapted from // SpireProc_SmecMove (2009/03/31 V0.3) // // Notes: // // 1) When SpireProc_Setup_SmecScan is used, SpireProc_SmecMove2Home needs // to be run before. // 2) The procedures leave the SMEC running at end, i.e there is no // finalhold position command! // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_SmecMove2Home { int smecPosn = 13500; // SMEC final position (encoder value) int smecCurrPosn = 3500; // SMEC current position (encoder value) bool debug = false; }{ // // // // // Define some variables: // int t = time(); // // hex string: string hstr = ""; // // time string: string tstr = ""; // // Hardcoded name and version of calibration tables: string tabName = "SpireTable_SmecNominalSettings.txt"; string version = "v00"; // // // // // Start procedure: // tstr = SpireTimeStr(time()); SpireMsg(3," " + tstr + ": Proc SmecMove2Home started"); SpireMsg(3," $Id: $"); // // // // // Move to position (only if we have to): // if(smecCurrPosn != smecPosn) { // // fetch SMEC movement parameters // int moveCmd = ilookup(tabName,version,"MoveCmd"); int moveSpeed = ilookup(tabName,version,"MoveSpeed"); int moveTime = (smecCurrPosn - smecPosn) / moveSpeed; if(moveTime < 0) { moveTime = moveTime * -1; } moveTime = moveTime + 2; // allow 2 sec to stabilise if(debug) { debug_print("Movement Time: " + moveTime); } // // // // // Set SMEC mode to hold its position: // SpireSendDrcuCmd(0x90490000,0); // // // // // Move to position: // // Set scan speeds: SpireSendDrcuCmd(0x90470000 + moveCmd,0); delay(1); SpireSendDrcuCmd(0x90560000 + moveCmd,0); // // Set SMEC position: SpireSendDrcuCmd(0x90450000 + smecPosn,0); delay(1); // // Move SMEC to position: SpireSendDrcuCmd(0x90490001,0); sync(); } // // // // // End procedure: // tstr = SpireTimeStr(time()); SpireMsg(3," " + tstr + ": Proc SmecMove2Home ended"); SpireMsg(2," Proc SmecMove2Home (" + (time() - t) + " seconds)"); } // SpireBbFtsScan // // $id$ // // Execute a set of spectrometer scans at a given resolution // // This BB assumes that the spectrometer starts at the ScanStart position // and returns the spectrometer back to the ScanStart position at the end // // returns the actual time on-source // // K.J. King // // 20/ April 2007: KJK v1.4: // SCR3056 - now read Home position from Spectrometer.txt // SPR2835 - now returns the correct on-source integration time for the number of scans requested // // 04 November 2008: KJK // Added data_rate commands // 27 January 2009: KJK // - Added "C" to available scan resolution options (SCR-1114) // - Changed lookup calls to use versioning procedures (SCR-1154) // - Added command to set/reset SCANRES parameter (SCR-0605) for each scan // - Changed assumed begining and end positions to ScanStart and // no longer uses Home position (SCR-3057) // // double block SpireBbFtsScan SPIRE 8454 { string resolution = "" in ["H","M","L","C"]; int nscans = 0; int step = 0; string specVersion = "v00"; bool debug = false; }{ // Retrieve required SMEC params // int resId = SpireProc_GetTableEntryInt("SpireTable_Spectrometer.txt","ResChar",resolution,"ResId",specVersion,debug); int scanStart = SpireProc_GetTableEntryInt("SpireTable_Spectrometer.txt","ResChar",resolution,"ScanStart",specVersion,debug); int scanEnd = SpireProc_GetTableEntryInt("SpireTable_Spectrometer.txt","ResChar",resolution,"ScanEnd",specVersion,debug); int scanFSpeed = SpireProc_GetTableEntryInt("SpireTable_Spectrometer.txt","ResChar",resolution,"ScanFSpeed",specVersion,debug); int scanRSpeed = SpireProc_GetTableEntryInt("SpireTable_Spectrometer.txt","ResChar",resolution,"ScanRSpeed",specVersion,debug); int scanFCmd = SpireProc_GetTableEntryInt("SpireTable_Spectrometer.txt","ResChar",resolution,"ScanFCmd",specVersion,debug); int scanRCmd = SpireProc_GetTableEntryInt("SpireTable_Spectrometer.txt","ResChar",resolution,"ScanRCmd",specVersion,debug); string waveform = SpireProc_GetTableEntryString("SpireTable_Spectrometer.txt","ResChar",resolution,"Waveform",specVersion,debug); // // adjust nscans to obtain correct number of scans at observing speed if(waveform == "SAWTOOTH") { nscans = nscans * 2; } // // Calculate the scan 'forward','reverse' travel times int scanFTime = (scanEnd - scanStart) * (nscans / 2) / scanFSpeed; int scanRTime = (scanEnd - scanStart) * (nscans / 2) / scanRSpeed; // int t = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": SpireBbFtsScan started"); SpireMsg(2," $Id:$"); // // ..... configuration ..... // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // set STEP SpireProc_Set_ObsStep(step,debug); // // Set SCANRES parameter tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_UPDATE_TABLE_RAW(7, 6, 1, " + resId + ")"); Spire_UPDATE_TABLE_RAW(7,6,1,[{resId}]); // Set SMEC to hold its position SpireSendDrcuCmd(0x90490000,0); // // execute scans // // Set scan start and ending position // SpireSendDrcuCmd(0x90460000 + scanStart,0); SpireSendDrcuCmd(0x90450000 + scanEnd,0); delay(1); // // Set scan forward and reverse speed (only different if we are performing a saw tooth scan) SpireSendDrcuCmd(0x90470000 + scanFCmd,0); SpireSendDrcuCmd(0x90560000 + scanRCmd,0); delay(1); // // Specify number of scans SpireSendDrcuCmd(0x90480000 + nscans,0); // // Start data collection (DCU frames (assumes everything setup) + SMEC frames (idem)) // // Set number of frames to continuous SpireSendDrcuCmd(0x843d0000,0); SpireSendDrcuCmd(0x91c3ffff,0); // Start data collection SpireSendDrcuCmd(0x843e0001,0); SpireSendDrcuCmd(0x91c10001,0); // set datarate double rate = 0.0; rate = dlookup("Datarates.txt","Scan","DCU"); rate = rate + dlookup("Datarates.txt","Scan","BSM"); rate = rate + dlookup("Datarates.txt","Scan","SMEC"); data_rate(rate); // // Start scanning SpireSendDrcuCmd(0x90490002,0); delay(scanFTime + scanRTime + nscans + 2); // allow 1 sec for turnaround at end of each scan // // When scan is finished stop data generation SpireSendDrcuCmd(0x843e0000,0); SpireSendDrcuCmd(0x91c10000,0); data_rate(0.0); delay(1); Spire_FLUSH_FIFO(0x3000); delay(1); // hold position SpireSendDrcuCmd(0x90490000,0); // // reset SCANRES parameter tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_UPDATE_TABLE_RAW(7, 6, 1, " + 0 + ")"); Spire_UPDATE_TABLE_RAW(7,6,1,[{0}]); // // calculate actual on source observing time double srcTime = SpireProc_GetTableEntryDouble("SpireTable_Spectrometer.txt","ResChar",resolution,"Osit",specVersion,debug); // effective on source integration time per scan if(waveform == "SAWTOOTH") { srcTime = srcTime * double(nscans / 2); } else { srcTime = srcTime * double(nscans); } // // ..... completion ..... // sync(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB Fts Scan ended"); SpireMsg(1," ..Scanning (" + (time() - t) + " seconds)"); // return srcTime; } // SpirePOF2Observing // // $Id: SpirePOF2Observing.txt,v 1.3 2007/01/15 18:34:14 kking Exp $ // // This is the procedure to calculate // instrument observing parameters for the 7-point Jiggle observing mode // // {double,int,int,int,int,int} procedure SpirePOF2Observing { int nRepetitions = 1 in [1,1200]; // number of repeats of basic observing cycle (=1 nod cycle) }{ SpireMsg(2," POF2 Observing Parameters "); SpireMsg(2," $Id: SpirePOF2Observing.txt,v 1.3 2007/01/15 18:34:14 kking Exp $"); // // fetch operating parameters double flashTime = double(ilookup("SpireParms.txt","POF2","FlashTime")); // Optimum time between flashes double calTime = double(ilookup("SpireParms.txt","POF3","CalTime")); // Minimum time between gyro calibrations int jiggleTable = ilookup("OpsParms.txt","POF2","TableId"); // Jiggle Table ID int jiggleSize = ilookup("OpsParms.txt","POF2","TableSize"); // Jiggle Table length int nChops = ilookup("OpsParms.txt","POF2","NChops"); // number of chop cycles per jiggle position int nJiggs = ilookup("OpsParms.txt","POF2","NJiggs"); // number of jiggle positions in a jiggle map int nNodPosns = ilookup("OpsParms.txt","POF2","NNodPosns"); // number of nod positions in a nod cycle int nNodCycles = ilookup("OpsParms.txt","POF2","NNodCycles"); // number of nod cycles in one repetition bool initFlash = blookup("SpireParms.txt","POF2","InitFlash"); // initial flash flag bool endFlash = blookup("SpireParms.txt","POF2","EndFlash"); // final flash flag double srcTime = dlookup("OpsParms.txt","POF2","SrcTime"); // effective on source integration time per nod cycle // // ***************************************** // Display input parameters // ***************************************** SpireMsg(3," POF2 Logic input values:"); SpireMsg(3," ..nRepetitions: " + nRepetitions); SpireMsg(3," POF2 Fixed values:"); SpireMsg(3," ..jiggleTable: " + jiggleTable); SpireMsg(3," ..jiggleSize: " + jiggleSize); SpireMsg(3," ..nChops: " + nChops); SpireMsg(3," ..nJiggs: " + nJiggs); SpireMsg(3," ..nNodPosns: " + nNodPosns); SpireMsg(3," ..nNodCycles: " + nNodCycles); SpireMsg(3," ..initFlash: " + initFlash); SpireMsg(3," ..endFlash: " + endFlash); SpireMsg(3," ..SrcTime: " + srcTime); // // calculate observing parameters SpireMsg(2," Calculated Parameters:"); // // number of times to repeat the jiggle cycle at each nod position // Note: this is currently read from a calibration table but could be calculated // if it is required to dynamically assign integration time to each nod position // rather than by repeating complete nod cycles int nNodInts = ilookup("OpsParms.txt","POF2","NNodInts"); SpireMsg(3," Required number of jiggle cycles at each nod position: " + nNodInts); // // number of nod cycles to perform int nCycles = nRepetitions * nNodCycles; SpireMsg(3," Required number of Nod cycles: " + nCycles); // // observing time per nod cycle double cycleTime = double(nNodPosns * duration(SpireBbJiggle("POF2",jiggleTable,0,nJiggs,nNodInts,0))); SpireMsg(3," Time for a Nod cycle: " + cycleTime); // // total observing time double totalTime = double(nCycles) * cycleTime; SpireMsg(3," Total observing time: " + totalTime); // // number of nod cycles per Gyro calibration // Note: this only takes into account on source observing time, not movement between nod positions, // which is assumed to be a small fraction of the observing time, and so the value obtained is approximate int nCals = ifloor(totalTime / calTime); // SpireMsg(3," Number of Gyro Calibrations: " + nCals); int nCal = iceil(totalTime / cycleTime); // default is no gyro calibrations during observation if(nCals > 0) { nCal = iceil(double(nCycles) / double(nCals + 1)); } if(nCycles % nCal == 0) { nCal = nCal + 1; } // SpireMsg(3," Number of Gyro Calibrations(adjusted): " + nCals); // SpireMsg(3," Number of nod cycles per Gyro calibration: " + nCal); // // number of nod cycles per PCAL calibration // Note: this only takes into account on source observing time, not movement between nod poditions, // which is assumed to be a small fraction of the observing time, and so the value obtained is approximate int nFlashes = ifloor(totalTime / flashTime); SpireMsg(3," Number of Flashes: " + nFlashes); int nFlash = iceil(totalTime / cycleTime); // default is no flashes during observation if(nFlashes > 0) { nFlash = iceil(double(nCycles) / double(nFlashes + 1)); } if(nCycles % nFlash == 0) { nFlash = nFlash + 1; } SpireMsg(3," Number of Flashes(adjusted): " + nFlashes); SpireMsg(3," Number of nod cycles per PCAL calibration: " + nFlash); return {srcTime,nCycles,nNodPosns,nNodInts,nCal,nFlash}; } // SpireBbScanLine // // $Id: SpireBbScanLine.txt,v 1.2 2006/10/10 10:20:51 kking Exp $ // // Building Block to execute a scan line operation as part of a scan map: // take detector data for a fixed period of time // // Note: this BB assumes that the detector bias and sampling frequency and // the BSM sampling frequency have been set appropriately // // This BB assumes that 2 seconds have been included in the scan time to allow // setting of the BB and STEP at the start of the scan. // It also assumes that 2 seconds have been included at the end of the scan to // reset the STEP parameter // (see SpirePOF5Observing) // double block SpireBbScanLine SPIRE 8451 { int len = 0; // total length of scan int step = 0; }{ int t = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB ScanLine started"); SpireMsg(2," $Id: SpireBbScanLine.txt,v 1.2 2006/10/10 10:20:51 kking Exp $"); // // check input values int tStart = 2; int tEnd = 2; int osit = len - tStart - tEnd; if(osit < 0) { error("time for scan is less than minimum time required to setup scan"); } // // ..... configuration ..... // // set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // set STEP hstr = SpireHexStr(step,4); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP_RAW(" + hstr + ")"); Spire_SET_OBS_STEP_RAW(step); // // ..... execution ..... // // wait to end of line wait_until(t + tStart + osit); // // ..... completion ..... // // set STEP hstr = SpireHexStr(0,4); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP_RAW(" + hstr + ")"); Spire_SET_OBS_STEP_RAW(0); // wait_until(t + tStart + osit + tEnd); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB ScanLine ended"); SpireMsg(1," ..Scanning (" + (time() - t) + " seconds)"); // return double(osit); } // $Id: SpireBbParallelCoolerRecycle.txt,v 1.2 2008/02/06 15:08:02 dcesarsk Exp $ // // History 6-feb-2008 DAC File renamed to SpireBbParalelCoolerRecycle.txt // Did not change BB name to keep current BBID // // This building block executes the cooler recycle procedure // // The instrument should be in the REDY mode before execution of this observation // int block SpirePacsBbCoolerRecycle SPIRE 2569 { }{ int t0 = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB Cooler Recycle started"); SpireMsg(2," $Id: SpireBbParallelCoolerRecycle.txt,v 1.2 2008/02/06 15:08:02 dcesarsk Exp $"); // int cmd = 0x0; // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // // Select the current instrument in operation (prime/redundant) string side = "prime"; // // Command List info // int tableid = 0x53; // Table Identifier for CREC VM int startindex = 0; // Start Index in CREC VM Table int nparams = 0x15; // Number of parameters to VM // // Retrieve the VM input parameters int a = ilookup("CoolerRecycling.txt","a",side); // Heat Switch ON current (during Recycling) int b = ilookup("CoolerRecycling.txt","b",side); // Heat Switch OFF current int c = ilookup("CoolerRecycling.txt","c",side); // Pump Heat Switch Actuation Temperature int d = ilookup("CoolerRecycling.txt","d",side); // Pump Heater Dissipation 1 int e = ilookup("CoolerRecycling.txt","e",side); // Pump Condensation Temperature 1 int f = ilookup("CoolerRecycling.txt","f",side); // Pump Heater Dissipation 2 int g = ilookup("CoolerRecycling.txt","g",side); // Pump Condensation Temperature 2 int h = ilookup("CoolerRecycling.txt","h",side); // Pump Heater Dissipation 3 int i = ilookup("CoolerRecycling.txt","i",side); // Pump Heater Dissipation 4 int j = ilookup("CoolerRecycling.txt","j",side); // Pump Condensation Temperature Threshold int k = ilookup("CoolerRecycling.txt","k",side); // Evaporator Condensation Temperature int l = ilookup("CoolerRecycling.txt","l",side); // Evaporator Heat Switch Actuation Temperature int m = ilookup("CoolerRecycling.txt","m",side); // Pump Threshold Temperature int n = ilookup("CoolerRecycling.txt","n",side); // Heat Switch ON current int o = ilookup("CoolerRecycling.txt","o",side); // Sampling Interval (sec) int p = ilookup("CoolerRecycling.txt","p",side); // Heatswitch Timeout (min) int q = ilookup("CoolerRecycling.txt","q",side); // Pump Heating Timeout 1 (min) int r = ilookup("CoolerRecycling.txt","r",side); // Pump Heating Timeout 2 (min) int s = ilookup("CoolerRecycling.txt","s",side); // Evaporator Timeout (min) int t = ilookup("CoolerRecycling.txt","t",side); // Pump Cooling Timeout (min) int u = ilookup("CoolerRecycling.txt","u",side); // Global Timeout (min) // // Set Mode to CREC mois_comment("Set the SPIRE mode to CREC for Cooler Recycle"); SpireSetObsMode("CREC"); // // start executing recycle VM mois_comment("Execute the SPIRE command to perform Automatic Cooler Recycle"); mois_spacon("This command will take about " + (u + 1) + " minutes to execute"); {int}[] crecparams = [{a},{b},{c},{d},{e},{f},{g},{h},{i},{j},{k},{l},{m},{n},{o},{p},{q},{r},{s},{t},{u}]; tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_RUN_VM_RAW(" + tableid + "," + startindex + "," + nparams + "," + crecparams + ")"); Spire_RUN_VM_RAW(tableid,startindex,nparams,crecparams); // DAC // Do not wait here; return needed duration, caller will wait as necessary // Wait for completion // Insert a delay equal to the CREC VM global time out plus a minute int howLong = u * 60 + 58; // // Next instructions will be issued by caller // Set MODE to REDY mois_comment("Set the SPIRE mode to REDY"); /// SpireSetObsMode("REDY"); // // completion /// tstr = SpireTimeStr(time()); /// SpireMsg(2," " + tstr + ": BB Cooler Recycle ended"); /// SpireMsg(1," ..Cooler Recycle (" + (time() - t0) + " seconds)"); return howLong; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_PhotFSetPhase.txt // /////////////////////////////////////////////////////////////////////////// // // BB to set phase of photometer arrays // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/05/07 V0.1: Initial version adapted from // PF_Phase.txt (v1.4 2008/01/31 20:24:34) // 2008/05/08 V0.2: Restrict script to send only 2 commands per second // by moving one delay(1) // 2008/07/04 V0.3: Renumber version; add PTC phase // 2009/01/27 V1.0: Add debug_print; Remove unsetting of BBID at end. // Add HSPOT messages; // 2009/02/14 V1.1: Instead of using commands call SpireProc_Set_PhotPhase // and add sync() after setBbId // /////////////////////////////////////////////////////////////////////////// // block SpireBb_PhotFSetPhase SPIRE 14010 { int psw_phase = 0x0 in [0,255]; //Default phase is 0 [Hex] int pmw_phase = 0x0 in [0,255]; //Default phase is 0 [Hex] int plw_phase = 0x0 in [0,255]; //Default phase is 0 [Hex] int ptc_phase = 0x0 in [0,255]; //Default phase is 0 [Hex] bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Define some variables: // string hstr = ""; // a hex string string tstr = ""; // a time string // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": SpireBb_PhotFSetPhase started"); SpireMsg(2," $Id: $"); hstr = SpireHexStr($BBID,8); SpireMsg(3," BBID = " + hstr); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); sync(); // // // // // Set the phase for the three arrays and the PTC bolometer: // SpireProc_Set_PhotPhase(psw_phase,pmw_phase,plw_phase,ptc_phase,debug); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SpireBb_PhotFSetPhase ended"); SpireMsg(1," ..Set Phot phases (" + (time() - t) + " secs)"); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpirePhoto_Cal_StdLoadCurve.txt // /////////////////////////////////////////////////////////////////////////// // // CUS script for: 'Phot Standard Load Curve' // // in *basic_fine_pointing* or *no_pointing* mode // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/06/09 V0.1: Initial version adapted from // Mode_ILT_PERF_DAB_P_CPS.txt (v 1.3 2008/01/31 23:35:17) // 2008/06/20 V0.2: Move SpireBb_StartupObs to start // 2008/07/03 V0.3: Renumber version; SpireProc_Set_PhotNominalbias changed // name; SpireBb_PhotFSetupData has extra parameter; use // also PTC bolometers // 2008/07/21 V0.4: Allow nafid as input parameter // 2008/08/15 V0.5: Change name of default input bias_table; // Remove test number; modify description // Adapt to change in call to low level script // SpireProc_CalcParam_BiasFreqSampFreq.txt // 2008/11/11 V0.6: Allow 'no pointing' as input option; Adapt debug printing // 2008/11/12 V0.7: Implement mode setting; Add isBright // Change 'no pointing' implementation // 2009/02/01 V1.0: Add debug_print as input and pass it to some low level // scripts. Use new SpireBb_EndObsAll and SpireBb_StartObsAll. // Read nominal bias frequency and bias divider from new // SpireTable_DetectorSettings.txt. Implemented message // if activating isBright setting. Implemented setting // of datarates. Replace SpireProc_Set_PhotNominal by // SpireProc_Set_FreqSampAmpPhasNominal. Bias levels used // for the load curve are now calculated in // SpireProc_CalcParam_LoadCurve. // 2009/02/17 V1.1: Use SpireBb_PhotSetMode to set to PHOTSTBY during // SLEW and FINAL_HOLD. Read boresight from // SpireTable_OpsParms. New setting of datarates. // Remove cal. table name from input. Replace call to // SpireBb_PhotFSetupData with call to SpireBb_PhotFSetPhase // and SpireBb_PhotFSetBiasAmpl to set user requested // frequency, phase, and first BiasAmpl. // 2009/02/19 V1.2: Elevate version05 to input. // 2009/03/04 V1.3: Add isSerendipity, isPcal, and 8 more dummy parameters // to the script for future use. Replace 'message' by // 'error' if isBright is selected. // 2009/05/06 V1.4: Add in move BSM to hold at start. Gather procedures at // start and end in separate BB. // 2009/06/05 V1.5: Hardcode STBY 'v00' in EndBB (SPR-1477) // /////////////////////////////////////////////////////////////////////////// // // Script assumes that: // // 1) Instrument is in PHOTSTBY at beginning // (i.e. bias amplitude, phase, frequency [mclkdiv,biasdiv] are nominal) // // 2) Phase is kept constant (from input) during this test, i.e no // adjustment of the phase with changing bias amplitude and frequency // // 3) Bias frequency, sampling rate, and phase are input parameters // // 4) Boresight of array can be read from following cal table: // SpireTable_OpsParms.txt // /////////////////////////////////////////////////////////////////////////// // obs SpirePhoto_Cal_StdLoadCurve { /* ****************************************************** */ /* USER PARAMETER DEFINITION, CUS SIGNATURE for EX-HSpot */ /* ****************************************************** */ /* */ double ra = 0.0 in [0.0,360.0]; // RA of target double dec = 0.0 in [-90.0,90.0]; // DEC of target int naifid = 0; // NAIF identifier bool isBright = false; // Use settings for bright source (==tick) bool pointing = true; // Should telescope 'point' (==tick) or do a 'no pointing' (==untick)? /* */ double biasfreq = 130.2 in [70.0,200.0]; // Bias frequency [Hz] double samplerate = 18.6 in [1.0,20.0]; // Sampling rate [Hz] (Careful, don't exceed number of data packages to be transferred from spacecraft!) double phasedeg_psw = 180.7 in [0.0,360.0]; // PSW Bias phase [deg] double phasedeg_pmw = 180.7 in [0.0,360.0]; // PMW Bias phase [deg] double phasedeg_plw = 180.7 in [0.0,360.0]; // PLW Bias phase [deg] double phasedeg_ptc = 180.7 in [0.0,360.0]; // PTC Bias phase [deg] int ftime = 10; // Readout time at each bias level [s] string version01 = "v00"; // Version in cal table SpireTable_PhotModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams string version03 = "v00"; // Version in cal table SpireTable_StdLoadCurveLevels string version05 = "v00"; // Version in cal table SpireTable_OpsParms.txt bool debug = false; // Allow (==tick) or suppress cus debug_print statements bool isSerendipity = true; // Allow (==tick) serendipity mode to be activated or prohibit (==untick) it (currently not in use)? bool isPcal = true; // Allow (==tick) regular PcalFlash in script or prohibit (==untick) it (currently not in use)?. bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ // ****************************************************** */ // CALCULATE DURATIONS for POINTING STATES */ // ****************************************************** */ // // // // // Check for is bright setting: // if(isBright) { isBright = false; error("IsBright does not make sense here. Try again (e.g. subtract the phase shift manually from the input)!"); } // // // // // Declare some variable: // // Photometer or FTS: bool phot = true; bool fts = !phot; // string tabName = ""; string selCol = ""; string selVal = ""; string tarCol = ""; string version = ""; double scirate = 0.0; double chkrate = 0.0; double nhkrate = 0.0; // int obsStep = 0; // // Hardcoded calibration tables: // string tabName01 = "SpireTable_PhotModeParams.txt"; string tabName02 = "SpireTable_CommonModeParams.txt"; string tabName03 = "SpireTable_StdLoadCurveLevels.txt"; string tabName04 = "SpireTable_BsmNominalSettings.txt"; string tabName05 = "SpireTable_OpsParms.txt"; // // Currently hardcoded version and model parameter: // string version04 = "v00"; // Version in cal table SpireTable_BsmNominalSettings string model = "initial"; // Model in cal table SpireTable_BsmNominalSettings // // Dummy value for Spec script: // (needed but not used in phot script!) // int smecHomePosn = 3500; // SMEC home position int ssw_bias = 45; // int slw_bias = 45; // int ssw_phase = 128; // int slw_phase = 128; // // // // // // Setup mode: // // Set obsMode for QLA: string obsModeQla = "ENG_CAL_OBS12"; // Note: this needs entry in MIB table and in SpireTableInstConfigs.txt // // Set obsMode for datarates: string obsMode = "PEngCalObs"; // Note: this is currently only a maximum value // // // // // Retrieve bias levels used for the load curve: // tabName = tabName03; version = version03; int[] nbiaslist = SpireProc_CalcParam_LoadCurve(tabName,version,debug); // // Lookup first bias level: int psw_bias = nbiaslist[0]; int pmw_bias = nbiaslist[0]; int plw_bias = nbiaslist[0]; int ptc_bias = nbiaslist[0]; // // // // // Convert user input to Hex values: // // for bias frequency and sample rate: // int[] hexvalues = SpireProc_CalcParam_BiasFreqSampFreq(biasfreq,samplerate,fts,debug); int mclkdiv = hexvalues[0]; int biasdiv = hexvalues[1]; if(debug) { debug_print("Hex values of mclkdiv/biasdiv are: " + mclkdiv + " " + biasdiv); } // // for bias phase: // int[] phasehex = SpireProc_CalcParam_PhotPhaseConvert(phasedeg_psw,phasedeg_pmw,phasedeg_plw,phasedeg_ptc,debug); int psw_phase = phasehex[0]; int pmw_phase = phasehex[1]; int plw_phase = phasehex[2]; int ptc_phase = phasehex[3]; // // // // // Read BSM home parameters: // // Select version flag and set GetTableEntry parameters: // version = version04; tabName = tabName04; selCol = "model"; // Name of column for selecting selVal = model; // Value of 'string' selector // // Read hold position from calibration table: // tarCol = "chop_0_I"; int hold_chop = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "jigg_0_I"; int hold_jigg = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // Calculate timing for the pointing request: // // BBs called during slew: int tslewmin = duration(SpireBb_StartStdLoadCurve(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,mclkdiv,biasdiv,psw_bias,pmw_bias,plw_bias,ptc_bias,psw_phase,pmw_phase,plw_phase,ptc_phase,ssw_bias,slw_bias,ssw_phase,slw_phase,debug)); // // BBs carried out when the pointing is reached: if(pointing) { int tinithold = 0; } else { tinithold = tslewmin; } // // BB carried out during pointing: int tp = duration(SpireProc_Exec_PhotStdLoadCurve(nbiaslist,ftime,debug)); // // BB carried out at the end: int tfinalhold = duration(SpireBb_EndStdLoadCurve(phot,isBright,version01,version02,debug)); // if(debug) { debug_print("tslewmin = " + tslewmin); debug_print("tinithold = " + tinithold); debug_print("tpointing = " + tp); debug_print("tfinalhold = " + tfinalhold); } // // ****************************************************** */ // POINTING MODE DECLARATION */ // ****************************************************** */ // // // // // Lookup boresight: // tabName = tabName05; selCol = "mode"; selVal = obsMode; tarCol = "Boresight"; version = version05; string ib = SpireProc_GetTableEntryString(tabName,selCol,selVal,tarCol,version,debug); // // Set pointing mode: // if(pointing) { int[] ts = basic_fine_pointing(true,tslewmin,tinithold,tfinalhold,ib,naifid,ra,dec,0.0,0.0,tp); } else { ts = no_pointing(true,tinithold,tfinalhold,tp); } // if(debug) { debug_print("Output timing vector from the pointing request: " + ts); } // }{ // ****************************************************** */ // POINTING STATES WITH OBSERVING MODE LOGIC */ // ****************************************************** */ // // // // // Set datarates: // string rateType = "chk"; chkrate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); ess_hk_data_rate(chkrate); // rateType = "nhk"; // nhkrate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); non_ess_hk_data_rate(nhkrate); // rateType = "sci"; scirate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); data_rate(scirate); // if(debug) { debug_print("Set CHK datarate to: " + chkrate); debug_print("Set NHK datarate to: " + nhkrate); debug_print("Set SCI datarate to: " + scirate); } // // Start the state_machine: // int[] state = [0]; // while(state[0] >= 0) { if(debug) { debug_print("Current state: " + state); } state = next_state(); if(debug) { debug_print("Next state: " + state); } // if(state[0] == 1) { // STATE = SLEW ( Spacecraft is slewing ) // // // // // Startup observation: // SpireBb_StartStdLoadCurve(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,mclkdiv,biasdiv,psw_bias,pmw_bias,plw_bias,ptc_bias,psw_phase,pmw_phase,plw_phase,ptc_phase,ssw_bias,slw_bias,ssw_phase,slw_phase,debug); // //delay(timeSlewCal); } if(state[0] == 2) { // STATE = INIT_HOLD ( spacecraft is idling at source ) // // // // // If no pointing observation do stuff here which is // done nominally during SLEW: // if(!pointing) { // // // // // Startup observation: // SpireBb_StartStdLoadCurve(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,mclkdiv,biasdiv,psw_bias,pmw_bias,plw_bias,ptc_bias,psw_phase,pmw_phase,plw_phase,ptc_phase,ssw_bias,slw_bias,ssw_phase,slw_phase,debug); // } // //delay(tinithold); // } if(state[0] == 3) { // STATE = POINT ( spacecraft is at nominal RA,DEC (staring, raster) ) // // // // // // Execute load curve: // SpireProc_Exec_PhotStdLoadCurve(nbiaslist,ftime,debug); // //delay(tp); // } if(state[0] == 5) { // STATE = FINAL_HOLD ( "sky" observation ends, performing final activ.) // // // // // Set scientific datarate back to zero: // data_rate(0.0); // // // // // Reconfigure at the end (incl. resetting of OBSID and BBIB): // // Hardcode STBY values for resetting (SPR-1477): // version01 = "v00"; version02 = "v00"; // SpireBb_EndStdLoadCurve(phot,isBright,version01,version02,debug); // } if(state[0] == -1) { // STATE = END ( end of the pointing/commanding part of the code ) // } } } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_BsmMove.txt // /////////////////////////////////////////////////////////////////////////// // // BB to return BSM to hold position // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/09/08 V0.1: Initial version adapted from SpireBb_PhotChop // (2008/08/04 V0.2) // 2008/10/13 V0.2: Adapt to name change of calibration file. // 2008/11/06 V0.3: Change name // 2009/01/27 V1.0: Change call to calibration file. Add debug_print as input. // Remove unsetting of BBID at end. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_BsmMove SPIRE 14028 { int chopPosn = 2048 in [0,65535]; int jiggPosn = 2048 in [0,65535]; bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // // // // // Start BB: // SpireMsg(4," " + time() + ": SpireBb_BsmMove started"); SpireMsg(4," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); sync(); // // // // // // Move BSM: // SpireProc_Set_BsmMove(chopPosn,jiggPosn,debug); // // // // // End BB: // SpireMsg(4," " + time() + ": BB SpireBb_BsmMove ended"); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_SpecOffsetAuto.txt // /////////////////////////////////////////////////////////////////////////// // // BB to set the detector offset for the spectrometer arrays // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/08/11 V0.1: Initial version adapted from // SpireBb_PhotOffsetAuto.txt (2008/07/03 V0.2) // SOffset_Auto.txt (v1.4 2008/01/31 20:24:37) // 2009/02/19 V0.2: Move all commands in low level procedure // SpireProc_Set_SpecOffsetAuto. This fixes a bug // detected in FS2 with setting the correct (spec==4) // datamode at the end. // 2009/05/07 V0.3: Fixed bug. Script was not setting BBID. // 2009/06/05 V0.4: Fix Hspot message at end of script (SPR-1481). // /////////////////////////////////////////////////////////////////////////// // block SpireBb_SpecOffsetAuto SPIRE 14015 { bool dcuData = false; // Is (==tick) the DCU currently sampled? bool debug = false; // Allow (==tick) or suppress cus debug_print statement }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SpireBb_SpecOffsetAuto started"); SpireMsg(2," $Id:$"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); sync(); // // // // // Take offset: // SpireProc_Set_SpecOffsetAuto(dcuData,debug); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SpireBb_SpecOffsetAuto ended"); SpireMsg(1," ..SpecOffsetAuto End (" + (time() - t) + " seconds)"); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_StartFovMapFpgScan.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to configure at the start of // SpirePhoto/Spectro_CalGCO_FovMapFpgScan. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // // 2009/05/05 V0.1: Initial version adapted from // SpireBb_StartBsmAngleCal (2009/05/05 V0.1), // SpirePhoto_CalGCO_FovMapFpgScan (2009/03/04 V1.2), and // SpireSpectro_CalGCO_FovMapFpgScan (2009/03/04 V0.4) // BB includes now to move BSM/SMEC to hold/home. // 2009/07/10 V1.0: Fix bug SPR-SPIRE-1612 // // Notes: // 1) Scripts assumes that SpireBb_SpecOffsetAuto is run // during INITHOLD or at first POINTING. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_StartFovMapFpgScan SPIRE 14066 { bool phot = true; // Photometer (==tick) or FTS (==untick)? string obsModeQla = "ENG_CAL_OBS04"; string obsMode = "PEngCalObs"; bool isBright = false; // Use settings for bright source (==tick) string version01 = "v00"; // Version in cal table SpireTable_Phot/SpecModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams int hold_chop = 37632; // Chop hold position int hold_jigg = 39520; // Jiggle hold position int smecHomePosn = 3500; // SMEC home position bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // int mode_id = 0; string obsmode = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB StartFovMapFpgScan configuration started"); SpireMsg(2," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Startup observation: // SpireProc_Set_StartObsAll(obsModeQla); // // // // // In case move SMEC to home: // if(!phot) { // // Calculate available time for possible movement: // int tmove = duration(SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug)) + duration(SpireProc_Set_SpecMode(obsMode,isBright,version01,version02,debug)) + duration(SpireProc_Set_ObsStep(999,debug)) + duration(SpireBb_SpecOffsetAuto(false,debug)); // // Calculate max offset for which time is available: // int smecMaxOff = tmove * 500; // Note, 500 is maximum possible SMEC speed. int smecStart = smecHomePosn + smecMaxOff; // Note, formula above only reasonable // when smecHomePosn small compared to 39500 // Safety check: if(smecStart > 39500) { smecStart = 39500; } if(debug) { debug_print("smecStart: " + smecStart); debug_print("smecHomePosn: " + smecHomePosn); debug_print("tmove: " + tmove); } // // Move from maximal offset to home: // SpireProc_SmecMove2Home(smecHomePosn,smecHomePosn + smecMaxOff,debug); } // // // // // Move BSM back to hold: // SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug); // // // // // Initialise instrument (in case to isBright): // if(phot) { SpireProc_Set_PhotMode(obsMode,isBright,version01,version02,debug); } else { SpireProc_Set_SpecMode(obsMode,isBright,version01,version02,debug); } //delay(timeSlewCal); // // // // // Set Obs step at to fff: // int obsStep = 4095; SpireProc_Set_ObsStep(obsStep,debug); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB StartFovMapFpgScan configuration ended"); SpireMsg(1," ..StartFovMapFpgScan took " + (time() - t) + " seconds)"); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////// // // SpireProc_Set_PhotMode // /////////////////////////////////////////////////////////// // // Procedure to configure some important instrument parameters // for the photometer depending on the mode. The procedure returns // the DCU, BSM, DPU, and SCU data rate. // /////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/02/15 V0.1: Initial version adapted from // SpireProc_Set_PhotPhase (2009/02/14 V0.2) // 2009/07/10 V1.0: Temporary fix for SPR-SPIRE-1613 (hardcode command) // /////////////////////////////////////////////////////////////////////////// // double[] procedure SpireProc_Set_PhotMode { string obsMode = "PHOTSTBY"; // Obs mode as defined in calibration files bool isBright = false in [true,false]; // IsBright (==tick) flag string version01 = "v00"; // Version in cal.tab. SpireTable_PhotModeParams string version02 = "v00"; // Version in cal.tab. SpireTable_CommonModeParams bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Define some variables: // string tarCol = ""; string selCol = "mode"; string tabName = ""; string version = ""; string selVal = ""; string tstr = ""; // // Photometer or FTS?: bool phot = true; bool fts = !phot; // // Hardcoded name of calibration tables: // string tabName01 = "SpireTable_PhotModeParams.txt"; string tabName02 = "SpireTable_CommonModeParams.txt"; // // // // // Start procedure: // tstr = SpireTimeStr(time()); SpireMsg(4," " + tstr + ": SpireProc_Set_PhotMode started"); SpireMsg(4," $Id:$"); // // // // // In case select isBright: // if(obsMode != "PHOTSTBY" && obsMode != "PHTSTBY") { if(isBright) { selVal = obsMode + "_b"; } else { selVal = obsMode; } } else { selVal = obsMode; } // // // // // Read parameters from calibration tables: // // Table SpireTable_PhotModeParams: // tabName = tabName01; version = version01; // tarCol = "mclkDiv"; int mclkDiv = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // tarCol = "biasDiv"; int biasDiv = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // tarCol = "pswBias"; int psw_bias = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // tarCol = "pmwBias"; int pmw_bias = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // tarCol = "plwBias"; int plw_bias = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // tarCol = "ptcBias"; int ptc_bias = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // tarCol = "pswPhase"; int psw_phase = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // tarCol = "pmwPhase"; int pmw_phase = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // tarCol = "plwPhase"; int plw_phase = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // tarCol = "ptcPhase"; int ptc_phase = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // tarCol = "dcuDataRate"; double dcuDataRate = SpireProc_GetTableEntryDouble(tabName,selCol,selVal,tarCol,version,debug); // // Table SpireTable_CommonModeParams: // tabName = tabName02; version = version02; // tarCol = "dcuDataMode"; int dcuDataMode = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // tarCol = "bsmFrameRate"; int bsmFrameRate = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "bsmDataRate"; // double bsmDataRate = SpireProc_GetTableEntryDouble(tabName,selCol,selVal,tarCol,version,debug); // tarCol = "dpuDataRate"; double dpuDataRate = SpireProc_GetTableEntryDouble(tabName,selCol,selVal,tarCol,version,debug); // tarCol = "scuFrameRate"; int scuFrameRate = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // tarCol = "scuDataRate"; double scuDataRate = SpireProc_GetTableEntryDouble(tabName,selCol,selVal,tarCol,version,debug); // // // // // Debug printing of all fetched parameters: // if(debug) { debug_print(" mclkDiv: " + mclkDiv); debug_print(" biasDiv: " + biasDiv); debug_print(" psw_bias: " + psw_bias); debug_print(" pmw_bias: " + pmw_bias); debug_print(" plw_bias: " + plw_bias); debug_print(" ptc_bias: " + ptc_bias); debug_print(" psw_phase: " + psw_phase); debug_print(" pmw_phase: " + pmw_phase); debug_print(" plw_phase: " + plw_phase); debug_print(" ptc_phase: " + ptc_phase); debug_print(" dcuDataRate: " + dcuDataRate); debug_print(" dcuDataMode: " + dcuDataMode); debug_print("bsmFrameRate: " + bsmFrameRate); debug_print(" bsmDataRate: " + bsmDataRate); debug_print(" dpuDataRate: " + dpuDataRate); debug_print("scuFrameRate: " + scuFrameRate); debug_print(" scuDataRate: " + scuDataRate); } // // // // // Set the DCU bias frequency, sampling rate, and data mode: // // Safety checks: // if(mclkDiv == -1) { error("mclkDiv is not defined for this mode. Think again or call help!"); } if(biasDiv == -1) { error("biasDiv is not defined for this mode. Think again or call help!"); } if(dcuDataMode == -1) { error("dcuDataMode is not defined for this mode. Think again or call help!"); } // SpireProc_Set_DcuFreqSampMode(mclkDiv,biasDiv,dcuDataMode,phot,debug); // // // // // Set the phases of the photometer array: // // Safety checks: // if(psw_phase == -1) { error("psw_phase is not defined for this mode. Think again or call help!"); } if(pmw_phase == -1) { error("pmw_phase is not defined for this mode. Think again or call help!"); } if(plw_phase == -1) { error("plw_phase is not defined for this mode. Think again or call help!"); } if(ptc_phase == -1) { error("ptc_phase is not defined for this mode. Think again or call help!"); } // SpireProc_Set_PhotPhase(psw_phase,pmw_phase,plw_phase,ptc_phase,debug); // // // // // Set the bias amplitud of the photometer array: // // Safety checks: // if(psw_bias == -1) { error("psw_bias is not defined for this mode. Think again or call help!"); } if(pmw_bias == -1) { error("pmw_bias is not defined for this mode. Think again or call help!"); } if(plw_bias == -1) { error("plw_bias is not defined for this mode. Think again or call help!"); } if(ptc_bias == -1) { error("ptc_bias is not defined for this mode. Think again or call help!"); } // SpireProc_Set_PhotBias(psw_bias,pmw_bias,plw_bias,ptc_bias,debug); // // // // // Set the BSM framerate: // // Safety checks: // if(bsmFrameRate == -1) { error("bsmFrameRate is not defined for this mode. Think again or call help!"); } // SpireProc_Set_BsmFramerate(bsmFrameRate,debug); // // // // // Set the SCU framerate // // Safety checks: // if(scuFrameRate == -1) { error("scuFrameRate is not defined for this mode. Think again or call help!"); } // SpireProc_Set_ScuFramerate(scuFrameRate,debug); // // // // // Temporary fix for SPR-SPIRE-1613 (hardcode command): // // Set sampling to continuous SpireSendDrcuCmd(0x843d0000,0); sync(); // // // // // End procedure: // tstr = SpireTimeStr(time()); SpireMsg(4," " + tstr + ": SpireProc_Set_PhotMode ended"); // // // // // Return data rates: // return [dcuDataRate,bsmDataRate,dpuDataRate,scuDataRate]; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpirePhoto_Cal_PcalLoadCurve.txt // /////////////////////////////////////////////////////////////////////////// // // CUS script for: 'Phot PCAL Load Curve' // // in *basic_fine_pointing* or *no_pointing* mode // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/06/09 V0.1: Initial version adapted from // Mode_ILT_PERF_DAB_P_CPS.txt (v 1.3 2008/01/31 23:35:17) // 2008/06/20 V0.2: Move SpireBb_StartupObs to start // 2008/07/03 V0.3: Renumber version; SpireProc_Set_PhotNominalbias changed // name; SpireBb_PhotFSetupData has extra parameter; // use also PTC as input // 2008/07/21 V0.4: Allow nafid as input parameter // 2008/08/15 V0.5: Remove test number; use modified script to do // LC with PCAL flash (SpireProc_Exec_PhotPcalLoadCurve); // Change name of default input table with bias levels; // Adapt to change in call to low level script // SpireProc_CalcParam_BiasFreqSampFreq.txt // 2008/11/11 V0.6: Allow 'no pointing' as input option; Adapt debug printing // 2008/11/12 V0.7: Implement mode setting; Add isBright // Change 'no pointing' implementation // 2009/02/02 V1.0: Add debug_print as input and pass it to some low // level scripts. Add setting of NHK STEP parameter // in SpireProc_Exec_PhotPcalLoadCurve. Set first STEP // already during SLEW and unset at end during INIT_HOLD. // Use new SpireBb_EndObsAll and SpireBb_StartObsAll. // Read nominal bias frequency and bias divider from new // SpireTable_DetectorSettings.txt. Implemented setting // of datarates. Replace SpireProc_Set_PhotNominal by // SpireProc_Set_FreqSampAmpPhasNominal. Implemented message // if activating isBright setting. // 2009/02/16 V1.1: Replace call to SpireTable_DetectorSettings bu call to // SpireTable_PhotModeParams. Remove cal. tables from input // and hardcode them. Read boresight from SpireTable_OpsParms. // Use SpireProc_Set_PhotMode to set instrument to PHTSTBY // during SLEW. Replace call to SpireBb_PhotFSetupData with // call to SpireBb_PhotFSetPhase, SpireBb_PhotFSetBiasAmpl // and SpireBb_DcuSetFreqSamp to set user requested inputs // plus first bias level during SLEW. Use new setting of // datarates. Unset isBright if set. Use SpireBb_PhotSetMode // to set back to PHOTSTBY at end. // 2009/02/18 V1.2: Adapt to change in call to SpireProc_Exec_PhotPcalLoadCurve // 2009/02/19 V1.3: Elevate version05 to input. // 2009/03/04 V1.4: Add isSerendipity, isPcal, and 8 more dummy parameters // to the script for future use. Replace 'message' by // 'error' if isBright is selected. // 2009/05/07 V1.5: Add in move BSM to hold at start. Gather procedures at // start and end in separate BB. // 2009/06/05 V1.6: Hardcode STBY 'v00' in EndBB (SPR-1477) // /////////////////////////////////////////////////////////////////////////// // // Script assumes that: // // 1) Instrument is in PHOTSTBY at beginning // (i.e. bias amplitude, phase, frequency [mclkdiv,biasdiv] are nominal) // // 2) Phase is kept constant (from input) during this test, i.e no // adjustment of the phase with changing bias amplitude and frequency // // 3) Bias frequency, sampling rate, and phase are input parameters // // 4) Boresight of array can be read from following cal table using // the mode 'PEngCalObs': SpireTable_OpsParms.txt // /////////////////////////////////////////////////////////////////////////// // obs SpirePhoto_Cal_PcalLoadCurve { /* ****************************************************** */ /* USER PARAMETER DEFINITION, CUS SIGNATURE for EX-HSpot */ /* ****************************************************** */ /* */ double ra = 0.0 in [0.0,360.0]; // RA of target double dec = 0.0 in [-90.0,90.0]; // DEC of target int naifid = 0; // NAIF identifier bool isBright = false; // Use settings for bright source (==tick) bool pointing = true; // Should telescope 'point' (==tick) or do a 'no pointing' (==untick)? /* */ double biasfreq = 130.2 in [70.0,200.0]; // Bias frequency [Hz] double samplerate = 18.6 in [1.0,20.0]; // Sampling rate [Hz] (Careful, don't exceed number of data packages to be transferred from spacecraft!) double phasedeg_psw = 180.7 in [0.0,360.0]; // PSW Bias phase [deg] double phasedeg_pmw = 180.7 in [0.0,360.0]; // PMW Bias phase [deg] double phasedeg_plw = 180.7 in [0.0,360.0]; // PLW Bias phase [deg] double phasedeg_ptc = 180.7 in [0.0,360.0]; // PTC Bias phase [deg] int ftime = 10; // Readout time at each bias level [s] string version01 = "v00"; // Version in cal table SpireTable_PhotModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams string version03 = "v00"; // Version in cal table SpireTable_PcalLoadCurveLevels string version05 = "v00"; // Version in cal table SpireTable_OpsParms.txt bool debug = false; // Allow (==tick) or suppress cus debug_print statements bool isSerendipity = true; // Allow (==tick) serendipity mode to be activated or prohibit (==untick) it (currently not in use)? bool isPcal = true; // Allow (==tick) regular PcalFlash in script or prohibit (==untick) it (currently not in use)?. bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ // // // // // Check for is bright setting: // if(isBright) { isBright = false; error("IsBright does not make sense here. Try again (e.g. subtract the phase shift manually from the input)!"); } // // // // // Declare some variable: // // Photometer or FTS: bool phot = true; bool fts = !phot; // string tabName = ""; string selCol = ""; string selVal = ""; string tarCol = ""; string version = ""; double scirate = 0.0; double chkrate = 0.0; double nhkrate = 0.0; // int obsStep = 0; // // Hardcoded calibration tables: // string tabName01 = "SpireTable_PhotModeParams.txt"; string tabName02 = "SpireTable_CommonModeParams.txt"; string tabName03 = "SpireTable_PcalLoadCurveLevels.txt"; string tabName04 = "SpireTable_CommandLists.txt"; string tabName05 = "SpireTable_OpsParms.txt"; string tabName06 = "SpireTable_BsmNominalSettings.txt"; // // Currently hardcoded version and model parameter: // string version06 = "v00"; // Version in cal table SpireTable_BsmNominalSettings string model = "initial"; // Model in cal table SpireTable_BsmNominalSettings // // Dummy value for Spec script: // (needed but not used in phot script!) // int smecHomePosn = 3500; // SMEC home position int ssw_bias = 45; // int slw_bias = 45; // int ssw_phase = 128; // int slw_phase = 128; // // // // // // Setup mode: // // Set obsMode for QLA: string obsModeQla = "ENG_CAL_OBS10"; // Note: this needs entry in MIB table and in SpireTableInstConfigs.txt // // Set obsMode for datarates: string obsMode = "PEngCalObs"; // Note: this is currently only a maximum value // // // // // Retrieve bias levels used for the load curve: // tabName = tabName03; version = version03; int[] nbiaslist = SpireProc_CalcParam_LoadCurve(tabName,version,debug); // // Lookup first bias level: int psw_bias = nbiaslist[0]; int pmw_bias = nbiaslist[0]; int plw_bias = nbiaslist[0]; int ptc_bias = nbiaslist[0]; // // // // // Convert user input to Hex values: // // for bias frequency and sample rate: // int[] hexvalues = SpireProc_CalcParam_BiasFreqSampFreq(biasfreq,samplerate,fts,debug); int mclkdiv = hexvalues[0]; int biasdiv = hexvalues[1]; if(debug) { debug_print("Hex values of mclkdiv/biasdiv are: " + mclkdiv + " " + biasdiv); } // // for bias phase: // int[] phasehex = SpireProc_CalcParam_PhotPhaseConvert(phasedeg_psw,phasedeg_pmw,phasedeg_plw,phasedeg_ptc,debug); int psw_phase = phasehex[0]; int pmw_phase = phasehex[1]; int plw_phase = phasehex[2]; int ptc_phase = phasehex[3]; // // // // // Read VM parameters from calibration table: // tabName = tabName04; selVal = "Flash"; int vmId = ilookup(tabName,selVal,"Id"); int vmIndex = ilookup(tabName,selVal,"Index"); int nParms = ilookup(tabName,selVal,"Nparms"); // // // // // Read BSM home parameters: // // Select version flag and set GetTableEntry parameters: // version = version06; tabName = tabName06; selCol = "model"; // Name of column for selecting selVal = model; // Value of 'string' selector // // Read hold position from calibration table: // tarCol = "chop_0_I"; int hold_chop = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "jigg_0_I"; int hold_jigg = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // ****************************************************** */ // CALCULATE DURATIONS for POINTING STATES */ // ****************************************************** */ // // BBs called during slew: // int tslewmin = duration(SpireBb_StartPcalLoadCurve(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,mclkdiv,biasdiv,psw_bias,pmw_bias,plw_bias,ptc_bias,psw_phase,pmw_phase,plw_phase,ptc_phase,ssw_bias,slw_bias,ssw_phase,slw_phase,debug)); // // BBs carried out when the pointing is reached: // if(pointing) { int tinithold = 0; } else { tinithold = tslewmin; } // // BB carried out during pointing: // int tp = duration(SpireProc_Exec_PhotPcalLoadCurve(nbiaslist,ftime,mclkdiv,biasdiv,vmId,vmIndex,nParms,debug)); // // BB carried out at the end: // int tfinalhold = duration(SpireBb_EndPcalLoadCurve(phot,isBright,version01,version02,debug)); // // // // // Debug printing: // if(debug) { debug_print("tslewmin = " + tslewmin); debug_print("tinithold = " + tinithold); debug_print("tpointing = " + tp); debug_print("tfinalhold = " + tfinalhold); } // // ****************************************************** */ // POINTING MODE DECLARATION */ // ****************************************************** */ // // // // // Lookup boresight: // tabName = tabName05; selCol = "mode"; selVal = obsMode; tarCol = "Boresight"; version = version05; string ib = SpireProc_GetTableEntryString(tabName,selCol,selVal,tarCol,version,debug); // // Set pointing mode: // if(pointing) { int[] ts = basic_fine_pointing(true,tslewmin,tinithold,tfinalhold,ib,naifid,ra,dec,0.0,0.0,tp); } else { ts = no_pointing(true,tinithold,tfinalhold,tp); } // if(debug) { debug_print("Output timing vector from the pointing request: " + ts); } // }{ // ****************************************************** */ // POINTING STATES WITH OBSERVING MODE LOGIC */ // ****************************************************** */ // // // // // Set datarates: // string rateType = "chk"; chkrate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); ess_hk_data_rate(chkrate); // rateType = "nhk"; // nhkrate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); non_ess_hk_data_rate(nhkrate); // rateType = "sci"; scirate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); data_rate(scirate); // if(debug) { debug_print("Set CHK datarate to: " + chkrate); debug_print("Set NHK datarate to: " + nhkrate); debug_print("Set SCI datarate to: " + scirate); } // // Start the state_machine: // int[] state = [0]; // while(state[0] >= 0) { if(debug) { debug_print("Current state: " + state); } state = next_state(); if(debug) { debug_print("Next state: " + state); } // if(state[0] == 1) { // STATE = SLEW ( Spacecraft is slewing ) // // // // // Startup observation: // SpireBb_StartPcalLoadCurve(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,mclkdiv,biasdiv,psw_bias,pmw_bias,plw_bias,ptc_bias,psw_phase,pmw_phase,plw_phase,ptc_phase,ssw_bias,slw_bias,ssw_phase,slw_phase,debug); // //delay(timeSlewCal); } if(state[0] == 2) { // STATE = INIT_HOLD ( spacecraft is idling at source ) // // // // // // If no pointing observation do stuff here which is // done nominally during SLEW: // if(!pointing) { // // // // // Startup observation: // SpireBb_StartPcalLoadCurve(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,mclkdiv,biasdiv,psw_bias,pmw_bias,plw_bias,ptc_bias,psw_phase,pmw_phase,plw_phase,ptc_phase,ssw_bias,slw_bias,ssw_phase,slw_phase,debug); // } //delay(tinithold); // } if(state[0] == 3) { // STATE = POINT ( spacecraft is at nominal RA,DEC (staring, raster) ) // // // // // // Execute load curve with PCAL flashes: // SpireProc_Exec_PhotPcalLoadCurve(nbiaslist,ftime,mclkdiv,biasdiv,vmId,vmIndex,nParms,debug); // //delay(tp); // } if(state[0] == 5) { // STATE = FINAL_HOLD ( "sky" observation ends, performing final activ.) // // // // // Set scientific datarate back to zero: // data_rate(0.0); // // // // // Reconfigure at the end (incl. resetting of OBSID and BBIB): // // Hardcode STBY values for resetting (SPR-1477): // version01 = "v00"; version02 = "v00"; // SpireBb_EndPcalLoadCurve(phot,isBright,version01,version02,debug); // // } if(state[0] == -1) { // STATE = END ( end of the pointing/commanding part of the code ) // } } } // SpireBbPhotSerendipity // // $Id: SpireBbPhotSerendipity.txt,v 1.3 2007/04/20 12:26:09 kking Exp $ // // Building Block to take serendipity data for a specified period of time // // If the time specified is less than the minimum then this BB takes the minimum time anyway // // Note: this BB assumes that the detector bias and sampling frequency and // the BSM sampling frequency have been set appropriately // // 20/04/07: v1.3: removed check on opsMode value // // 04 November 2008: // changed to accept observing mode // changed to provide operations mode rather than data mode as a parameter to StartDcuData // block SpireBbPhotSerendipity SPIRE 8452 { string obsMode = ""; int len = 0 in [0,10000]; // scan length in seconds - maximum determined by max time between Tsync }{ message("2 " + time() + ": BB Phot Serendipity started"); message("2 $Id: SpireBbPhotSerendipity.txt,v 1.3 2007/04/20 12:26:09 kking Exp $"); message("3 length = " + len); int t = time(); // // find actual length of BB int tSerendipity = ilookup("SpireParms.txt",obsMode,"TSerendipity"); // minimum time for Serendipity observation if(len < tSerendipity) { len = tSerendipity; } // // ..... configuration ..... // // set BBID message("5 " + time() + "Cmd: Spire_SET_BBID_RAW(" + $BBID + ")"); Spire_SET_BBID_RAW($BBID); // set value delay(2); // allow HSK to reflect new value // // ..... initialisation ..... // // // ..... execution ..... // // start sampling detectors SpireStartDcuData("PSer"); // // wait to end of time int tStop = duration(SpireStopDcuData()); wait_until(t + len - tStop - 2); // // stop detector sampling SpireStopDcuData(); // // ..... completion ..... // // wait_until(t + len); message("2 " + time() + ": BB Phot Serendipity ended"); message("0 Serendipity Mode (" + (time() - t) + " seconds)"); // } // SpirePacsBbParallelEnd // // $Id: SpirePacsBbParallelEnd.txt,v 1.1 2006/10/11 10:23:40 kking Exp $ // // Building Block to reconfigure the instrument to PHOT_STBY mode from POF5 (scan map) mode // // block SpirePacsBbParallelEnd SPIRE 8338 { }{ int t = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB Parallel Reconfiguration started"); SpireMsg(2," $Id: SpirePacsBbParallelEnd.txt,v 1.1 2006/10/11 10:23:40 kking Exp $"); // // ..... configuration ..... // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // set STEP to zero tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP_RAW(0x0000)"); Spire_SET_OBS_STEP_RAW(0x0); // // Move BSM to HOLD int bsmHoldChopPosn = ilookup("BSM.txt","Hold","ChopPosn"); int bsmHoldJiggPosn = ilookup("BSM.txt","Hold","JiggPosn"); SpireBsmMove(bsmHoldChopPosn,bsmHoldJiggPosn); // // Set Mode to PHT_STBY tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_MODE_RAW(0x0300)"); Spire_SET_OBS_MODE_RAW(0x300); // // Clear OBSID/BBID to null values tstr = SpireTimeStr(time()); message("5 " + tstr + "Cmd: Spire_SET_BBID_RAW(0x80000000)"); Spire_SET_BBID_RAW(0x80000000); int obsId = SpireNullObsid(); tstr = SpireTimeStr(time()); hstr = SpireHexStr(obsId,8); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBSID_RAW(" + hstr + ")"); Spire_SET_OBSID_RAW(obsId); // // ..... completion ..... // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB Parallel Reconfiguration ended"); SpireMsg(1," ..Parallel Reconfiguration to PHT_STBY mode (" + (time() - t) + " seconds)"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_PtcHtrCurr.txt // /////////////////////////////////////////////////////////////////////////// // // BB to set PTC heater current. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/03/30 V0.1: Initial version adapted from // PTCHTR_CURR.txt (SDS, email 30.03.2009) // /////////////////////////////////////////////////////////////////////////// // block SpireBb_PtcHtrCurr SPIRE 14033 { int ptc_curr = 0x0; // PTC heater current (Raw) bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Define some variables: // string hstr = ""; // a hex string string tstr = ""; // a time string // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": SpireBb_PtcHtrCurr started"); SpireMsg(2," $Id: $"); hstr = SpireHexStr($BBID,8); SpireMsg(3," BBID = " + hstr); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); sync(); // // // // // Set PTC current: // SpireSendDrcuCmd(0xa0c60000 + ptc_curr,0); // // // // // Reset DRCU counter: // tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_RESET_DRCU_COUNTERS(" + hstr + ")"); Spire_RESET_DRCU_COUNTERS(); sync(); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SpireBb_PtcHtrCurr ended"); SpireMsg(1," ..Set Phot phases (" + (time() - t) + " secs)"); // } // SpireEngCoolerRecycle // // $id$ // // This observation executes the cooler recycle procedure // // The instrument should be in the REDY mode before execution of this observation // // 03/11/2007 KJK updated to add SpireBbStartOBS and SpireBbEndObs at start and end of the observation // // 17/11/2008 KJK updated to include CCU monitoring command (SCR 5446) // this includes bringing the StartOBs and EndObs BBs to the Initail and final hold parst of the observation // obs SpireEngCoolerRecycle { }{ int tih = duration(SpireBbStartObs()) + duration(SpireBbCcuMonitorPeriodRecycle()); int tfh = duration(SpireBbEndObs()) + duration(SpireBbCcuMonitorPeriodDefault()); int tp = duration(SpireCoolerRecycle()); int[] ts = no_pointing(true,tih,tfh,tp); }{ int[] state = [0]; while(state[0] >= 0) { state = next_state(); if(state[0] == 2) { // *********************** INITIAL HOLD // set OBSID SpireBbStartObs(); SpireBbCcuMonitorPeriodRecycle(); } if(state[0] == 3) { // *********************** EXECUTE SpireCoolerRecycle(); } if(state[0] == 5) { // *********************** FINAL HOLD SpireBbCcuMonitorPeriodDefault(); SpireBbEndObs(); } } } // SpireBbBsmOff // // $id$ // // This building block switches off the BSM // // 29/05/2009: KJK // Now exits with mode set to REDY (as expected from the IUM) // block SpireBbBsmOff SPIRE 267 { }{ int t0 = time(); string hstr = ""; // hex string string tstr = ""; // time string tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB BSM Off started"); SpireMsg(2," $Id: SpireBbBsmOff.txt,v 1.1 2007/08/02 10:15:44 kking Exp $"); // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); delay(1); // // set Step to zero SpireSetObsStep(0); // // Flag the current operation SpireSetObsMode("REDY"); delay(1); // // Send BSM to chop target position 0 SpireSendDrcuCmd(0x90c38000,0); // Send BSM to jiggle target position 0 SpireSendDrcuCmd(0x91438000,0); // Force Open loop in both axis SpireSendDrcuCmd(0x90c20003,0); SpireSendDrcuCmd(0x91420003,0); // Power off chop axis SpireSendDrcuCmd(0x90c00000,0); // Power off jiggle axis SpireSendDrcuCmd(0x91400000,0); delay(1); // // completion tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB BSM Off ended"); SpireMsg(1," ..BSM Off (" + (time() - t0) + " seconds)"); } // Missionphase : PACS FM Test // // Purpose : Switch on of bolometer groups // // Author : T. Mueller // // File : PHOT_switchon_groups // Arguments : none // // // Description : This script will switch on the different groups // of the instrument. BOLC will start in "HK only" mode. // // Comments : Coded based on PhFPU UM, Draft 5 // // Version : 1.1 // History : 1.0 / 08-Nov-2006 initial version by TM // 1.1 / 08-Nov-2006 TM: autonomy function 17 added // 1.1.1 14-nov-2006 Disable autonomy function for time being // 1.2 17-nov-2006 Enable AF with delay after switchon // 1.3 09-apr-2007 disable AFs before starting // procedure PHOT_switchon_groups { }{ // disable AF 12, AF 15, AF 17 // disable AF 12 (to check for the protection biases) Pacs_DPU_SET_FUNCT("EVENT_BOL_BIAS","DISABLE"); // disable AF 15 (to check for the VSS currents of groups and BUs) Pacs_DPU_SET_FUNCT("EVENT_BOL_I_RO","DISABLE"); // disable AF 17 (to check for group power) Pacs_DPU_SET_FUNCT("EVENT_BOL_V_PWR","DISABLE"); // delay(2); // PC103420 "DMC_SEND_COMMAND_BOLC" SEND COMMAND TO BOL CONTROLLER // PP071420 "BOLOMETER_COMMAND" // // # Execute BOLC initialisation // # for CQM we switched on everything at once, now group by // # group starting with 1 // // # Switch-on group 1 The corresponding bits // # are (2^0)=1, which is 1 in hex. // tcsend PC103420 {PP071420 0x0A000001 LO} // waittime 1.0 int operand = 0xa000001; Pacs_DMC_SEND_COMMAND_BOLC(operand); delay(1); // # Switch-on groups 1,2. The corresponding bits // # are (2^0+2^1)=3, which is 3 in hex. // tcsend PC103420 {PP071420 0x0A000003 LO} // waittime 1.0 operand = 0xa000003; Pacs_DMC_SEND_COMMAND_BOLC(operand); delay(1); // # Switch-on groups 1,2,3. The corresponding bits // # are (2^0+2^2+2^3)=7, which is 7 in hex. // tcsend PC103420 {PP071420 0x0A000007 LO} // waittime 1.0 operand = 0xa000007; Pacs_DMC_SEND_COMMAND_BOLC(operand); delay(1); // # Switch-on groups 1,2,3,4. The corresponding bits // # are (2^0+2^1+2^2+2^3)=15, which is F in hex. // tcsend PC103420 {PP071420 0x0A00000F LO} // waittime 1.0 operand = 0xa00000f; Pacs_DMC_SEND_COMMAND_BOLC(operand); delay(1); // # Switch-on groups 1,2,3,4,5. The corresponding bits // # are (2^0+2^1+2^2+2^3+2^4)=31, which is 1F in hex. // tcsend PC103420 {PP071420 0x0A00001F LO} // waittime 1.0 operand = 0xa00001f; Pacs_DMC_SEND_COMMAND_BOLC(operand); delay(1); // # Switch-on groups 1,2,3,4,5,6. The corresponding bits // # are (2^0+2^1+2^2+2^3+2^4+2^5)=63, which is 3F in hex. // tcsend PC103420 {PP071420 0x0A00003F LO} // waittime 1.0 operand = 0xa00003f; Pacs_DMC_SEND_COMMAND_BOLC(operand); delay(8); //------------------------------------ // autonomy function //------------------------------------ // autonomy function 17 "generate_event_pwr" checks the // HK entries: PC_PWR_ANA_P_#, PC_PWR_ANA_N_# and PC_PWR_DIG_#, // with # = [1,2,3,4,5,6,7] Pacs_DPU_SET_FUNCT("EVENT_BOL_V_PWR","ENABLE"); // Wait another 2 sec delay(2); // //----------------- // End of Procedure //----------------- } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_CalcParam_SpecPhaseConvert.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to translate user input in deg for bias phase // into nearest Hex values for ssw_phase, pmw_phase, slw_phase, and ptc_phase // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/08/12 V0.1: Initial version adapted from // SpireProc_CalcParam_PhotPhaseConvert (2008/07/03 V0.2) // 2009/02/19 V0.2: Add debug_print as input and implement. // /////////////////////////////////////////////////////////////////////////// int[] procedure SpireProc_CalcParam_SpecPhaseConvert { double input_phase_ssw = 0.0 in [0.0,360.0]; // Input SSW Bias Phase [0.0 - 360.0] [deg] double input_phase_slw = 0.0 in [0.0,360.0]; // Input SLW Bias Phase [0.0 - 360.0] [deg] bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Convert from deg to nearest RAW values: // double conversion_factor = 255.0 / 360.0; // int raw_phase_ssw = iround(conversion_factor * input_phase_ssw); int raw_phase_slw = iround(conversion_factor * input_phase_slw); // // // // // // Convert nearest RAW values back to deg: // double phase_ssw = double(raw_phase_ssw) / conversion_factor; double phase_slw = double(raw_phase_slw) / conversion_factor; // // // // // Printout: // if(debug) { debug_print("Input deg value for SSW/SLW phase amplitude: " + input_phase_ssw + "/" + input_phase_slw); debug_print("Output Hex values for SSW/SLW: " + raw_phase_ssw + "/" + raw_phase_slw); debug_print("Commanded deg values for SSW/SLW: " + phase_ssw + "/" + phase_slw); } // // // // // Return required values: // return [raw_phase_ssw,raw_phase_slw]; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_SpecFTakeData.txt // /////////////////////////////////////////////////////////////////////////// // // BB to start taking data with spectrometer arrays // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/08/11 V0.1: Initial version adapted from // SpireBb_PhotFTakeData.txt (2008/07/04 V0.2) // SF_Data_QLA (v1.4 2008/01/31 20:24:37) // 2009/02/19 V0.2: Add debug_print option. Replace delay(1) with delay(2) // after FLUSH_FIFO. Remove unsetting of BBID. Add Hspot // messages. // // Note: - BB assumes no DCU data is taken when started! // - BB still includes nonessential setting of data mode (0x843c0004) // /////////////////////////////////////////////////////////////////////////// // block SpireBb_SpecFTakeData SPIRE 14014 { int ftime = 0x0; //Time for data generation (if frames are continuous) bool debug = false; // Allow (==tick) or suppress cus debug_print statement }{ // // // // // Define some variables: // string hstr = ""; // a hex string string tstr = ""; // a time string // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": SpireBb_SpecFTakeData started"); SpireMsg(2," $Id: $"); hstr = SpireHexStr($BBID,8); SpireMsg(3," BBID = " + hstr); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); //sync(); // // // // // Reset DCU (x1000) fifo: // tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_RESET_FIFOS(0x1000)"); Spire_RESET_FIFOS(0x1000); delay(1); // // // // // Set data mode to 'spectrometer full array': // SpireSendDrcuCmd(0x843c0004,0); //delay(1); // // // // // Start data collection: // SpireSendDrcuCmd(0x843e0001,0); // // // // // Wait for data to be taken: // delay(ftime); // // // // // Stop data collection: // SpireSendDrcuCmd(0x843e0000,0); //delay(1); // // // // // Flush DCU fifo: // tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_FLUSH_FIFO(0x1000)"); Spire_FLUSH_FIFO(0x1000); delay(2); // } // SpireBbSmecOn // // $id$ // // This building block switches on the SMEC // // The instrument should be in the REDY mode before execution of this building block // // 29/04/2009 KJK: First Version // 18/07/2009 MP: Added change made by Sunil on 16th to header // (see SPR-SPIRE-1638) // block SpireBbSmecOn SPIRE 530 { string version = "v00"; bool debug = false; }{ int t0 = time(); string hstr = ""; // hex string string tstr = ""; // time string tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SMEC On started"); SpireMsg(2," $Id$"); // // intialise variables int ffGain = ilookup("SpireTable_SmecNominalSettings.txt",version,"ffGain"); int encPwr = ilookup("SpireTable_SmecNominalSettings.txt",version,"encPwr"); int s1Off = ilookup("SpireTable_SmecNominalSettings.txt",version,"s1Off"); int s2Off = ilookup("SpireTable_SmecNominalSettings.txt",version,"s2Off"); int lvdtScale = ilookup("SpireTable_SmecNominalSettings.txt",version,"lvdtScale"); int lvdtOff = ilookup("SpireTable_SmecNominalSettings.txt",version,"lvdtOff"); // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); delay(1); // // set Step to zero SpireSetObsStep(0); // // Flag the current operation SpireSetObsMode("SMEC_ON"); delay(1); // // Set Feed Forward Gain SpireSendDrcuCmd(0x90540000 + ffGain,0); // // switch on optical encoder SpireSendDrcuCmd(0x90400000 + encPwr,0); delay(1); // // Set encoder signal offsets SpireSendDrcuCmd(0x90580000 + s1Off,0); SpireSendDrcuCmd(0x905a0000 + s2Off,0); // // Switch on LVDT SpireSendDrcuCmd(0x90410001,0); SpireSendDrcuCmd(0x905f0000 + lvdtScale,0); SpireSendDrcuCmd(0x905e0000 + lvdtOff,0); delay(1); // // Reset Ki to avoid having a Ki value when SMEC is sitting at zero mechanical position SpireSendDrcuCmd(0x904d0000,0); delay(1); // // Change contents of MCU engineering frames to contain only SMEC parameters // MCU Eng Par #4: SMEC encoder fine position SpireSendDrcuCmd(0x91d4006b,0); // MCU Eng Par #9: SMEC encoder sig1 offset SpireSendDrcuCmd(0x91d90058,0); // MCU Eng Par #10: SMEC mean position error SpireSendDrcuCmd(0x91da006f,0); // MCU Eng Par #11: SMEC encoder sig1 amplitude SpireSendDrcuCmd(0x91db0057,0); // MCU Eng Par #12: SMEC mean speed SpireSendDrcuCmd(0x91dc006e,0); // MCU Eng Par #13: SMEC DAC value SpireSendDrcuCmd(0x91dd0069,0); // MCU Eng Par #14: SMEC LVDT position SpireSendDrcuCmd(0x91de0065,0); delay(1); // // Set MCU Eng sampling to 125Hz and start data generation SpireSendDrcuCmd(0x91c40013,0); delay(1); SpireSendDrcuCmd(0x91c3ffff,0); delay(1); SpireSendDrcuCmd(0x91c10001,0); delay(1); // // completion tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SMEC On ended"); SpireMsg(1," ..SMEC ON (" + (time() - t0) + " seconds)"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_Set_SpecOffsetAuto.txt // /////////////////////////////////////////////////////////////////////////// // // BB to set the detector offset for the spectrometer arrays // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/02/18 V0.1: Initial version adapted // SpireBb_SpecOffsetAuto (2008/08/11 V0.1) // Add HSpot messages. Increase first delay after // data collection to 3s (from 2s) to be symmetric // to photometer script. Increase delay to 2 after // Spire_FLUSH_FIFO. Fix bug detected in FS2 with // setting the correct (spec==4) datamode at the end. // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Set_SpecOffsetAuto { bool dcuData = false; // Is (==tick) the DCU currently sampled? bool debug = false; // Allow (==tick) or suppress cus debug_print statement }{ // // // // // Define some variables: // // a time string: string tstr = ""; // // // // // Start procedure: // message("4 " + time() + ": SpireProc_Set_SpecOffsetAuto started"); message("4 $Id: $"); // // // // // In case stop data: // if(dcuData) { SpireSendDrcuCmd(0x843e0000,0); } // // // // // Reset DCU (x1000) fifo: // tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_RESET_FIFOS(0x1000)"); Spire_RESET_FIFOS(0x1000); sync(); // // // // // Set data mode to 'Set automatic offset': // SpireSendDrcuCmd(0x843c0014,0); // // // // // Start data collection: // SpireSendDrcuCmd(0x843e0001,0); delay(3); // // // // // Stop data collection: // SpireSendDrcuCmd(0x843e0000,0); // // // // // Set data mode to 'Get offset data': // SpireSendDrcuCmd(0x843c001c,0); delay(1); // // // // // Start data collection: // SpireSendDrcuCmd(0x843e0001,0); delay(3); // // // // // Stop data collection: // SpireSendDrcuCmd(0x843e0000,0); // // // // // Flush DCU fifo: // tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_FLUSH_FIFO(0x1000)"); Spire_FLUSH_FIFO(0x1000); delay(2); // // // // // Set data mode back to nominal (==spec): // SpireSendDrcuCmd(0x843c0004,0); // // // // // In case start data collection: // if(dcuData) { SpireSendDrcuCmd(0x843e0001,0); } sync(); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_EndIltPcalFlash.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to reconfigure at the end of // SpirePhoto/Spectro_Cal_IltPcalFlash.txt // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // // 2009/05/06 V1.0: Initial version adapted from // SpireBb_EndBsmAngleCal (2009/05/05 V1.2), // SpirePhoto_Cal_IltPcalFlash (2009/03/04 V1.4), and // SpireSpectro_Cal_IltPcalFlash (2009/03/04 V0.5) // 2009/05/07 V1.1: Set dcuFrameNumber and scuFrameNumber back to continuous // to unset setting passed to VM. // 2009/06/05 V1.2: Replace Spire_SEND_DRCU_COMMAND with SpireSendDrcuCmd // as requested in SPR-1482. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_EndIltPcalFlash SPIRE 14047 { bool phot = true; // Photometer (==tick) or FTS (==untick)? bool isBright = false in [true,false]; // IsBright (==tick) flag string version01 = "v00"; // Version in cal.tab. SpireTable_PhotModeParams string version02 = "v00"; // Version in cal.tab. SpireTable_CommonModeParams bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // int mode_id = 0; string obsmode = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB EndIltPcalFlash reconfiguration started"); SpireMsg(2," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Set obsstep back to 0: // tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP(0)"); Spire_SET_OBS_STEP(0); // // // // // Set instrument back to Phot/Spec-STBY: // if(phot) { SpireProc_Set_PhotMode("PHTSTBY",isBright,version01,version02,debug); } else { SpireProc_Set_SpecMode("SPECSTBY",isBright,version01,version02,debug); } // // // // // Set number of DCU frames to continuous: // int dcuFrameNumber = 0; if(phot) { dcuFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","PHTSTBY","dcuFrameNumber","v00",debug); } else { dcuFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","SPECSTBY","dcuFrameNumber","v00",debug); } // SpireSendDrcuCmd(0x843d0000 + dcuFrameNumber,0); // // // // // Set number of SCU frames to continuous: // int scuFrameNumber = 0; if(phot) { scuFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","PHTSTBY","scuFrameNumber","v00",debug); } else { scuFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","SPECSTBY","scuFrameNumber","v00",debug); } SpireSendDrcuCmd(0xa0840000 + scuFrameNumber,0); delay(1); // // // // // End observation: // SpireProc_Set_EndObsAll(phot); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB EndIltPcalFlash reconfiguration ended"); SpireMsg(1," ..Reconfiguration to " + obsmode + "mode (" + (time() - t) + " seconds)"); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_CalcParam_RasterCross.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to calculate the pointing positions of an 11 x 11 raster // plus an interlaced cross // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/10/13 V0.1: Initial version adapted from // SpireProc_CalcParam_FpgInitialPointing (2008/07/28 V0.2) // 2008/11/03 V0.2: Allow to switch on/off interlaced cross // 2009/03/30 V0.3: Add header line. Promote debug option to input. // /////////////////////////////////////////////////////////////////////////// // {double[],double[]} procedure SpireProc_CalcParam_RasterCross { double d1 = 4.0; // Angular stepsize along Y axis [arcsec] double d2 = 4.0; // Angular stepsize along Z axis [arcsec] bool cross = true; // Add interlaced cross or use a simple 11x11 raster? bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Declare some variables: // int m = 11; // Number of points in a raster line [odd number!] int n = 11; // Number of raster lines or scan lines [odd number!] // // // // // Create 11x11 raster: // int npoints = m * n; double[] yarray = [0.0]; double[] zarray = [0.0]; double z = 0.0; double y = 0.0; int m2 = iround(double(m - 1) / 2.0); int n2 = iround(double(n - 1) / 2.0); int index = 0; bool odd = true; // for(int row = 1 .. n) { z = double(-1 * n2 + (row - 1)) * d2; if(debug) { //debug_print("row: " + row); //debug_print("z: " + z); } for(int col = 1 .. m) { if(odd) { y = double(-1 * m2 + (col - 1)) * d1; } else { y = double(m2 - (col - 1)) * d1; } zarray[index] = z; yarray[index] = y; index = index + 1; if(debug) { //debug_print("col: " + col); //debug_print("y: " + y); //debug_print("z,y: " + z + "," + y); } } if(odd) { odd = false; } else { odd = true; } } // // // // // Add interlaced cross raster: // if(cross) { for(int yc = 1 .. m - 1) { z = 0.0; y = (double(m2) - 0.5 - double(yc - 1)) * d1; if(debug) { //debug_print("yc/y: " + yc + ","+ y); } zarray[index] = z; yarray[index] = y; index = index + 1; } // for(int zc = 1 .. n - 1) { y = 0.0; z = (double(n2) - 0.5 - double(zc - 1)) * d2; if(debug) { debug_print("zc/z: " + zc + "," + z); } zarray[index] = z; yarray[index] = y; index = index + 1; } } // if(debug) { debug_print("zarray = " + zarray); debug_print("yarray = " + yarray); } // return {zarray,yarray}; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireSpectro_Cal_LoadCurvePcalOn.txt // /////////////////////////////////////////////////////////////////////////// // // CUS script for: 'Spec Load Curve with PCAL on' // // in *basic_fine_pointing* or *no_pointing* mode // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/07/07 V0.1: Initial version adapted from // SpirePhoto_Cal_LoadCurvePcalOn (2009/06/05 V1.0) // 2009/07/12 V0.2: Changed default values (SCR-SPIRE-1631) // // Sunil Sidher: // 2009/08/03 V0.3: Changed input PCAL bias current from 3.8mA to 6.0mA (SPIRE SCR-1768) /////////////////////////////////////////////////////////////////////////// // // Script assumes that: // // 1) Instrument is in SPECSTBY at beginning // (i.e. bias amplitude, phase, frequency [mclkdiv,biasdiv] are nominal) // // 2) Phase is kept constant (from input) during this test, i.e no // adjustment of the phase with changing bias amplitude and frequency // // 3) Bias frequency, sampling rate, and phase are input parameters // // 4) Boresight of array can be read from following cal table: // SpireTable_OpsParms.txt // // 5) PCAL bias calibration coefficients are read from following cal table: // SpireTable_PcalCurrentConvCoef.txt // // 6) List of bias amplitudes are read from same calibration file as for the // SpireSpectro_Cal_StdLoadCurve, i.e. SpireTable_StdLoadCurveLevels.txt // /////////////////////////////////////////////////////////////////////////// // obs SpireSpectro_Cal_LoadCurvePcalOn { /* ****************************************************** */ /* USER PARAMETER DEFINITION, CUS SIGNATURE for EX-HSpot */ /* ****************************************************** */ /* */ double ra = 0.0 in [0.0,360.0]; // RA of target double dec = 0.0 in [-90.0,90.0]; // DEC of target int naifid = 0; // NAIF identifier bool isBright = false; // Use settings for bright source (==tick) bool pointing = true; // Should telescope 'point' (==tick) or do a 'no pointing' (==untick)? /* */ double biasfreq = 160.09 in [80.0,240.0]; // Bias frequency [Hz] double samplerate = 80.05 in [1.0,80.5]; // Sampling rate [Hz] (Careful, don't exceed number of data packages to be transferred from spacecraft!) double phasedeg_ssw = 184.9 in [0.0,360.0]; // SSW Bias phase [deg] double phasedeg_slw = 190.6 in [0.0,360.0]; // SLW Bias phase [deg] int ftime = 10; // Readout time at each bias level [s] double pcal_bias =6.0 in [0.0,7.0]; // PCAL bias level [mA] string version01 = "v00"; // Version in cal table SpireTable_SpecModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams string version03 = "v00"; // Version in cal table SpireTable_StdLoadCurveLevels string version05 = "v00"; // Version in cal table SpireTable_OpsParms.txt string version09 = "v01"; // Version in cal table SpireTable_PcalCurrentConvCoef bool debug = false; // Allow (==tick) or suppress cus debug_print statements bool isSerendipity = true; // Allow (==tick) serendipity mode to be activated or prohibit (==untick) it (currently not in use)? bool isPcal = true; // Allow (==tick) regular PcalFlash in script or prohibit (==untick) it (currently not in use)?. bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ // ****************************************************** */ // CALCULATE DURATIONS for POINTING STATES */ // ****************************************************** */ // // // // // Check for is bright setting: // if(isBright) { isBright = false; error("IsBright does not make sense here. Try again (e.g. subtract the phase shift manually from the input)!"); } // // // // // Declare some variable: // // Spectrometer or FTS: bool phot = false; bool fts = !phot; // string tabName = ""; string selCol = ""; string selVal = ""; string tarCol = ""; string version = ""; double scirate = 0.0; double chkrate = 0.0; double nhkrate = 0.0; // int obsStep = 0; // // Hardcoded calibration tables: // string tabName01 = "SpireTable_SpecModeParams.txt"; string tabName02 = "SpireTable_CommonModeParams.txt"; string tabName03 = "SpireTable_StdLoadCurveLevels.txt"; string tabName04 = "SpireTable_BsmNominalSettings.txt"; string tabName05 = "SpireTable_OpsParms.txt"; string tabName06 = "SpireTable_SmecNominalSettings.txt"; string tabName09 = "SpireTable_PcalCurrentConvCoef.txt"; // Currently hardcoded version and model parameter: // string version06 = "v00"; // Version in cal table SpireTable_SmecNominalSettings string version04 = "v00"; // Version in cal table SpireTable_BsmNominalSettings string model = "initial"; // Model in cal table SpireTable_BsmNominalSettings // // Dummy value for Phot script: // (needed but not used in spec script!) // int psw_bias = 62; int pmw_bias = 62; int plw_bias = 62; int ptc_bias = 62; int psw_phase = 127; int pmw_phase = 127; int plw_phase = 127; int ptc_phase = 127; // // Currently hardcoded parameter: // Is (==tick) the DCU currently sampled? bool dcuData = false; // // // // // Setup mode: // // Set obsMode for QLA: string obsModeQla = "ENG_CAL_OBS44"; // Note: this needs entry in MIB table and in SpireTableInstConfigs.txt // // Set obsMode for datarates: string obsMode = "SEngCalObs"; // Note: this is currently only a maximum value // // // // // Retrieve bias levels used for the load curve: // tabName = tabName03; version = version03; int[] nbiaslist = SpireProc_CalcParam_LoadCurve(tabName,version,debug); // // Lookup first bias level: int ssw_bias = nbiaslist[0]; int slw_bias = nbiaslist[0]; // // // // // Convert user input to Hex values: // // for bias frequency and sample rate: // int[] hexvalues = SpireProc_CalcParam_BiasFreqSampFreq(biasfreq,samplerate,fts,debug); int mclkdiv = hexvalues[0]; int biasdiv = hexvalues[1]; if(debug) { debug_print("Hex values of mclkdiv/biasdiv are: " + mclkdiv + " " + biasdiv); } // // for bias phase: // int[] phasehex = SpireProc_CalcParam_SpecPhaseConvert(phasedeg_ssw,phasedeg_slw,debug); int ssw_phase = phasehex[0]; int slw_phase = phasehex[1]; // // // // // Read BSM home parameters: // // Select version flag and set GetTableEntry parameters: // version = version04; tabName = tabName04; selCol = "model"; // Name of column for selecting selVal = model; // Value of 'string' selector // // Read hold position from calibration table: // tarCol = "chop_0_I"; int hold_chop = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "jigg_0_I"; int hold_jigg = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // // // // Read SMEC home position from calibration file: // tarCol = "Home"; tabName = tabName06; selVal = version06; int smecHomePosn = ilookup(tabName,selVal,tarCol); // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // Calculate timing for the pointing request: // // BBs called during slew: int tslewmin = duration(SpireBb_StartLoadCurvePcalOn(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,mclkdiv,biasdiv,ssw_bias,pmw_bias,slw_bias,ptc_bias,ssw_phase,pmw_phase,slw_phase,ptc_phase,ssw_bias,slw_bias,ssw_phase,slw_phase,debug)); // // BBs carried out when the pointing is reached: if(pointing) { int tinithold = 0; } else { tinithold = tslewmin; } // // BB carried out during pointing: int tp = duration(SpireProc_Exec_SpecLoadCurvePcalOn(nbiaslist,ftime,dcuData,pcal_bias,version09,debug)); // // BB carried out at the end: int tfinalhold = duration(SpireBb_EndLoadCurvePcalOn(phot,isBright,version01,version02,debug)); // if(debug) { debug_print("tslewmin = " + tslewmin); debug_print("tinithold = " + tinithold); debug_print("tpointing = " + tp); debug_print("tfinalhold = " + tfinalhold); } // // ****************************************************** */ // POINTING MODE DECLARATION */ // ****************************************************** */ // // // // // Lookup boresight: // tabName = tabName05; selCol = "mode"; selVal = obsMode; tarCol = "Boresight"; version = version05; string ib = SpireProc_GetTableEntryString(tabName,selCol,selVal,tarCol,version,debug); // // Set pointing mode: // if(pointing) { int[] ts = basic_fine_pointing(true,tslewmin,tinithold,tfinalhold,ib,naifid,ra,dec,0.0,0.0,tp); } else { ts = no_pointing(true,tinithold,tfinalhold,tp); } // if(debug) { debug_print("Output timing vector from the pointing request: " + ts); } // }{ // ****************************************************** */ // POINTING STATES WITH OBSERVING MODE LOGIC */ // ****************************************************** */ // // // // // Set datarates: // string rateType = "chk"; chkrate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); ess_hk_data_rate(chkrate); // rateType = "nhk"; // nhkrate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); non_ess_hk_data_rate(nhkrate); // rateType = "sci"; scirate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); data_rate(scirate); // if(debug) { debug_print("Set CHK datarate to: " + chkrate); debug_print("Set NHK datarate to: " + nhkrate); debug_print("Set SCI datarate to: " + scirate); } // // Start the state_machine: // int[] state = [0]; // while(state[0] >= 0) { if(debug) { debug_print("Current state: " + state); } state = next_state(); if(debug) { debug_print("Next state: " + state); } // if(state[0] == 1) { // STATE = SLEW ( Spacecraft is slewing ) // // // // // Startup observation: // SpireBb_StartLoadCurvePcalOn(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,mclkdiv,biasdiv,psw_bias,pmw_bias,plw_bias,ptc_bias,psw_phase,pmw_phase,plw_phase,ptc_phase,ssw_bias,slw_bias,ssw_phase,slw_phase,debug); // //delay(timeSlewCal); } if(state[0] == 2) { // STATE = INIT_HOLD ( spacecraft is idling at source ) // // // // // If no pointing observation do stuff here which is // done nominally during SLEW: // if(!pointing) { // // // // // Startup observation: // SpireBb_StartLoadCurvePcalOn(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,mclkdiv,biasdiv,ssw_bias,pmw_bias,slw_bias,ptc_bias,ssw_phase,pmw_phase,slw_phase,ptc_phase,ssw_bias,slw_bias,ssw_phase,slw_phase,debug); // } // //delay(tinithold); // } if(state[0] == 3) { // STATE = POINT ( spacecraft is at nominal RA,DEC (staring, raster) ) // // // // // // Execute load curve with PCAL on: // SpireProc_Exec_SpecLoadCurvePcalOn(nbiaslist,ftime,dcuData,pcal_bias,version09,debug); // //delay(tp); // } if(state[0] == 5) { // STATE = FINAL_HOLD ( "sky" observation ends, performing final activ.) // // // // // Set scientific datarate back to zero: // data_rate(0.0); // // // // // Reconfigure at the end (incl. resetting of OBSID and BBIB): // // Hardcode STBY values for resetting (SPR-1477): // version01 = "v00"; version02 = "v00"; // SpireBb_EndLoadCurvePcalOn(phot,isBright,version01,version02,debug); // } if(state[0] == -1) { // STATE = END ( end of the pointing/commanding part of the code ) // } } } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_Set_SmecFramerate.txt // /////////////////////////////////////////////////////////////////////////// // // Set MCU framerate (SMEC sampling rate) // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/02/15 V0.1: Initial version adapted from // SpireProc_Set_BsmFramerate (2009/02/15 V0.2) // 2009/03/31 V0.2: Fix bug in calculation of framerateHz if input is 0. // 2009/06/05 V0.3: Replace Spire_SEND_DRCU_COMMAND with SpireSendDrcuCmd // as requested in SPR-1482. // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Set_SmecFramerate { int frate = 149; // Specifies the frame rate [Dec(Hex)] bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // string tstr = ""; // // // // // Start procedure: // tstr = SpireTimeStr(time()); SpireMsg(4," " + tstr + ": SpireProc_Set_SmecFramerate started"); SpireMsg(4," $Id:$"); // // // // // Calculate Hex value from user input: // double framerateHz = 0.0; if(frate != 0) { framerateHz = 1000000.0 / (double(frate) * 420.0); } SpireSendDrcuCmd(0x91c00000 + frate,0); delay(1); // if(debug) { debug_print("Set MCU framerate (==SMEC ampling rate) to " + frate + " [dec(Hex)]"); debug_print("Set MCU framerate (==SMEC ampling rate) to " + framerateHz + " [Hz]"); } // // // // // End procedure: // tstr = SpireTimeStr(time()); SpireMsg(4," " + tstr + ": SpireProc_Set_SmecFramerate ended"); // } // SpirePhotoPointJiggle // // $id$ // // The high level script for the Spire Photometer Point Source observing mode using a 7-pnt jiggle map // // 07 Nov 2007 KJK removed the current point number (np) from the STEP value set during Final Hold. // This value is not set in any other STEP value // 15 Feb 2008: KJK Now sets np in the STEP value for the FINAL_HOLD PCalFlash // 04 Nov 2008: KJK // added data_rate commands // added commands to setup the detector sampling beofre starting operations // 26 Jan 2008: KJK // Now uses general observation start Bb (SpireBb_StartObsAll) // Now uses general observation end Bb (SpireBb_EndObsAll // 07/02/2009 V0.1: KJK added new parameters to SpirePOF2Pointing, SpirePOF2Config, SpirePOF2End // 10/03/2009 KJK: // SCR 1274, add additional dummy parameters // Update input API to include versions for all cal tables // 02/07/2009 KJK: // Added configuration input parameters to pass to SpirePOF2Config, SpirePOF2Pointing and SpirePOF2End // 05/07/2009 KJK: // SPR-1593 - Updated calls to SpirePOF2Pointing and SpireBbPcalFlash to use flashVersion // // {int,int,int,int} obs SpirePhotoPointJiggle { double ra = 0.0 in [0.0,360.0]; // RA of Target double dec = 0.0 in [-90.0,90.0]; // Dec of Target int naifid = 0; // NAIF identifier string source = "point" in ["point","small","large"]; // source type bool choppingAvoidOn = false; // is chopping avoidance selected int choppingAvoidNumber = 0 in [0,3]; // the number of chopping avoid angles selected double choppingAvoidFrom1 = 0.0 in [0.0,360.0]; double choppingAvoidTo1 = 0.0 in [0.0,360.0]; double choppingAvoidFrom2 = 0.0 in [0.0,360.0]; double choppingAvoidTo2 = 0.0 in [0.0,360.0]; double choppingAvoidFrom3 = 0.0 in [0.0,360.0]; double choppingAvoidTo3 = 0.0 in [0.0,360.0]; int nRepetitions = 1 in [1,600]; // number of repeats of basic observing cycle double sourceFluxPSW = -1.0; double sourceFluxPMW = -1.0; double sourceFluxPLW = -1.0; bool isBright = false; // Use settings for bright source (==tick) bool isJiggleMap = true; int nCycles = 1; // total number of nod cycles to perform int nNodInts = 1; // number of times to repeat NJigg jiggles at each nod position int nCal = 999999; // number of nod cycles per Gyro calibration int nFlash = 999999; // number of nod cycles per PCAL flash string spireVersion = "v00"; // Version in cal table SpireTable_SpireParms string opsVersion = "v00"; // Version in cal table SpireTable_OpsParms string flashVersion = "v00"; // Version in cal table SpireTable_FlashParms string chopVersion = "v00"; // Version in cal table SpireTable_ChopParms string photVersion = "v00"; // Version in cal table SpireTable_PhotModeParams.txt string comVersion = "v00"; // Version in cal table SpireTable_CommonModeParams.txt bool debug = false; // debug messages flag bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ // ***************** // check user inputs // ***************** if(source != "point") { error("SpirePhotoPointJiggle: Source is not a point"); } // // ***************** // set constants // ***************** string obsMode = "POF2"; bool isPhot = true; // is a photometer observation double yOffset = 0.0; // offset to observation position from target in Y direction (arcsecs) double zOffset = 0.0; // offset to observation position from target in Z direction (arcsecs) // // ***************************************** // set up telescope pointing mode // ***************************************** // // ***** operating mode parameters ***** string ib = slookup("OpsParms.txt",obsMode,"Boresight"); // instrument boresight double deltaY = dlookup("OpsParms.txt",obsMode,"DeltaY"); // offset to pixel centre from boresight in Y direction (arcsecs) double deltaZ = dlookup("OpsParms.txt",obsMode,"DeltaZ"); // offset to pixel centre from boresight in Z direction (arcsecs) bool fixed = blookup("OpsParms.txt",obsMode,"Fixed"); // pattern angle definition double pattNod = dlookup("OpsParms.txt",obsMode,"Patt"); // direction of nod double chopThrow = dlookup("OpsParms.txt",obsMode,"D1"); // nod separation int jiggleTable = ilookup("OpsParms.txt",obsMode,"TableId"); // Jiggle Table ID int jiggleSize = ilookup("OpsParms.txt",obsMode,"TableSize"); // Jiggle Table length int nChops = ilookup("OpsParms.txt",obsMode,"NChops"); // number of chop cycles per jiggle position int nJiggs = ilookup("OpsParms.txt",obsMode,"NJiggs"); // number of jiggle positions per nod position int nNodPosns = ilookup("OpsParms.txt",obsMode,"NNodPosns"); // number of nod positions in a nod cycle bool initFlash = blookup("SpireParms.txt",obsMode,"InitFlash"); // initial flash flag bool endFlash = blookup("SpireParms.txt",obsMode,"EndFlash"); // final flash flag double cycTime = dlookup("OpsParms.txt",obsMode,"SrcTime"); // effective on source integration time per nod cycle // // ***** pointing mode timing parameters ***** {int,int,int,int,int,int} pof2Point = SpirePOF2Pointing(nCycles,nNodInts,nCal,nFlash,isBright,flashVersion,photVersion,comVersion,debug); int tSlewMin = pof2Point{0}; int tInitHold = pof2Point{1}; int tFinalHold = pof2Point{2}; int tp = pof2Point{3}; int tHold = pof2Point{4}; int nHold = pof2Point{5}; // // ***** fetch timing information ***** int tFlash = duration(SpireBbPcalFlash("PFlash",flashVersion,0,debug)); // time for a PCAL flash int tSerendipity = duration(SpireBbPhotSerendipity(obsMode,0)); // minimum time for a serendipity observation // // // ****** execute telescope pointing mode ****** // int[] ts = nodding_pointing(true,tSlewMin,tInitHold,tFinalHold,ib,naifid,ra,dec,fixed,pattNod,yOffset + deltaY,zOffset + deltaZ,nCycles * nNodPosns / 2,chopThrow,tp,tp,0,0,tHold,nHold,false); // }{ // ***************************************** // Display input parameters // ***************************************** SpireMsg(3," Using MODE " + obsMode); SpireMsg(3," Input values:"); SpireMsg(3," ..RA: " + ra); SpireMsg(3," ..Dec: " + dec); SpireMsg(3," ..NAIF ID: " + naifid); SpireMsg(3," ..Y Offset: " + yOffset); SpireMsg(3," ..Z Offset: " + zOffset); SpireMsg(3," ..No of Nod Cycles: " + nCycles); SpireMsg(3," ..No of Ints per Nod Posn: " + nNodInts); // SpireMsg(3," ..No of Nod Cycles between Gyro Calibrations: " + nCal); SpireMsg(3," ..No of Nod Cycles between Flashes: " + nFlash); SpireMsg(3," POF2 Fixed values:"); SpireMsg(3," ..ib: " + ib); SpireMsg(3," ..deltaY: " + deltaY); SpireMsg(3," ..deltaZ: " + deltaZ); SpireMsg(3," ..fixed: " + fixed); SpireMsg(3," ..pattNod: " + pattNod); SpireMsg(3," ..chopThrow: " + chopThrow); SpireMsg(3," ..jiggleTable: " + jiggleTable); SpireMsg(3," ..jiggleSize: " + jiggleSize); SpireMsg(3," ..nChops: " + nChops); SpireMsg(3," ..nJiggs: " + nJiggs); SpireMsg(3," ..nNods: " + nNodPosns); SpireMsg(3," ..initFlash: " + initFlash); SpireMsg(3," ..endFlash: " + endFlash); SpireMsg(3," Composite Nodding Pointing Mode Input values:"); SpireMsg(3," ..tSlewMin: " + tSlewMin); SpireMsg(3," ..tInitHold: " + tInitHold); SpireMsg(3," ..tFInalHold: " + tFinalHold); SpireMsg(3," ..tp: " + tp); SpireMsg(3," ..tHold: " + tHold); SpireMsg(3," ..nHold: " + nHold); SpireMsg(3," Composite Nodding Pointing Mode Output values:"); SpireMsg(3," ..tobs: " + ts[0]); SpireMsg(3," ..tslew: " + ts[1]); SpireMsg(3," ..tnod: " + ts[2]); SpireMsg(3," ..tss: " + ts[3]); SpireMsg(3," ..tload: " + ts[4]); SpireMsg(3," ..tend: " + ts[5]); // ***************************************** // execute observation // ***************************************** SpireMsg(0,"Observation Start"); SpireMsg(0," Uses observing mode POF2 (7-pnt Jiggle Map)"); SpireMsg(3," $Id:$"); data_rate(0.0); double chkrate = dlookup("Datarates.txt",obsMode,"CHK"); ess_hk_data_rate(chkrate); double nhkrate = dlookup("Datarates.txt",obsMode,"NHK"); non_ess_hk_data_rate(nhkrate); // //??p pointing file generation ------------------------------ double pos = 90.0; //??p double[] rdp0 = PtOffset([ra,dec,pos],zOffset,yOffset,0.0,false); //??p pointing file generation ------------------------------ // int tslew = ts[1]; // slew time string tstr = ""; // time string bool holdFlag = false; // true when holding at nod position int otf = 0x8000; // On Target Flag int nf = 0x4000; // Nod Flag int step = 0x0; // value of STEP parameter double srcTime = 0.0; // total on source integration time int np = 0; // pointing counter double s = 0.0; int[] state = [0]; while(state[0] >= 0) { state = next_state(); if(state[0] == 1) { // *********************** SLEWING tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " Slewing to start position"); // set up observation parameters SpireBb_StartObsAll(obsMode); // perform serendipity operation if possible if(tslew > tSerendipity + tSlewMin) { SpireBbPhotSerendipity(obsMode,tslew - tSlewMin - 2); } // configure instrument for operations SpireBbPOF2Config(obsMode,isBright,photVersion,debug); } if(state[0] == 2) { // *********************** INITIAL HOLD tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " Initialising Instrument"); // initialise instrument SpireBbPOF2Init(); // calibrate if necessary if(initFlash || nFlash < nCycles) { tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " PCAL Calibration inserted"); SpireBbPcalFlash("PFlash",flashVersion,otf,debug); } } if(state[0] == 5) { // *********************** FINAL HOLD tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " Reconfiguring Instrument"); // calibrate if necessary if(endFlash || nFlash < nCycles) { tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " PCAL Calibration inserted"); SpireBbPcalFlash("PFlash",flashVersion,otf | np,debug); } // reconfigure back to PHOT_STBY configuration SpireBbPOF2End("PHTSTBY",isBright,photVersion,comVersion,debug); SpireBb_EndObsAll(isPhot); } if(state[0] == 6) { // *********************** HOLD tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " PCAL Calibration inserted"); SpireBbPcalFlash("PFlash",flashVersion,otf,debug); } if(state[0] == 3) { // *********************** POINTING //??p pointing file generation ------------------------------ //??p PtOutput(rdp0); //??p pointing file generation ------------------------------ tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " Instrument at Pointing Position"); SpireMsg(2," " + tstr + " Start Jiggles " + np); step = otf; s = SpireBbJiggle("POF2",jiggleTable,0,nJiggs,nNodInts,step); srcTime = srcTime + s; np = np + 1; step = 0; SpireBbMove(step); } if(state[0] == 7) { // *********************** NOD //??p pointing file generation ------------------------------ //??p PtNod(rdp0,patt,d1,patt,false,false); //??p pointing file generation ------------------------------ tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " Instrument at Nod Position"); SpireMsg(2," " + tstr + " Start Jiggles " + np); step = nf | otf; s = SpireBbJiggle("POF2",jiggleTable,0,nJiggs,nNodInts,step); srcTime = srcTime + s; np = np + 1; step = 0; SpireBbMove(step); } if(state[0] == 9) { // *********************** LOAD } } assert (time() == ts[0] + ts[1]); // // finish observation tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " Instrument Reconfigured"); // // SpireMsg(0,"Observation Completed (" + time() + " seconds)"); SpireMsg(0,"Note: Total time (s) = Observation Completed time - slew time + Observatory Overheads"); return {nCycles,iround(cycTime),iround(srcTime),time() - iround(srcTime) - tslew}; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_CalcParam_BsmFramerate.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to translate user input in mV for bias amplitude // into nearest Hex values for psw_bias, pmw_bias, plw_bias, and ptc_bias // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/02/15 V0.1: Initial version adapted from // SpireProc_Set_BsmFramerate (2008/11/13 V0.1) // /////////////////////////////////////////////////////////////////////////// int procedure SpireProc_CalcParam_BsmFramerate { double frateHz = 0.0; // Input BSM framerate [Hz] bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Convert from Hz to RAW values: // int frateInt = iround(1000000.0 / (frateHz * 420.0)); // // // // // Debug printout: // if(debug) { debug_print("Input Hz value for BSM framerate: " + frateHz); debug_print("Output Dec(Hex) values for BSM framerate: " + frateInt); } // // // // // Return required values: // return frateInt; } // SpireBbCoolerRecycle // // $id$ // // This building block executes the cooler recycle procedure // // The instrument should be in the REDY mode before execution of this observation // // 17/11/2008 KJK added sync command // block SpireBbCoolerRecycle SPIRE 2568 { }{ int t0 = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB Cooler Recycle started"); SpireMsg(2," $Id: SpireBbCoolerRecycle.txt,v 1.1 2007/08/02 10:15:44 kking Exp $"); // int cmd = 0x0; // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // // Select the current instrument in operation (prime/redundant) string side = "prime"; // // Command List info // int tableid = 0x53; // Table Identifier for CREC VM int startindex = 0; // Start Index in CREC VM Table int nparams = 0x15; // Number of parameters to VM // // Retrieve the VM input parameters int a = ilookup("CoolerRecycling.txt","a",side); // Heat Switch ON current (during Recycling) int b = ilookup("CoolerRecycling.txt","b",side); // Heat Switch OFF current int c = ilookup("CoolerRecycling.txt","c",side); // Pump Heat Switch Actuation Temperature int d = ilookup("CoolerRecycling.txt","d",side); // Pump Heater Dissipation 1 int e = ilookup("CoolerRecycling.txt","e",side); // Pump Condensation Temperature 1 int f = ilookup("CoolerRecycling.txt","f",side); // Pump Heater Dissipation 2 int g = ilookup("CoolerRecycling.txt","g",side); // Pump Condensation Temperature 2 int h = ilookup("CoolerRecycling.txt","h",side); // Pump Heater Dissipation 3 int i = ilookup("CoolerRecycling.txt","i",side); // Pump Heater Dissipation 4 int j = ilookup("CoolerRecycling.txt","j",side); // Pump Condensation Temperature Threshold int k = ilookup("CoolerRecycling.txt","k",side); // Evaporator Condensation Temperature int l = ilookup("CoolerRecycling.txt","l",side); // Evaporator Heat Switch Actuation Temperature int m = ilookup("CoolerRecycling.txt","m",side); // Pump Threshold Temperature int n = ilookup("CoolerRecycling.txt","n",side); // Heat Switch ON current int o = ilookup("CoolerRecycling.txt","o",side); // Sampling Interval (sec) int p = ilookup("CoolerRecycling.txt","p",side); // Heatswitch Timeout (min) int q = ilookup("CoolerRecycling.txt","q",side); // Pump Heating Timeout 1 (min) int r = ilookup("CoolerRecycling.txt","r",side); // Pump Heating Timeout 2 (min) int s = ilookup("CoolerRecycling.txt","s",side); // Evaporator Timeout (min) int t = ilookup("CoolerRecycling.txt","t",side); // Pump Cooling Timeout (min) int u = ilookup("CoolerRecycling.txt","u",side); // Global Timeout (min) // // Set Mode to CREC mois_comment("Set the SPIRE mode to CREC for Cooler Recycle"); SpireSetObsMode("CREC"); // // start executing recycle VM mois_comment("Execute the SPIRE command to perform Automatic Cooler Recycle"); mois_spacon("This command will take about " + (u + 1) + " minutes to execute"); {int}[] crecparams = [{a},{b},{c},{d},{e},{f},{g},{h},{i},{j},{k},{l},{m},{n},{o},{p},{q},{r},{s},{t},{u}]; tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_RUN_VM_RAW(" + tableid + "," + startindex + "," + nparams + "," + crecparams + ")"); Spire_RUN_VM_RAW(tableid,startindex,nparams,crecparams); // Wait for completion // Insert a delay equal to the CREC VM global time out plus a minute delay(u * 60 + 58); // // Set MODE to REDY mois_comment("Set the SPIRE mode to REDY"); SpireSetObsMode("REDY"); // sync(); // // completion tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB Cooler Recycle ended"); SpireMsg(1," ..Cooler Recycle (" + (time() - t0) + " seconds)"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_Set_BsmChop.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to execute chopping or jiggling operations. Script returns // the actual time on-source. It sets the obsStep, resets the FIFOs, // runs the VM, and flushes the FIFOs. It does not set the datarate. // // Note: VM does not reset dcusample/bsmsample at end, so this needs // to be done in the surrounding end script. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/02/16 V0.1: Initial version adapted from // SpireBb_Chop (2009/01/27 V1.0) // Added VM table parameters as input and removed // BSM framerate from input. Round wait_time up and // removed the adding of 3s for saftey. // // Sunil Sidher // 2009/07/28 V0.2: Added 2s to the wait_time to prevent the step changing too // soon (Recommendation 3 in SPIRE SCR-1710) /////////////////////////////////////////////////////////////////////////// // double procedure SpireProc_Set_BsmChop { int vmId = 71; // Raw VM table number [Dec(Hex)] int vmIndex = 0; // Raw VM index [Dec(Hex)] int nParms = 10; // Number of parameters passed to VM int onChop = 0; // on-source Chop position int onJigg = 0; // on-source Jiggle positio int offChop = 0; // off-source Chop position int offJigg = 0; // off-source Jiggle position int ncycles = 50; // Number of chop cycles [#] int chop_period = 500000; //period of chop cycles in [microsec] int dcumode = 0; // DCU data mode (e.g. 0 == Full photometer) int dcusample = 4; //Number of DCU samples per chop position [#] int dcudelay = 34959; //Dealy to start sampling the DCU [microsec] int bsmsample = 31; //Number of BSM samples per position [#] int step = 0; // Step number [dec] bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Define some variables: // int t = time(); string tstr = ""; // // // // // Start procedure: // tstr = SpireTimeStr(time()); SpireMsg(4," " + tstr + ": SpireProc_Set_BsmChop started"); SpireMsg(4," $Id:$"); // // // // // Set obsstep: // SpireProc_Set_ObsStep(step,debug); // // // // // Reset DCU and MCU (x3000) fifo: // tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_RESET_FIFOS(0x3000)"); Spire_RESET_FIFOS(0x3000); delay(1); // // // // // Setup VM parameters: // {int}[] chopparams = [{onChop},{onJigg},{offChop},{offJigg},{ncycles},{chop_period},{dcumode},{dcusample},{dcudelay},{bsmsample}]; // // // // // Execute VM: // tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_RUN_VM_RAW(" + vmId + "," + vmIndex + "," + nParms + "," + chopparams + ")"); Spire_RUN_VM(vmId,vmIndex,nParms,chopparams); // // // // // Finish VM: // // Calculate time for VM to finish (add 0s for safety): // int wait_time = iceil(double(chop_period + dcudelay) * double(ncycles) / 1000000.0 + 2.0); if(debug) { debug_print("Wait time will be :" + " " + wait_time + " " + "sec"); } delay(wait_time); // // // // // Flush DCU and MCU fifos: // tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_FLUSH_FIFO_RAW(0x3000)"); Spire_FLUSH_FIFO(0x3000); delay(2); // // // // // Calculate time on source: // if(debug) { debug_print("chop_period: " + chop_period); debug_print("ncycles: " + ncycles); debug_print("dcudelay: " + dcudelay); } double srcTime = double(ncycles) * ((0.5 * double(chop_period) - double(dcudelay)) / 1000000.0); if(debug) { debug_print("On source time: " + srcTime + " [s]"); } // // // // // End procedure: // tstr = SpireTimeStr(time()); SpireMsg(4," " + tstr + ": SpireProc_Set_BsmChop ended"); SpireMsg(1," ..Chop/Jigg (" + (time() - t) + " seconds)"); // return srcTime; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireSpectro_Cal_BsmAngleCal.txt // /////////////////////////////////////////////////////////////////////////// // // CUS script for: 'Spec BSM Angle Calibration' // // in *basic_fine_pointing* mode or *no_pointing* mode // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/11/07 V0.1: Initial version adapted from // SpirePhoto_Cal_BsmAngleCal (2008/11/07 V0.3) // 2008/11/12 V0.2: Implement mode setting; Add isBright // 2009/01/21 V0.3: Modify unreasonable default values of ref pos; // Correct pass-on of chop/fts parameter to low level script; // Correct typo in input description; Add ranges for // input positions; Add safety check pos1= 0) { if(debug) { debug_print("Current state: " + state); } state = next_state(); if(debug) { debug_print("Next state: " + state); } // if(state[0] == 1) { // STATE = SLEW ( Spacecraft is slewing ) // // // // // Startup observation: // SpireBb_StartBsmAngleCal(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,framerate,smecHomePosn,debug); // // //delay(timeSlewCal); } if(state[0] == 2) { // STATE = INIT_HOLD ( spacecraft is idling at source ) // // // // // If no pointing observation do stuff here which is // done nominally during SLEW: // if(!pointing) { // // // // // Startup observation: // SpireBb_StartBsmAngleCal(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,framerate,smecHomePosn,debug); } // // // // // Set offsets: // SpireBb_SpecOffsetAuto(dcuData,debug); // // // // // Stop any remaining SMEC movement: // SpireBb_SmecHold(debug); // //delay(tinithold); // } if(state[0] == 3) { // STATE = POINT ( spacecraft is at nominal RA,DEC (staring, raster) ) // // // // // // Execute BSM angle calibration: // SpireProc_Exec_BsmAngleCal(increment,ref_chop,ref_jigg,hold_chop,hold_jigg,max_chop,max_jigg,min_chop,min_jigg,vmId,vmIndex,nParms,chopf,ftime,framerate,biasdivHz,fts,chop,debug); // //delay(tp); // } if(state[0] == 5) { // STATE = FINAL_HOLD ( "sky" observation ends, performing final activ.) // // // // // Set scientific datarate back to zero: // data_rate(0.0); // // // // // Reconfigure at the end (incl. resetting of OBSID and BBIB): // SpireBb_EndBsmAngleCal(phot,hold_chop,hold_jigg,isBright,version01,version02,debug); } if(state[0] == -1) { // STATE = END ( end of the pointing/commanding part of the code ) // } } } //$Id: PHOT_dpu_dmc_setup.txt,v 1.5 2008/05/28 09:27:05 vanessad Exp $ // Missionphase : // // Purpose : Prepare DPU and DMC for photometry // // TCL author : TM // TCL file : tm_phot_dpu_dmc_setup.tcl // CUS author : DAC // Script file : PHOT_dpu_dmc_setup.txt // // Input arguments // type name description // // Return values // Type Name Default Description // // Description : This script will set the DPU HK list, write and set the // FPGA timing parameters (if necessary), set the // synchronization source for the sequencer, forward data // to the packet encoder and validate the sciece data // // Dependencies : // // Preconditions : // // Comments : // // Version : 1.1 // History : 0.1 11-apr-2005 creation by DAC; based on V1.2 of TM // 0.2 13-apr-2005 DAC Graded as a procedure // 0.3 20-oct-2005 DAC Use FPGA parameters from SPEC // : 1.0 12-apr-2006 update by TM for new FPGA parameter settings // taking out switch-on of temp sensors // 1.1 11-aug-2006 TM delay(1) introduced between sequential // FPGA parameter settings // 2.0 21-nov-2006 Removed "duree" information; introduced // CAL file holding FPGA parametrer phase_inc // Spelled out FPGA parameters // 2.1 15-jan-2008 Script renamed *txt for PV database, added // demanded TC as per SCR-0797 // 2.2 15-Jul-2008 update IA_CHOP address // 2.3 11-nov-2008 change phase_shift_reg to 1 procedure PHOT_dpu_dmc_setup { string hk_list = "BOTH Array" in ["BOTH Array","BLUE Array","RED Array"]; /* sync source */ /* 1 = synchronize on blue spectrometer ramps */ /* 2 = synchronize on red spectrometer ramps */ /* 4 = synchronize on BOL readouts */ int sync_srce = 4; }{ // Start regular HK Pacs_DPU_SET_HK_LIST("PHOT",hk_list); // Add chop_ia information as per SCR-0797 // Description of DMC_WRT_DIAG_HK_CONF_TAB from DEC/MEC User Manual: // // Custom Hk Configuration Table : This buffer contains configuration data // allowing us to increase the number of available HK measure without // recompiling the application. The table is composed of 10 entries each of // them being 5 words long: //f1. the address of the memory area to monitor // int f1 = 0x3469f; int f1 = 0x346ab; //f2. the size (in words) of the memory area to monitor int f2 = 0x1; //f3. the size (in bytes) of the memory area to monitor int f3 = 0x2; //f4. a pointer to a function performing the monitoring (if you want to use this // field, it is highly probable that you need to patch your code anyway to // upload the new monitoring function). int f4 = 0x0; //f5. the validity at startup (0 = invalid, 1 = valid) int f5 = 0x1; // All the fields are initialized to zero at startup. (for advanced users only) {int}[] params = [{f1},{f2},{f3},{f4},{f5}]; int[] forsum = [f1,f2,f3,f4,f5]; int check_sum = checksum("int",forsum); int wrdLen = 5; Pacs_DMC_WRT_DIAGHK_CONF_TAB(wrdLen,params,check_sum); int iBOL = 4; params = [{iBOL}]; check_sum = checksum("int",[iBOL]); Pacs_DMC_WRT_BOL_REC_OPT(params,check_sum); // DEC/MEC User Manual; section 4.4.3 // 1. and 2. Stop forwarding data to packet encoder (bit 2 set) int iPAR = 4; params = [{iPAR}]; check_sum = checksum("int",[iPAR]); Pacs_DMC_WRT_B_DEC_REC_OPT(params,check_sum); Pacs_DMC_WRT_R_DEC_REC_OPT(params,check_sum); // 3. Upload DMC_WRT_TIMING_FPGA_PAR with {0,1,0,26,0x977602A,0x32} // Write and set FPGA timing parameters // DMC_WRT_TIMING_FPGA_PAR int sync_src_det = 0; // changes for Phase shift from 0 to 1 int phase_shift_reg = 1; int bolc_freq_div = 0; int pd5_reg = 26; //int phase_inc: read from CAL-U file FPGA_params int ctrl_reg = 0x32; // Read phase_inc from CAL-U file FPGA_params. // Here we always read the row "Plast". When updating the CAL-U file rename // the existing "Plast" row to "Pold1", "Pold2", etc. and add the latest // phase_inc in the new row "Plast" int phase_inc = ilookup("FPGA_params","Plast","phase_inc"); int[] aux = [sync_src_det,phase_shift_reg,bolc_freq_div,pd5_reg,phase_inc,ctrl_reg]; check_sum = checksum("int",aux); {int}[] parlist = Array2grp_1(aux); // Write to register and activate Pacs_DMC_WRT_TIMING_FPGA_PAR(parlist,check_sum); // 4. Apply the new parameters Pacs_DMC_SET_TIMING_FPGA_PAR(); // 5. Change the sync signal Pacs_DMC_SYNCHRONIZE_ON_DET(sync_srce); // 6. Wait 1 second delay(1); //7. Upload WRT_TIMING_FPGA_PAR with {0,1,0,26,0x977602A,0x22} ctrl_reg = 0x22; aux = [sync_src_det,phase_shift_reg,bolc_freq_div,pd5_reg,phase_inc,ctrl_reg]; check_sum = checksum("int",aux); parlist = Array2grp_1(aux); // Write to register and activate Pacs_DMC_WRT_TIMING_FPGA_PAR(parlist,check_sum); // 8. Apply the new parameters Pacs_DMC_SET_TIMING_FPGA_PAR(); // 9. Start forwarding data from BOL to SPU (bit 2 is clear) iBOL = 0; params = [{iBOL}]; check_sum = checksum("int",[iBOL]); Pacs_DMC_WRT_BOL_REC_OPT(params,check_sum); // Validate science data photometry Pacs_DMC_VAL_SCI_DATA_BOTH(); } // SpireBbEndObs // // $Id: SpireBbEndObs.txt,v 1.1 2007/08/02 10:15:44 kking Exp $ // // Building Block to reconfigure after an engineering observation // // 17/11/2008 KJK: added sync() statement to round up total duration // block SpireBbEndObs SPIRE 3 { }{ int t = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB End Obs started"); SpireMsg(2," $Id: SpireBbEndObs.txt,v 1.1 2007/08/02 10:15:44 kking Exp $"); // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); delay(1); // // set STEP to one tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP_RAW(0x0001)"); Spire_SET_OBS_STEP_RAW(0x1); delay(1); // // Clear OBSID/BBID/STEP to null values // // set STEP to zero tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP_RAW(0x0000)"); Spire_SET_OBS_STEP_RAW(0x0); // tstr = SpireTimeStr(time()); message("5 " + tstr + "Cmd: Spire_SET_BBID_RAW(0x80000000)"); Spire_SET_BBID_RAW(0x80000000); delay(1); // int obsId = SpireNullObsid(); tstr = SpireTimeStr(time()); hstr = SpireHexStr(obsId,8); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBSID_RAW(" + hstr + ")"); Spire_SET_OBSID_RAW(obsId); // sync(); // // ..... completion ..... tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB End Obs ended"); SpireMsg(1," ..Obs Reconfiguration (" + (time() - t) + " seconds)"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_PhotJfetVssTestC.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to perfomr VSS C test for photometer // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // // 2009/05/21 V0.1: Initial version adapted from PJFET_Vss_TestC.txt // (undated, as of 2009/05/21 in fs2_test@lichfield by SDS) // /////////////////////////////////////////////////////////////////////////// // block SpireBb_PhotJfetVssTestC SPIRE 14070 { double jfet_Vss_start = -1.0; //Starting JFET source voltage double jfet_Vss_end = -2.0; //ending JFET source voltage double jfet_Vss_step = -0.5; //steping JFET source volatge int ftime = 30; //wait time at each level; bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // int mode_id = 0; string obsmode = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB PhotJfetVssTestC started"); SpireMsg(2," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Calculate the number of levels: // int n_levels = iround(abs((jfet_Vss_end - jfet_Vss_start) / jfet_Vss_step)); int[] jfet_Vss_levels = [0x0]; for(int j = 0 .. n_levels) { jfet_Vss_levels[j] = iround((jfet_Vss_start + jfet_Vss_step * double(j)) / -5.0 * 255.0); } // // // // // Set data mode to nominal: // SpireSendDrcuCmd(0x843c0000,0); // // // // // Start data generation: // SpireSendDrcuCmd(0x843e0001,0); delay(1); // // // // // Do loop over Jfet values: // int loop_cnt = 0; while(loop_cnt != n_levels + 1) { delay(1); for(int k = 0 .. 11) { SpireSendDrcuCmd(0x84050000 + 0x10000 * k + jfet_Vss_levels[loop_cnt],0); delay(1); if(debug) { debug_print("levels is:" + jfet_Vss_levels[loop_cnt]); } } // Now set the TC JFET Vss SpireSendDrcuCmd(0x84140000 + jfet_Vss_levels[loop_cnt],0); delay(1); Spire_SET_OBS_STEP(0x2 + loop_cnt); delay(ftime); Spire_SET_OBS_STEP(0xffff); loop_cnt = loop_cnt + 1; } // Set Vss back to nominal value of -1.5 V for(int l = 0 .. 11) { SpireSendDrcuCmd(0x8405004c + 0x10000 * l,0); delay(1); } // Now set TC JFET Vss back to nominal value of -1.5 V SpireSendDrcuCmd(0x8414004c,0); delay(1); // Stop data generation and flush DCU FIFO SpireSendDrcuCmd(0x843e0000,0); delay(1); message("5 " + time() + "Cmd: Spire_FLUSH_FIFO(0x1000)"); Spire_FLUSH_FIFO(0x1000); delay(3); message("5 " + time() + "Cmd: Spire_RESET_FIFOS(0x7000)"); Spire_RESET_FIFOS(0x7000); delay(1); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB PhotJfetVssTestC ended"); SpireMsg(1," ..StartPtcPwr took " + (time() - t) + " seconds)"); // } /////////////////////////////////////////////////////////////////////////// // // SpireBb_StartupObs.txt // /////////////////////////////////////////////////////////////////////////// // // Script will set OBSID and reset the DRCU counter // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/05/01 V0.1: Initial version adapted from old StartObs.txt and // ClearObs.txt templates used in ILT; replaces old // SpireBbStartObs.txt script // 2008/11/12 V0.2: Add setting of Obsmode parameter // currently (for SOVT2) fixed to 0x3E8 == ENG_CAL_OBS // /////////////////////////////////////////////////////////////////////////// // block SpireBb_StartupObs SPIRE 14001 { string obsmode = "ENG_CAL_OBS"; // Parameter to specify the configuration mode }{ // // // // // Set the OBSIDs for the current observation: // Spire_SET_OBSID($OBSID); //delay(1); // // // // // Set the BBs to SPIRE bbid: // Spire_SET_BBID($BBID); delay(1); // // // // // Reset DRCU counter: // Spire_RESET_DRCU_COUNTERS(); //delay(1); // // // // // // Set the MODE using the SET_OBS_MODE Spire command // // int mode_id = ilookup("InstrumentConfigurations.txt",obsmode,"value"); int mode_id = 1000; // Fixed for SOVT2 Spire_SET_OBS_MODE(mode_id); // // // // // Set the BBID(s) to null: // Spire_SET_BBID(0x80000000); delay(1); // // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireSpectro_CalGCO_FovMapFpgScan.txt // /////////////////////////////////////////////////////////////////////////// // // CUS script for: 'Spec FOV Mapping Line Scan (FPG Scan)' // // in * line_scan_with_off_pointing * mode // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/11/06 V0.1: Initial version, adapted from // SpirePhoto_CalGCO_FovMapFpgScan (2008/09/16 V0.2) // allow scan along 60deg symmetry line // 2008/11/12 V0.2: Implement mode setting; Add isBright // 2009/03/02 V0.3: Add debug_print as input abd pass to low level scripts. // Use new SpireBb_EndObsAll and SpireBb_StartObsAll. Read // nominal bias frequency and bias dividerfrom new // SpireTable_SpecModeParams. Implemented setting of // datarates. Implemented isBright setting. Change call to // SpireBb_StartDcuData. Replace call to SpireProc_Set_ObsStep // with call to SpireBb_SetObsStep. Introduce // SpireBb_WaitAtGcp at GCP and use SpireBbScanLine during // the line scanning to collect data within defined BBIDs. // Use SpireBb_SpecSetMode to set to SPECSTBY during SLEW and // FINAL_HOLD. Change calculation of gcp_period_min to match // SpirePhoto_CalGCO_FovMapFpgScan. Do no set obsStep to zero // in FINAL_HOLD this is already done in SpireBb_WaitAtGcp. // 2009/03/04 V0.4: Add isSerendipity, isPcal, and 8 more dummy parameters // to the script for future use. Set gcp_time to // 20 (desired value for SOVT2). // 2009/05/07 V0.5: Add in move BSM/SMEC to hold/home at start. Add new // SpireBb_SmecHold to account for the fact that // SpireBb_SmecMove2Home does not stop SMEC. // Gather procedures at start and end in separate BB. // /////////////////////////////////////////////////////////////////////////// // Script assumes that: // // 1) Instrument is in SPECSTBY // (i.e. bias amplitude, phase, frequency [mclkdiv,biasdiv] are nominal) // // 2) Bias frequency (mclkdiv) and sampling rate (biasdiv) are the same // for all three arrays and could be taken from following cal table: // SpireTable_SpecModeParams.txt // // 3) That currently the gyro reconstruction is only available for // non-SSO targets. // /////////////////////////////////////////////////////////////////////////// // obs SpireSpectro_CalGCO_FovMapFpgScan { /* ****************************************************** */ /* USER PARAMETER DEFINITION, CUS SIGNATURE for EX-HSpot */ /* ****************************************************** */ double ra = 0.0 in [0.0,360.0]; // RA of target [deg] double dec = 0.0 in [-90.0,90.0]; // DEC of target [deg] int naifid = 0; // Put '0' to use RA and DEC, otherwise put correct 'NAFID' bool isBright = false; // Use settings for bright source (==tick) /* */ bool refSelected = true; // ExpHSpot (refSelected) parameter bool refByOffset = true; // ExpHSpot (refByOffset) parameter double raoff = 0.0 in [0.0,360.0]; // RA of GCP position, or relative offset [deg] double decoff = 0.0 in [-90.0,90.0]; // DEC of GCP position, or relative offset [deg] string ib = "S24_0"; // Central aperture (defined in SIAM) of raster double d1 = 500.0 in [20.0,7200.0]; // Length of the scan line along scan axis [arcsec] double d2 = 31.4 in [2.0,480.0]; // Spacing of adjacent scan lines along orthogonal axis [arcsec] int n = 9 in [1,240]; // Number of raster lines or scan lines. double rate = 30.0 in [0.1,60.0]; // Scan rate of a line scan [arcsec/s] string scan_dir = "plusY" in ["plusY","minusY","plusZ","minusZ","30degplusYZ","210degminusYZ","60degplusYZ","240degminusYZ"]; // Scan direction of first line int gcp_time = 20; // Time spend at GCP (gyro calibration position) [s] int gcp_period = 600; // Maximum time between successiv GCP visits [s] string version01 = "v00"; // Version in cal table SpireTable_SpecModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParam bool debug = false; // Allow (==tick) or suppress cus debug_print statements bool isSerendipity = true; // Allow (==tick) serendipity mode to be activated or prohibit (==untick) it (currently not in use)? bool isPcal = true; // Allow (==tick) regular PcalFlash in script or prohibit (==untick) it (currently not in use)?. bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ // ****************************************************** */ // CALCULATE DURATIONS for POINTING STATES */ // ****************************************************** */ // // // // // Current restrictions: // if(naifid != 0) { error("Currently no SSO objects are allowed as input!"); } // // // // // Declare some variable: // // Photometer or FTS: bool phot = false; bool fts = !phot; // // Start timing of script: int start = time(); int linestart = time(); // // Line counter (start at 1): int linecount = 1; // // GCP counter (start at 1): int gcpcounter = 1; // // string tabName = ""; string selCol = ""; string selVal = ""; string tarCol = ""; string version = ""; double scirate = 0.0; double chkrate = 0.0; double nhkrate = 0.0; // int obsStep = 0; // // Hardcoded calibration tables: // string tabName01 = "SpireTable_SpecModeParams.txt"; string tabName02 = "SpireTable_CommonModeParams.txt"; string tabName03 = "SpireTable_PcalLevelCheckLevels.txt"; string tabName06 = "SpireTable_BsmNominalSettings.txt"; string tabName09 = "SpireTable_SmecNominalSettings.txt"; // // Currently hardcoded version parameter: // string version09 = "v00"; // Version in cal table SpireTable_SmecNominalSettings string version06 = "v00"; // Version in cal table SpireTable_BsmNominalSettings string model = "initial"; // Model in cal table SpireTable_BsmNominalSettings // // Currently hardcoded parameter: // Is (==tick) the DCU currently sampled? bool dcuData = false; // // // // // Setup mode: // // Set obsMode for QLA: string obsModeQla = "ENG_CAL_OBS33"; // Note: this needs entry in MIB table and in SpireTableInstConfigs.txt // // Set obsMode for datarates: string obsMode = "SEngCalObs"; // Note: this is currently only a maximum value // // // // // Increase scan length to allow time to mark start/end of the scan: // int tStart = 2; int tEnd = 2; // Note: the two 2 seconds are justified in SpireBbScanLine.txt d1 = d1 + double(tStart + tEnd) * rate; // // // // // Read BSM home parameters: // // Select version flag and set GetTableEntry parameters: // version = version06; tabName = tabName06; selCol = "model"; // Name of column for selecting selVal = model; // Value of 'string' selector // // Read hold position from calibration table: // tarCol = "chop_0_I"; int hold_chop = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "jigg_0_I"; int hold_jigg = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // // // // Read SMEC home position from calibration file: // tarCol = "Home"; tabName = tabName09; selVal = version09; int smecHomePosn = ilookup(tabName,selVal,tarCol); // // // ****************************************************** */ // CALCULATE DURATIONS for POINTING STATES */ // ****************************************************** */ // // // // // Calculate timing for the pointing request: // // BBs called during slew: int tslewmin = duration(SpireBb_StartFovMapFpgScan(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,debug)); // // BBs carried out when the pointing is reached: int tinithold = duration(SpireBb_SpecOffsetAuto(dcuData,debug)) + duration(SpireBb_StartDcuData()); // // BB carried out during pointing: //int tp = 0; // // BB carried at off position: int top = duration(SpireBb_WaitAtGcp(gcp_time,debug)); // == Time spent at the OFF position. // // BB carried out at the end: int tfinalhold = duration(SpireBb_EndFovMapFpgScan(phot,hold_chop,hold_jigg,isBright,version01,version02,debug)) + duration(SpireBb_StopDcuData()); // // Debug_printing? // if(debug) { debug_print("tslewmin = " + tslewmin); debug_print("tinithold = " + tinithold); //debug_print("tpointing = " + tp); debug_print("tfinalhold = " + tfinalhold); } // // ****************************************************** */ // POINTING MODE DECLARATION */ // ****************************************************** */ // // // // // Fixed parameters for pointing mode: // bool fixed = false; // Pattern orientation (true==sky; false==array) double yoff = 0.0; // Offset of pattern in the direction of the +Y double zoff = 0.0; // Offset of pattern in the direction of the +Z int nrepeat = 1; // [1,1200] Number of repetitions of the pattern. int thold = 0; // The duration of the hold when nhold>0. int nhold = 0; // Number of nods or raster points or scan lines before // // performing a hold. int nload = 0; // The number of slews (e.g. nods) before performing // // a load operation int tloadmin = 0; // The minimum duration of a load operation. // // // // // Select scan direction: // double patt = 90.0; // Rotation angle of the pattern // if(scan_dir == "plusY") { patt = 90.0; } if(scan_dir == "minusY") { patt = 270.0; } if(scan_dir == "plusZ") { patt = 0.0; } if(scan_dir == "minusZ") { patt = 180.0; } if(scan_dir == "30degplusYZ") { patt = 30.0; } if(scan_dir == "210degminusYZ") { patt = 210.0; } if(scan_dir == "60degplusYZ") { patt = 60.0; } if(scan_dir == "240degminusYZ") { patt = 240.0; } // // // // // Select the number (k) of scan lines before performing a measurement // at the GCP: // // Start with k=1: // int k = 1; // // Calculate times in pointing mode: // int[] ts_tr = line_scan_with_off_pointing(false,tslewmin,tinithold,tfinalhold,ib,naifid,ra,dec,fixed,patt,yoff,zoff,n,d1,d2,rate,k,top,raoff,decoff,nrepeat,thold,nhold,tloadmin,nload); // returns: {tobs, tslew, tacc, tdec, tl, tll, tsop, tload, tend} if(debug) { debug_print("Pointing vector for k=1: " + ts_tr); } int tacc = ts_tr[2]; // acceleration time int tdec = ts_tr[3]; // deceleration time int tl = ts_tr[4]; // time for actual scan of single line in map area int tll = ts_tr[5]; // turnaround time bewteen 2 lines int tsop = ts_tr[6]; // slew time from/to OFF position // Note: 'tsop' includes acceleration/deceleration time // // Calculate/check minimum time between successive visits to GCP position: // int gcp_period_min = tl + 2 * tsop + top; // if(debug) { debug_print("gcp_period_min: " + gcp_period_min); } if(gcp_period_min > gcp_period) { error("Maximum time between successiv GCP visits smaller than minimum time between two possible visits!"); } // // Loop to find best k: // // Calculate time between two offset positions: int tboff = k * tl + (k - 1) * tll + (k - 1) * (tacc + tdec) + 2 * tsop + gcp_time; if(debug) { debug_print("Time between two offset positions: " + tboff); } // do { k = k + 1; // // Calculate new time between two offset positions: tboff = k * tl + (k - 1) * tll + 0 * (tacc + tdec) + 2 * tsop + gcp_time; if(debug) { debug_print("k is now: " + k); debug_print("New time between two offset positions: " + tboff); } } while (tboff < gcp_period); // // Set best k: // if(k > 1) { // use previous k values k = k - 1; } if(k > n) { // k must not be larger than number of lines k = n; } if(debug) { debug_print("selected k is: " + k); } // // // // // Set pointing mode: // //int[] ts = line_scan_with_off_pointing(true,tslewmin,tih,tfh,ib,naifid, // ra,dec,fixed,patt,yoff,zoff,n,d1,d2,rate,k,top,raoff,decoff,nrepeat, // thold,nhold,tloadmin,nload); // int[] ts = line_scan_with_off_pointing(true,tslewmin,tinithold,tfinalhold,ib,naifid,ra,dec,fixed,patt,yoff,zoff,n,d1,d2,rate,k,top,raoff,decoff,nrepeat,thold,nhold,tloadmin,nload); // // // // // // Fill in timings of actual pointing mode: tacc = ts[2]; // acceleration time tdec = ts[3]; // deceleration time tl = ts[4]; // time for actual scan of single line in map area tll = ts[5]; // turnaround time bewteen 2 lines tsop = ts[6]; // slew time from/to OFF position // Note: 'tsop' includes acceleration/deceleration time if(debug) { debug_print("Output timing vector from the pointing request: " + ts); debug_print("Time for actual scan of single line in requested area: " + tl); } // // // // // }{ // ****************************************************** */ // POINTING STATES WITH OBSERVING MODE LOGIC */ // ****************************************************** */ // // // // // Set datarates: // string rateType = "chk"; chkrate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); ess_hk_data_rate(chkrate); // rateType = "nhk"; // nhkrate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); non_ess_hk_data_rate(nhkrate); // rateType = "sci"; scirate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); data_rate(scirate); // if(debug) { debug_print("Set CHK datarate to: " + chkrate); debug_print("Set NHK datarate to: " + nhkrate); debug_print("Set SCI datarate to: " + scirate); } // // // Start the state_machine: // int[] state = [0]; // while(state[0] >= 0) { if(debug) { debug_print("Current state: " + state); } state = next_state(); if(debug) { debug_print("Next state: " + state); } // if(state[0] == 1) { // STATE = SLEW ( Spacecraft is slewing ) // // // // // Startup observation: // SpireBb_StartFovMapFpgScan(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,debug); // //delay(timeSlewCal); } if(state[0] == 2) { // STATE = INIT_HOLD (spacecraft is idling at source) // //delay(tinithold); // // // // // Set offsets: // SpireBb_SpecOffsetAuto(dcuData,debug); // // // // // Start data generation before scan: // SpireBb_StartDcuData(); // } if(state[0] == 4) { // STATE = OFF position // // // // // Show time elapsed between visits to GCP: // int t = time() - start; if(gcpcounter > 1) { message("Time elapsed since last visit to GCP: " + t); if(debug) { debug_print("Time elapsed since last visit to GCP: " + t); } } gcpcounter = gcpcounter + 1; // // Reset timer: start = time(); // // // // // Wait at GCP: // SpireBb_WaitAtGcp(gcp_time,debug); // } if(state[0] == 5) { // STATE = FINAL_HOLD ( "sky" observation ends, performing final activities ) // // // // // Stop data generation after scan: // SpireBb_StopDcuData(); // // // // // Set scientific datarate back to zero: // data_rate(0.0); // // // // // Reconfigure at the end (incl. resetting of OBSID and BBIB): // SpireBb_EndFovMapFpgScan(phot,hold_chop,hold_jigg,isBright,version01,version02,debug); // } if(state[0] == 6) { //delay(thold); } if(state[0] == 8) { // STATE = ( line ) // // // // // // Start timing: // int tscan = time(); // // // // // Debug printing // if(debug) { debug_print("state[0]: " + state[0]); debug_print("state[1]: " + state[1]); debug_print("state[2]: " + state[2]); debug_print("linecount: " + linecount); } // if(linecount == 1) { linestart = time(); } else { int tline = time() - linestart; if(debug) { debug_print("Time elapsed since first line: " + tline); } } // // // // // Wait while scan is performed: // SpireBbScanLine(tl,linecount); linecount = linecount + 1; // // } if(state[0] == 9) { //delay(tloadmin); } if(state[0] == -1) { // STATE = END ( end of the pointing/commanding part of the code ) // } } } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpirePhoto_Cal_PhaseUp.txt // /////////////////////////////////////////////////////////////////////////// // // CUS script for: 'Phot Phase Up' // // in *basic_fine_pointing* or *no_pointing* mode // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/05/07 V0.1: Initial version adapted from // Mode_ILT_PERF_DPH_P.txt (v1.4 2008/01/31 20:24:33) // 2008/05/08 V0.2: Add proper limit for bias amplitude, frequency, and // sampling rate // 2008/06/09 V0.3: Changed name to be conform with new naming convention. // Allow to input different bias amplitude for each array. // 2008/06/20 V0.4: Move SpireBb_StartupObs to start // 2008/07/03 V0.5: Renumber version; add limits for number_steps and // step_size; change default biasfreq; // SpireProc_Set_PhotNominalbias changed name; // SpireBb_PhotFSetupData has extra parameter; // add PTC bolometers to input // 2008/08/15 V0.6: Remove test number; Adapt to change of name // of low level script SpireProc_CalcParam_PhotPhaseUp.txt // Adapt to change in call to low level script // SpireProc_CalcParam_BiasFreqSampFreq.txt // 2008/09/22 V0.7: Allow 'no pointing' as input option; Adapt debug printing // 2008/11/11 V0.8: Improve 'no pointing' HSpot pop-up info at tick mark // 2008/11/12 V0.9: Implement mode setting; Add isBright // Change ENGCALOBS to ENG_CAL_OBS // 2009/02/01 V1.0: Add debug_print as input and pass it to some low level // scripts. Use new SpireBb_EndObsAll and SpireBb_StartObsAll. // Read nominal bias frequency and bias divider from new // SpireTable_DetectorSettings.txt. Implemented message // if activating isBright setting. Implemented setting // of datarates. Replace SpireProc_Set_PhotNominal by // SpireProc_Set_FreqSampAmpPhasNominal. Change Hspot // description of ftime. // 2009/02/17 V1.1: Use SpireBb_PhotSetMode to set to PHOTSTBY during // SLEW and FINAL_HOLD. Read boresight from // SpireTable_OpsParms. New setting of datarates. // Replace call to SpireBb_PhotFSetupData by call to // SpireBb_DcuSetFreqSamp, SpireBb_PhotFSetPhase, and // SpireBb_PhotFSetBiasAmpl. Correct first phase is now // set during SLEW instead of target phase // 2009/02/19 V1.2: Elevate version05 to input. // 2009/03/04 V1.3: Add isSerendipity, isPcal, and 8 more dummy parameters // to the script for future use. Replace 'message' with // 'error' when isBright is used. // 2009/03/30 V1.4: Fix bug in call to SpireBb_StartObsAll (see SCR-1329). // Updated unit in description of input biasmV_p.. // 2009/05/06 V1.5: Add in move BSM to hold at start. Gather procedures at // start and end in separate BB. // 2009/06/05 V1.6: Hardcode STBY 'v00' in EndBB (SPR-1477) // /////////////////////////////////////////////////////////////////////////// // Script assumes that: // // 1) Instrument is in PHOTSTBY at beginning // (i.e. bias amplitude, phase, frequency [mclkdiv,biasdiv] are nominal) // // 2) Phases are user input // // 3) Bias frequency and sampling rate are user inputs both in Hz. They // are translated in the script to the Hex values of mclkdiv and biasdiv. // // 4) Boresight of array can be read from following cal table: // SpireTable_OpsParms.txt // /////////////////////////////////////////////////////////////////////////// // obs SpirePhoto_Cal_PhaseUp { /* ****************************************************** */ /* USER PARAMETER DEFINITION, CUS SIGNATURE for EX-HSpot */ /* ****************************************************** */ /* */ double ra = 0.0 in [0.0,360.0]; // RA of target double dec = 0.0 in [-90.0,90.0]; // DEC of target bool isBright = false; // Use settings for bright source (==tick) bool pointing = true; // Should telescope 'point' (==tick) or do a 'no pointing' (==untick)? /* */ double biasfreq = 130.2 in [70.0,200.0]; // Bias frequency [Hz] double samplerate = 18.6 in [1.0,20.0]; // Sampling rate [Hz] (Careful, don't exceed number of data packages to be transferred from spacecraft!) double biasmV_psw = 31.2 in [0.0,127.813]; // PSW Bias amplitude (zero2peak) [mV] double biasmV_pmw = 31.2 in [0.0,128.625]; // PMW Bias amplitude (zero2peak) [mV] double biasmV_plw = 31.2 in [0.0,129.159]; // PLW Bias amplitude (zero2peak) [mV] double biasmV_ptc = 127.6 in [0.0,254.265]; // PTC Bias amplitude (zero2peak) [mV] double target_phase = 183.0 in [0.0,360.0]; // Central phase shift (target phase) [degree] int number_steps = 5 in [1,127]; // Number of steps to one side [int] int step_size = 1 in [1,20]; // Raw step size (1 step==1.411 degrees) [dec(HEX)] int ftime = 10; // Time at each phase [s] string version01 = "v00"; // Version in cal table SpireTable_PhotModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams string version05 = "v00"; // Version in cal table SpireTable_OpsParms.txt bool debug = false; // Allow (==tick) or suppress cus debug_print statements bool isSerendipity = true; // Allow (==tick) serendipity mode to be activated or prohibit (==untick) it (currently not in use)? bool isPcal = true; // Allow (==tick) regular PcalFlash in script or prohibit (==untick) it (currently not in use)?. bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ // ****************************************************** */ // CALCULATE DURATIONS for POINTING STATES */ // ****************************************************** */ // // // // // Check for is bright setting: // if(isBright) { isBright = false; error("IsBright does not make sense while doing phase ups. Try again!"); } // // // // // Declare some variable: // // // Photometer or FTS: bool phot = true; bool fts = !phot; // string tabName = ""; string selCol = ""; string selVal = ""; string tarCol = ""; string version = ""; double scirate = 0.0; double chkrate = 0.0; double nhkrate = 0.0; // // Hardcoded calibration tables: // string tabName01 = "SpireTable_PhotModeParams.txt"; string tabName03 = "SpireTable_BsmNominalSettings.txt"; string tabName02 = "SpireTable_CommonModeParams.txt"; string tabName05 = "SpireTable_OpsParms.txt"; // // Currently hardcoded version and model parameter: // string version03 = "v00"; // Version in cal table SpireTable_BsmNominalSettings string model = "initial"; // Model in cal table SpireTable_BsmNominalSettings // // Dummy value for Spec script: // (needed but not used in phot script!) // int smecHomePosn = 3500; // SMEC home position int ssw_bias = 45; // int slw_bias = 45; // // // // // // Setup mode: // // Set obsMode for QLA: string obsModeQla = "ENG_CAL_OBS11"; // Note: this needs entry in MIB table and in SpireTableInstConfigs.txt // // Set obsMode for datarates: string obsMode = "PEngCalObs"; // Note: this is currently only a maximum value // // // // // Calculate a raw phase value used for the initial setup: // int target_phase_raw = iround(target_phase * 255.0 / 360.0); // // // // // Calculate list of phases: // int[] raw_phase_list = SpireProc_CalcParam_PhaseUp(target_phase,number_steps,step_size,debug); if(debug) { debug_print("Phase list [dec(HEX)]: " + raw_phase_list); } // // // // // Convert user input to Hex values: // // for bias frequency and sample rate: // int[] hexvalues = SpireProc_CalcParam_BiasFreqSampFreq(biasfreq,samplerate,fts,debug); int mclkdiv = hexvalues[0]; int biasdiv = hexvalues[1]; if(debug) { debug_print("Hex values of mclkdiv/biasdiv are: " + mclkdiv + " " + biasdiv); } // // for bias amplitude: // int[] biashex = SpireProc_CalcParam_PhotBiasConvert(biasmV_psw,biasmV_pmw,biasmV_plw,biasmV_ptc,debug); int psw_bias = biashex[0]; int pmw_bias = biashex[1]; int plw_bias = biashex[2]; int ptc_bias = biashex[3]; // // // // // Read BSM home parameters: // // Select version flag and set GetTableEntry parameters: // version = version03; tabName = tabName03; selCol = "model"; // Name of column for selecting selVal = model; // Value of 'string' selector // // Read hold position from calibration table: // tarCol = "chop_0_I"; int hold_chop = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "jigg_0_I"; int hold_jigg = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // Calculate timing for the pointing request: // // BBs called during slew: // int tslewmin = duration(SpireBb_StartPhaseUp(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,mclkdiv,biasdiv,psw_bias,pmw_bias,plw_bias,ptc_bias,ssw_bias,slw_bias,raw_phase_list,debug)); // // BBs carried out when the pointing is reached: if(pointing) { int tinithold = 0; } else { tinithold = tslewmin; } // // BB carried out during pointing: int tp = duration(SpireProc_Exec_PhotPhaseUp(raw_phase_list,ftime,debug)); // // BB carried out at the end: int tfinalhold = duration(SpireBb_EndPhaseUp(phot,isBright,version01,version02,debug)); // // Debug_printing? // if(debug) { debug_print("tslewmin = " + tslewmin); debug_print("tinithold = " + tinithold); debug_print("tpointing = " + tp); debug_print("tfinalhold = " + tfinalhold); } // // ****************************************************** */ // POINTING MODE DECLARATION */ // ****************************************************** */ // // // // // Lookup boresight: // tabName = tabName05; selCol = "mode"; selVal = obsMode; tarCol = "Boresight"; version = version05; string ib = SpireProc_GetTableEntryString(tabName,selCol,selVal,tarCol,version,debug); // // Set pointing mode: // if(pointing) { int[] ts = basic_fine_pointing(true,tslewmin,tinithold,tfinalhold,ib,0,ra,dec,0.0,0.0,tp); } else { ts = no_pointing(true,tinithold,tfinalhold,tp); } // if(debug) { debug_print("Output timing vector from the pointing request: " + ts); } // }{ // ****************************************************** */ // POINTING STATES WITH OBSERVING MODE LOGIC */ // ****************************************************** */ // // // // // Set datarates: // string rateType = "chk"; chkrate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); ess_hk_data_rate(chkrate); // rateType = "nhk"; // nhkrate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); non_ess_hk_data_rate(nhkrate); // rateType = "sci"; scirate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); data_rate(scirate); // if(debug) { debug_print("Set CHK datarate to: " + chkrate); debug_print("Set NHK datarate to: " + nhkrate); debug_print("Set SCI datarate to: " + scirate); } // // Start the state_machine: // int[] state = [0]; // while(state[0] >= 0) { if(debug) { debug_print("Current state: " + state); } state = next_state(); if(debug) { debug_print("Next state: " + state); } // if(state[0] == 1) { // STATE = SLEW ( Spacecraft is slewing ) // // // // // Startup observation: // SpireBb_StartPhaseUp(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,mclkdiv,biasdiv,psw_bias,pmw_bias,plw_bias,ptc_bias,ssw_bias,slw_bias,raw_phase_list,debug); // //delay(timeSlewCal); } if(state[0] == 2) { // STATE = INIT_HOLD ( spacecraft is idling at source ) // if(!pointing) { // // // // // Startup observation: // SpireBb_StartPhaseUp(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,mclkdiv,biasdiv,psw_bias,pmw_bias,plw_bias,ptc_bias,ssw_bias,slw_bias,raw_phase_list,debug); // } //delay(tinithold); // } if(state[0] == 3) { // STATE = POINT ( spacecraft is at nominal RA,DEC (staring, raster) ) // // // // // // Execute stepping through phase list: // SpireProc_Exec_PhotPhaseUp(raw_phase_list,ftime,debug); // //delay(tp); // } if(state[0] == 5) { // STATE = FINAL_HOLD ( "sky" observation ends, performing final activ.) // // // // // Set scientific datarate back to zero: // data_rate(0.0); // // // // // Reconfigure at the end (incl. resetting of OBSID and BBIB): // // Hardcode STBY values for resetting (SPR-1477): // version01 = "v00"; version02 = "v00"; // SpireBb_EndPhaseUp(phot,isBright,version01,version02,debug); // } if(state[0] == -1) { // STATE = END ( end of the pointing/commanding part of the code ) // } } } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////// // // SpireProc_Exec_BsmPidTuning.txt // /////////////////////////////////////////////////////////// // // Procedure to tune BSM PID // /////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/03/30 V0.1: Initial version adapted from // SPIRE_IST_BSM_CHOP_POS1.txt (SDS, email 30.03.2009) // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Exec_BsmPidTuning { int vmId = 71; // Raw VM table number [Dec(Hex)] int vmIndex = 0; // Raw VM index [Dec(Hex)] int nParms = 10; // Number of parameters passed to VM double chopf = 2.0; // Chop frequency [Hz] int ftime = 15; // Read-out time [s] double framerate = 125.0; // Specifies the MCU framerate [Hz] (photometer) double biasdivHz = 18.6; // Sampling rate [Hz] (photometer) bool fts = false; // FTS or photometer (for dcumode) int on_source_chop = 0xb600; // On source chop position int on_source_jiggle = 0x9a60; // On source jiggle position int off_source_chop = 0x6a28; // Off source chop position int off_source_jiggle = 0x9a60; // Off source jiggle position double chopkp_range = 1.0; // Percentage half-range for tuning Chop Kp around ILT nominal values (+/1%) double chopki_range = 10.0; // Percentage half-range for tuning Chop Ki around ILT nominal values (+/1%) double chopkd_range = 10.0; // Percentage half-range for tuning Chop Kd around ILT nominal values (+/1%) int nkp = 1; // Number of steps for Chop Kp for half-range int nki = 3; // Number of steps for Chop Ki for half-range int nkd = 3; // Number of steps for Chop Kd for half-range string version03 = "v00"; // Version in cal table SpireTable_BsmNominalSettings string model = "initial"; // Model in cal table SpireTable_BsmNominalSettings bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Define some variables: // string version = ""; string tabName = ""; string tarCol = ""; // if(fts) { // DCU data mode (4 == Full spectrometer): int dcumode = 4; } else { // DCU data mode (0 == Full photometer): dcumode = 0; } // // Hardcoded calibration tables: // string tabName03 = "SpireTable_BsmNominalSettings.txt"; // // // // // Retrieve Nominal BSMPID parameter for close loop operation from caltable: // version = version03; tabName = tabName03; // // Name of column for selecting: string selCol = "model"; // // Value of 'string' selector: string selVal = model; // // Read chopkp from calibration table: // tarCol = "chop_kp"; int chopkp = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // Read chopki from calibration table: // tarCol = "chop_ki"; int chopki = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // Read chopkd from calibration table: // tarCol = "chop_kd"; int chopkd = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // if(debug) { debug_print("chopkp: " + chopkp); debug_print("chopki: " + chopki); debug_print("chopkd: " + chopkd); } // // // // // // Calculate step sizes for Chop Kp, Ki and Kd: // int kpstep = iround(chopkp_range * double(chopkp) / (double(nkp) * 100.0)); int kistep = iround(chopki_range * double(chopki) / (double(nki) * 100.0)); int kdstep = iround(chopkd_range * double(chopkd) / (double(nkd) * 100.0)); if(debug) { debug_print("kpstep, kistep, kdstep: " + kpstep + " " + kistep + " " + kdstep); } // // // // // Calculate BSM chop parameters: // int[] chopparam1 = SpireProc_CalcParam_BsmSetup(ftime,chopf,biasdivHz,framerate,debug); int ncycles = chopparam1[0]; int chop_period = chopparam1[1]; int dcusample = chopparam1[2]; int dcudelay = chopparam1[3]; int bsmsample = chopparam1[4]; // // // // // For each set of PID parameters, perform a number fo chop cycles // to establish the optimum PID values: // // First obsstep: int obsstep = 1; // for(int i = -nkp .. nkp) { int kp = chopkp + i * kpstep; for(int j = -nki .. nki) { int ki = chopki + j * kistep; for(int k = -nkd .. nkd) { int kd = chopkd + k * kdstep; if(debug) { debug_print("kp, ki, kd: " + kp + " " + ki + " " + kd); } SpireBb_SetBsmChopPid(kp,ki,kd,debug); // SpireBb_Chop(vmId,vmIndex,nParms,on_source_chop,on_source_jiggle,off_source_chop,off_source_jiggle,ncycles,chop_period,dcumode,dcusample,dcudelay,bsmsample,obsstep,debug); obsstep = obsstep + 1; } } } // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpirePhoto_Cal_PtcPwr.txt // /////////////////////////////////////////////////////////////////////////// // // CUS script for: 'CoP: PtcPwr' // // in *basic_fine_pointing* or *no_pointing* mode // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/03/30 V0.1: Initial version adapted from // SPIRE_IST_PTC_PWR (SDS, email 30.03.2009) // 2009/05/06 V0.2: Add in move BSM to hold at start. Gather procedures at // start and end in separate BB. // 2009/06/05 V1.0: Hardcode STBY 'v00' in EndBB (SPR-1477) // /////////////////////////////////////////////////////////////////////////// // // Script assumes that: // // 1) Instrument is in PHOTSTBY at beginning // (i.e. bias amplitude, phase, frequency [mclkdiv,biasdiv] are nominal) // // 2) Boresight of array can be read from following cal table: // SpireTable_OpsParms.txt // // Note: Script is written for no_pointing as baseline, i.e. it is // not properly using the SLEW time to setup. // /////////////////////////////////////////////////////////////////////////// // obs SpirePhoto_Cal_PtcPwr { /* ****************************************************** */ /* USER PARAMETER DEFINITION, CUS SIGNATURE for EX-HSpot */ /* ****************************************************** */ /* */ double ra = 0.0 in [0.0,360.0]; // RA of target double dec = 0.0 in [-90.0,90.0]; // DEC of target int naifid = 0; // NAIF identifier bool isBright = false; // Use settings for bright source (==tick) bool pointing = true; // Should telescope 'point' (==tick) or do a 'no pointing' (==untick)? /* */ int[] ptc_curr = [0x0,0x200,0x400,0x600,0x800,0xa00,0xc00,0xe00,0xfff,0x0]; // IST default values for the PTC current levels int ftime = 1400; // Time at each PTC Heater setting [s] int twait = 600; // Wait time between setting PTC current and resetting offsets [s] string version01 = "v00"; // Version in cal table SpireTable_PhotModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams string version05 = "v00"; // Version in cal table SpireTable_OpsParms.txt bool debug = false; // Allow (==tick) or suppress cus debug_print statements bool isSerendipity = true; // Allow (==tick) serendipity mode to be activated or prohibit (==untick) it (currently not in use)? bool isPcal = false; // Allow (==tick) regular PcalFlash in script or prohibit (==untick) it (currently not in use)?. bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ // ****************************************************** */ // CALCULATE DURATIONS for POINTING STATES */ // ****************************************************** */ // // // // // Check for is isPcal setting: // if(isPcal) { isPcal = false; error("IsPcal does not make sense here! Try again or file your complaintand send it to Sunil."); } // // // // // Declare some variable: // // Photometer or FTS: bool phot = true; bool fts = !phot; // string tabName = ""; string selCol = ""; string selVal = ""; string tarCol = ""; string version = ""; double scirate = 0.0; double chkrate = 0.0; double nhkrate = 0.0; // int obsStep = 0; // // Hardcoded calibration tables: // string tabName01 = "SpireTable_PhotModeParams.txt"; string tabName02 = "SpireTable_CommonModeParams.txt"; string tabName03 = "SpireTable_StdLoadCurveLevels.txt"; string tabName04 = "SpireTable_BsmNominalSettings.txt"; string tabName05 = "SpireTable_OpsParms.txt"; // // Currently hardcoded version and model parameter: // string version04 = "v00"; // Version in cal table SpireTable_BsmNominalSettings string model = "initial"; // Model in cal table SpireTable_BsmNominalSettings // // // // // Setup mode: // // Set obsMode for QLA: string obsModeQla = "ENG_CAL_OBS13"; // Note: this needs entry in MIB table and in SpireTableInstConfigs.txt // // Set obsMode for datarates: string obsMode = "PEngCalObs"; // Note: this is currently only a maximum value // // // // // Read BSM home parameters: // // Select version flag and set GetTableEntry parameters: // version = version04; tabName = tabName04; selCol = "model"; // Name of column for selecting selVal = model; // Value of 'string' selector // // Read hold position from calibration table: // tarCol = "chop_0_I"; int hold_chop = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "jigg_0_I"; int hold_jigg = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // Calculate timing for the pointing request: // // BBs called during slew: int tslewmin = duration(SpireBb_StartPtcPwr(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,debug)); // // BBs carried out when the pointing is reached: if(pointing) { int tinithold = duration(SpireBb_PhotOffsetAuto(debug)); } else { tinithold = tslewmin + duration(SpireBb_PhotOffsetAuto(debug)); } // // BB carried out during pointing: int tp = duration(SpireProc_Exec_PtcPwr(ptc_curr,ftime,twait,debug)); // // BB carried out at the end: int tfinalhold = duration(SpireBb_EndPtcPwr(phot,isBright,version01,version02,debug)); // if(debug) { debug_print("tslewmin = " + tslewmin); debug_print("tinithold = " + tinithold); debug_print("tpointing = " + tp); debug_print("tfinalhold = " + tfinalhold); } // // ****************************************************** */ // POINTING MODE DECLARATION */ // ****************************************************** */ // // // // // Lookup boresight: // tabName = tabName05; selCol = "mode"; selVal = obsMode; tarCol = "Boresight"; version = version05; string ib = SpireProc_GetTableEntryString(tabName,selCol,selVal,tarCol,version,debug); // // Set pointing mode: // if(pointing) { int[] ts = basic_fine_pointing(true,tslewmin,tinithold,tfinalhold,ib,naifid,ra,dec,0.0,0.0,tp); } else { ts = no_pointing(true,tinithold,tfinalhold,tp); } // if(debug) { debug_print("Output timing vector from the pointing request: " + ts); } // }{ // ****************************************************** */ // POINTING STATES WITH OBSERVING MODE LOGIC */ // ****************************************************** */ // // // // // Set datarates: // string rateType = "chk"; chkrate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); ess_hk_data_rate(chkrate); // rateType = "nhk"; // nhkrate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); non_ess_hk_data_rate(nhkrate); // rateType = "sci"; scirate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); data_rate(scirate); // if(debug) { debug_print("Set CHK datarate to: " + chkrate); debug_print("Set NHK datarate to: " + nhkrate); debug_print("Set SCI datarate to: " + scirate); } // // Start the state_machine: // int[] state = [0]; // while(state[0] >= 0) { if(debug) { debug_print("Current state: " + state); } state = next_state(); if(debug) { debug_print("Next state: " + state); } // if(state[0] == 1) { // STATE = SLEW ( Spacecraft is slewing ) // // // // // Startup observation: // SpireBb_StartPtcPwr(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,debug); // //delay(timeSlewCal); } if(state[0] == 2) { // STATE = INIT_HOLD ( spacecraft is idling at source ) // // // // // If no pointing observation do stuff here which is // done nominally during SLEW: // if(!pointing) { // // // // // Startup observation: // SpireBb_StartPtcPwr(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,debug); // } // // // // // Set offsets: // SpireBb_PhotOffsetAuto(debug); // // //delay(tinithold); // } if(state[0] == 3) { // STATE = POINT ( spacecraft is at nominal RA,DEC (staring, raster) ) // // // // // // Execute loop: // SpireProc_Exec_PtcPwr(ptc_curr,ftime,twait,debug); // //delay(tp); // } if(state[0] == 5) { // STATE = FINAL_HOLD ( "sky" observation ends, performing final activ.) // // // // // Set scientific datarate back to zero: // data_rate(0.0); // // // // // Reconfigure at the end (incl. resetting of OBSID and BBIB): // // Hardcode STBY values for resetting (SPR-1477): // version01 = "v00"; version02 = "v00"; // SpireBb_EndPtcPwr(phot,isBright,version01,version02,debug); // } if(state[0] == -1) { // STATE = END ( end of the pointing/commanding part of the code ) // } } } // Set CCU monitoring period for cooler recycling // command SpireCcuMonitorPeriodRecycle HFKACQP2 { } { bus_schedule(SC, 6); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_Set_BsmMove.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to move BSM in jiggle and chop // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/02/02 V1.0: Initial version adapted from // SpireBsmMove (KK, v 1.1 2006/08/10) and // SpireBb_BsmMove2Hold (2009/01/27 V1.0) // 2009/02/15 V1.1: Add 0x90c60001 at end to start movement. // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Set_BsmMove { int chopPosn = 2048 in [0,65535]; int jiggPosn = 2048 in [0,65535]; bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Define some variables: // int cmd = 0; // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // // // // // Start procedure: // tstr = SpireTimeStr(time()); SpireMsg(4," " + tstr + ": SpireProc_Set_BsmMove started"); SpireMsg(4," $Id: $"); SpireMsg(3," ChopPosn = " + chopPosn); SpireMsg(3," JIggPosn = " + jiggPosn); // // // // // Move BSM: // // set Chop position: cmd = 0x90c30000 + chopPosn; SpireSendDrcuCmd(cmd,0); // // set Jiggle Position: cmd = 0x91430000 + jiggPosn; SpireSendDrcuCmd(cmd,0); // // One-off synchronous movement to the current Chop and Jiggle position: cmd = 0x90c60001; SpireSendDrcuCmd(cmd,0); // // // // // Add delay to wait for BSM to settle (TBC): // delay(3); // // // // // End procedure: // tstr = SpireTimeStr(time()); SpireMsg(4," " + tstr + ": SpireProc_Set_BsmMove ended"); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_Exec_PhotPhaseUp.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to loop through a list of phase values // for the 'Phot Phase Up' task // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/05/07 V0.1: Initial version adapted from // Mode_ILT_PERF_DPH_P.txt (v1.4 2008/01/31 20:24:33) // 2008/07/03 V0.2: Renumber version; change description; // SpireBb_PhotFSetPhase now with PTC phase // 2008/11/07 V0.3: Remove test number from script // 2009/02/01 V1.0: Add debug_print as input and pass to low level scripts. // 2009/02/17 V1.1: Do not set first phase, now done during SLEW. // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Exec_PhotPhaseUp { int[] raw_phase_list = [127,128,129,130,131,132,133]; // Raw phase list (0-255) [dec(HEX)] int ftime = 10; // Time at each bias level [sec] bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Setup bias amplitude and frequency: // --> during slew!! // // // // // // Start the phase loop: // for(int l = 0 .. length(raw_phase_list) - 1) { // // // // // Set phases for arrays: // if(l > 0) { SpireBb_PhotFSetPhase(raw_phase_list[l],raw_phase_list[l],raw_phase_list[l],raw_phase_list[l],debug); } // // // // // Stop DCU data before resetting offsets: // SpireBb_StopDcuData(); // // // // // Set offsets: // SpireBb_PhotOffsetAuto(debug); // // // // // Take data: // SpireBb_PhotFTakeData(ftime,debug); // // // // // Debug printing: // if(debug) { debug_print("Phase finished is: " + raw_phase_list[l]); } } // // } // SpireBbMove // // $id$ // // telescope movement BB // // K.J. King // block SpireBbMove SPIRE 12032 { int step = 0; }{ int t = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB Move started"); SpireMsg(2," $Id: SpireBbMove.txt,v 1.1 2006/08/10 09:38:57 kking Exp $"); // // ..... configuration ..... // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // set STEP hstr = SpireHexStr(step,4); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP_RAW(" + hstr + ")"); Spire_SET_OBS_STEP_RAW(step); // // execute // delay(2); // // ..... completion ..... // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB Move ended"); SpireMsg(1," ..Moving (" + (time() - t) + " seconds)"); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_SpecSetMode.txt // /////////////////////////////////////////////////////////////////////////// // // BB to configure some important instrument parameters // for the spectrometer depending on the mode. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/02/19 V0.1: Initial version adapted from // SpireBb_PhotSetMode (2009/02/15 V0.1) // /////////////////////////////////////////////////////////////////////////// // block SpireBb_SpecSetMode SPIRE 14032 { string obsMode = "SPECSTBY"; // Obs mode as defined in calibration files bool isBright = false in [true,false]; // IsBright (==tick) flag string version01 = "v00"; // Version in cal.tab. SpireTable_SpecModeParams string version02 = "v00"; // Version in cal.tab. SpireTable_CommonModeParams bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Define some variables: // string hstr = ""; // a hex string string tstr = ""; // a time string // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": SpireBb_SpecSetMode started"); SpireMsg(2," $Id: $"); hstr = SpireHexStr($BBID,8); SpireMsg(3," BBID = " + hstr); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); sync(); // // // // // Call procedure to set parameters: // SpireProc_Set_SpecMode(obsMode,isBright,version01,version02,debug); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SpireBb_SpecSetMode ended"); SpireMsg(1," ..Set Phot phases (" + (time() - t) + " secs)"); // } // SpireBbPOF2Init // // $Id: SpireBbPOF2Init.txt,v 1.1 2006/08/10 09:38:57 kking Exp $ // // Building Block to initialise the instrument for POF2 (7-point jiggle) operation // // The complete instrument setup operation is divided into two parts: // Configuration: actions that can be executed during the slew to the start // position of the S/C pointing mode. // Initialisation: actions that must be carried out at the S/C intial pointing // position before any observational operations are executed. // // This building Block implements the second part of the setup // // 04 November 2008: // added data_rate commands // added commands to setup the detector sampling // block SpireBbPOF2Init SPIRE 8225 { }{ int t = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB POF2 Initialisation started"); SpireMsg(2," $Id: SpireBbPOF2Init.txt,v 1.1 2006/08/10 09:38:57 kking Exp $"); // // ..... configuration ..... // int cmd = 0x0; // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // set STEP to On Target tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP_RAW(0x8000)"); Spire_SET_OBS_STEP_RAW(0x8000); // // set detector offsets // set DCU data mode to Auto Offset cmd = 0x843c0010; SpireSendDrcuCmd(cmd,0); // start auto offset generation cmd = 0x843e0001; SpireSendDrcuCmd(cmd,0); delay(15); // // dump detector offsets // stop auto offset generation cmd = 0x843e0000; SpireSendDrcuCmd(cmd,0); // set DCU data mode to get offset data cmd = 0x843c0018; SpireSendDrcuCmd(cmd,0); // start offset data dump cmd = 0x843e0001; SpireSendDrcuCmd(cmd,0); // set datarate double rate = 0.0; rate = dlookup("Datarates.txt","POffsets","DCU"); data_rate(rate); delay(5); // stop offset data dump cmd = 0x843e0000; SpireSendDrcuCmd(cmd,0); data_rate(0.0); // // flush data tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_FLUSH_FIFO_RAW(0x1000)"); Spire_FLUSH_FIFO_RAW(0x1000); delay(2); // // set up detectors for operations // SpireConfigDcuData("POF2"); sync(); // // ..... completion ..... // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB POF2 Initialisation ended"); SpireMsg(1," ..POF2 Initialisation (" + (time() - t) + " seconds)"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_SmecMove2Home.txt // /////////////////////////////////////////////////////////////////////////// // // BB to return SMEC to home position // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/11/02 V0.1: Initial version adapted from SpireBb_MoveBsm2Hold // (2008/10/13 V0.2) // 2009/02/02 V0.2: (KJK) Updated to be used in all scripts // - added smecCurrposn input parameter to allow calculation // of time to move to Home from current SMEC position // - read HOME parameter from SMECNominalSettings Table // - generate messages for all DRCU commands // 2009/02/15 V0.3: (MP) Made some cosmetic changes // /////////////////////////////////////////////////////////////////////////// // block SpireBb_SmecMove2Home SPIRE 14018 { int smecCurrPosn = 1000; bool debug = false; }{ // // // // // Define some variables: // int t = time(); // // a hex string: string hstr = ""; // a time string: string tstr = ""; // // Hardcoded calibration file and version: string tabName = "SpireTable_SmecNominalSettings.txt"; string version = "v00"; // // // // // Start BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SmecMove2Home started"); SpireMsg(2," $Id: $"); // // // // // Set the BBID: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // // // // Fetch Home position: // int smecHome = ilookup(tabName,version,"Home"); if(debug) { debug_print("Setting SMEC back to home position: " + smecHome); } // // // // // Move to Home position: // SpireProc_SmecMove(smecHome,smecCurrPosn,debug); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SmecMove2Home ended"); SpireMsg(1," BB SmecMove2Home (" + (time() - t) + " seconds)"); } // SpireBbBsmMove // // $id$ // // move the BSM to a position given in a jiggle table // // K.J. King // block SpireBbBsmMove SPIRE 8455 { int jiggleTable = 0; int position = 0; int step = 0; }{ int t = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB Bsm Move started"); SpireMsg(2," $Id: SpireBbBsmMove.txt,v 1.2 2007/01/11 16:14:51 kking Exp $"); // // ..... configuration ..... // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // set STEP hstr = SpireHexStr(step,4); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP_RAW(" + hstr + ")"); Spire_SET_OBS_STEP_RAW(step); delay(2); // // execute // int id = ilookup("CommandLists.txt","BSMMove","Id"); // number of table containing the BSMMove command list int index = ilookup("CommandLists.txt","BSMMove","Index"); // start point in table containing the BSMMove command list int nParms = ilookup("CommandLists.txt","BSMMove","Nparms"); // number of parameters to the BSMMove command list {int}[] parms = [{jiggleTable},{position}]; tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_RUN_VM_RAW(" + id + "," + index + "," + nParms + "," + parms + ")"); Spire_RUN_VM_RAW(id,index,nParms,parms); delay(2); // // ..... completion ..... // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB Bsm Move ended"); SpireMsg(1," ..Moving (" + (time() - t) + " seconds)"); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_StartStdLoadCurve.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to configure at the start of // SpirePhoto/Spectro_Cal_StdLoadCurve. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // // 2009/05/05 V0.1: Initial version adapted from // SpireBb_StartBsmAngleCal (2009/05/05 V0.1), // SpirePhoto_Cal_StdLoadCurve (2009/03/04 V1.3), and // SpireSpectro_Cal_StdLoadCurve (2009/03/04 V0.5) // BB includes now to move BSM/SMEC to hold/home. // 2009/07/03 V1.0: Fix bug to allow spectrometer to use script. // 2009/07/05 V1.1: Properly fix it, so that BOTH spec and phot can use // script. // 2009/07/10 V1.2: Fix bug SPR-SPIRE-1612 // // Notes: // 1) Scripts assumes that SpireBb_SpecOffsetAuto is run // during INITHOLD or at first POINTING. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_StartStdLoadCurve SPIRE 14050 { bool phot = true; // Photometer (==tick) or FTS (==untick)? string obsModeQla = "ENG_CAL_OBS12"; string obsMode = "PEngCalObs"; bool isBright = false; // Use settings for bright source (==tick) string version01 = "v00"; // Version in cal table SpireTable_Phot/SpecModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams int hold_chop = 37632; // Chop hold position int hold_jigg = 39520; // Jiggle hold position int smecHomePosn = 3500; // SMEC home position int mclkdiv = 149; // mclkdiv (spec ==~ 121) int biasdiv = 6; // biasdiv (spec ==~ 1) int psw_bias = 62; // int pmw_bias = 62; // int plw_bias = 62; // int ptc_bias = 62; // int psw_phase = 127; // int pmw_phase = 127; // int plw_phase = 127; // int ptc_phase = 127; // int ssw_bias = 45; // int slw_bias = 45; // int ssw_phase = 128; // int slw_phase = 128; // bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // int mode_id = 0; string obsmode = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB StartStdLoadCurve configuration started"); SpireMsg(2," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Startup observation: // SpireProc_Set_StartObsAll(obsModeQla); // // // // // In case move SMEC to home: // if(!phot) { // // Calculate available time for possible movement: // int tmove = duration(SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug)) + duration(SpireProc_Set_SpecMode(obsMode,isBright,version01,version02,debug)) + duration(SpireProc_Set_DcuFreqSamp(mclkdiv,biasdiv,phot,debug)) + duration(SpireProc_Set_PhotPhase(psw_phase,pmw_phase,plw_phase,ptc_phase,debug)) + duration(SpireProc_Set_PhotBias(psw_bias,pmw_bias,plw_bias,ptc_bias,debug)) + duration(SpireBb_SpecOffsetAuto(false,debug)); // // Calculate max offset for which time is available: // int smecMaxOff = tmove * 500; // Note, 500 is maximum possible SMEC speed. int smecStart = smecHomePosn + smecMaxOff; // Note, formula above only reasonable // when smecHomePosn small compared to 39500 // Safety check: if(smecStart > 39500) { smecStart = 39500; } if(debug) { debug_print("smecStart: " + smecStart); debug_print("smecHomePosn: " + smecHomePosn); debug_print("tmove: " + tmove); } // // Move from maximal offset to home: // SpireProc_SmecMove2Home(smecHomePosn,smecHomePosn + smecMaxOff,debug); } // // // // // Move BSM back to hold: // SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug); // // // // // Initialise instrument (in case to isBright): // if(phot) { SpireProc_Set_PhotMode(obsMode,isBright,version01,version02,debug); } else { SpireProc_Set_SpecMode(obsMode,isBright,version01,version02,debug); } //delay(timeSlewCal); // // // // // Set requested frequency and phase plus first bias level: // SpireProc_Set_DcuFreqSamp(mclkdiv,biasdiv,phot,debug); if(phot) { SpireProc_Set_PhotPhase(psw_phase,pmw_phase,plw_phase,ptc_phase,debug); SpireProc_Set_PhotBias(psw_bias,pmw_bias,plw_bias,ptc_bias,debug); } else { SpireProc_Set_SpecBias(ssw_bias,slw_bias,debug); SpireProc_Set_SpecPhase(ssw_phase,slw_phase,debug); } // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB StartStdLoadCurve configuration ended"); SpireMsg(1," ..StartStdLoadCurve took " + (time() - t) + " seconds)"); // } // File : CONF_chopper.cus // Missionphase : PACS FM Test // // Purpose : Configure the chopper servo loop // // Author : DAC/MN // CUSification : DAC/MN // Arguments : // string calUfile CAL-U file // string calUcol Column identifier // // // Description : Read servo loop parameters off a CALU table; a set // of parameters is arranged as a column; different // columns list different sets. Must specify the CALU // file name and the column identification string. // Example: CONF_chopper ("CONFChopper","nom_sky") // // Comments : // // Version : 0.4 // History : 0.1 9-nov-2006 Initial version // 0.2 22-feb-2007 Adapted to revised CONFChopper table // (PosLimit <=> Scaling // 0.3 8-mar-2007 Added 2sec delay at end per HD's mail // 0.4 9-jun-2007 Changed entries for new DECMEC (MN) // 0.4 9-jun-2007 newly optimised parameters (MN) procedure CONF_chopper { string fileU = "CONFChopper"; // CAL-U file string calUcol = "nom_sky"; // Column identifier }{ // # DMC_WRT_CHOP_CONF_PAR (21 params). Use values // obtaied from CALU file int aKp = ilookup(fileU,"Kp",calUcol); int aKi = ilookup(fileU,"Ki",calUcol); int aKd = ilookup(fileU,"Kd",calUcol); int aKf = ilookup(fileU,"Kf",calUcol); int aRate = ilookup(fileU,"Rate",calUcol); int aAccumLimit = ilookup(fileU,"AccumLimit",calUcol); int aOutputLimit = ilookup(fileU,"OutputLimit",calUcol); int aPosLimit = ilookup(fileU,"PosLimit",calUcol); int aErrorLimit = ilookup(fileU,"ErrorLimit",calUcol); int aPosOffset = ilookup(fileU,"PosOffset",calUcol); int aKiCurr = ilookup(fileU,"KiCurr",calUcol); int aSelectFieldPlateLUT = ilookup(fileU,"SelectFieldPlateLUT",calUcol); int aSpare = ilookup(fileU,"Spare",calUcol); int aFilterN1 = ilookup(fileU,"FilterN1",calUcol); int aFilterN2 = ilookup(fileU,"FilterN2",calUcol); int aFilterN3 = ilookup(fileU,"FilterN3",calUcol); int aFilterD1 = ilookup(fileU,"FilterD1",calUcol); int aFilterD2 = ilookup(fileU,"FilterD2",calUcol); int aInductance = ilookup(fileU,"Inductance",calUcol); int aResistance = ilookup(fileU,"Resistance",calUcol); int aControlLoopGain = ilookup(fileU,"ControlLoopGain",calUcol); // Create tuple array and int array {int}[] list_tuple = [{aKp},{aKi},{aKd},{aKf},{aRate},{aAccumLimit},{aOutputLimit},{aPosLimit},{aErrorLimit},{aPosOffset},{aKiCurr},{aSelectFieldPlateLUT},{aSpare},{aFilterN1},{aFilterN2},{aFilterN3},{aFilterD1},{aFilterD2},{aInductance},{aResistance},{aControlLoopGain}]; // Define as int [] to compute check sum int[] list_int = [aKp,aKi,aKd,aKf,aRate,aAccumLimit,aOutputLimit,aPosLimit,aErrorLimit,aPosOffset,aKiCurr,aSelectFieldPlateLUT,aSpare,aFilterN1,aFilterN2,aFilterN3,aFilterD1,aFilterD2,aInductance,aResistance,aControlLoopGain]; int chksum = checksum("int",list_int); Pacs_DMC_WRT_CHOP_CONF_PAR(list_tuple,chksum); delay(2); } /////////////////////////////////////////////////////////////////////////// // // SpirePhoto_CalGCO_FovMapCrossRaster.txt // /////////////////////////////////////////////////////////////////////////// // // CUS script for: 'Phot FOV Mapping Cross Raster' // // in *custom_map_pointing* mode // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/09/16 V0.1: Initial version renamed from // SpirePhoto_CalGCO_PhotFovMapCrossRaster (2008/09/16 V0.2) // Restrict input chopf. // 2008/10/13 V0.2: Adapt to name changes in low level scripts. Remove // stepsize restrictions. // 2008/11/06 V0.3: Adapt to name change in low level script // 2008/11/12 V0.4: Add serendipity mode; Mark missing debug_print // Implement mode setting; Add isBright // Implement proper setting of MCU framerate // Change default gyro re-calibration period // 2009/03/17 V1.0: Use SpireBb_PhotSetMode to set to PHOTSTBY during // SLEW and FINAL_HOLD. Move debug parameter to // input and pass to low level scripts. Replace call to // SpireProc_Set_BsmFramerate with call to // SpireBb_SetBsmFramerate (fixing SPR5890). // Set obsStep back to zero at FINAL_HOLD. Use new // SpireBb_EndObsAll and SpireBb_StartObsAll. // Implement setting of datarates. Add debug to // SpireBb_PhotOffsetAuto(). Remove unsetting of framerate // at FINAL_HOLD, now done in SpireBb_PhotSetMode. // Adapt new inputs by updated SpireBb_Chop. Replace // SpireBb_BsmMove2Hold by SpireBb_BsmMove. // Implement proper setting of MCU framerate, i.e. only set // if user request differenet value from default. Add // isSerendipity (replacing serendipity), isPcal, and 8 more // dummy parameters to the script for future use. Replaced // call to SpireProc_CalcParam_PhotFovMapCrossRaster with // call to SpireProc_CalcParam_FovMapCrossRaster. // Adapt to modification in SpireProc_Exec_Serendipity. Make // change to description of k. // 2009/05/05 V1.1: Add in move BSM to hold at start. Gather procedures at // start and end in separate BB. Remove isSerendipity approach. // 2009/06/05 V1.2: Hardcode STBY 'v00' in EndBB (SPR-1477) // /////////////////////////////////////////////////////////////////////////// // Script assumes that: // // 1) Instrument is in PHOTSTBY // (i.e. bias amplitude, phase, frequency [mclkdiv,biasdiv] are nominal) // // 2) Bias frequency (mclkdiv) and sampling rate (biasdiv) are the same // for all three arrays and could be taken from following cal table: // SpireTable_PhotModeParams.txt // // 3) Home position of BSM can be read from SpireTable_BsmNominalSettings.txt // // 4) Some VM parameters for chopping are read from following cal table: // SpireTable_CommandLists.txt // /////////////////////////////////////////////////////////////////////////// // obs SpirePhoto_CalGCO_FovMapCrossRaster { /* ****************************************************** */ /* USER PARAMETER DEFINITION, CUS SIGNATURE for EX-HSpot */ /* ****************************************************** */ double ra = 0.0 in [0.0,360.0]; // RA of target double dec = 0.0 in [-90.0,90.0]; // DEC of target int naifid = 0; //NAIF identifier: put '0' to use RA/DEC, or correct 'NAIFID' /* */ bool isBright = false; // Use settings for bright source (==tick) string ib = "S14_0"; // Central aperture (defined in SIAM) of raster double d1 = 4.0; // Angular stepsize along Y axis [arcsec] double d2 = 4.0; // Angular stepsize along Z axis [arcsec] int m = 9 in [3,2997]; // Total number of points in Y/Z [odd number, symmetric!] int k = 0; // Additional visits to GCP on each arm of the cross int ftime = 60; // Read-out time [s] double chopf = 2.0 in [0.1,4.0]; // Chop frequency [Hz] int offChopfh = 9600; // off-source chop position (+ or - relative to hold) [Dec(Hex)] double framerate = 125.0; // Specifies the MCU framerate [Hz] int gcp_time = 20; // Time spend at GCP (gyro calibration position) [s] int gcp_period = 600; // Maximum time between successiv GCP visits [s] string version01 = "v00"; // Version in cal table SpireTable_PhotModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParas string version03 = "v00"; // Version in cal table SpireTable_BsmNominalSettings string model = "initial"; // Model in cal table SpireTable_BsmNominalSettings bool debug = false; // Allow (==tick) or suppress cus debug_print statements bool isSerendipity = true; // Allow (==tick) serendipity mode to be activated or prohibit (==untick) it? bool isPcal = true; // Allow (==tick) regular PcalFlash in script or prohibit (==untick) it (currently not in use)?. bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ // // // // // Current restrictions: // if(naifid != 0) { error("Currently no SSO objects are allowed as input!"); } // // // // // Declare some variable: // // Photometer or FTS: bool phot = true; bool fts = !phot; // // Start timing of script: int start = time(); // // Keep track of actual visits to GCP: double maxgcp_period = 0.0; // // First obsstep [HEX]: int obsstep = 0x0; // // Count raster points: int raster_counter = 0; // int obsStep = 0; int tslewminadd = 0; bool setFramerate = true; string version = ""; string tabName = ""; double scirate = 0.0; double chkrate = 0.0; double nhkrate = 0.0; // // DCU data mode (0 == Full photometer; 4 == Full spectrometer): int dcumode = 0; // // Hardcoded calibration tables: // string tabName01 = "SpireTable_PhotModeParams.txt"; string tabName02 = "SpireTable_CommonModeParams.txt"; string tabName03 = "SpireTable_BsmNominalSettings.txt"; string tabName04 = "SpireTable_CommandLists.txt"; // // Dummy value for smecHomePosn (needed but not used in phot script!) int smecHomePosn = 3500; // SMEC home position // // Currently hardcoded parameter: // Useful length of serendipity observation int limit = 20; // // // // // Setup mode: // // Set obsMode for QLA: string obsModeQla = "ENG_CAL_OBS03"; // Note: this needs entry in MIB table and in SpireTableInstConfigs.txt // // Set obsMode for setup and datarates: string obsMode = "PEngCalObs"; // Note: datarates are currently only maximum values // // // // // Setup parameters for BSM chopping movement: // // Select version flag and set GetTableEntry parameters: // version = version03; tabName = tabName03; string selCol = "model"; // Name of column for selecting string selVal = model; // Value of 'string' selector // // Read hold position from calibration table: // string tarCol = "chop_0_I"; int hold_chop = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "jigg_0_I"; int hold_jigg = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // Set chop/jigg positions: // // on-source Chop position [Dec(Hex)]: int onChop = hold_chop; // // on-source Jiggle position: int onJigg = hold_jigg; // // off-source Chop position: int offChop = hold_chop + offChopfh; // // off-source Jiggle position: int offJigg = hold_jigg; // // Read VM parameters from calibration table: // tabName = tabName04; selVal = "Chop"; int vmId = ilookup(tabName,selVal,"Id"); int vmIndex = ilookup(tabName,selVal,"Index"); int nParms = ilookup(tabName,selVal,"Nparms"); // // // // // Read nominal bias frequency and bias divider: // // Select version flag and set GetTableEntry parameters: version = version01; tabName = tabName01; selCol = "mode"; // Name of column for selecting selVal = obsMode; // Value of 'string' selector // tarCol = "mclkDiv"; int mclkdiv = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // tarCol = "biasDiv"; int biasdiv = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // // // // Calculate nominal sampling rate from mclkdiv and biasdiv: // double mclkdivHz = 1.0E7 / (512.0 * double(mclkdiv + 1)); double biasdivHz = 1.0 / (double(biasdiv) + 1.0) * mclkdivHz; if(debug) { debug_print("Nominal sampling rate is: " + biasdivHz + " [Hz]"); } // // // // // // Compare read-out time and dwell time on GCP: // int dtime = 0; // time to be spend on GCP position if(gcp_time < ftime) { dtime = ftime; } else { dtime = gcp_time; } if(debug) { debug_print("ftime: " + ftime); debug_print("gcp_time: " + gcp_time); debug_print("dtime: " + dtime); } // // // // // Calculate BSM chop parameters: // int[] chopparam1 = SpireProc_CalcParam_BsmSetup(ftime,chopf,biasdivHz,framerate,debug); int ncycles = chopparam1[0]; int chop_period = chopparam1[1]; int dcusample = chopparam1[2]; int dcudelay = chopparam1[3]; int bsmsample = chopparam1[4]; // int[] chopparam2 = SpireProc_CalcParam_BsmSetup(dtime,chopf,biasdivHz,framerate,debug); int ncycles_2 = chopparam2[0]; int chop_period_2 = chopparam2[1]; int dcusample_2 = chopparam2[2]; int dcudelay_2 = chopparam2[3]; int bsmsample_2 = chopparam2[4]; // // // // // Compare user input of BSM framerate with default value: // version = version02; tabName = tabName02; tarCol = "bsmFrameRate"; int bsmFrameRate = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); double bsmFrameRateHz = 1000000.0 / (double(bsmFrameRate) * 420.0); if(debug) { debug_print("Nominal BSM sampling rate is: " + bsmFrameRateHz + " [Hz]"); } // // Compare nominal with input BSM framerate: // int frate = SpireProc_CalcParam_BsmFramerate(framerate,debug); if(frate == bsmFrameRate) { setFramerate = false; } // // ****************************************************** */ // CALCULATE DURATIONS for POINTING STATES */ // ****************************************************** */ // // // // // Calculate timing for the pointing request: // // BBs called during slew: // int tslewmin = duration(SpireBb_StartFovMapCrossRaster(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,setFramerate,frate,smecHomePosn,debug)); // //BBs carried out when the pointing is reached: // int tinithold = 0; // // BB carried out during pointing: // int tp_np = duration(SpireBb_Chop(vmId,vmIndex,nParms,onChop,onJigg,offChop,offJigg,ncycles,chop_period,dcumode,dcusample,dcudelay,bsmsample,9999,debug)) + duration(SpireBb_PhotOffsetAuto(debug)); int tp_gp = duration(SpireBb_Chop(vmId,vmIndex,nParms,onChop,onJigg,offChop,offJigg,ncycles_2,chop_period_2,dcumode,dcusample_2,dcudelay_2,bsmsample_2,9999,debug)) + duration(SpireBb_PhotOffsetAuto(debug)); // // BB carried out at the end: // int tfinalhold = duration(SpireBb_EndFovMapCrossRaster(phot,hold_chop,hold_jigg,isBright,version01,version02,debug)); // // // // // Debug printing: // if(debug) { debug_print("tslewmin = " + tslewmin); debug_print("tinithold = " + tinithold); debug_print("tpointing normal= " + tp_np); debug_print("tpointing @GCP= " + tp_gp); debug_print("tfinalhold = " + tfinalhold); } // // ****************************************************** */ // POINTING MODE DECLARATION */ // ****************************************************** */ // // // // // Fixed parameters for pointing mode: // // Pattern orientation (true==sky; false==array): bool fixed = false; // // Rotation angle of the pattern: double patt = 90.0; // // Offset of pattern in the direction of the +Y: double yoffset = 0.0; // // Offset of pattern in the direction of the +Z: double zoffset = 0.0; // // The duration of the hold when nhold>0: int thold = 0; // // Number of nods or raster points or scan lines before // performing a hold. int nhold = 0; // double pattnod = 0.0; // double chopthrow = 2.0; // int nnod = 1; // int knod = 0; // int nload = 0; // int tloadmin = 0; // // // // // // Calculate array of points: // {double[],double[],bool[]} array = SpireProc_CalcParam_FovMapCrossRaster(d1,d2,m,k,debug); double[] zarray = array{0}; double[] yarray = array{1}; bool[] raster = array{2}; int nump = length(yarray); // // // // // Set pointing vector: // int[] tpv = [0]; for(int index = 0 .. nump - 1) { if(raster[index]) { tpv[index] = tp_np; } else { tpv[index] = tp_gp; } index = index + 1; } if(debug) { debug_print("tpv = " + tpv); } // // // // // Set pointing mode: // //custom_map_pointing(true, tslewmin, tinithold, tfinalhold, ib, naifid, //ra,dec,fixed,patt,yoffset,zoffset,yarray,zarray,tpv, pattnod,chopthrow, //nnod,knod,tloadmin,nload, thold, nhold); // int[] ts = custom_map_pointing(true,tslewmin,tinithold,tfinalhold,ib,naifid,ra,dec,fixed,patt,yoffset,zoffset,yarray,zarray,tpv,pattnod,chopthrow,nnod,knod,tloadmin,nload,thold,nhold); // if(debug) { debug_print("Output timing vector from the pointing request: " + ts); } // }{ // ****************************************************** */ // POINTING STATES WITH OBSERVING MODE LOGIC */ // ****************************************************** */ // // // // // Set datarates: // string rateType = "chk"; chkrate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); ess_hk_data_rate(chkrate); // rateType = "nhk"; // nhkrate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); non_ess_hk_data_rate(nhkrate); // rateType = "sci"; scirate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); data_rate(scirate); // if(debug) { debug_print("Set CHK datarate to: " + chkrate); debug_print("Set NHK datarate to: " + nhkrate); debug_print("Set SCI datarate to: " + scirate); } // // // Start the state_machine: // int[] state = [0]; // while(state[0] >= 0) { if(debug) { debug_print("Current state: " + state); } state = next_state(); if(debug) { debug_print("Next state: " + state); } // if(state[0] == 1) { // STATE = SLEW ( Spacecraft is slewing ) // // // // // Startup observation: // SpireBb_StartFovMapCrossRaster(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,setFramerate,frate,smecHomePosn,debug); // // // // // Perform serendipity operation if possible: // // // Read slew time from pointing mode: //int tslew = ts[1]; // Slew time // // Minimum time for a serendipity observation: //int tSerendipity = duration(SpireProc_Exec_Serendipity(0,debug)); //if(debug) { // debug_print("Minimum time for a serendipity observation: " + tSerendipity); //} // //if(tslew > tSerendipity + tslewmin + 20) { // // Time remaining for serendipity observation: // int stime = tslew - tslewmin; // // // // Execute observation: // if(isSerendipity) { // SpireProc_Exec_Serendipity(stime,debug); // } //} // //delay(timeSlewCal); } if(state[0] == 2) { // STATE = INIT_HOLD ( spacecraft is idling at source ) // // //delay(tinithold); } if(state[0] == 3) { // STATE = POINT (spacecraft is at nominal RA,DEC (staring, raster)) // // // // // Set offsets at each raster point: // SpireBb_PhotOffsetAuto(debug); // // // // // Different timings for different raster points (normal vs. GCP): // if(raster[raster_counter] == false) { // // // // // Show time elapsed between visits to GCP: // if(raster_counter == 0) { // Reset timer: start = time(); } else { int t = time() - start; // Check elapsed time and give out error: maxgcp_period = max(maxgcp_period,double(t)); if(maxgcp_period > double(gcp_period)) { error("gcp_period constraint violated!! Increase k parameter by 1"); } message("Time elapsed since last visit to GCP: " + t); if(debug) { debug_print("Time elapsed since last visit to GCP: " + t); debug_print("Maximum time between two GCPs: " + maxgcp_period); } // // Reset timer: start = time(); } // // // // // Run chop VM (includes data taking) and set obs step parameter: // if(debug) { debug_print("Chop on GCP raster point!"); } SpireBb_Chop(vmId,vmIndex,nParms,onChop,onJigg,offChop,offJigg,ncycles_2,chop_period_2,dcumode,dcusample_2,dcudelay_2,bsmsample_2,65535,debug); // } else { // // // // // Run chop VM (includes data taking) and set obs step parameter: // if(debug) { debug_print("Chop on regular raster point!"); } SpireBb_Chop(vmId,vmIndex,nParms,onChop,onJigg,offChop,offJigg,ncycles,chop_period,dcumode,dcusample,dcudelay,bsmsample,obsstep,debug); obsstep = obsstep + 1; // } raster_counter = raster_counter + 1; // } if(state[0] == 5) { // STATE = FINAL_HOLD ("sky" observation ends, performing final activities ) // // // // // Set scientific datarate back to zero: // data_rate(0.0); // // // // // Reconfigure at the end (incl. resetting of OBSID and BBIB): // // Hardcode STBY values for resetting (SPR-1477): // version01 = "v00"; version02 = "v00"; version03 = "v00"; model = "initial"; // SpireBb_EndFovMapCrossRaster(phot,hold_chop,hold_jigg,isBright,version01,version02,debug); // } if(state[0] == -1) { // STATE = END (end of the pointing/commanding part of the code) // } } } // Missionphase : // // Purpose : Move the PHOT filter wheel to one of the two defined // positions // // TCL script : N/A // CUS script : Diego A. Cesarsky // // CVS file : PHOT_fltw_move.txt // // Arguments : // Type Name DefVal Description // string flt_id POS A One of two preset positions [POS A, POS B] // // Description : Switch ON filter controller, move wheel, switch OFF // // Dependencies : Low level PACS TCs // // Preconditions : Servo loop already configured // // Comments : useless comment by Bart // Quite useless indeed! // // Version : 0.1 13-Aug-2004 Creation by DAC // History : 0.2 28-Oct-2004 Renamed from FLTW_move.txt; demoded // from BB to simple procedure // 0.3 13-apr-2005 DAC Renamed from BOLO_flt_move, filter_id // is now a string (ENG value) // 0.4 20-1pr-2005 DAC Read wheel move time from PACSparams // 0.5 19-feb-2008 Return time in sec // : int procedure PHOT_fltw_move { string filter_id = "POS A" in ["POS A","POS B"]; }{ // Get the duration of the move int move_time = iceil(dlookup("PACSparams","fltw_time","freq_time")); // Same in [sec] int move_time_sec = Msec2sec(move_time); // debug_print("PHOT fltw moves to " + filter_id + // "; " + move_time_sec + " [sec]"); // Set the filter wheel: switch on the filter/grating controller Pacs_DMC_SWON_FW_PHOTO(); // Move filter to desired position Pacs_DMC_MOVE_PHOT_FW_LOC(filter_id); // Wait move_time_sec sec for wheel to end its movement delay(move_time_sec); // Switch off the controller Pacs_DMC_SWOF_GRAT_CONT(); // Return duration return move_time_sec; } // SpirePOF3Estimate // // $Id: SpirePOF3Estimate.txt,v 1.5 2007/04/20 16:05:49 kking Exp $ // // This procedure calculates the estimated noise and signal/noise // for the given observing time. // // for input values, a value less than 0 indicates value unknown // // 20/04/07: v1.3: SCR3054 // v1.5: SCR3012 // {string,double,double,double,double,bool,double,double,double}[] procedure SpirePOF3Estimate { double osit = 0.0; // on-source integration time double sourceFluxPSW = -1.0; double sourceFluxPMW = -1.0; double sourceFluxPLW = -1.0; double sourceBrightPSW = -1.0; double sourceBrightPMW = -1.0; double sourceBrightPLW = -1.0; bool isBright = false; }{ SpireMsg(3," Calculating POF3 noise estimates"); SpireMsg(3," $Id: SpirePOF3Estimate.txt,v 1.5 2007/04/20 16:05:49 kking Exp $"); SpireMsg(3," Input:"); SpireMsg(3," Osit: " + osit); SpireMsg(3," PSW Flux density: " + sourceFluxPSW); SpireMsg(3," PMW Flux density: " + sourceFluxPMW); SpireMsg(3," PLW Flux density: " + sourceFluxPLW); SpireMsg(3," PSW Surface Brightness: " + sourceBrightPSW); SpireMsg(3," PMW Surface Brightness: " + sourceBrightPMW); SpireMsg(3," PLW Surface Brightness: " + sourceBrightPLW); SpireMsg(3," isBright: " + isBright); // // fetch the flux uncertainty information for POF3 string tabName = "Phot_Sensitivities.txt"; if(isBright) { tabName = "Phot_BrightSensitivities.txt"; } double psw_func = dlookup(tabName,"POF3","PSWFluxUnc"); double pmw_func = dlookup(tabName,"POF3","PMWFluxUnc"); double plw_func = dlookup(tabName,"POF3","PLWFluxUnc"); // fetch the surface brightness uncertainty information for POF3 double psw_bunc = dlookup(tabName,"POF3","PSWBrightUnc"); double pmw_bunc = dlookup(tabName,"POF3","PMWBrightUnc"); double plw_bunc = dlookup(tabName,"POF3","PLWBrightUnc"); // fetch confusion limits double psw_conf = dlookup(tabName,"POF3","PSWConfLim"); double pmw_conf = dlookup(tabName,"POF3","PMWConfLim"); double plw_conf = dlookup(tabName,"POF3","PLWConfLim"); SpireMsg(3," Input Sensitivity Values:"); SpireMsg(3," Band: PSW PMW PLW"); SpireMsg(3," Flux Uncertainty: " + psw_func + " " + pmw_func + " " + plw_func); SpireMsg(3," SUrface Brightness Uncertainty: " + psw_bunc + " " + pmw_bunc + " " + plw_bunc); SpireMsg(3," Conf Limit: " + psw_conf + " " + pmw_conf + " " + plw_conf); // // calculate noise estimates {string,double,double,double,double,bool,double,double,double}[] estimates = [{"250",sourceFluxPSW,-1.0,-1.0,psw_conf,false,sourceBrightPSW,-1.0,-1.0},{"350",sourceFluxPMW,-1.0,-1.0,pmw_conf,false,sourceBrightPMW,-1.0,-1.0},{"500",sourceFluxPLW,-1.0,-1.0,plw_conf,false,sourceBrightPLW,-1.0,-1.0}]; estimates[0]{2} = psw_func / sqrt(osit); if(estimates[0]{2} < psw_conf) { estimates[0]{5} = true; } if(sourceFluxPSW >= 0.0) { estimates[0]{3} = sourceFluxPSW / estimates[0]{2}; if(estimates[0]{3} > 200.0) { estimates[0]{3} = 200.0; } } estimates[0]{7} = psw_bunc / sqrt(osit); if(sourceBrightPSW >= 0.0) { estimates[0]{8} = sourceBrightPSW / estimates[0]{7}; if(estimates[0]{8} > 200.0) { estimates[0]{8} = 200.0; } } estimates[1]{2} = pmw_func / sqrt(osit); if(estimates[1]{2} < pmw_conf) { estimates[1]{5} = true; } if(sourceFluxPMW >= 0.0) { estimates[1]{3} = sourceFluxPMW / estimates[1]{2}; if(estimates[1]{3} > 200.0) { estimates[1]{3} = 200.0; } } estimates[1]{7} = pmw_bunc / sqrt(osit); if(sourceBrightPMW >= 0.0) { estimates[1]{8} = sourceBrightPMW / estimates[1]{7}; if(estimates[1]{8} > 200.0) { estimates[1]{8} = 200.0; } } estimates[2]{2} = plw_func / sqrt(osit); if(estimates[2]{2} < plw_conf) { estimates[2]{5} = true; } if(sourceFluxPLW >= 0.0) { estimates[2]{3} = sourceFluxPLW / estimates[2]{2}; if(estimates[2]{3} > 200.0) { estimates[2]{3} = 200.0; } } estimates[2]{7} = plw_bunc / sqrt(osit); if(sourceBrightPLW >= 0.0) { estimates[2]{8} = sourceBrightPLW / estimates[2]{7}; if(estimates[2]{8} > 200.0) { estimates[2]{8} = 200.0; } } // // return values SpireMsg(3," Output Estimates:"); SpireMsg(3," Band: " + estimates[0]{0} + " " + estimates[1]{0} + " " + estimates[2]{0}); SpireMsg(3," Source Flux " + estimates[0]{1} + " " + estimates[1]{1} + " " + estimates[2]{1}); SpireMsg(3," 1 Sigma Flux Noise: " + estimates[0]{2} + " " + estimates[1]{2} + " " + estimates[2]{2}); SpireMsg(3," Flux Signal/Noise: " + estimates[0]{3} + " " + estimates[1]{3} + " " + estimates[2]{3}); SpireMsg(3," Conf Level: " + estimates[0]{4} + " " + estimates[1]{4} + " " + estimates[2]{4}); SpireMsg(3," Conf Flag: " + estimates[0]{5} + " " + estimates[1]{5} + " " + estimates[2]{5}); SpireMsg(3," 1 Sigma Brightness Noise: " + estimates[0]{7} + " " + estimates[1]{7} + " " + estimates[2]{7}); SpireMsg(3," Brightness Signal/Noise: " + estimates[0]{8} + " " + estimates[1]{8} + " " + estimates[2]{8}); // return estimates; } // CVS comments : $Id: PacsPhotDefaults.txt,v 1.1 2008/05/26 15:12:49 vanessad Exp $ // Purpose : Fill index=0 of OBCP and PHOTxxx tuples with known // sensible default values // // CUS author : DAC // Script file : PacsPhotDefaults.txt // // Input arguments // type name Description // string srcID HSPOT define source ID // // Return values // Type Name Description // tuple confPHOTx & confOBCP electronics and OBCP default parameters // // Description : Give default values to tuples OBCP and PHOT. May // use more information from yet to be created CAL-U files. So far // only "throw" (HSPOT defined) appears necessary as a call argument // // Dependencies : // // Preconditions : // // Comments : // // History : 0.1 29-nov-2005 DAC. Based on PacsSpecDefaults // 0.2 18-jan-2006 Introduced string calU variable // 0.3 20-jan-2006 Use new PHOT_CHOP_params table where chopper positions // are defined in arcsec; added verbose // 1.0 1-sep-2006 - Use sourceID instead of "throw" since chopper // throw depends on SRCE // - editorial clean // 2.0 10-oct-2007 Implemented SCR-3628: introduction of CAL-U file // CONF_PHOT_params. This requires adding a new input // variable: primePar {{int,int,int,int,int,int,int,int,int},{int,int,int,int,int,int,int,int,int},{int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int}} procedure PacsPhotDefaults { string srcID = "pointSRC" in ["pointSRC","smallSRC","largeSRC"]; // SourceID string primePar = "Prime" in ["Prime","Parallel"]; // Observing mode bool isBrightPacs = false; bool verbose = true; // Generate bla-bla }{ // Define variables to be used here {int,int,int,int,int,int,int,int,int} confPHOTblu = {0,0,0,0,0,0,0,0,0}; {int,int,int,int,int,int,int,int,int} confPHOTred = {0,0,0,0,0,0,0,0,0}; {int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int} confOBCP = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // Open CAL-U with compression, raw pixels, etc. information if(!isBrightPacs) { int gain_red = ilookup("CONF_PHOT_params","gain_red",primePar); } else { gain_red = ilookup("CONF_PHOT_params","gain_red","BrightPacs"); } confPHOTred{0} = gain_red; if(!isBrightPacs) { int gain_blu = ilookup("CONF_PHOT_params","gain_blu",primePar); } else { gain_blu = ilookup("CONF_PHOT_params","gain_blu","BrightPacs"); } confPHOTblu{0} = gain_blu; if(!isBrightPacs) { int comp_mode_red = ilookup("CONF_PHOT_params","comp_mode_red",primePar); } else { comp_mode_red = ilookup("CONF_PHOT_params","comp_mode_red","BrightPacs"); } confPHOTred{3} = comp_mode_red; if(!isBrightPacs) { int comp_mode_blu = ilookup("CONF_PHOT_params","comp_mode_blu",primePar); } else { comp_mode_blu = ilookup("CONF_PHOT_params","comp_mode_blu","BrightPacs"); } confPHOTblu{3} = comp_mode_blu; if(!isBrightPacs) { int nb_raw_red = ilookup("CONF_PHOT_params","nb_raw_red",primePar); } else { nb_raw_red = ilookup("CONF_PHOT_params","nb_raw_red","BrightPacs"); } confPHOTred{6} = nb_raw_red; if(!isBrightPacs) { int nb_raw_blu = ilookup("CONF_PHOT_params","nb_raw_blu",primePar); } else { nb_raw_blu = ilookup("CONF_PHOT_params","nb_raw_blu","BrightPacs"); } confPHOTblu{6} = nb_raw_blu; // Chopper and grating expected at their default positions string calU = "SPEC_MEC_Defaults"; int chop_def = ilookup(calU,"Photometry","chopper"); confOBCP{17} = chop_def; // Position filter wheel at default position // int fw_pos = ilookup(calU,"Photometry","FW"); // Initialize to don't care/don't know int fw_pos = 1; confOBCP{19} = fw_pos; int nb_cycles_obs_cal = 1; confOBCP{0} = nb_cycles_obs_cal; int nb_SRC_OFF = 1; confOBCP{3} = nb_SRC_OFF; int nb_rdouts_plateau = 4; confOBCP{4} = nb_rdouts_plateau; int nb_CS1_CS2 = 0; confOBCP{5} = nb_CS1_CS2; // Read chopper positions [arcsec] and convert to ENG units calU = "PHOT_CHOP_params"; string convU = "PHOT_CHOP_sky"; double auxSRC = dlookup(calU,srcID,"SRC"); int onSRC = PacsReadChopSky(convU,auxSRC); double auxREF1 = dlookup(calU,srcID,"REF1"); int onREF1 = PacsReadChopSky(convU,auxREF1); double auxREF2 = dlookup(calU,srcID,"REF2"); int onREF2 = PacsReadChopSky(convU,auxREF2); // Report settings if verbose if(verbose) { debug_print("++PhotDefaults CHOPPER: " + auxSRC + " [arcsec] -> " + onSRC + " [ENG]"); debug_print("++PhotDefaults CHOPPER: " + auxREF1 + " [arcsec] -> " + onREF1 + " [ENG]"); debug_print("++PhotDefaults CHOPPER: " + auxREF2 + " [arcsec] -> " + onREF2 + " [ENG]"); } confOBCP{12} = onSRC; confOBCP{13} = onREF1; confOBCP{14} = onREF2; // chop_pos_CS1 = confOBCP[0]{15}; // chop_pos_CS2 = confOBCP[0]{16}; int detector = 1; confOBCP{18} = detector; return {confPHOTblu,confPHOTred,confOBCP}; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////// // // SpireProc_Exec_SpecMultiLevelNoise.txt // /////////////////////////////////////////////////////////// // // Procedure to loop through a list of bias amplitudes for // the 'Spec Multi-Level Noise ' task setting the correct // phase included in calibration table. // /////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/09/09 V0.1: Initial version adapted from // SpireProc_Exec_PhotMultiLevelNoise (2008/08/04 V0.3) // 2009/02/19 V0.2: Adapt to change in cal table setup. Add debug_print // option (also to low level scripts). Fixed bug, // biasfreq and samplerate were not set each time in the loop. // SpireProc_CalcParam_SpecMultiLevelNoiseLevels changed, // adapt reading of return values. // 2009/03/04 V0.3: Implement isBright setting in the way of adapting // the phase at each bias amplitude level. // // Sunil Sidher // 2009/07/21 V0.4: Implemented isPcal flag to perform standard AOT style PCAL flashes after each bias setting // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Exec_SpecMultiLevelNoise { double biasfreq = 160.09; // Bias frequency (Hz) double samplerate = 80.05; // Sampling frequency (Hz) string tabName01 = "SpireTable_SpecMultiLevelNoiseLevels.txt"; // Calibration table name string version01 = "v00"; // Version parameter defined in calibration table bool isBright = false; // Use settings for bright source (==tick) bool isPcal = true; // Allow (==tick) regular PcalFlash in script or prohibit (==untick) it? string tabName02 = "SpireTable_IsBrightPhaseShift.txt"; // Calibration table name string version02 = "v00"; // Version parameter defined in calibration table int ftime = 300; // Readout time at each bias level [s] bool debug = false; // Allow (==tick) or suppress cus debug_print statement }{ // // // // // Declare some variable: // // Photometer or FTS: bool phot = false; bool fts = !phot; // // // // // Read isBright phase shift from calibration table: // int specPhaseShift = ilookup(tabName02,version02,"specPhaseShift"); // // // // // Convert input and read correct levels from calibration table: // {string,int,int,int,double,double}[] level_table = SpireProc_CalcParam_SpecMultiLevelNoiseLevels(biasfreq,samplerate,tabName01,version01,debug); int size = length(level_table); if(debug) { debug_print("size = " + size); debug_print("Version selector used in calibration table: " + version01); } // // // // // Create list of bias levels and associated phases: // int[] nbiaslist = []; int[] sswnphaselist = []; int[] slwnphaselist = []; // for(int j = 0 .. size - 1) { if(debug) { debug_print("level_table = " + level_table[j]); } {string,int,int,int,double,double} row = level_table[j]; int mclkDiv = row{1}; int biasDiv = row{2}; nbiaslist[j] = row{3}; double sswphase = row{4}; sswnphaselist[j] = iround(sswphase * 255.0 / 360.0); double slwphase = row{5}; slwnphaselist[j] = iround(slwphase * 255.0 / 360.0); if(isBright) { sswnphaselist[j] = SpireProc_CalcParam_IsBrightPhaseShift(sswnphaselist[j],specPhaseShift,debug); slwnphaselist[j] = SpireProc_CalcParam_IsBrightPhaseShift(slwnphaselist[j],specPhaseShift,debug); } } if(debug) { debug_print("mclkdiv/biasdiv = " + mclkDiv + "/" + biasDiv); } // // // // // Set selected bias frequency and sampling rate before loop: // SpireBb_DcuSetFreqSamp(mclkDiv,biasDiv,phot,debug); // // // // // Start the bias loop: // for(int l = 0 .. length(nbiaslist) - 1) { // // // // // Safety checks: // if(nbiaslist[l] > 255) { nbiaslist[l] = 255; debug_print("Input bias amplitude list is corrupt! Raw value > 255 requested!"); } if(sswnphaselist[l] > 255) { sswnphaselist[l] = 255; debug_print("Input SSW bias phase list is corrupt! Raw value > 255 requested!"); } if(slwnphaselist[l] > 255) { slwnphaselist[l] = 255; debug_print("Input SLW bias phase list is corrupt! Raw value > 255 requested!"); } // // // // // Set bias amplitude and phase: // if(debug) { debug_print("the biaslevel is :" + nbiaslist[l] + " SSW phase is: " + sswnphaselist[l] + "; SLW phase is: " + slwnphaselist[l]); } // // Set bias amplitude: SpireBb_SpecFSetBiasAmpl(nbiaslist[l],nbiaslist[l],debug); // // Set phase: SpireBb_SpecFSetPhase(sswnphaselist[l],slwnphaselist[l],debug); // // // // // Stop DCU data before resetting offsets: // SpireBb_StopDcuData(); // // // // // // Set offsets: // // DCU data is stopped: bool dcuData = false; SpireBb_SpecOffsetAuto(dcuData,debug); // // // // // Take data: // SpireBb_SpecFTakeData(ftime,debug); // // // // // // Perform standard AOT style PCAL flash if(isPcal) { SpireBbPcalFlash("SFlashEng","v00",0,false); } // // // // // Printing: // if(debug) { debug_print("Bias level " + nbiaslist[l] + " done."); } } // // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////// // // SpireProc_Exec_PhotLoadCurvePcalOn.txt // /////////////////////////////////////////////////////////// // // Procedure to loop through a list of bias amplitudes // for the 'Phot Load Curve Pcal On' task // /////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/04/01 V0.1: Initial version adapted from // SpireProc_Exec_PhotStdLoadCurve (2009/02/01 V1.0) // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Exec_PhotLoadCurvePcalOn { int[] nbiaslist = [0,50,100,255]; // List of raw bias levels in range (0-255) int ftime = 10; // Readout time at each bias level [s] double pcal_bias = 3.8 in [0.0,7.0]; // PCAL bias level [mA] string version = "v01"; // Version in cal table SpireTable_PcalCurrentConvCoef bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Switch on PCAL: // SpireBb_PcalOn(pcal_bias,version,debug); // // // // // Start the LC bias loop: // for(int l = 0 .. length(nbiaslist) - 1) { // // // // // Safety check: // if(nbiaslist[l] > 255) { nbiaslist[l] = 255; if(debug) { debug_print("Input bias list is corrupt! Raw value > 255 requested!"); } } // // // // // Set bias amplitude: // if(l == 0) { if(debug) { debug_print("Bias already set during slew"); } } else { SpireBb_PhotFSetBiasAmpl(nbiaslist[l],nbiaslist[l],nbiaslist[l],nbiaslist[l],debug); } // // // // // Stop DCU data before resetting offsets: // SpireBb_StopDcuData(); // // // // // Set offsets: // SpireBb_PhotOffsetAuto(debug); // // // // // Take data: // SpireBb_PhotFTakeData(ftime,debug); // // // // // Debug printing: // if(debug) { debug_print("Bias level " + nbiaslist[l] + " done."); } } // // // // // Switch off PCAL: // SpireBb_PcalOn(0.0,version,debug); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_PhotOffsetAuto.txt // /////////////////////////////////////////////////////////////////////////// // // BB to set the detector offset for the photometer arrays // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/05/02 V0.1: Initial version adapted from // POffset_Auto (v1.4 2008/01/31 20:24:35) // 2008/07/03 V0.2: Renumber version; Add comments to replace '?'s; // add RESET_FIFO at start // 2008/08/11 V0.3: Change description // 2009/01/31 V1.0: Add debug_print option. Remove unsetting of BBID. // Increased delay to 2 after FLUSH_FIFO. Replace last // delay(1) with sync(). // 2009/02/19 V1.1: Move all commands in low level procedure // SpireProc_Set_PhotOffsetAuto. // 2009/05/07 V1.2: Fixed bug. Script was not setting BBID. // 2009/06/05 V1.3: Fix Hspot message at end of script (SPR-1481). // // Note currently BB hardcodes the DCU data to be unsampled when // BB is started. Low level script already has option to account // for a continous sampling during STBY. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_PhotOffsetAuto SPIRE 14007 { bool debug = false; // Allow (==tick) or suppress cus debug_print statement }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SpireBb_PhotOffsetAuto started"); SpireMsg(2," $Id:$"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); sync(); // // // // // Take offset: // // currently hardcoded parameter: bool dcuData = false; // SpireProc_Set_PhotOffsetAuto(dcuData,debug); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SpireBb_PhotOffsetAuto ended"); SpireMsg(1," ..PhotOffsetAuto End (" + (time() - t) + " seconds)"); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_EndBsmPidTuning.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to reconfigure at the end of SpirePhoto_Cal_BsmPidTuning. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // // 2009/05/06 V1.0: Initial version adapted from // SpireBb_EndBsmAngleCal (2009/05/05 V1.2) and // SpirePhoto_Cal_BsmPidTuning (2009/04/01 V0.2). // 2009/05/07 V1.1: Set dcuFrameNumber and mcuFrameNumber back to continuous // to unset setting passed to VM. // 2009/06/05 V1.2: SPR-1476: Set PID parameters back to nominal. To do this // input parameters need to be changed. SPR-1482: // Replace 2 Spire_SEND_DRCU_COMMANDs with SpireSendDrcuCmd. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_EndBsmPidTuning SPIRE 14057 { bool phot = true; // Photometer (==tick) or FTS (==untick)? bool isBright = false in [true,false]; // IsBright (==tick) flag string version01 = "v00"; // Version in cal.tab. SpireTable_PhotModeParams string version02 = "v00"; // Version in cal.tab. SpireTable_CommonModeParams string version03 = "v00"; // Version in cal table SpireTable_BsmNominalSettings string model = "initial"; // Model in cal table SpireTable_BsmNominalSettings bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // // Hardcoded calibration tables: string tabName03 = "SpireTable_BsmNominalSettings.txt"; // string version = version03; string tabName = tabName03; string selCol = "model"; string selVal = model; string tarCol = "chop_0_I"; // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // int mode_id = 0; string obsmode = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB EndBsmPidTuning reconfiguration started"); SpireMsg(2," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Set obsstep back to 0: // tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP(0)"); Spire_SET_OBS_STEP(0); // // // // // Set instrument back to Phot/Spec-STBY: // if(phot) { SpireProc_Set_PhotMode("PHTSTBY",isBright,version01,version02,debug); } else { SpireProc_Set_SpecMode("SPECSTBY",isBright,version01,version02,debug); } // // // // // Read BSM hold position from calibration table: // version = version03; tabName = tabName03; selCol = "model"; selVal = model; // tarCol = "chop_0_I"; int hold_chop = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "jigg_0_I"; int hold_jigg = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // // // // Move BSM back to hold: // SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug); // // // // // Set number of DCU frames to continuous: // int dcuFrameNumber = 0; if(phot) { dcuFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","PHTSTBY","dcuFrameNumber","v00",debug); } else { dcuFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","SPECSTBY","dcuFrameNumber","v00",debug); } // SpireSendDrcuCmd(0x843d0000 + dcuFrameNumber,0); // // // // // Set number of MCU frames to continuous: // int mcuFrameNumber = 0; if(phot) { mcuFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","PHTSTBY","mcuFrameNumber","v00",debug); } else { mcuFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","SPECSTBY","mcuFrameNumber","v00",debug); } SpireSendDrcuCmd(0x91c30000 + mcuFrameNumber,0); delay(1); // // // // // Read nominal PID parameters from calibration file: // version = version03; tabName = tabName03; selCol = "model"; selVal = model; // tarCol = "chop_kp"; int kp = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "chop_ki"; int ki = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "chop_kd"; int kd = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // // // // Set PID parameters back to nominal (STBY) values: // SpireProc_Set_BsmChopPid(kp,ki,kd,debug); // // // // // End observation: // SpireProc_Set_EndObsAll(phot); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB EndBsmPidTuning reconfiguration ended"); SpireMsg(1," ..Reconfiguration to " + obsmode + "mode (" + (time() - t) + " seconds)"); // } /////////////////////////////////////////////////////////////////////////// // // SpireBb_Serendipity.txt // /////////////////////////////////////////////////////////////////////////// // // BB to wait while doing a serendipity observation // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/11/12 V0.1: Initial version // 2009/03/16 V1.1: Remove unsetting of BBID. Add sync. Add debug as option. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_Serendipity SPIRE 14021 { int wtime = 0; // Waiting time for observation to finish bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Set the BBs to SPIRE bbid: // Spire_SET_BBID($BBID); sync(); // // // // // Waiting time: // // Take setting of BBID into account: if(wtime == 0) { wtime = 0; } else { wtime = wtime - 1; } // // wait (and take data): delay(wtime); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_PcalOn.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to set PCAL to input PCAL bias level. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/04/01 V0.1: Initial version adapted from // SpireProc_PcalFlash (2008/11/07 V0.1) // // Note, by setting pcal_bias to 0.0 the same script switches OFF PCAL. // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_PcalOn { double pcal_bias = 3.8 in [0.0,7.0]; // PCAL bias level [mA] string version = "v01"; // Version in cal table SpireTable_PcalCurrentConvCoef bool debug = false; }{ // // // // // Define some variables: // string tstr = ""; // // Hardcoded calibration tables: // string tabName = "SpireTable_PcalCurrentConvCoef.txt"; // // // // // Start procedure: // message("4 " + time() + ": SpireProc_PcalON started"); message("4 $Id: $"); // // // // // Retrieve PCAL bias calibration coefficients: // double[] coeff = [0.0]; coeff[0] = dlookup(tabName,version,"c_0"); coeff[1] = dlookup(tabName,version,"c_1"); // // // // // Calculate RAW PCAL bias values for each of the flashes from mA list: // int raw_level = 0; raw_level = iround((pcal_bias * 0.0010 - coeff[0]) / coeff[1]); // // // // // Set PCAL bias to input bias level: // SpireSendDrcuCmd(0xa0c80000 + raw_level,0); // Note, reduced wait time from IST 10sec to 5secs: delay(5); // // // // // End procedure: // message("4 " + time() + ": SpireProc_Set_PcalOn ended"); // } // CVS comments : $Id: PHOT_aot_epilogue.txt,v 1.2 2007/04/25 15:14:03 dcesarsk Exp $ // Missionphase : // Purpose : Stop PHOTOmeter observations at end of AOT // // TCL author : // TCL file : // CUS author : Diego Cesarsky // Script file : PHOT_aot_epilogue.txt // // Input arguments // Type Name Default Description // // Description : Not much for now (just STOP SPU) // // Dependencies : PACS TCs // // Preconditions : // // Comments : // // History : 0.1 19-apr-2006 First creation // 1.0 23-sep-2008 SCR 4431 data_rate procedure PHOT_aot_epilogue { }{ // Stop the Long and Short SPUs Pacs_SPUS_STOP_REDUCT_COMPR(); Pacs_SPUL_STOP_REDUCT_COMPR(); data_rate(0.0); // Sync the bus (function duration will get the "true" duration) sync(); // end of procedure } // CVS comments : $Id: WriteBBID.txt,v 1.6 2007/04/26 15:44:10 dcesarsk Exp $ // Missionphase : // // Purpose : // // CUS script : Diego A. Cesarsky (diego.cesarsky@mpe.mpg.de) // CVS file : WriteBBID.txt // // Input arguments // Type Name DefVal Description // int iBBID N/A BBID obtained from environment // // Description : Write BBID to DEC/MEC; print decoded BBID // to output log // // Dependencies : Pacs_DMC_SET_BBID // DecodeBBID // // Comments : // // Version : 0.1 23-Sep-2004 First creation // History : 0.2 28-Sep-2004 Show BBID "decoded" on output screen. // Remove set_unset choice // 0.3 7-Oct-2004 Rationalize name convention: renamed to // WriteBBID (idem with file name) // 0.4 12-Oct-2004 Added write to EGSE equipment (will have to // add later writes to IST equipment ??) // 0.5 21-Oct-2004 Added write to CDMS // 0.6 9-May-2005 Remove write to EGSE and to CDMS // 0.7 22-nov-2006 Removed debug statement // : // procedure WriteBBID { int iBBID = 0x40000000; // Building Block ID }{ // Write BBID to DEC/MEC and to output log Pacs_DMC_SET_BBID(iBBID); /// DecodeBBID(iBBID); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////// // // SpireProc_Exec_PhotPcalLoadCurve.txt // /////////////////////////////////////////////////////////// // // Procedure to loop through a list of bias amplitudes and flashing // PCAL for the 'Phot PCAL Load Curve' task // /////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/06/09 V0.1: Initial version adapted from // Mode_ILT_PERF_DAB_P_CPS.txt (v1.3 2008/01/31 23:35:17) // 2008/07/04 V0.2: Renumber version; include PTC in loop; skip first setup in // SpireBb_PhotFSetupData, as it is already done during slew // 2008/08/15 V0.3: Remove test number; Move calculation of flash parameters // from SpireProc_CalcParam_PhotIltPcalFlash to here // 2009/02/02 V1.0: Add debug_print as input and pass it to low level script. // Replace SpireProc_Exec_PcalFlash by direct call to // SpireBb_PcalFlash. Adapt input to updated SpireBb_PcalFlash // with rate and step. // 2009/02/16 V1.1: Promote new VM table parameters of SpireBb_PcalFlash // to input. // 2009/02/18 V1.2: Adapt to change in call to SpireBb_PcalFlash. // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Exec_PhotPcalLoadCurve { int[] nbiaslist = [0,50,100,255]; // List of raw bias levels in range (0-255) int ftime = 10; // Readout time at each bias level [s] int mclkdiv = 149; //Default (IST) bias freq (== 130.20833 Hz) int biasdiv = 6; //Default (IST) sampling freq (== 18.60119 Hz) int vmId = 70; // Raw VM table number [Dec(Hex)] int vmIndex = 0; // Raw VM index [Dec(Hex)] int nParms = 9; // Number of parameters passed to VM bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Predefine version in SpireTable_PhotPcalCurrentConvCoef.txt: // string ver_a = "v01"; if(debug) { debug_print("The nominal version in SpireTable_PcalCurrentConvCoef.txt is v01"); } // // // // // Retrieve PCAL bias calibration coefficients: // double[] coeff = [0.0]; coeff[0] = dlookup("SpireTable_PcalCurrentConvCoef.txt",ver_a,"c_0"); coeff[1] = dlookup("SpireTable_PcalCurrentConvCoef.txt",ver_a,"c_1"); // // // // // Set some ILT standard values for PCAL flash: // // Period of cycle in microsec: int flashperiod = 4000000; // Period of cycle in millisec: int period = flashperiod / 1000; // Number of cycles: int ncycles = 15; // DCU data mode (default = PF ==0; FTS = SF == 4): int ndcumode = 0; // SCU sampling rate (f =80Hz/(1+scumode)): int scumode = 0; // // // // // Calculate the RAW bias levels: // //[mA] Low Level for 1st PCAL flash: double lowbias_0 = 0.0; //[mA] High Level for 1st PCAL flash: double highbias_0 = 3.8; //[mA] Low Level for 2nd PCAL flash: double lowbias_1 = 0.0; //[mA] High Level for 2nd PCAL flash: double highbias_1 = 4.8; // int pcal_low_bias_0 = iround((lowbias_0 * 0.0010 - coeff[0]) / coeff[1]); int pcal_high_bias_0 = iround((highbias_0 * 0.0010 - coeff[0]) / coeff[1]); int pcal_low_bias_1 = iround((lowbias_1 * 0.0010 - coeff[0]) / coeff[1]); int pcal_high_bias_1 = iround((highbias_1 * 0.0010 - coeff[0]) / coeff[1]); // // // // // Deduce number of DCU samples, SCU samples and DCU sample delay based on mclkdiv and biasdiv: // int[] flash_params = SpireProc_CalcParam_PcalFlash(period,mclkdiv,biasdiv,debug); int dcusamples = flash_params[0]; int scusamples = flash_params[1]; int dcudelay = flash_params[2]; if(debug) { debug_print("//////////////////////////////////////////////////////////////"); debug_print(""); debug_print("CALCULATED DCU SAMPLES : " + dcusamples); debug_print("CALCULATED SCU SAMPLES : " + scusamples); debug_print("CALCULATED SAMP DELAY : " + dcudelay + "microsec"); debug_print(""); debug_print("//////////////////////////////////////////////////////////"); } // // // // // Start the LC bias loop: // for(int l = 0 .. length(nbiaslist) - 1) { // // // // // Safety check: // if(nbiaslist[l] > 255) { nbiaslist[l] = 255; error("Input bias list is corrupt! Raw value > 255 requested!"); } // // // // // Set STEP: // int obsStep = l + 1; // NHK Step parameter if(obsStep == 1) { if(debug) { debug_print("First obsStep already set during slew"); } } else { SpireBb_SetObsStep(obsStep,debug); } // // // // // Set bias amplitude: // if(l == 0) { if(debug) { debug_print("Bias already set during slew"); } } else { SpireBb_PhotFSetBiasAmpl(nbiaslist[l],nbiaslist[l],nbiaslist[l],nbiaslist[l],debug); } // // // // // Stop DCU data before resetting offsets: // SpireBb_StopDcuData(); // // // // // // Set offsets: // SpireBb_PhotOffsetAuto(debug); // // // // // // Execute PCAL flashes: // // First PCAL Flash: // SpireBb_PcalFlash(vmId,vmIndex,nParms,pcal_low_bias_0,pcal_high_bias_0,ncycles,flashperiod,ndcumode,dcusamples,dcudelay,scumode,scusamples,obsStep,debug); // // Second PCAL Flash: // SpireBb_PcalFlash(vmId,vmIndex,nParms,pcal_low_bias_1,pcal_high_bias_1,ncycles,flashperiod,ndcumode,dcusamples,dcudelay,scumode,scusamples,obsStep,debug); // // // Take data: // SpireBb_PhotFTakeData(ftime,debug); // // // // // // Debug printing: // if(debug) { debug_print("Bias level " + nbiaslist[l] + " done."); } } // // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireSpectro_Cal_PcalLoadCurve.txt // /////////////////////////////////////////////////////////////////////////// // // CUS script for: 'Spec PCAL Load Curve' // // in *basic_fine_pointing* or *no_pointing* mode // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/09/16 V0.1: Initial version adapted from // SpirePhoto_Cal_PcalLoadCurve (2008/08/15 V0.5) // 2008/11/11 V0.2: Allow 'no pointing' as input option; Adapt debug printing // 2008/11/12 V0.3: Implement mode setting; Add isBright // Change 'no pointing' implementation // 2009/02/19 V0.4: Add debug_print as input and pass it to some low // level scripts. Add setting of NHK STEP parameter // in SpireProc_Exec_PhotPcalLoadCurve. Set first STEP // already during SLEW and unset at end during INIT_HOLD. // Use new SpireBb_EndObsAll and SpireBb_StartObsAll. // Read nominal bias frequency and bias divider from new // SpireTable_SpecModeParams.txt. Implemented setting // of datarates. Implemented message if activating isBright // setting. Remove cal. tables from input and hardcode them. // Read boresight from SpireTable_OpsParms. Use // SpireProc_Set_SpecMode to set instrument to SPECSTBY // during SLEW. Replace call to SpireBb_SpecFSetupData with // call to SpireBb_SpecFSetPhase, SpireBb_SpecFSetBiasAmpl // and SpireBb_DcuSetFreqSamp to set user requested inputs // plus first bias level during SLEW. Unset isBright if set. // Use SpireBb_SpecSetMode to set back to SPECSTBY at end. // Adapt to change in call to SpireProc_Exec_SpecPcalLoadCurve. // 2009/03/04 V0.5: Add isSerendipity, isPcal, and 8 more dummy parameters // to the script for future use. Replace 'message' by // 'error' if isBright is selected. // 2009/05/07 V0.6: Add in move BSM/SMEC to hold/home at start. Add new // SpireBb_SmecHold to account for the fact that // SpireBb_SmecMove2Home does not stop SMEC. // Gather procedures at start and end in separate BB. // /////////////////////////////////////////////////////////////////////////// // // Script assumes that: // // 1) Instrument is in SPECSTBY at beginning // (i.e. bias amplitude, phase, frequency [mclkdiv,biasdiv] are nominal) // // 2) Phase is kept constant (from input) during this test, i.e no // adjustment of the phase with changing bias amplitude and frequency // // 3) Bias frequency, sampling rate, and phase are input parameters // // 4) Boresight of array can be read from following cal table using // the mode 'SEngCalObs': SpireTable_OpsParms.txt // /////////////////////////////////////////////////////////////////////////// // obs SpireSpectro_Cal_PcalLoadCurve { /* ****************************************************** */ /* USER PARAMETER DEFINITION, CUS SIGNATURE for EX-HSpot */ /* ****************************************************** */ /* */ double ra = 0.0 in [0.0,360.0]; // RA of target double dec = 0.0 in [-90.0,90.0]; // DEC of target int naifid = 0; // NAIF identifier bool isBright = false; // Use settings for bright source (==tick) bool pointing = true; // Should telescope 'point' (==tick) or do a 'no pointing' (==untick)? /* */ double biasfreq = 160.1 in [80.0,240.0]; // Bias frequency [Hz] double samplerate = 80.0 in [1.0,80.5]; // Sampling rate [Hz] (Careful, don't exceed number of data packages to be transferred from spacecraft!) double phasedeg_ssw = 184.9 in [0.0,360.0]; // SSW Bias phase [deg] double phasedeg_slw = 190.6 in [0.0,360.0]; // SLW Bias phase [deg] int ftime = 10; // Readout time at each bias level [s] string version01 = "v00"; // Version in cal table SpireTable_SpecModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams string version03 = "v00"; // Version in cal table SpireTable_PcalLoadCurveLevels string version05 = "v00"; // Version in cal table SpireTable_OpsParms.txt bool debug = false; // Allow (==tick) or suppress cus debug_print statements bool isSerendipity = true; // Allow (==tick) serendipity mode to be activated or prohibit (==untick) it (currently not in use)? bool isPcal = true; // Allow (==tick) regular PcalFlash in script or prohibit (==untick) it (currently not in use)?. bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ // // // // // Check for is bright setting: // if(isBright) { isBright = false; error("IsBright does not make sense here. Try again (e.g. subtract the phase shift manually from the input)!"); } // // // // // Declare some variable: // // Photometer or FTS: bool phot = false; bool fts = !phot; // string tabName = ""; string selCol = ""; string selVal = ""; string tarCol = ""; string version = ""; double scirate = 0.0; double chkrate = 0.0; double nhkrate = 0.0; // int obsStep = 0; // // Hardcoded calibration tables: // string tabName01 = "SpireTable_PhotModeParams.txt"; string tabName02 = "SpireTable_CommonModeParams.txt"; string tabName03 = "SpireTable_PcalLoadCurveLevels.txt"; string tabName04 = "SpireTable_CommandLists.txt"; string tabName05 = "SpireTable_OpsParms.txt"; string tabName06 = "SpireTable_BsmNominalSettings.txt"; string tabName09 = "SpireTable_SmecNominalSettings.txt"; // // Currently hardcoded version and model parameter: // string version09 = "v00"; // Version in cal table SpireTable_SmecNominalSettings string version06 = "v00"; // Version in cal table SpireTable_BsmNominalSettings string model = "initial"; // Model in cal table SpireTable_BsmNominalSettings // // Dummy value for Phot script: // (needed but not used in spec script!) // int psw_bias = 62; // int pmw_bias = 62; // int plw_bias = 62; // int ptc_bias = 62; // int psw_phase = 127; // int pmw_phase = 127; // int plw_phase = 127; // int ptc_phase = 127; // // // Currently hardcoded parameter: // Is (==tick) the DCU currently sampled? bool dcuData = false; // // // // // Setup mode: // // Set obsMode for QLA: string obsModeQla = "ENG_CAL_OBS39"; // Note: this needs entry in MIB table and in SpireTableInstConfigs.txt // // Set obsMode for datarates: string obsMode = "SEngCalObs"; // Note: this is currently only a maximum value // // // // // Retrieve bias levels used for the load curve: // tabName = tabName03; version = version03; int[] nbiaslist = SpireProc_CalcParam_LoadCurve(tabName,version,debug); // // Lookup first bias level: int ssw_bias = nbiaslist[0]; int slw_bias = nbiaslist[0]; // // // // // Convert user input to Hex values: // // for bias frequency and sample rate: // int[] hexvalues = SpireProc_CalcParam_BiasFreqSampFreq(biasfreq,samplerate,fts,debug); int mclkdiv = hexvalues[0]; int biasdiv = hexvalues[1]; if(debug) { debug_print("Hex values of mclkdiv/biasdiv are: " + mclkdiv + " " + biasdiv); } // // for bias phase: // int[] phasehex = SpireProc_CalcParam_SpecPhaseConvert(phasedeg_ssw,phasedeg_slw,debug); int ssw_phase = phasehex[0]; int slw_phase = phasehex[1]; // // // // // Read VM parameters from calibration table: // tabName = tabName04; selVal = "Flash"; int vmId = ilookup(tabName,selVal,"Id"); int vmIndex = ilookup(tabName,selVal,"Index"); int nParms = ilookup(tabName,selVal,"Nparms"); // // // // // Read BSM home parameters: // // Select version flag and set GetTableEntry parameters: // version = version06; tabName = tabName06; selCol = "model"; // Name of column for selecting selVal = model; // Value of 'string' selector // // Read hold position from calibration table: // tarCol = "chop_0_I"; int hold_chop = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "jigg_0_I"; int hold_jigg = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // // // // Read SMEC home position from calibration file: // tarCol = "Home"; tabName = tabName09; selVal = version09; int smecHomePosn = ilookup(tabName,selVal,tarCol); // // // ****************************************************** */ // CALCULATE DURATIONS for POINTING STATES */ // ****************************************************** */ // // // // // Calculate timing for the pointing request: // // BBs called during slew: int tslewmin = duration(SpireBb_StartPcalLoadCurve(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,mclkdiv,biasdiv,psw_bias,pmw_bias,plw_bias,ptc_bias,psw_phase,pmw_phase,plw_phase,ptc_phase,ssw_bias,slw_bias,ssw_phase,slw_phase,debug)); // // BBs carried out when the pointing is reached: if(pointing) { int tinithold = 0; } else { tinithold = tslewmin; } // // BB carried out during pointing: int tp = duration(SpireProc_Exec_SpecPcalLoadCurve(nbiaslist,ftime,mclkdiv,biasdiv,vmId,vmIndex,nParms,dcuData,debug)); // // BB carried out at the end: int tfinalhold = duration(SpireBb_EndPcalLoadCurve(phot,isBright,version01,version02,debug)); // if(debug) { debug_print("tslewmin = " + tslewmin); debug_print("tinithold = " + tinithold); debug_print("tpointing = " + tp); debug_print("tfinalhold = " + tfinalhold); } // // ****************************************************** */ // POINTING MODE DECLARATION */ // ****************************************************** */ // // // // // Lookup boresight: // tabName = tabName05; selCol = "mode"; selVal = obsMode; tarCol = "Boresight"; version = version05; string ib = SpireProc_GetTableEntryString(tabName,selCol,selVal,tarCol,version,debug); // // Set pointing mode: // if(pointing) { int[] ts = basic_fine_pointing(true,tslewmin,tinithold,tfinalhold,ib,naifid,ra,dec,0.0,0.0,tp); } else { ts = no_pointing(true,tinithold,tfinalhold,tp); } // if(debug) { debug_print("Output timing vector from the pointing request: " + ts); } // }{ // ****************************************************** */ // POINTING STATES WITH OBSERVING MODE LOGIC */ // ****************************************************** */ // // // // // Set datarates: // string rateType = "chk"; chkrate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); ess_hk_data_rate(chkrate); // rateType = "nhk"; // nhkrate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); non_ess_hk_data_rate(nhkrate); // rateType = "sci"; scirate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); data_rate(scirate); // if(debug) { debug_print("Set CHK datarate to: " + chkrate); debug_print("Set NHK datarate to: " + nhkrate); debug_print("Set SCI datarate to: " + scirate); } // // Start the state_machine: // int[] state = [0]; // while(state[0] >= 0) { if(debug) { debug_print("Current state: " + state); } state = next_state(); if(debug) { debug_print("Next state: " + state); } // if(state[0] == 1) { // STATE = SLEW ( Spacecraft is slewing ) // // // // // Startup observation: // SpireBb_StartPcalLoadCurve(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,mclkdiv,biasdiv,psw_bias,pmw_bias,plw_bias,ptc_bias,psw_phase,pmw_phase,plw_phase,ptc_phase,ssw_bias,slw_bias,ssw_phase,slw_phase,debug); // //delay(timeSlewCal); } if(state[0] == 2) { // STATE = INIT_HOLD ( spacecraft is idling at source ) // // // // // // If no pointing observation do stuff here which is // done nominally during SLEW: // if(!pointing) { // // // // // Startup observation: // SpireBb_StartPcalLoadCurve(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,mclkdiv,biasdiv,psw_bias,pmw_bias,plw_bias,ptc_bias,psw_phase,pmw_phase,plw_phase,ptc_phase,ssw_bias,slw_bias,ssw_phase,slw_phase,debug); // } } // //delay(tinithold); // if(state[0] == 3) { // STATE = POINT ( spacecraft is at nominal RA,DEC (staring, raster) ) // // // // // Execute load curve with PCAL flashes: // SpireProc_Exec_SpecPcalLoadCurve(nbiaslist,ftime,mclkdiv,biasdiv,vmId,vmIndex,nParms,dcuData,debug); // //delay(tp); // } if(state[0] == 5) { // STATE = FINAL_HOLD ("sky" observation ends, performing final activ.) // // // // // Set scientific datarate back to zero: // data_rate(0.0); // // // // // Reconfigure at the end (incl. resetting of OBSID and BBIB): // SpireBb_EndPcalLoadCurve(phot,isBright,version01,version02,debug); // } if(state[0] == -1) { // STATE = END ( end of the pointing/commanding part of the code ) // } } } // SpireSpectroRasterLogic // // $Id: SpireSpectroRasterLogic.txt,v 1.5 2006/11/08 14:44:15 kking Exp $ // // This procedure selectes the SPIRE observing mode and calculates its instrument parameters // for raster spectrometer observations // // This type of observation may be executed using either the SOF1 or SOF2 observing modes // // 10/03/2009 KJK: // SCR 1274, add additional dummy parameters // Update input API to include versions for all cal tables // 17/03/2009 KJK: // Updated return values to put nCycles1 in nHCycles and nCycles2 in nLCycles // Modified to set nCycles2 = 0 if only single resolution scans are requested // {{double,double,double,double,double,double}[],{double,double,double,double,double,double}[],bool,int,int,int,int,int,int,int,double,int,double} obs SpireSpectroRasterLogic { double ra = 0.0 in [0.0,360.0]; // RA of Target double dec = 0.0 in [-90.0,90.0]; // DEC of Target int naifid = 0; // NAIF identifier string pointing = "raster" in ["single","raster"]; // pointing type string sampling = "sparse" in ["sparse","intermediate","full"]; // spatial sampling string resolution = "H" in ["H","M","L","H+L"]; // spectral resolution double mapSize1 = 0.0 in [0.0,30.0]; // arc minutes double mapSize2 = 0.0 in [0.0,30.0]; // arc minutes double mapOffsetY = 0.0 in [-300.0,300.0]; // arc minutes double mapOffsetZ = 0.0 in [-300.0,300.0]; // arc minutes bool mapOrientationArray = true; // is the map orientation an array (rather than array with constraints) double mapOrientationConFrom = 0.0 in [0.0,360.0]; double mapOrientationConTo = 360.0 in [0.0,360.0]; int nRepetitions1 = 2 in [2,1200]; // number of times to repeat spectral scan pairs for single resolution scan modes and high resolution in H+L mode int nRepetitions2 = 2 in [2,1200]; // number of times to repeat spectral scan pairs for low resolution scans for 'H+L" mode double wavelength1 = -1.0; // wavelength double wavelength2 = -1.0; // wavelength double wavelength3 = -1.0; // wavelength double wavelength4 = -1.0; // wavelength double wavelength5 = -1.0; // wavelength double wavelength6 = -1.0; // wavelength double wavelength7 = -1.0; // wavelength double wavelength8 = -1.0; // wavelength double lineFlux1 = -1.0; // line flux estimate double lineFlux2 = -1.0; // line flux estimate double lineFlux3 = -1.0; // line flux estimate double lineFlux4 = -1.0; // line flux estimate double lineFlux5 = -1.0; // line flux estimate double lineFlux6 = -1.0; // line flux estimate double lineFlux7 = -1.0; // line flux estimate double lineFlux8 = -1.0; // line flux estimate bool isJyContinuum = true; // is continuum specified in Jy rather than Wm-2um-1 double contFlux1 = -1.0; // continuum flux estimate double contFlux2 = -1.0; // continuum flux estimate double contFlux3 = -1.0; // continuum flux estimate double contFlux4 = -1.0; // continuum flux estimate double contFlux5 = -1.0; // continuum flux estimate double contFlux6 = -1.0; // continuum flux estimate double contFlux7 = -1.0; // continuum flux estimate double contFlux8 = -1.0; // continuum flux estimate bool isBright = false; string spireVersion = "v00"; // Version in cal table SpireTable_SpireParms string opsVersion = "v00"; // Version in cal table SpireTable_OpsParms string flashVersion = "v00"; // Version in cal table SpireTable_FlashParms string specVersion = "v00"; // Version in cal table SpireTable_Spectrometer bool debug = false; // debug messages flag bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ // check inputs if(pointing != "raster") { error("SpireSpectroRasterLogic: Pointing is not set to raster"); } SpireMsg(0,"Spectrometer Raster Observation"); // ******************************************** // Calculate possible pointing parameters // ******************************************** // int nCycles1 = 0; int nCycles2 = 0; double tCycle1 = 0.0; double tCycle2 = 0.0; int scansPerCycle1 = 0; int scansPerCycle2 = 0; double osit1 = 0.0; double osit2 = 0.0; int nRasters = 1; int nMaps = 1; int nCycles = 1; int nFlashes = 0; double tFlash = 0.0; int nCals = 0; double tCal = 0.0; int tSlewMin = 0; int tInitHold = 0; int tFinalHold = 0; string ib = ""; // instrument boresight double yOffset = 0.0; // offset to observation position from target in Y direction (arcsecs) double zOffset = 0.0; // offset to observation position from target in Z direction (arcsecs) double deltaY = 0.0; // offset to pixel centre from boresight in Y direction (arcsecs) double deltaZ = 0.0; // offset to pixel centre from boresight in Z direction (arcsecs) int tHold = 0; int nHold = 0; // double[] wavelength = [wavelength1,wavelength2,wavelength3,wavelength4,wavelength5,wavelength6,wavelength7,wavelength8]; double[] lineFlux = [lineFlux1,lineFlux2,lineFlux3,lineFlux4,lineFlux5,lineFlux6,lineFlux7,lineFlux8]; double[] contFlux = [contFlux1,contFlux2,contFlux3,contFlux4,contFlux5,contFlux6,contFlux7,contFlux8]; // // ***************************************** // select instrument ops mode // ***************************************** // string opsMode = ""; // opsMode int md = 0; // value of MODE parameter if(sampling == "sparse") { opsMode = "SOF1"; md = 0x410; } else { if(sampling == "intermediate") { opsMode = "SOF2_int"; } else { if(sampling == "full") { opsMode = "SOF2"; } else { error("SpireSpectroPoint: Unknown sampling"); } } md = 0x420; } // // ***************************************** // set up scan sets // ***************************************** // string res1 = resolution; if(resolution == "H+L") { res1 = "H"; } string res2 = "L"; if(resolution != "H+L") { nRepetitions2 = 0; } // ***************************************** // get observing parameters // ***************************************** // ib = slookup("OpsParms.txt",opsMode,"Boresight"); deltaY = dlookup("OpsParms.txt",opsMode,"DeltaY"); // offset to pixel centre from boresight in Y direction (arcsecs) deltaZ = dlookup("OpsParms.txt",opsMode,"DeltaZ"); // offset to pixel centre from boresight in Z direction (arcsecs) bool fixed = blookup("OpsParms.txt",opsMode,"Fixed"); // pattern angle definition double pattNod = dlookup("OpsParms.txt",opsMode,"Patt"); // direction of nod double chopThrow = dlookup("OpsParms.txt",opsMode,"D1"); yOffset = mapOffsetY * 60.0 + deltaY; // offset to observation position from target in Y direction (arcsecs) zOffset = mapOffsetZ * 60.0 + deltaZ; // offset to observation position from target in Z direction (arcsecs) {int,double,int,double,int,double,int,double,int,int,double,int,double} sofObs = SpireSOF12Observing(opsMode,res1,res2,nRepetitions1,nRepetitions2,specVersion,opsVersion,flashVersion,debug); nCycles1 = sofObs{0}; tCycle1 = sofObs{1}; scansPerCycle1 = sofObs{2}; osit1 = sofObs{3}; nCycles2 = sofObs{4}; tCycle2 = sofObs{5}; scansPerCycle2 = sofObs{6}; osit2 = sofObs{7}; nMaps = sofObs{8}; nFlashes = sofObs{9}; tFlash = sofObs{10}; nCals = sofObs{11}; tCal = sofObs{12}; // {int,int,int,int,int,int} sofPoint = SpireSOF12Pointing(opsMode,res1,nCycles1,tCycle1,scansPerCycle1,res2,nCycles2,tCycle2,scansPerCycle2,nMaps,nFlashes,tFlash,specVersion,flashVersion,debug); tSlewMin = sofPoint{0}; tInitHold = sofPoint{1}; tFinalHold = sofPoint{2}; tHold = sofPoint{4}; nHold = sofPoint{5}; // ***************************************** // set telescope pointing mode // ***************************************** // // calculate raster positions {double[],double[]} sofRaster = SpireSpecRasterPositions(opsMode,0.0,0.0,mapSize1 * 60.0,mapSize2 * 60.0); double[] yArray = sofRaster{0}; double[] zArray = sofRaster{1}; int[] tp = []; int nPoints = length(yArray); for(int n = 0 .. nPoints - 1) { tp[n] = sofPoint{3}; } if(nHold > nPoints) { nHold = 0; } // int[] ts = custom_map_pointing(true,tSlewMin,tInitHold,tFinalHold,ib,naifid,ra,dec,fixed,pattNod,yOffset,zOffset,yArray,zArray,tp,pattNod,chopThrow,1,0,0,0,tHold,nHold); }{ // ********************************* // Return instrument parameters // ********************************* {{double,double,double,double,double,double}[],{double,double,double,double,double,double}[]} estimates = SpireSOF12Estimate(resolution,osit1,osit2,wavelength1,wavelength2,wavelength3,wavelength4,wavelength5,wavelength6,wavelength7,wavelength8,lineFlux1,lineFlux2,lineFlux3,lineFlux4,lineFlux5,lineFlux6,lineFlux7,lineFlux8,isJyContinuum,contFlux1,contFlux2,contFlux3,contFlux4,contFlux5,contFlux6,contFlux7,contFlux8,isBright,specVersion,debug); // bool isChopped = false; // int nHCycles = nCycles1; int nMCycles = 0; int nLCycles = nCycles2; return {estimates{0},estimates{1},isChopped,nRasters,nPoints,nMaps,nHCycles,nMCycles,nLCycles,nCals,tCal,nFlashes,tFlash}; } // SpireBbStartDcuData // // $Id: SpireBbStartDcuData.txt,v 1.1 2006/08/10 09:38:58 kking Exp $ // // Building Block to start generation of detector data TM packets // // // 04 November 2008: // changed to use the SpireStartDrcuData procedure // changed to receive operations mode rather than data mode as a parameter // block SpireBbStartDcuData SPIRE 8456 { string opsMode = ""; }{ message("4 " + time() + ": SpireBbStartDcuData started"); message("4 $Id: SpireBbStartDcuData.txt,v 1.1 2006/08/10 09:38:58 kking Exp $"); // SpireStartDcuData(opsMode); // message("4 " + time() + ": SpireBbStartDcuData ended"); // } // SpireStopDcuData // // $Id: SpireStopDcuData.txt,v 1.3 2007/04/02 09:50:56 kking Exp $ // // Procedure to stop generation of detector data TM packets // // 30 March 2007: Added additional parameter to RESET_FIFOS message // 02 April 2007: Added additional parameter to RESET_FIFOS cmd // 04 November 2008: added data_rate command // // procedure SpireStopDcuData { }{ message("4 " + time() + ": SpireStopDcuData started"); message("4 $Id: SpireStopDcuData.txt,v 1.3 2007/04/02 09:50:56 kking Exp $"); // // stop data collection SpireSendDrcuCmd(0x843e0000,0); data_rate(0.0); // // flush data from FIFOs message("5 " + time() + "Cmd: Spire_FLUSH_FIFO(0x1000)"); Spire_FLUSH_FIFO_RAW(0x1000); delay(3); message("5 " + time() + "Cmd: Spire_RESET_FIFOS(0x1000)"); Spire_RESET_FIFOS(0x1000); // delay(1); message("4 " + time() + ": SpireStopDcuData ended"); // } // SpireBbSetPtc // // $id$ // // This building block starts or stops the PTC PID Command List // // 09/06/2009 KJK: First Version // block SpireBbSetPtc SPIRE 1611 { string ptc = "Off" in ["On","Off"]; string version = "v00"; bool debug = false; }{ int t0 = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB Set PTC started"); SpireMsg(2," $Id: $"); // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // // stop PTC VM // this stops the VM from another command list - this stops the possibility of a TC execution error if the // VM is not running int vm = ilookup("SpireTable_CommandLists.txt","PTC","Vm"); tstr = SpireTimeStr(time()); {int}[] cl = [{0x58000000 + vm},{0x7f000000}]; SpireMsg(5," " + tstr + "Cmd: Spire_EXECUTE_COMMAND_LIST_RAW(" + 2 + "," + cl + ")"); Spire_EXECUTE_COMMAND_LIST_RAW(2,cl); delay(2); // // ensure PTC bias is zero SpireSendDrcuCmd(0xa0c60000,0); // set PTC HTR bias to zero delay(2); // if(ptc == "On") { // start PTC VM, if required // // Get Command List info int tableId = ilookup("SpireTable_CommandLists.txt","PTC","TableId"); int startIndex = ilookup("SpireTable_CommandLists.txt","PTC","Index"); int nParams = ilookup("SpireTable_CommandLists.txt","PTC","NParms"); // // Retrieve the input parameters int deltaTemp = ilookup("SpireTable_CL_PTC.txt",version,"DeltaTemp"); int ptcTempCmd = ilookup("SpireTable_CL_PTC.txt",version,"PtcTempCmd"); int loopPeriod = ilookup("SpireTable_CL_PTC.txt",version,"LoopPeriod"); int kp = ilookup("SpireTable_CL_PTC.txt",version,"Kp"); int ki = ilookup("SpireTable_CL_PTC.txt",version,"Ki"); int kd = ilookup("SpireTable_CL_PTC.txt",version,"Kd"); int kiLimit = ilookup("SpireTable_CL_PTC.txt",version,"KiLimit"); int lpFiltGain = ilookup("SpireTable_CL_PTC.txt",version,"LpFiltGain"); int lpFiltB1 = ilookup("SpireTable_CL_PTC.txt",version,"LpFiltB1"); int lpFiltB2 = ilookup("SpireTable_CL_PTC.txt",version,"LpFiltB2"); int dacOffset = ilookup("SpireTable_CL_PTC.txt",version,"DacOffset"); int maxDac = ilookup("SpireTable_CL_PTC.txt",version,"MaxDac"); int pwmFlag = ilookup("SpireTable_CL_PTC.txt",version,"PwmFlag"); int frameCount = ilookup("SpireTable_CL_PTC.txt",version,"FrameCount"); int initCount = ilookup("SpireTable_CL_PTC.txt",version,"InitCount"); int errorComp = ilookup("SpireTable_CL_PTC.txt",version,"ErrorComp"); // // start executing Command List {int}[] params = [{deltaTemp},{ptcTempCmd},{loopPeriod},{kp},{ki},{kd},{kiLimit},{lpFiltGain},{lpFiltB1},{lpFiltB2},{dacOffset},{maxDac},{pwmFlag},{frameCount},{initCount},{errorComp}]; tstr = SpireTimeStr(time()); if(vm == 1) { SpireMsg(5," " + tstr + "Cmd: Spire_RUN_VM1_RAW(" + tableId + "," + startIndex + "," + nParams + "," + params + ")"); Spire_RUN_VM1_RAW(tableId,startIndex,nParams,params); } if(vm == 2) { SpireMsg(5," " + tstr + "Cmd: Spire_RUN_VM2_RAW(" + tableId + "," + startIndex + "," + nParams + "," + params + ")"); Spire_RUN_VM2_RAW(tableId,startIndex,nParams,params); } if(vm == 3) { SpireMsg(5," " + tstr + "Cmd: Spire_RUN_VM3_RAW(" + tableId + "," + startIndex + "," + nParams + "," + params + ")"); Spire_RUN_VM3_RAW(tableId,startIndex,nParams,params); } // delay(2); } // sync(); // // completion tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB Set PTC ended"); } // SpireBbSmecOff // // $id$ // // This building block switches off the SMEC // // 07/05/2009: KJK // First Version // // 27/05/2009: SDS // Updated for SPIRE SCR-1719 to set Kp and Ki to zero at SMEC switch-off // block SpireBbSmecOff SPIRE 532 { string version = "v00"; bool debug = false; }{ int t0 = time(); string hstr = ""; // hex string string tstr = ""; // time string tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SMEC Off started"); SpireMsg(2," $Id:$"); // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); delay(1); // // set Step to zero SpireSetObsStep(0); // // Flag the current operation SpireSetObsMode("SMEC_OFF"); delay(1); // // Set SMEC to Home position int smecHome = ilookup("SpireTable_SmecNominalSettings.txt",version,"Home"); // hold current position SpireSendDrcuCmd(0x90490000,0); // set Home position SpireSendDrcuCmd(0x90450000 + smecHome,0); SpireSendDrcuCmd(0x90460000,0); delay(1); // set movement speed int moveCmd = ilookup("SpireTable_SmecNominalSettings.txt",version,"MoveCmd"); SpireSendDrcuCmd(0x90470000 + moveCmd,0); SpireSendDrcuCmd(0x90560000 + moveCmd,0); delay(1); // move it SpireSendDrcuCmd(0x90490001,0); delay(20); // // Open the control loop SpireSendDrcuCmd(0x90440006,0); // // switch off position sensors SpireSendDrcuCmd(0x90400000,0); SpireSendDrcuCmd(0x90410000,0); delay(1); // // Set SMEC Kp and Ki to 0 (SPIRE SCR-1719) SpireSendDrcuCmd(0x904a0000,0); SpireSendDrcuCmd(0x904d0000,0); delay(1); // // completion tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SMEC Off ended"); SpireMsg(1," ..SMEC Off (" + (time() - t0) + " seconds)"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_GetTableEntryInt.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to select a double entry in a calibration table // giving a string input as selector using the versioning approach. // // Note: Currently script is restricted to a 'string' selector! // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/01/26 V0.1: Initial version adapted from // SpireProc_CalcParam_FpgInitialPointing.txt (2008/11/06 V0.3) // 2009/07/12 V1.0: Fix SPR-SPIRE-1636 (reduce number of debug printouts) // Change default values for testing. // /////////////////////////////////////////////////////////////////////////// // int procedure SpireProc_GetTableEntryInt { string tabName = "SpireTable_PhotModeParams.txt"; // Name of the table to be selected from string selCol = "mode"; // Name of column for selecting string selVal = "PHTSTBY"; // Value of 'string' selector string tarCol = "mclkDiv"; // Target column name string version = "v00"; // Version parameter defined in calibration table bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Define some variable: // int intVar = 0; // // Define columns: string[] versionCol = scolumn(tabName,"version"); int[] targetCol = icolumn(tabName,tarCol); string[] selectorCol = scolumn(tabName,selCol); // // Read table size: int nrows = table_size(tabName); // // // // // Cycle through values to get all rows with correct version tag: // //Setup: {int,string}[] rows = [{0,""}]; int nindex = 0; bool match = false; // for(int j = 0 .. nrows - 1) { //if(debug) { // debug_print("versionCol[j]: " + versionCol[j]); //} if(versionCol[j] == version) { rows[nindex] = {targetCol[j],selectorCol[j]}; nindex = nindex + 1; match = true; } } //if(debug) { // debug_print("selected rows: " + rows); //} // Safety check: if(!match) { error("Calibration table empty or wrong version selected!"); } // // // // // Make final selection from all rows (selected by version): // int nentries = length(rows); int counter = 0; match = false; for(int i = 0 .. nentries - 1) { //if(debug) { // debug_print("rows sliced:" + rows[i]{0} + "/" + rows[i]{1}); //} if(rows[i]{1} == selVal) { intVar = rows[i]{0}; match = true; counter = counter + 1; } } // Safety checks: if(!match) { error("Entry " + selVal + " not found in calibration table. Call for help and wait to be rescued!"); } // if(counter > 1) { error("Selector string " + selVal + " is present at least twice in the versioned calibration table. Please report this bug to the relevant authorities!"); } // // // // // Return required value: // if(debug) { debug_print(" If you believe it of not, I found " + tarCol + "=" + intVar + " as version " + version + " when selecting for " + selCol + "=" + selVal + " in table " + tabName); } return intVar; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_Set_DcuFreqSamp.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to configure the DCU bias frequency and sampling rate. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/02/17 V0.1: Initial version adapted from // SpireProc_Set_DcuFreqSampMode (2009/02/15 V0.1) // removing the setting of the dcuDataMode // 2009/06/05 V1.0: Replace Spire_SEND_DRCU_COMMAND with SpireSendDrcuCmd // as requested in SPR-1482. // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Set_DcuFreqSamp { int mclkDiv = 149; // Bias freq. (for photometer == 130.20833 Hz) int biasDiv = 6; // Sampling freq. (for photometer == 18.60119 Hz) bool phot = true; // Set for photometer (==tick) or FTS bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Define some variables: // string tstr = ""; // // Photometer or FTS?: bool fts = !phot; // // // // // Start procedure: // tstr = SpireTimeStr(time()); SpireMsg(4," " + tstr + ": SpireProc_Set_DcuFreqSampMode started"); SpireMsg(4," $Id:$"); // // // // // Set the selected bias frequency, sampling frequency, and DCU data mode: // // Set mclkdiv and biasdiv: // if(phot) { SpireSendDrcuCmd(0x84190000 + mclkDiv,0); SpireSendDrcuCmd(0x84180000 + biasDiv,0); } else { SpireSendDrcuCmd(0x84390000 + mclkDiv,0); SpireSendDrcuCmd(0x84380000 + biasDiv,0); } sync(); // // // // // Calculate bias and sampling frequencies based on mclkdiv and biasdiv: // // Calculate bias frequency Hz: double bias_f = 1.0E7 / (512.0 * double(mclkDiv + 1)); // // Calculate sampling rate Hz: double s_rate = bias_f / (1.0 + double(biasDiv)); // // // // // Calculate frametime (time between successive frames = 1/sampling rate): // //Frametime difference in ms: double framerate = 1.0 / s_rate * 1000.0; // // // // // Debug Printing: // // if(debug) { debug_print(" BIAS FREQUENCY IS : " + bias_f + " [Hz]"); debug_print("SAMPLING FREQUENCY IS : " + s_rate + " [Hz]"); debug_print(" FRAMETIME DIFF IS : " + framerate + " [ms]"); } // // // // // End procedure: // tstr = SpireTimeStr(time()); SpireMsg(4," " + tstr + ": SpireProc_Set_DcuFreqSampMode ended"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_GetTableEntryDouble.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to select a double entry in a calibration table // giving a string input as selector using the versioning approach. // // Note: Currently script is restricted to a 'string' selector! // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/01/26 V0.1: Initial version adapted from // SpireProc_CalcParam_FpgInitialPointing.txt (2008/11/06 V0.3) // 2009/07/12 V1.0: Fix SPR-SPIRE-1636 (reduce number of debug printouts) // Change default values for testing. // /////////////////////////////////////////////////////////////////////////// // double procedure SpireProc_GetTableEntryDouble { string tabName = "SpireTable_PhotModeParams.txt"; // Name of the table to be selected from string selCol = "mode"; // Name of column for selecting string selVal = "PHTSTBY"; // Value of 'string' selector string tarCol = "dcuDataRate"; // Target column name string version = "v00"; // Version parameter defined in calibration table bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Define some variable: // double doubleVar = 0.0; // // Define columns: string[] versionCol = scolumn(tabName,"version"); double[] targetCol = dcolumn(tabName,tarCol); string[] selectorCol = scolumn(tabName,selCol); // // Read table size: int nrows = table_size(tabName); // // // // // Cycle through values to get all rows with correct version tag: // //Setup: {double,string}[] rows = [{0.0,""}]; int nindex = 0; bool match = false; // for(int j = 0 .. nrows - 1) { //if(debug) { // debug_print("versionCol[j]: " + versionCol[j]); //} if(versionCol[j] == version) { rows[nindex] = {targetCol[j],selectorCol[j]}; nindex = nindex + 1; match = true; } } //if(debug) { // debug_print("selected rows: " + rows); //} // Safety check: if(!match) { error("Calibration table empty or wrong version selected!"); } // // // // // Make final selection from all rows (selected by version): // int nentries = length(rows); int counter = 0; match = false; for(int i = 0 .. nentries - 1) { //if(debug) { // debug_print("rows sliced:" + rows[i]{0} + "/" + rows[i]{1}); //} if(rows[i]{1} == selVal) { doubleVar = rows[i]{0}; match = true; counter = counter + 1; } } // Safety checks: if(!match) { error("Entry " + selVal + " not found in calibration table. Call for help and wait to be rescued!"); } // if(counter > 1) { error("Selector string " + selVal + " is present at least twice in the versioned calibration table. Please report this bug to the relevant authorities!"); } // // // // // Return required value: // if(debug) { debug_print(" If you believe it of not, I found " + tarCol + "=" + doubleVar + " as version " + version + " when selecting for " + selCol + "=" + selVal + " in table " + tabName); } return doubleVar; } // Missionphase : // // Purpose : Perform the cooler recycling // // TCL author : TM // TCL file : tm_phot_cooler_recycling.tcl // CUS author : DAC // Script file : BOLO_cool_recycle.txt // // Input arguments // type name description // N/A // // Return values // Type Description // int [] Several duration times // // Description : see PhFPU UM, chapter 4 // // Dependencies : // // Preconditions : // // Comments : Based on the PhFPU UM Draft 6.0 and abundant e-mail // exchanges with SAp // // Version : 2.0 // History : 0.1 08-Apr-2005 creation by DAC; based on TM's // version 1.0 of 24-Sep-2004 // 0.2 15-apr-2005 DAC Forgot WriteBBID!! // 0.3 18-apr-2005 DAC Added Switch Off All Groups // and SetOn All Temp Probes // 0.4 20-sep-2005 Added DPU_SET_HK_LIST to "PHOT" // and to "NO_PRIME" // 0.5 21-sep-2005 Zeroed several HEATER currents // 1.0 26-sep-2005 Added delay(600) as the last operation // 1.1 28-sep-2005 Modified as per Marcs's mail: // "replace: // step 0 (1.18 mA on HSE, 0.0 mA on HSP, wait 300 sec) // step 1 (1.4 mA on HSE, wait 600 sec) // by // step 1(1.4 mA on HSE, 0.0 mA on HSP, wait 600 sec)" // 1.2 7-mar-2006 ....HEATER_CURR renamed to HEATER_CUR // 1.3 26-apr-2006 update with respect to // Preparation_au_recyclage.txt and // Recyclage_Auto_Time.txt and // starting out of SAFE mode (groups // are on, but not biases are set and // temperature sensors are on) // 1.4 10-oct-2006 autonomy function added // 1.5 08-nov-2006 TM: checked for groups off // 1.6 13-nov-2006 TM: cleaning of SP and HSP to zero // 1.7 14-nov-2006 Wait 15 minutes before enabling autonomy function // 1.8 30-nov-2006 Wait 20 minutes before enabling autonomy function // 1.9 09-apr-2007 Modifications of AFs // 2.0 11-apr-2007 SP heater current set explicitly to zero // 2.1 17-oct-2008 KO, extra_cool_time and extra_stab_time variables added // int[] block BOLO_cool_recycle PACS 2003 { int extra_cool_time = 0; // in second before disconnecting the evaporator from 2K int extra_stab_time = 0; // in second after the end of the recycling procedure }{ // disable AF 14 (to check for TEMP_EV < 0.3 K) Pacs_DPU_SET_FUNCT("EVENT_BOL_T_FPU","DISABLE"); // disable AF 21 (to check if the absolute value of the HSP current is below 2*10^(-5)A) Pacs_DPU_SET_FUNCT("EVENT_BOL_I_SP1","DISABLE"); // enable AF 18 (to check if the current of the sorption pump heater is below 30mA) Pacs_DPU_SET_FUNCT("EVENT_BOL_I_SP2","ENABLE"); // // Obtain and set Block ID WriteBBID($BBID); // Define variables to communicate various durations to HSPOT. // NOTE: all time variables in units of number of ramps (SPEC) or // number of readouts (BOLO). The calling program must convert this // count into actual duration in true time units [seconds]. // SRC, REF, CAL, OVR stand for time spent on SRC, REF (on sky), // CAL source, and overheads (wait for something). Total // duration is given by duree_num. If no error, this duration // must be equal to the sum of all others // NOTE: here all durations are given in [sec] int duree_num = 0; int duree_SRC = 0; int duree_REF = 0; int duree_CAL = 0; int duree_OVR = 0; // Set HK to PHOT Pacs_DPU_SET_HK_LIST("PHOT","BOTH Array"); // content of "Preparation_au_recyclage.txt" // Set SP heater current to to 0.00000000 amperes (0) // # P 07 01 0000 int operand = 0x7010000; Pacs_DMC_SEND_COMMAND_BOLC(operand); int t_wait = 1; delay(t_wait); duree_num = t_wait; duree_OVR = t_wait; // Set HSP heater current to to 0.00000000 amperes (0) // # P 07 02 0000 operand = 0x7020000; Pacs_DMC_SEND_COMMAND_BOLC(operand); t_wait = 1; delay(t_wait); duree_num = duree_num + t_wait; duree_OVR = duree_OVR + t_wait; // Set HSE heater current to to 0.00140000 amperes (3572) // # P 07 03 0DF4 // Attendre 300000 ms // # S 01 0493E0 operand = 0x7030df4; Pacs_DMC_SEND_COMMAND_BOLC(operand); t_wait = 300; delay(t_wait); duree_num = duree_num + t_wait; duree_OVR = duree_OVR + t_wait; // Set HSE heater current to to 0.00118000 amperes (3011) // # P 07 03 0BC3 // Attendre 900000 ms // # S 01 0DBBA0 operand = 0x7030bc3; Pacs_DMC_SEND_COMMAND_BOLC(operand); t_wait = 900; delay(t_wait); duree_num = duree_num + t_wait; duree_OVR = duree_OVR + t_wait; //***************************************************************** //** ** //** Automatic Cooling reclycling ** //** ("Recyclage_Auto_Time.txt") ** //** ** //***************************************************************** // // - 23/01/06 Procedure of reclycling in Saclay cryostat with Phfpu MV // - note : this is timing version without temperature test // // Initialisation of BOLC // // Set temp probe on/off FF hexa // # P 07 00 00 FF // // Initialisation of LTU // // Inhiber enregistrement TM // # S 08 // Valider enregistrement TM // # S 09 // // Initial conditions // TEMP_SP < 10K // TEMP_EV < 2K // // Set SP heater current to to 0.02730000 amperes (2231) // # P 07 01 08B7 // // Attendre 2100000 ms // # S 01 200B20 operand = 0x70108b7; Pacs_DMC_SEND_COMMAND_BOLC(operand); t_wait = 2100; delay(t_wait); duree_num = duree_num + t_wait; duree_OVR = duree_OVR + t_wait; // // Set SP heater current to to 0.00700000 amperes (580) // # P 07 01 0244 // // Attendre 2820000 ms // # S 01 2B07A0 operand = 0x7010244; Pacs_DMC_SEND_COMMAND_BOLC(operand); t_wait = 2820; delay(t_wait); duree_num = duree_num + t_wait; duree_OVR = duree_OVR + t_wait; // // Additional wait time for the evaporator cooling down delay(extra_cool_time); duree_num = duree_num + extra_cool_time; duree_OVR = duree_OVR + extra_cool_time; // // Set HSE heater current to to 0.00000000 amperes (0) // # P 07 03 0000 // // Attendre 720000 ms // # S 01 0AFC80 operand = 0x7030000; Pacs_DMC_SEND_COMMAND_BOLC(operand); t_wait = 720; delay(t_wait); duree_num = duree_num + t_wait; duree_OVR = duree_OVR + t_wait; // // Set SP heater current to to 0.00000000 amperes (0) // # P 07 01 0000 operand = 0x7010000; Pacs_DMC_SEND_COMMAND_BOLC(operand); t_wait = 1; delay(t_wait); duree_num = duree_num + t_wait; duree_OVR = duree_OVR + t_wait; // // Set HSP heater current to to 0.00140000 amperes (3569) // # P 07 02 0DF1 // // Attendre 480000 ms // # S 01 075300 operand = 0x7020df1; Pacs_DMC_SEND_COMMAND_BOLC(operand); t_wait = 480; delay(t_wait); duree_num = duree_num + t_wait; duree_OVR = duree_OVR + t_wait; // // Set HSP heater current to to 0.00118000 amperes (3010) // # P 07 02 0BC2 operand = 0x7020bc2; Pacs_DMC_SEND_COMMAND_BOLC(operand); t_wait = 1; delay(t_wait); duree_num = duree_num + t_wait; duree_OVR = duree_OVR + t_wait; // // ************************ // ** ** // ** end recycling ** // ** ** // ************************ // Last message debug_print("Recycling completed, in about 20 min, TEMP_EV < 0.3 K"); t_wait = 1200; duree_num = duree_num + t_wait; duree_OVR = duree_OVR + t_wait; delay(t_wait); // // AF settings // // disable AF 18 (to check if the current of the sorption pump heater is below 30mA) Pacs_DPU_SET_FUNCT("EVENT_BOL_I_SP2","DISABLE"); // enable AF 21 (to check if the absolute value of the HSP current is below 2*10^(-5)A) Pacs_DPU_SET_FUNCT("EVENT_BOL_I_SP1","ENABLE"); // // Set HK to NO PRIME (to have the clean SAFE settings again) Pacs_DPU_SET_HK_LIST("NO_PRIME","BOTH Array"); // // Additional wait time for the evaporator temperature stabilisation delay(extra_stab_time); duree_num = duree_num + extra_stab_time; duree_OVR = duree_OVR + extra_stab_time; // // Return the array of times int[] time_array = [duree_num,duree_SRC,duree_REF,duree_CAL,duree_OVR]; return time_array; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_SetupSmecScan.txt // /////////////////////////////////////////////////////////////////////////// // // Prepare SMEC for scanning // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/03/30 V0.1: Initial version adapted for // SpireProc_Setup_SmecScan.txt (2009/03/25 V0.1) // /////////////////////////////////////////////////////////////////////////// // block SpireBb_SetupSmecScan SPIRE 14035 { string resolution = "L" in ["L","M","H","C"]; // Resolution (low, medium, high,calibration) string version = "v00"; // Version in cal table SpireTable_Spectrometer bool debug = false; // Allow (==tick) or suppress cus debug_print statement }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SpireBb_SetupSmecScan started"); SpireMsg(2," $Id:$"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Call low level procedure to do scan:: // SpireProc_Setup_SmecScan(resolution,version,debug); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SpireBb_SetupSmecScan ended"); SpireMsg(1," ..BBSetupSmecScan (" + (time() - t) + " seconds)"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_Setup_SmecScan.txt // /////////////////////////////////////////////////////////////////////////// // // Prepare SMEC for scanning // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/03/25 V0.1: Initial version adapted from // SpireBb_SmecScan (2008/11/03 V0.1) // SpireBbFtsScan (KJK, 2009/01/01) // 2009/03/31 V0.2: Add important note to header. // /////////////////////////////////////////////////////////////////////////// // Script assumes that: // // 1) SMEC scan parameters can be read from calibration table: // SpireTable_Spectrometer.txt // // Note, when SpireProc_Setup_SmecScan is used it needs to be run // after the SpireProc_SmecMove! // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Setup_SmecScan { string resolution = "L" in ["L","M","H","C"]; // Resolution (low, medium, high,calibration) string version = "v00"; // Version in cal table SpireTable_Spectrometer bool debug = false; // Allow (==tick) or suppress cus debug_print statement }{ // // // // // Define some variables: // string tstr = ""; string selCol = ""; string selVal = ""; string tarCol = ""; // // Hardcoded calibration tables: // string tabName = "SpireTable_Spectrometer.txt"; // // // // // // Start procedure: // tstr = SpireTimeStr(time()); SpireMsg(4," " + tstr + ": SpireProc_Setup_SmecScan started"); SpireMsg(4," $Id:$"); // // // // // Retrieve required SMEC parameters from calibration tables: // int resId = SpireProc_GetTableEntryInt("SpireTable_Spectrometer.txt","ResChar",resolution,"ResId",version,debug); int scanStart = SpireProc_GetTableEntryInt("SpireTable_Spectrometer.txt","ResChar",resolution,"ScanStart",version,debug); int scanEnd = SpireProc_GetTableEntryInt("SpireTable_Spectrometer.txt","ResChar",resolution,"ScanEnd",version,debug); int scanFCmd = SpireProc_GetTableEntryInt("SpireTable_Spectrometer.txt","ResChar",resolution,"ScanFCmd",version,debug); int scanRCmd = SpireProc_GetTableEntryInt("SpireTable_Spectrometer.txt","ResChar",resolution,"ScanRCmd",version,debug); // if(debug) { debug_print("resId: " + resId); debug_print("scanStart: " + scanStart); debug_print("scanEnd: " + scanEnd); debug_print("scanFCmd: " + scanFCmd); debug_print("scanRCmd: " + scanRCmd); } // // // // // Set SCANRES HSK parameter: // tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_UPDATE_TABLE_RAW(7, 6, 1, " + resId + ")"); Spire_UPDATE_TABLE_RAW(7,6,1,[{resId}]); // // // // // Set SMEC to hold its position (stop trajectory generation) SpireSendDrcuCmd(0x90490000,0); // // // // // Set scan start and ending position: // SpireSendDrcuCmd(0x90450000 + scanEnd,0); delay(1); SpireSendDrcuCmd(0x90460000 + scanStart,0); // // // // // Set scan forward and reverse speed // (only different if we are performing a saw tooth scan): // SpireSendDrcuCmd(0x90470000 + scanFCmd,0); delay(1); SpireSendDrcuCmd(0x90560000 + scanRCmd,0); sync(); // // // // // End procedure: // tstr = SpireTimeStr(time()); SpireMsg(4," " + tstr + ": SpireProc_Setup_SmecScan ended"); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_SmecScan.txt // /////////////////////////////////////////////////////////////////////////// // // Scan SMEC N-times at input spectral resolution // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/11/03 V0.1: Initial version adapted from // SFBeamPeakUp_SMECScan.txt (v 1.4 2008/01/31 20:24:37) and // SpireBbFtsScan.txt (20/04/07: v1.4) // 2009/03/30 V0.2: Move all commands to new low level script // SpireProc_SmecScan. Add header line. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_SmecScan SPIRE 14020 { string resolution = "L" in ["L","M","H","C"]; // Resolution (low, medium, high,calibration) int nscans = 1; // Number of SMEC scans (back+forth == 1) string version = "v00"; // Version in cal table SpireTable_Spectrometer bool debug = false; // Allow (==tick) or suppress cus debug_print statement }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SpireBb_SmecScan started"); SpireMsg(2," $Id:$"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Call low level procedure to do scan:: // SpireProc_SmecScan(resolution,nscans,version,debug); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SpireBb_SmecScan ended"); SpireMsg(1," ..SmecScan (" + (time() - t) + " seconds)"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_Exec_SpecStdLoadCurve.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to loop through a list of bias amplitudes for // the 'Spec Standard Load Curve' task // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/08/12 V0.1: Initial version adapted from // SpireProc_Exec_PhotStdLoadCurve (2008/07/04 V0.2) // based on // Mode_ILT_PERF_DAB_S_Levels (v1.3 2008/01/31 23:35:17) // 2009/02/19 V0.2: Add debug_print as input. Add dcuData to input. // /////////////////////////////////////////////////////////////////////////// procedure SpireProc_Exec_SpecStdLoadCurve { int[] nbiaslist = [0,50,100,255]; // List of raw bias levels in range (0-255) int ftime = 10; // Readout time at each bias level [s] bool dcuData = false; // Is (==tick) the DCU currently sampled? bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // Start the LC bias loop: // for(int l = 0 .. length(nbiaslist) - 1) { // // // // // Safety check: // if(nbiaslist[l] > 255) { nbiaslist[l] = 255; if(debug) { debug_print("Input bias list is corrupt! Raw value > 255 requested!"); } } // // // // // Set bias amplitude: // if(l == 0) { if(debug) { debug_print("Bias already set during slew"); } } else { SpireBb_SpecFSetBiasAmpl(nbiaslist[l],nbiaslist[l],debug); } // // // // // Stop DCU data before resetting offsets: // SpireBb_StopDcuData(); // // // // // // Set offsets: // SpireBb_SpecOffsetAuto(dcuData,debug); // // // // // Take data: // SpireBb_SpecFTakeData(ftime,debug); // // // // // // Printing: // if(debug) { debug_print("Bias level " + nbiaslist[l] + " done."); } } // // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_StartFpgInitialPointing.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to configure at the start of // SpirePhoto/Spectro_CalGCO_FpgInitialPointing. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // // 2009/05/05 V0.1: Initial version adapted from // SpireBb_StartBsmAngleCal (2009/05/05 V0.1), // SpirePhoto_CalGCO_FpgInitialPointing (2009/03/03 V1.3), and // SpireSpectro_CalGCO_FpgInitialPointing (2009/03/03 V0.4) // BB includes now to move BSM/SMEC to hold/home. // 2009/07/03 V1.0: Set SMEC framerate to zero so VM will NOT generate // BSM and SMEC data. This is needed for running the // Spec FpgInitialPointing. // 2009/07/10 V1.1: Fix bug SPR-SPIRE-1612 // // Notes: // 1) Scripts assumes that SpireBb_SpecOffsetAuto is run // during INITHOLD or at first POINTING. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_StartFpgInitialPointing SPIRE 14054 { bool phot = true; // Photometer (==tick) or FTS (==untick)? string obsModeQla = "ENG_CAL_OBS01"; string obsMode = "PEngCalObs"; bool isBright = false; // Use settings for bright source (==tick) string version01 = "v00"; // Version in cal table SpireTable_Phot/SpecModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams int hold_chop = 37632; // Chop hold position int hold_jigg = 39520; // Jiggle hold position int smecHomePosn = 3500; // SMEC home position bool setFramerate = true; // int frate = 0; // bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // int mode_id = 0; string obsmode = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB StartFpgInitialPointing configuration started"); SpireMsg(2," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Startup observation: // SpireProc_Set_StartObsAll(obsModeQla); // // // // // In case move SMEC to home: // if(!phot) { // // Calculate available time for possible movement: // int tmove = duration(SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug)) + duration(SpireProc_Set_SpecMode(obsMode,isBright,version01,version02,debug)) + duration(SpireBb_SpecOffsetAuto(false,debug)); if(setFramerate) { tmove = tmove + duration(SpireProc_Set_BsmFramerate(frate,debug)); } // // Calculate max offset for which time is available: // int smecMaxOff = tmove * 500; // Note, 500 is maximum possible SMEC speed. int smecStart = smecHomePosn + smecMaxOff; // Note, formula above only reasonable // when smecHomePosn small compared to 39500 // Safety check: if(smecStart > 39500) { smecStart = 39500; } if(debug) { debug_print("smecStart: " + smecStart); debug_print("smecHomePosn: " + smecHomePosn); debug_print("tmove: " + tmove); } // // Move from maximal offset to home: // SpireProc_SmecMove2Home(smecHomePosn,smecHomePosn + smecMaxOff,debug); } // // // // // Move BSM back to hold: // SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug); // // // // // Initialise instrument (in case to isBright): // if(phot) { SpireProc_Set_PhotMode(obsMode,isBright,version01,version02,debug); } else { SpireProc_Set_SpecMode(obsMode,isBright,version01,version02,debug); } //delay(timeSlewCal); // // // // // Set BSM framerate (==BSM sampling rate): // if(setFramerate) { SpireProc_Set_BsmFramerate(frate,debug); } // // // // // Set SMEC framerate (== SMEC sampling rate) to zero: // if(!phot) { SpireProc_Set_SmecFramerate(0,debug); } // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB StartFpgInitialPointing configuration ended"); SpireMsg(1," ..StartFpgInitialPointing took " + (time() - t) + " seconds)"); // } // SpireBbBsmJiggInit // // $id$ // // This building block initialises the BSM jiggle axis // // The BSM should be switched on (SpireBbBsmOn) before execution of this building block // // 27/04/2009 KJK: // Updated to use new NominalSettings Cal Tables // model, version and debug passed as parameters // 07/05/2009 KJK: // Added opsMode as input parameter to allow setting of bsmMoveMode from DefaultParams.txt calibration table // block SpireBbBsmJiggInit SPIRE 270 { string opsMode = "PHTSTBY"; string model = "initial"; string version = "v00"; bool debug = false; }{ int t0 = time(); string hstr = ""; // hex string string tstr = ""; // time string tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB BSM Jigg Init started"); SpireMsg(2," $Id$"); // // // intialise variables int jigglekd = SpireProc_GetTableEntryInt("SpireTable_BsmNominalSettings.txt","model",model,"jigg_kd",version,debug); int jigglekp = SpireProc_GetTableEntryInt("SpireTable_BsmNominalSettings.txt","model",model,"jigg_kp",version,debug); int jiggleki = SpireProc_GetTableEntryInt("SpireTable_BsmNominalSettings.txt","model",model,"jigg_ki",version,debug); int jiggle_t1 = SpireProc_GetTableEntryInt("SpireTable_BsmNominalSettings.txt","model",model,"jigg_filt1",version,debug); int jiggle_hold = SpireProc_GetTableEntryInt("SpireTable_BsmNominalSettings.txt","model",model,"jigg_0_I",version,debug); // // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); delay(1); // // set Step to zero SpireSetObsStep(0); // // flag the current operation SpireSetObsMode("BSM_INIT"); delay(1); // // Set Movement Mode for initialisation SpireSendDrcuCmd(0x90c60000,0); // // Set jiggle Kd parameter SpireSendDrcuCmd(0x91490000 + jigglekd,0); delay(1); // // Set jiggle Kp parameter SpireSendDrcuCmd(0x91480000 + jigglekp,0); delay(1); // // Set jiggle Ki parameter SpireSendDrcuCmd(0x914a0000 + jiggleki,0); delay(1); // // Set jiggle derivative filtering parameter 1 SpireSendDrcuCmd(0x914f0000 + jiggle_t1,0); delay(1); // // Remove slew rate limiter SpireSendDrcuCmd(0x9151ffff,0); delay(1); // // Set target position to HOLD SpireSendDrcuCmd(0x91430000 + jiggle_hold,0); delay(1); // // Close loop on jiggle axis SpireSendDrcuCmd(0x91420001,0); delay(1); // // Set Default Movement Mode int bsmMoveMode = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode",opsMode,"bsmMoveMode",version,debug); SpireSendDrcuCmd(0x90c60000 + bsmMoveMode,0); // // completion sync(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB BSM Jigg Init ended"); SpireMsg(1," ..BSM Jiggle Axis Initialisation (" + (time() - t0) + " seconds)"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_StartTransRespoAndDynBeamProf.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to configure at the start of // SpirePhoto_CalGCO_TransRespoAndDynBeamProf.txt // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // // 2009/05/07 V0.1: Initial version adapted from // SpireBb_StartBsmAngleCal (2009/05/05 V0.1), // SpirePhoto_CalGCO_TransRespoAndDynBeamProf (2009/03/04 V1.2) // BB includes now to move BSM to hold. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_StartTransRespoAndDynBeamProf SPIRE 14062 { bool phot = true; // Photometer (==tick) or FTS (==untick)? string obsModeQla = "ENG_CAL_OBS06"; string obsMode = "PEngCalObs"; bool isBright = false; // Use settings for bright source (==tick) string version01 = "v00"; // Version in cal table SpireTable_Phot/SpecModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams int hold_chop = 37632; // Chop hold position int hold_jigg = 39520; // Jiggle hold position bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // int mode_id = 0; string obsmode = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB StartTransRespoAndDynBeamProf configuration started"); SpireMsg(2," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Startup observation: // SpireProc_Set_StartObsAll(obsModeQla); // // // // // Move BSM back to hold: // SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug); // // // // // Initialise instrument (in case to isBright): // if(phot) { SpireProc_Set_PhotMode(obsMode,isBright,version01,version02,debug); } else { SpireProc_Set_SpecMode(obsMode,isBright,version01,version02,debug); } //delay(timeSlewCal); // // // // // Set Obs step at to fff: // int obsStep = 4095; SpireProc_Set_ObsStep(obsStep,debug); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB StartTransRespoAndDynBeamProf configuration ended"); SpireMsg(1," ..StartTransRespoAndDynBeamProf took " + (time() - t) + " seconds)"); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_PhotFSetBiasAmpl.txt // /////////////////////////////////////////////////////////////////////////// // // BB to set bias amplitude of photometer arrays // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/05/02 V0.1: Initial version adapted from // PFBias_Ampl.txt (v1.4 2008/01/31 20:24:34) // 2008/05/08 V0.2: Restrict script to send only 2 commands per second // by adding delay(1)'s // 2008/07/03 V0.3: Renumber version; Set also PTC bias properly // 2009/01/27 V1.0: Add debug_print; Remove unsetting of BBID at end. // Add HSPOT messages; // 2009/02/14 V1.1: Instead of using commands call SpireProc_Set_PhotBias // and add sync() after setBbId // 2009/05/07 V1.2: Fixed copy/paste bug to set bias instead of phase // /////////////////////////////////////////////////////////////////////////// // block SpireBb_PhotFSetBiasAmpl SPIRE 14006 { int psw_bias = 0x3e; //Default (IST) bias amplitud (==31.0761 mV) int pmw_bias = 0x3e; //Default (IST) bias amplitud (==31.2735 mV) int plw_bias = 0x3e; //Default (IST) bias amplitud (==31.4033 mV) int ptc_bias = 0x80; //Default (IST) bias amplitud (==127.6311 mV) bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Define some variables: // string hstr = ""; // a hex string string tstr = ""; // a time string // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": SpireBb_PhotFSetBiasAmpl started"); SpireMsg(2," $Id: $"); hstr = SpireHexStr($BBID,8); SpireMsg(3," BBID = " + hstr); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); sync(); // // // // // Set the bias levels for the three arrays and the PTC: // SpireProc_Set_PhotBias(psw_bias,pmw_bias,plw_bias,ptc_bias,debug); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SpireBb_PhotFSetPhase ended"); SpireMsg(1," ..Set Phot phases (" + (time() - t) + " secs)"); // } // SpirePOF3Observing // // $Id: SpirePOF3Observing.txt,v 1.3 2007/01/15 18:34:14 kking Exp $ // // This is the procedure to calculate // instrument observing parameters for the n-point Jiggle map observing mode // // {double,int,int,int,int,int} procedure SpirePOF3Observing { int nRepetitions = 1; // requested number of repetitions }{ SpireMsg(2," POF3 Observing Parameters "); SpireMsg(2," $Id: SpirePOF3Observing.txt,v 1.3 2007/01/15 18:34:14 kking Exp $"); // // fetch operating parameters double flashTime = double(ilookup("SpireParms.txt","POF3","FlashTime")); // Optimum time between flashes double calTime = double(ilookup("SpireParms.txt","POF3","CalTime")); // Minimum time between gyro calibrations int jiggleTable = ilookup("OpsParms.txt","POF3","TableId"); // Jiggle Table ID int jiggleSize = ilookup("OpsParms.txt","POF3","TableSize"); // Jiggle Table length int nChops = ilookup("OpsParms.txt","POF3","NChops"); // number of chop cycles per jiggle position int nJiggs = ilookup("OpsParms.txt","POF3","NJiggs"); // number of jiggle positions per nod position int nNodPosns = ilookup("OpsParms.txt","POF3","NNodPosns"); // number of nod positions in a nod cycle int nNodCycles = ilookup("OpsParms.txt","POF3","NNodCycles"); // number of nod cycles in a repetition bool initFlash = blookup("SpireParms.txt","POF3","InitFlash"); // initial flash flag bool endFlash = blookup("SpireParms.txt","POF3","EndFlash"); // final flash flag double srcTime = dlookup("OpsParms.txt","POF3","SrcTime"); // effective on source integration time per complete map // // ***************************************** // Display input parameters // ***************************************** SpireMsg(3," POF3 Observing input values:"); SpireMsg(3," ..nRepetitions: " + nRepetitions); SpireMsg(3," POF3 Fixed values:"); SpireMsg(3," ..jiggleTable: " + jiggleTable); SpireMsg(3," ..jiggleSize: " + jiggleSize); SpireMsg(3," ..nChops: " + nChops); SpireMsg(3," ..nJiggs: " + nJiggs); SpireMsg(3," ..nNodPosns: " + nNodPosns); SpireMsg(3," ..flashTime: " + flashTime); SpireMsg(3," ..calTime: " + calTime); SpireMsg(3," ..initFlash: " + initFlash); SpireMsg(3," ..endFlash: " + endFlash); SpireMsg(3," ..srcTime: " + srcTime); // // calculate observing parameters SpireMsg(2," Calculated Parameters:"); // // number of times to repeat the jiggle cycle at each nod position // Note: this is currently read from a calibration table but could be calculated // if it is required to dynamically assign integration time to each nod position // rather than by repeating complete nod cycles int nNodInts = ilookup("OpsParms.txt","POF3","NNodInts"); SpireMsg(3," Required number of jiggle cycles at each nod position: " + nNodInts); // // number of nod cycles to perform per map int nCycles = jiggleSize / nJiggs; SpireMsg(3," Number of nod cycles per Map: " + nCycles); // // number of maps to perform int nMaps = nRepetitions * nNodCycles / nCycles; // SpireMsg(3," Required number of Maps: " + nMaps); // // observing time per nod cycle double cycleTime = double(nNodPosns * duration(SpireBbJiggle("POF3",jiggleTable,0,nJiggs,nNodInts,0))); SpireMsg(3," Time for a Nod cycle: " + cycleTime); // // total observing time double totalTime = double(nMaps) * double(nCycles) * cycleTime; SpireMsg(3," Total observing time: " + totalTime); // // number of nod cycles per Gyro calibration // Note: this only takes into account on source observing time, not movement between nod positions, // which is assumed to be a small fraction of the observing time, and so the value obtained is approximate int nCals = ifloor(totalTime / calTime); // SpireMsg(3," Number of Gyro Calibrations: " + nCals); int nCal = iceil(totalTime / cycleTime); // default is no gyro calibrations during observation if(nCals > 0) { nCal = iceil(double(nCycles) * double(nMaps) / double(nCals + 1)); } if(nCycles % nCal == 0) { nCal = nCal + 1; } // SpireMsg(3," Number of Gyro Calibrations(adjusted): " + nCals); // SpireMsg(3," Number of nod cycles per Gyro calibration: " + nCal); // // number of cycles per PCAL calibration // Note: this only takes into account on source observing time, not movement between nod positions, // which is assumed to be a small fraction of the observing time, and so the value obtained is approximate int nFlashes = ifloor(totalTime / flashTime); SpireMsg(3," Number of Flashes: " + nFlashes); int nFlash = iceil(totalTime / cycleTime); // default is no flashes during observation if(nFlashes > 0) { nFlash = iceil(double(nCycles) * double(nMaps) / double(nFlashes + 1)); } if(nCycles % nFlash == 0) { nFlash = nFlash + 1; } SpireMsg(3," Number of Flashes(adjusted): " + nFlashes); SpireMsg(3," Number of nod cycles per PCAL calibration: " + nFlash); return {srcTime,nMaps,nCycles,nNodInts,nCal,nFlash}; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////// // // SpireProc_Exec_SpecPcalLoadCurve.txt // /////////////////////////////////////////////////////////// // // Procedure to loop through a list of bias amplitudes and flashing // PCAL for the 'Spec PCAL Load Curve' task // /////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/09/16 V0.1: Initial version adapted from // SpireProc_Exec_PhotPcalLoadCurve (2008/08/15 V0.3) // 2009/02/19 V0.2: Add debug_print as input and pass it to low level script. // Replace SpireProc_Exec_PcalFlash by direct call to // SpireBb_PcalFlash. Adapt input to updated SpireBb_PcalFlash // with rate and step. Promote new VM table parameters of // SpireBb_PcalFlash. Implement proper setting of FTS // ILT Pcal highbias levels (bug detected at SDAG#19). // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Exec_SpecPcalLoadCurve { int[] nbiaslist = [0,50,100,255]; // List of raw bias levels in range (0-255) int ftime = 10; // Readout time at each bias level [s] int mclkdiv = 0x79; //Default (IST) bias freq (== 160.092 Hz) int biasdiv = 0x1; //Default (IST) sampling freq (== 80.046 Hz) int vmId = 70; // Raw VM table number [Dec(Hex)] int vmIndex = 0; // Raw VM index [Dec(Hex)] int nParms = 9; // Number of parameters passed to VM bool dcuData = false; // Is (==tick) the DCU currently sampled? bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Predefine version in SpireTable_SpecPcalCurrentConvCoef.txt: // string ver_a = "v01"; if(debug) { debug_print("The nominal version in SpireTable_PcalCurrentConvCoef.txt is v01"); } // // // // // Retrieve PCAL bias calibration coefficients: // double[] coeff = [0.0]; coeff[0] = dlookup("SpireTable_PcalCurrentConvCoef.txt",ver_a,"c_0"); coeff[1] = dlookup("SpireTable_PcalCurrentConvCoef.txt",ver_a,"c_1"); // // // // // Set ILT standard values for PCAL flash: // // Period of cycle in microsec: int flashperiod = 4000000; // Period of cycle in millisec: int period = flashperiod / 1000; // Number of cycles: int ncycles = 15; // DCU data mode (default = PF == 0; SF == 0): int ndcumode = 4; // SCU sampling rate (f =80Hz/(1+scumode)): int scumode = 0; // // // // // Calculate the RAW bias levels: // //[mA] Low Level for 1st PCAL flash: double lowbias_0 = 0.0; //[mA] High Level for 1st PCAL flash: double highbias_0 = 4.8; //[mA] Low Level for 2nd PCAL flash: double lowbias_1 = 0.0; //[mA] High Level for 2nd PCAL flash: double highbias_1 = 6.0; // int pcal_low_bias_0 = iround((lowbias_0 * 0.0010 - coeff[0]) / coeff[1]); int pcal_high_bias_0 = iround((highbias_0 * 0.0010 - coeff[0]) / coeff[1]); int pcal_low_bias_1 = iround((lowbias_1 * 0.0010 - coeff[0]) / coeff[1]); int pcal_high_bias_1 = iround((highbias_1 * 0.0010 - coeff[0]) / coeff[1]); // // // // // Deduce number of DCU samples, SCU samples and DCU sample delay based on mclkdiv and biasdiv: // int[] flash_params = SpireProc_CalcParam_PcalFlash(period,mclkdiv,biasdiv,debug); int dcusamples = flash_params[0]; int scusamples = flash_params[1]; int dcudelay = flash_params[2]; if(debug) { debug_print("//////////////////////////////////////////////////////////////"); debug_print(""); debug_print("CALCULATED DCU SAMPLES : " + dcusamples); debug_print("CALCULATED SCU SAMPLES : " + scusamples); debug_print("CALCULATED SAMP DELAY : " + dcudelay + "microsec"); debug_print(""); debug_print("//////////////////////////////////////////////////////////"); } // // // // // Start the LC bias loop: // for(int l = 0 .. length(nbiaslist) - 1) { // // // // // Safety check: // if(nbiaslist[l] > 255) { nbiaslist[l] = 255; if(debug) { debug_print("Input bias list is corrupt! Raw value > 255 requested!"); } } // // // // // Set STEP: // int obsStep = l + 1; // NHK Step parameter if(obsStep == 1) { if(debug) { debug_print("First obsStep already set during slew"); } } else { SpireBb_SetObsStep(obsStep,debug); } // // // // // Set bias amplitude: // if(l == 0) { if(debug) { debug_print("Bias already set during slew"); } } else { SpireBb_SpecFSetBiasAmpl(nbiaslist[l],nbiaslist[l],debug); } // // // // // Stop DCU data before resetting offsets: // SpireBb_StopDcuData(); // // // // // // Set offsets: // SpireBb_SpecOffsetAuto(dcuData,debug); // // // // // // Execute PCAL flashes: // // First PCAL Flash: // SpireBb_PcalFlash(vmId,vmIndex,nParms,pcal_low_bias_0,pcal_high_bias_0,ncycles,flashperiod,ndcumode,dcusamples,dcudelay,scumode,scusamples,obsStep,debug); // // Second PCAL Flash: // SpireBb_PcalFlash(vmId,vmIndex,nParms,pcal_low_bias_1,pcal_high_bias_1,ncycles,flashperiod,ndcumode,dcusamples,dcudelay,scumode,scusamples,obsStep,debug); // // // Take data: // SpireBb_SpecFTakeData(ftime,debug); // // // // // // Printing: // if(debug) { debug_print("Bias level " + nbiaslist[l] + " done."); } } // // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_Set_StopMcuData.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to stop generation of MCU data TM packets // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/03/31 V1.0: Initial version adapted from // SpireProc_Set_StopDcuData (2009/01/30 V1.1) // 2009/06/05 V1.1: Remove wrong Hspot message. // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Set_StopMcuData { }{ // // // // // Start procedure: // message("4 " + time() + ": SpireProc_Set_StopMcuData started"); message("4 $Id: $"); // // // // // Stop data collection: // SpireSendDrcuCmd(0x91c10000,0); // // // // // Flush MCU (x2000) fifo: // message("5 " + time() + "Cmd: Spire_FLUSH_FIFO(0x2000)"); Spire_FLUSH_FIFO(0x2000); delay(2); // // // // // End procedure: // message("4 " + time() + ": SpireProc_Set_StopMcuData ended"); // } // SpireTimeStr // // a procedure to convert a time into a string in the form // [nnnnn] // string procedure SpireTimeStr { int t = 0; }{ string s = ""; if(t < 10) { s = "[0000"; } else { if(t < 100) { s = "[000"; } else { if(t < 1000) { s = "[00"; } else { if(t < 10000) { s = "[0"; } } } } // return s + t + "]"; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_Exec_BsmPcalFlash.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to loop through a list of BSM settings and flash PCAL // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/12/12 V0.1: Initial version adapted from // SPIRE_IST_BSM_PCALFLASH.txt and Proc_BSMStep.txt // (Sunil email 09/12/08 19:10) using as template: // SpireProc_Exec_PhotPcalLoadCurve (2008/08/15 V0.3) // 2009/02/02 V1.0: Pass debug_print to low level scripts. // Replace SpireProc_Exec_PcalFlash by direct call to // SpireBb_PcalFlash. Adapt input to updated SpireBb_PcalFlash // with rate and step. Rate is input, step set in loop. // Replace erroneous 0x90c3 by correct call to BB. // 2009/02/16 V1.1: Promote new VM table parameters of SpireBb_PcalFlash // to input. // 2009/02/18 V1.2: Adapt to change in call to SpireBb_PcalFlash. // 2009/03/04 V1.3: Make sure the correct ILT levels are used when // using with the FTS. Set default fts to false. // 2009/06/08 V1.4: Add in offset setting after each BSM movement just // before the Pcal Flash (see SPR-1496). // 2009/07/12 V1.5: Remove reference (in text only) to PhotPcalCurrentConvCoef // (SCR-SPIRE-1640). // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Exec_BsmPcalFlash { int c_start = 0x1000; // RAW chop target start position int c_end = 0xf000; // RAW chop target end position int c_step = 0x2000; // RAW chop target step in position int jiggPosn = 0x9a60; // Jiggle position used. int mclkdiv = 0x95; //Default (IST) bias freq (== 130.20833 Hz) int biasdiv = 0x6; //Default (IST) sampling freq (== 18.60119 Hz) int vmId = 70; // Raw VM table number [Dec(Hex)] int vmIndex = 0; // Raw VM index [Dec(Hex)] int nParms = 9; // Number of parameters passed to VM bool fts = false; // FTS or photometer (tick==FTS, needed for dcumode) bool debug = true; //Print-out debug statements (tick==Yes)? }{ // // // // // Predefine version in SpireTable_PcalCurrentConvCoef.txt: // string ver_a = "v01"; if(debug) { debug_print("The nominal version in SpireTable_PcalCurrentConvCoef.txt is v01"); } // // // // // Hardcoded parameter: // bool dcuData = false; // Is (==tick) the DCU currently sampled? // // // // // Retrieve PCAL bias calibration coefficients: // double[] coeff = [0.0]; coeff[0] = dlookup("SpireTable_PcalCurrentConvCoef.txt",ver_a,"c_0"); coeff[1] = dlookup("SpireTable_PcalCurrentConvCoef.txt",ver_a,"c_1"); // // // // // Set ILT standard values for PCAL flash: // // Period of cycle in microsec: int flashperiod = 4000000; // Period of cycle in millisec: int period = flashperiod / 1000; // Number of cycles: int ncycles = 15; // DCU data mode: if(fts) { int ndcumode = 4; // DCU data mode (4 == Full spectrometer) } else { ndcumode = 0; // DCU data mode (0 == Full photometer) } // SCU sampling rate (f =80Hz/(1+scumode)): int scumode = 0; // // // // // Calculate the RAW bias levels: // //[mA] Low Level for 1st PCAL flash: double lowbias_0 = 0.0; //[mA] High Level for 1st PCAL flash: double highbias_0 = 0.0; if(fts) { highbias_0 = 4.8; } else { highbias_0 = 3.8; } //[mA] Low Level for 2nd PCAL flash: double lowbias_1 = 0.0; //[mA] High Level for 2nd PCAL flash: double highbias_1 = 0.0; if(fts) { highbias_1 = 4.8; } else { highbias_1 = 6.0; } // int pcal_low_bias_0 = iround((lowbias_0 * 0.0010 - coeff[0]) / coeff[1]); int pcal_high_bias_0 = iround((highbias_0 * 0.0010 - coeff[0]) / coeff[1]); int pcal_low_bias_1 = iround((lowbias_1 * 0.0010 - coeff[0]) / coeff[1]); int pcal_high_bias_1 = iround((highbias_1 * 0.0010 - coeff[0]) / coeff[1]); // // // // // Deduce number of DCU samples, SCU samples and DCU sample delay based on mclkdiv and biasdiv: // int[] flash_params = SpireProc_CalcParam_PcalFlash(period,mclkdiv,biasdiv,debug); int dcusamples = flash_params[0]; int scusamples = flash_params[1]; int dcudelay = flash_params[2]; if(debug) { debug_print("//////////////////////////////////////////////////////////////"); debug_print(""); debug_print("CALCULATED DCU SAMPLES : " + dcusamples); debug_print("CALCULATED SCU SAMPLES : " + scusamples); debug_print("CALCULATED SAMP DELAY : " + dcudelay + "microsec"); debug_print(""); debug_print("//////////////////////////////////////////////////////////"); } // // // // // Execute the BSM/Flash loop: // // Calculate number of steps: int n_steps = (c_end - c_start) / c_step; // Define chop position: int chop_posn = 0; // Start loop: for(int i = 0 .. n_steps) { // // // // // Set STEP: // int obsStep = i + 1; // NHK Step parameter if(obsStep == 1) { if(debug) { debug_print("First obsStep already set during slew"); } } else { SpireBb_SetObsStep(obsStep,debug); } // // // // // Set BSM to position: // chop_posn = c_start + c_step * i; SpireBb_BsmMove(chop_posn,jiggPosn,debug); // // // // // Set detector offsets: // SpireBb_PhotOffsetAuto(debug); // // // // // Execute PCAL flashes: // // First PCAL Flash: // SpireBb_PcalFlash(vmId,vmIndex,nParms,pcal_low_bias_0,pcal_high_bias_0,ncycles,flashperiod,ndcumode,dcusamples,dcudelay,scumode,scusamples,obsStep,debug); // // Second PCAL Flash: // SpireBb_PcalFlash(vmId,vmIndex,nParms,pcal_low_bias_1,pcal_high_bias_1,ncycles,flashperiod,ndcumode,dcusamples,dcudelay,scumode,scusamples,obsStep,debug); // // // // // Printing: // if(debug) { debug_print("BSM position " + chop_posn + " done."); } } // // } // SpireBbSOF2Init // // $Id: SpireBbSOF2Init.txt,v 1.1 2006/08/10 09:38:58 kking Exp $ // // Building Block to initialise the instrument for SOF2 operation // // The complete instrument setup operation is divided into two parts: // Configuration: actions that can be executed during the slew to the start // position of the S/C pointing mode. // Initialisation: actions that must be carried out at the S/C intial pointing // position before any observational operations are executed. // // This building Block implements the second part of the setup // // 04 November 2008: // added data_rate commands // added commands to setup the detector sampling // block SpireBbSOF2Init SPIRE 8385 { }{ int t = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SOF2 Initialisation started"); SpireMsg(2," $Id: SpireBbSOF2Init.txt,v 1.1 2006/08/10 09:38:58 kking Exp $"); // // ..... configuration ..... // int cmd = 0x0; // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // set STEP to On Target tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP_RAW(0x8000)"); Spire_SET_OBS_STEP_RAW(0x8000); // // set detector offsets // set DCU data mode to Auto Offset cmd = 0x843c0014; SpireSendDrcuCmd(cmd,0); // start auto offset generation cmd = 0x843e0001; SpireSendDrcuCmd(cmd,0); delay(15); // // dump detector offsets // stop auto offset generation cmd = 0x843e0000; SpireSendDrcuCmd(cmd,0); // set DCU data mode to get offset data cmd = 0x843c001c; SpireSendDrcuCmd(cmd,0); // start offset data dump cmd = 0x843e0001; SpireSendDrcuCmd(cmd,0); // set datarate double rate = 0.0; rate = dlookup("Datarates.txt","SOffsets","DCU"); data_rate(rate); delay(5); // stop offset data dump cmd = 0x843e0000; SpireSendDrcuCmd(cmd,0); data_rate(0.0); // // flush data tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_FLUSH_FIFO_RAW(0x1000)"); Spire_FLUSH_FIFO_RAW(0x1000); delay(2); // // set up detectors for operations // SpireConfigDcuData("Scan"); sync(); // // ..... completion ..... // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SOF2 Initialisation ended"); SpireMsg(1," ..SOF2 Initialisation (" + (time() - t) + " seconds)"); } // SpireMsg // // $id$ // // Output a string as a message and optionally as a debug string // // This procedure allows message strings to be output to the debug_print // stream as well as the message stream. This allows the developer to // see messages even if the calling procedure stops or crashes before // it ends // procedure SpireMsg { int level = 0 in [0,5]; // message level string msg = ""; }{ int debugLevel = -1; // debug level - all messages with a level <= to this are out put to the debug_print stream // // output message message("" + level + msg); // // output debug string, if required if(level <= debugLevel) { debug_print(msg); } } /////////////////////////////////////////////////////////////////////////// // $Id:$ /////////////////////////////////////////////////////////////////////////// // // SpirePhoto_Cal_JfetVssTestC.txt // /////////////////////////////////////////////////////////////////////////// // // CUS script for: 'CoP: Phot Jfet Vss Test C' // // in *basic_fine_pointing* mode or *no_pointing* mode // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/05/21 V0.1: Initial version adapted from Mode_ILT_PERF_VSS_PC // (undated, as of 2009/05/21 in fs2_test@lichfield by SDS) // 2009/06/05 V1.0: Hardcode STBY 'v00' in EndBB (SPR-1477) // /////////////////////////////////////////////////////////////////////////// // Script assumes that: // // 1) Instrument is in PHOTSTBY // (i.e. bias amplitude, phase, frequency [mclkdiv,biasdiv] are nominal) // // 2) Bias frequency (mclkdiv) and sampling rate (biasdiv) are the same // for all three arrays and could be taken from following cal table: // SpireTable_PhotModeParams.txt // // 3) Further mode dependent parameters can be read from: // SpireTable_CommonModeParams.txt // /////////////////////////////////////////////////////////////////////////// // obs SpirePhoto_Cal_JfetVssTestC { /* ****************************************************** */ /* USER PARAMETER DEFINITION, CUS SIGNATURE for EX-HSpot */ /* ****************************************************** */ double ra = 0.0 in [0.0,360.0]; // RA of target double dec = 0.0 in [-90.0,90.0]; // DEC of target int naifid = 0; //NAIF identifier: put '0' to use RA/DEC, or correct 'NAIFID' bool pointing = true; // Should telescope 'point' (==tick) or do a 'no pointing' (==untick)? /* */ bool isBright = false; // Use settings for bright source (==tick) double jfet_Vss_start = -0.5; //Starting JFET source voltage double jfet_Vss_end = -4.0; //ending JFET source voltage double jfet_Vss_step = -0.1; //steping JFET source volatge int ftime = 60; //wait time at each level; string version01 = "v00"; // Version in cal table SpireTable_PhotModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams string version05 = "v00"; // Version in cal table SpireTable_OpsParms bool debug = false; // Allow (==tick) or suppress cus debug_print statements bool isSerendipity = true; // Allow (==tick) serendipity mode to be activated or prohibit (==untick) it (currently not in use)? bool isPcal = true; // Allow (==tick) regular PcalFlash in script or prohibit (==untick) it (currently not in use)?. bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ // ****************************************************** */ // CALCULATE DURATIONS for POINTING STATES */ // ****************************************************** */ // // // // // Check for is bright setting: // if(isBright) { isBright = false; error("IsBright does not make sense here. Try again!"); } // // // // // Declare some variable: // // FTS or photometer: bool fts = false; // Photometer or FTS bool phot = !fts; // string version = ""; string tabName = ""; double scirate = 0.0; double chkrate = 0.0; double nhkrate = 0.0; // int obsStep = 0; int frate = 0; int tinithold = 0; bool setFramerate = true; // // Hardcoded calibration tables: // string tabName01 = "SpireTable_PhotModeParams.txt"; string tabName02 = "SpireTable_CommonModeParams.txt"; string tabName03 = "SpireTable_BsmNominalSettings.txt"; string tabName05 = "SpireTable_OpsParms.txt"; // // Currently hardcoded version and model parameter: // string version03 = "v00"; // Version in cal table SpireTable_BsmNominalSettings string model = "initial"; // Model in cal table SpireTable_BsmNominalSettings // // Dummy value for Spec script: // (needed but not used in phot script!) // int smecHomePosn = 3500; // SMEC home position // // // // // // Setup mode: // // Set obsMode for QLA: string obsModeQla = "ENG_CAL_OBS16"; // Note: this needs entry in MIB table and in SpireTableInstConfigs.txt // // Set obsMode for setup and datarates: string obsMode = "PEngCalObs"; // Note: datarates are currently only maximum values // // // // // Read BSM home parameters: // // Select version flag and set GetTableEntry parameters: // version = version03; tabName = tabName03; string selCol = "model"; // Name of column for selecting string selVal = model; // Value of 'string' selector // // Read hold position from calibration table: // string tarCol = "chop_0_I"; int hold_chop = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "jigg_0_I"; int hold_jigg = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // Calculate timing for the pointing request: // // BBs called during slew: // int tslewmin = duration(SpireBb_StartJfetVssTestC(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,debug)); // // BBs carried out when the pointing is reached: // if(pointing) { tinithold = duration(SpireBb_PhotOffsetAuto(debug)); } else { tinithold = duration(SpireBb_PhotOffsetAuto(debug)) + tslewmin; } // // BB carried out during pointing: // int tp = duration(SpireBb_PhotJfetVssTestC(jfet_Vss_start,jfet_Vss_end,jfet_Vss_step,ftime,debug)); // // BB carried out at the end: // int tfinalhold = duration(SpireBb_EndJfetVssTestC(phot,hold_chop,hold_jigg,isBright,version01,version02,debug)); // // Debug printing?: if(debug) { debug_print("tslewmin = " + tslewmin); debug_print("tinithold = " + tinithold); debug_print("tpointing = " + tp); debug_print("tfinalhold = " + tfinalhold); } // // ****************************************************** */ // POINTING MODE DECLARATION */ // ****************************************************** */ // // // // // Lookup boresight: // tabName = tabName05; selCol = "mode"; selVal = obsMode; tarCol = "Boresight"; version = version05; string ib = SpireProc_GetTableEntryString(tabName,selCol,selVal,tarCol,version,debug); // // // // // // Set pointing mode: // if(pointing) { int[] ts = basic_fine_pointing(true,tslewmin,tinithold,tfinalhold,ib,naifid,ra,dec,0.0,0.0,tp); } else { ts = no_pointing(true,tinithold,tfinalhold,tp); } // if(debug) { debug_print("Output timing vector from the pointing request: " + ts); } // }{ // ******************************************************* */ // POINTING STATES WITH OBSERVING MODE LOGIC AND DATARATES */ // ******************************************************* */ // // // // // Set datarates: // string rateType = "chk"; chkrate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); ess_hk_data_rate(chkrate); // rateType = "nhk"; // nhkrate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); non_ess_hk_data_rate(nhkrate); // rateType = "sci"; scirate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); data_rate(scirate); // if(debug) { debug_print("Set CHK datarate to: " + chkrate); debug_print("Set NHK datarate to: " + nhkrate); debug_print("Set SCI datarate to: " + scirate); } // // Start the state_machine: // int[] state = [0]; // while(state[0] >= 0) { if(debug) { debug_print("Current state: " + state); } state = next_state(); if(debug) { debug_print("Next state: " + state); } // if(state[0] == 1) { // STATE = SLEW ( Spacecraft is slewing ) // // // // // Startup observation: // SpireBb_StartJfetVssTestC(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,debug); // } if(state[0] == 2) { // STATE = INIT_HOLD ( spacecraft is idling at source ) // // // // // If no pointing observation do stuff here which is // done nominally during SLEW: // if(!pointing) { // // // // // Startup observation: // SpireBb_StartBsmPidTuning(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,setFramerate,frate,debug); // } // // // // // Set offsets: // SpireBb_PhotOffsetAuto(debug); // //delay(tinithold); // } if(state[0] == 3) { // STATE = POINT ( spacecraft is at nominal RA,DEC (staring, raster) ) // // // // // // Execute JFET VSS Test C: // SpireBb_PhotJfetVssTestC(jfet_Vss_start,jfet_Vss_end,jfet_Vss_step,ftime,debug); // //delay(tp); // } if(state[0] == 5) { // STATE = FINAL_HOLD ( "sky" observation ends, performing final activ.) // // // // // Set scientific datarate back to zero: // data_rate(0.0); // // // // // Reconfigure at the end (incl. resetting of OBSID and BBIB): // // Hardcode STBY values for resetting (SPR-1477): // version01 = "v00"; version02 = "v00"; // SpireBb_EndJfetVssTestC(phot,hold_chop,hold_jigg,isBright,version01,version02,debug); // } if(state[0] == -1) { // STATE = END ( end of the pointing/commanding part of the code ) // } } } // SpireNullObsid // // $Id: SpireNullObsid.txt,v 1.1 2006/08/10 09:38:58 kking Exp $ // // A procedure to return the value of the null OBSID for this observation. // This entails taking the current OBSID and zeroing the lowest 28 bits // leaving the location bits in place. // // int procedure SpireNullObsid { }{ message("4 " + time() + ": NuLL_OBSID started"); message("4 $Id: SpireNullObsid.txt,v 1.1 2006/08/10 09:38:58 kking Exp $"); message("3 OBSID = " + $OBSID); // int obsId = $OBSID & 0xf0000000; // message("3 SpireNullObsid = " + obsId); message("4 " + time() + ": SpireNullObsid ended"); // return obsId; } // CVS comments : $Id: PacsPhotNoiseRMS.txt,v 1.6 2007/04/25 15:14:04 dcesarsk Exp $ // CVS file : PacsPhotNoiseRMS.txt // // Purpose : Returns minimum detectable flux [mJy] for S/N=1 // // Author : Diego A. Cesarsky // CUS script : DAC // // Arguments : pointCase // filterID // time_on // // Description : Noise computation based on sensitivity for time_on = 1 [sec] // // Dependencies : // // Preconditions : // // Comments : Based on D. Lutz's "Guesstimator.pro" // Newer version based on Alpog's 22-may-2006 e-mail // // Version : 0.1 6-Dec-2004 Creation by DAC // History : 0.2 4-sep-2006 // - Use new PHOTnoise table (based on alpog's e-mail 22-may-2006). // - Accept PointCase (may need it for SRC,REF considerations) // 0.3 10-oct-2006 SPR-2378 // - the factors sqrt(2) in point source and scan map mode // and and 1/sqrt(2) in small and large raster shall be removed, // as these factors are already taken into account in the values provided // by Albrecht Poglitsch (photometer_noise.txt) to account for (chopped) // background subtraction, where TIME is the pure "science time" // 1.0 3-nov-2006 Compute also extended source RMS reading updated // PHOTnoise CAL-U table; module returns now 4 values: // rms[0], rms[1] : point source BLU and RED // rms[2], rms[3] : extended source BLU and RED // : double[] procedure PacsPhotNoiseRMS { int pointCase = 21; // The PointCase code of PacsPhoto string filter = "blue1" in ["blue1","blue2"]; // Filter ID double intTIME = 1.0; // ON source time [sec] }{ // Sensitivity [Jy] per filter, i.e. flux for which S/N=1 is obtained in 1 sec // assuming the source is always seen on the detector (excludes the noise // from 'off' subtraction) string calU = "PHOTnoise"; // Point Source. Here the SRC is always in view if(pointCase == 11 || pointCase == 12) { double sensRED = dlookup(calU,"red","point"); double sensBLU = dlookup(calU,filter,"point"); // Compute "noise" after intTIME [sec] of integration [mJy] double pntRMSred = 1000.0 * sensRED / sqrt(intTIME); double pntRMSblu = 1000.0 * sensBLU / sqrt(intTIME); double extRMSred = 0.0; double extRMSblu = 0.0; } // Small source or raster map. Here the SRC is in view 1/2 time if(pointCase == 21 || pointCase == 22 || pointCase == 31 || pointCase == 32) { // Point source sensRED = dlookup(calU,"red","small"); sensBLU = dlookup(calU,filter,"small"); // Extended source double extsensRED = dlookup(calU,"red","EXTsmall"); double extsensBLU = dlookup(calU,filter,"EXTsmall"); // Compute "noise" after intTIME [sec] of integration [mJy] pntRMSred = 1000.0 * sensRED / sqrt(intTIME); pntRMSblu = 1000.0 * sensBLU / sqrt(intTIME); extRMSred = extsensRED / sqrt(intTIME); extRMSblu = extsensBLU / sqrt(intTIME); } // Scan mode. Here the SRC is always in view if(pointCase == 33) { // Point source sensRED = dlookup(calU,"red","scan"); sensBLU = dlookup(calU,filter,"scan"); // Extended source extsensRED = dlookup(calU,"red","EXTscan"); extsensBLU = dlookup(calU,filter,"EXTscan"); // Compute "noise" after intTIME [sec] of integration [mJy] pntRMSred = 1000.0 * sensRED / sqrt(intTIME); pntRMSblu = 1000.0 * sensBLU / sqrt(intTIME); extRMSred = extsensRED / sqrt(intTIME); extRMSblu = extsensBLU / sqrt(intTIME); } return [pntRMSred,pntRMSblu,extRMSred,extRMSblu]; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_CalcParam_PhotDataRates.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to retrive the datarate from the associated calibration table // for a given photometer mode. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/02/15 V1.0: Initial version adapted from // SpireProc_CalcParam_Datarates (2009/01/26 V1.0) // 2009/05/05 V1.1: Change calibration table where HK are read. // /////////////////////////////////////////////////////////////////////////// // double procedure SpireProc_CalcParam_PhotDataRates { string rateType = "chk" in ["chk","nhk","sci"]; // Data rate to be read string obsMode = "POF2"; // Parameter to specify the configuration mode string version01 = "v00"; // Version in cal table SpireTable_PhotModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Define some variable: // double rate = 0.0; // Name of column for selecting: string selCol = "mode"; // Value of 'string' selector: string selVal = obsMode; // Target column name: string tarCol = ""; string version = ""; // // Hardcoded calibration tables: // string tabName = ""; string tabName01 = "SpireTable_PhotModeParams.txt"; string tabName02 = "SpireTable_CommonModeParams.txt"; string tabName03 = "SpireTable_DefaultParams.txt"; // // Hardcoded version + mode name: // string version03 = "v00"; // Version in cal table SpireTable_DefaultParams string selValHk = "PHTSTBY"; // // // // // Select and set rate: // if(rateType == "chk") { tabName = tabName03; version = version03; tarCol = "chkDataRate"; double chkrate = SpireProc_GetTableEntryDouble(tabName,selCol,selValHk,tarCol,version,debug); rate = chkrate; } // if(rateType == "nhk") { tabName = tabName03; version = version03; tarCol = "nhkDataRate"; double nhkrate = SpireProc_GetTableEntryDouble(tabName,selCol,selValHk,tarCol,version,debug); rate = nhkrate; } // if(rateType == "sci") { string[] tarColSci = ["dcuDataRate","bsmDataRate","scuDataRate","dpuDataRate"]; double scirate = 0.0; double scirate2add = 0.0; for(int i = 1 .. 4) { tarCol = tarColSci[i - 1]; if(tarCol == "dcuDataRate") { tabName = tabName01; version = version01; } else { tabName = tabName02; version = version02; } scirate2add = SpireProc_GetTableEntryDouble(tabName,selCol,selVal,tarCol,version,debug); scirate = scirate + scirate2add; if(debug) { debug_print("Reading target column " + tarCol + " with scirate " + scirate2add); debug_print("The new scirate is: " + scirate); } } rate = scirate; } // // // // // Return required rate: // if(debug) { debug_print("The " + rateType + " rate is: " + rate + " [kbps]"); } return rate; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_RepTabAndMemChecksum.txt // /////////////////////////////////////////////////////////////////////////// // // BB to report tables and memory checksums // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/06/24 V0.1: Initial version following SPIRE-SCR-1527 // /////////////////////////////////////////////////////////////////////////// // block SpireBb_RepTabAndMemChecksum SPIRE 14073 { }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SpireBb_RepTabAndMemChecksum started"); SpireMsg(2," $Id:$"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Report on all the updated tables, including the HK report: // // Spire_REPORT_TABLE(0,0,0); delay(2); Spire_REPORT_TABLE(1,0,0); delay(4); Spire_REPORT_TABLE(5,0,0); delay(6); Spire_REPORT_TABLE(10,0,0); delay(2); // Spire_REPORT_TABLE(50,0,0); delay(2); Spire_REPORT_TABLE(51,0,0); delay(2); Spire_REPORT_TABLE(52,0,0); delay(2); Spire_REPORT_TABLE(53,0,0); delay(2); Spire_REPORT_TABLE(54,0,0); delay(2); // Spire_REPORT_TABLE(60,0,0); delay(4); Spire_REPORT_TABLE(61,0,0); delay(2); // Spire_REPORT_TABLE(70,0,0); delay(4); Spire_REPORT_TABLE(71,0,0); delay(2); Spire_REPORT_TABLE(72,0,0); delay(4); // Spire_REPORT_TABLE(80,0,0); delay(4); Spire_REPORT_TABLE(81,0,0); delay(4); Spire_REPORT_TABLE(82,0,0); delay(4); Spire_REPORT_TABLE(83,0,0); delay(4); Spire_REPORT_TABLE(100,0,0); delay(4); // Spire_REPORT_TABLE(102,0,0); delay(4); Spire_REPORT_TABLE(103,0,0); delay(4); Spire_REPORT_TABLE(212,0,0); delay(4); Spire_REPORT_TABLE(213,0,0); delay(4); // // // // // Do checksum: // Spire_CHECK_MEMORY("Program Memory",0x4000,0x1795); delay(2); // Spire_CHECK_MEMORY("Program Memory",0x6000,0xffff); delay(2); // Spire_CHECK_MEMORY("Program Memory",0x15fff,0xe14); delay(2); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SpireBb_RepTabAndMemChecksum ended"); SpireMsg(1," ..RepTabAndMemChecksum End (" + (time() - t) + " seconds)"); } /// $Id: SpireEngParallelCoolerRecycle.txt,v 1.1 2008/02/06 14:59:25 dcesarsk Exp $ // // Missionphase : FM RMS // // Purpose : Pacs/Spire cooler recycling as an OBS // // Author : Diego A. Cesarsky // // Arguments : None // // Description : Merge of Spire's and PACS cooler recycling scripts // // Dependencies : SpirePacsCoolerRecycle // // Comments : Renamed SpireEng from PacsEng script to avoid PACS // depending on SPIRE // // Version : 0.1 // History : 0.1 16-jan-2008 DAC Rename from // PacsEng_PacsSpire_cool_recycle // 0.2 6-feb-2008 DAC Renamed to // SpireEngParallelCoolerRecycle.txt // Renamed called procedure to // SpireParallelCoolerRecycle // 0.3 14-nov-2008 VD include CcuMonitor for MOC // 17-Nov-2008 KJK included setting/resetting of SPIRE OBSID before/after setting CCU Monitoring // obs SpireEngParallelCoolerRecycle { }{ bool execute = true; int tobsId = duration(WriteOBSID($OBSID)) + duration(SpireBbStartObs()); int tCcu = duration(Pacs_CcuMonitorStartRecycle()); int tih = tobsId + tCcu; int tendId = duration(WriteEndID()) + duration(SpireBbEndObs()); int tCcuDefault = duration(Pacs_CcuMonitorDefaultRecycle()); int tfh = tendId + tCcuDefault; int tp = duration(SpireParallelCoolerRecycle()); // Issue PointReq int[] ts = no_pointing(execute,tih,tfh,tp); }{ int[] state = [0]; while(state[0] >= 0) { state = next_state(); if(state[0] == 2) { // *********************** INITIAL HOLD // set OBSID WriteOBSID($OBSID); SpireBbStartObs(); Pacs_CcuMonitorStartRecycle(); } if(state[0] == 3) { // *********************** EXECUTE // Call the cooler Block SpireParallelCoolerRecycle(); } if(state[0] == 5) { // *********************** FINAL HOLD Pacs_CcuMonitorDefaultRecycle(); SpireBbEndObs(); WriteEndID(); } } } // SpireBbPdetOff // // $id$ // // This building block switches off the photometer detectors // // 07/04/2009 KJK: // removed setting o fmode to REDY as this BB should leave the mode as PDET_OFF // block SpireBbPdetOff SPIRE 1284 { }{ int t0 = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB PdetOff started"); SpireMsg(2," $Id: SpireBbPdetOff.txt,v 1.1 2007/08/02 10:15:58 kking Exp $"); // int cmd = 0x0; // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // Set STEP to 0 SpireSetObsStep(0x0); delay(1); // // Set MODE to PDET_OFF SpireSetObsMode("PDET_OFF"); delay(1); // // Switch off TC Vdd and Vss // SpireSendDrcuCmd(0x8413003f,0); SpireSendDrcuCmd(0x84140000,0); delay(1); // // Switch off PSW VDD and VSS SpireSendDrcuCmd(0x84120000,0); for(int i = 0 .. 5) { SpireSendDrcuCmd(0x84050000 + 0x10000 * i,0); delay(1); } // // Switch off PMW VDD and VSS SpireSendDrcuCmd(0x84130030,0); for(int j = 0 .. 3) { SpireSendDrcuCmd(0x840b0000 + 0x10000 * j,0); delay(1); } // // Switch off PLW VDD and VSS SpireSendDrcuCmd(0x84130000,0); for(int k = 0 .. 1) { SpireSendDrcuCmd(0x840f0000 + 0x10000 * k,0); } delay(1); // // Set DEMOD PHASE TO ZERO SpireSendDrcuCmd(0x841a0000,0); SpireSendDrcuCmd(0x841b0000,0); delay(1); SpireSendDrcuCmd(0x841c0000,0); SpireSendDrcuCmd(0x841d0000,0); delay(1); // // Set BIAS TO ZERO SpireSendDrcuCmd(0x84010000,0); SpireSendDrcuCmd(0x84020000,0); delay(1); SpireSendDrcuCmd(0x84030000,0); SpireSendDrcuCmd(0x84040000,0); delay(1); // // Switch OFF PLIAs SpireSendDrcuCmd(0xa0870004,0); delay(1); // // completion tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB PdetOff ended"); SpireMsg(1," ..PDET Switch Off (" + (time() - t0) + " seconds)"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireSpectro_Cal_IltPcalFlash.txt // /////////////////////////////////////////////////////////////////////////// // // CUS script for: 'Spec ILT PCAL Flash' // // in *basic_fine_pointing* or *no_pointing* mode // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/08/15 V0.1: Initial version adapted from // SpirePhoto_Cal_IltPcalFlash (2008/08/14 V0p5) // based on // Mode_ILT_PERF_DAB_S_CPS.txt (v1.3 2008/01/31 23:35:17) // 2008/11/11 V0.2: Allow 'no pointing' as input option; Adapt debug printing // 2008/11/12 V0.3: Implement mode setting; Add isBright // Change 'no pointing' implementation // 2009/02/19 V0.4: Add debug_print as input and pass it to some low // level scripts. Add setting of NHK STEP parameter // in SpireProc_Exec_IltPcalFlash and unset at end. // Use new SpireBb_EndObsAll and SpireBb_StartObsAll. // Implemented setting of datarates. Implemented message // if activating isBright setting. Remove cal table name // from input and hardcode. Replace call to // SpireBb_SpecFSetupData by call to SpireBb_DcuSetFreqSamp // SpireBb_SpecFSetPhase and SpireBb_SpecFSetBiasAmpl. // Use SpireBb_SpecSetMode to set to SPECSTBY during SLEW // and FINAL_HOLD. Unset isBright if set. Read boresight // from SpireTable_OpsParms. Update call to // SpireProc_Exec_IltPcalFlash to include proper setting // of FTS ILT Pcal highbias levels (bug detected at SDAG#19). // 2009/03/04 V0.5: Add isSerendipity, isPcal, and 8 more dummy parameters // to the script for future use. Change isBright behaviour. // Use maxbias for amplitude and subtract isBright phase // shift read from calibration file from the user input phase. // 2009/05/06 V0.6: Add in move BSM/SMEC to hold/home at start. Add new // SpireBb_SmecHold to account for the fact that // SpireBb_SmecMove2Home does not stop SMEC. // Gather procedures at start and end in separate BB. // // Caveat: isBright bias amplitude is hardcoded in script! // /////////////////////////////////////////////////////////////////////////// // Script assumes that: // // 1) Instrument is in SPECSTBY // (i.e. bias amplitude, phase, frequency [mclkdiv,biasdiv] are nominal) // // 2) Boresight of array can be read from following cal table: // SpireTable_OpsParms.txt // // 3) Phase shift for isBright setting can be read from following // cal table: SpireTable_IsBrightPhaseShift.txt // // 4) Needs additional procedure SpireProc_Exec_IltPcalFlash.txt and // SpireProc_CalcParam_IltPcalFlash to execute ILT PCAL flash. // /////////////////////////////////////////////////////////////////////////// // obs SpireSpectro_Cal_IltPcalFlash { /* ****************************************************** */ /* USER PARAMETER DEFINITION, CUS SIGNATURE for EX-HSpot */ /* ****************************************************** */ /* */ double ra = 0.0 in [0.0,360.0]; // RA of target double dec = 0.0 in [-90.0,90.0]; // DEC of target int naifid = 0; // NAIF identifier bool isBright = false; // Use settings for bright source (==tick) bool pointing = true; // Should telescope 'point' (==tick) or do a 'no pointing' (==untick)? /* */ double biasfreq = 160.09 in [80.0,240.0]; // Bias frequency [Hz] double samplerate = 80.05 in [1.0,80.5]; // Sampling rate [Hz] (Careful, don't exceed number of data packages to be transferred from spacecraft!) double biasmV_ssw = 31.13 in [0.0,176.385]; // SSW Bias amplitude (peak2peak) [mV] double biasmV_slw = 31.13 in [0.0,176.417]; // SLW Bias amplitude (peak2peak) [mV] double phasedeg_ssw = 184.9 in [0.0,360.0]; // SSW Bias phase [deg] double phasedeg_slw = 190.6 in [0.0,360.0]; // SLW Bias phase [deg] string version01 = "v00"; // Version in cal table SpireTable_SpecModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams string version05 = "v00"; // Version in cal table SpireTable_OpsParms string version06 = "v00"; // Version in cal table SpireTable_IsBrightPhaseShift bool debug = false; // Allow (==tick) or suppress cus debug_print statements bool isSerendipity = true; // Allow (==tick) serendipity mode to be activated or prohibit (==untick) it (currently not in use)? bool isPcal = true; // Allow (==tick) regular PcalFlash in script or prohibit (==untick) it (currently not in use)?. bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ // // // // // Check for is bright setting: // if(isBright) { message("IsBright selected! SxW bias amplitude is unchanged but isBright phase-shift is subtracted."); } // // // // // Declare some variable: // // Photometer or FTS: bool phot = false; bool fts = !phot; // string tabName = ""; string selCol = ""; string tarCol = ""; string selVal = ""; string version = ""; double scirate = 0.0; double chkrate = 0.0; double nhkrate = 0.0; // // Hardcoded calibration tables: // string tabName01 = "SpireTable_SpecModeParams.txt"; string tabName02 = "SpireTable_CommonModeParams.txt"; string tabName03 = "SpireTable_BsmNominalSettings.txt"; string tabName05 = "SpireTable_OpsParms.txt"; string tabName06 = "SpireTable_IsBrightPhaseShift.txt"; string tabName09 = "SpireTable_SmecNominalSettings.txt"; // // Currently hardcoded version and model parameter: // string version09 = "v00"; // Version in cal table SpireTable_SmecNominalSettings string version03 = "v00"; // Version in cal table SpireTable_BsmNominalSettings string model = "initial"; // Model in cal table SpireTable_BsmNominalSettings // // Dummy value for Phot script: // (needed but not used in spec script!) // int bias_psw = 62; // int bias_pmw = 62; // int bias_plw = 62; // int bias_ptc = 62; // int phase_psw = 127; // int phase_pmw = 127; // int phase_plw = 127; // int phase_ptc = 127; // // // Currently hardcoded parameter: // Is (==tick) the DCU currently sampled? bool dcuData = false; // // // // // Setup mode: // // Set obsMode for QLA: string obsModeQla = "ENG_CAL_OBS36"; // Note: this needs entry in MIB table and in SpireTableInstConfigs.txt // // Set obsMode for datarates: string obsMode = "SEngCalObs"; // Note: this is currently only a maximum value // // // // // Read isBright phase shift from calibration table: // int specPhaseShift = ilookup(tabName06,version06,"specPhaseShift"); // // // // // Convert user input to Hex values: // // for bias frequency and sample rate: // int[] hexvalues = SpireProc_CalcParam_BiasFreqSampFreq(biasfreq,samplerate,fts,debug); int mclkdiv = hexvalues[0]; int biasdiv = hexvalues[1]; if(debug) { debug_print("Hex values of mclkdiv/biasdiv are: " + mclkdiv + " " + biasdiv); } // // for bias phase: // int[] phasehex = SpireProc_CalcParam_SpecPhaseConvert(phasedeg_ssw,phasedeg_slw,debug); int phase_ssw = phasehex[0]; int phase_slw = phasehex[1]; if(isBright) { phase_ssw = SpireProc_CalcParam_IsBrightPhaseShift(phase_ssw,specPhaseShift,debug); phase_slw = SpireProc_CalcParam_IsBrightPhaseShift(phase_slw,specPhaseShift,debug); } // // for bias amplitude: // int[] biashex = SpireProc_CalcParam_SpecBiasConvert(biasmV_ssw,biasmV_slw,debug); int bias_ssw = biashex[0]; int bias_slw = biashex[1]; // // // // // Set PCAL Flash values to the once fixed used during ILT: // int period = 4000000; //PCAL Flash FULL period (high and low bias) [microsec] int ndcumode = 4; // DCU data mode (0 == PF; 4 == SF) // // // // // Read SMEC home position from calibration file: // tarCol = "Home"; tabName = tabName09; selVal = version09; int smecHomePosn = ilookup(tabName,selVal,tarCol); // // // // // Read BSM home parameters: // // Select version flag and set GetTableEntry parameters: // version = version03; tabName = tabName03; selCol = "model"; // Name of column for selecting selVal = model; // Value of 'string' selector // // Read hold position from calibration table: // tarCol = "chop_0_I"; int hold_chop = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "jigg_0_I"; int hold_jigg = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // // ****************************************************** */ // CALCULATE DURATIONS for POINTING STATES */ // ****************************************************** */ // // Calculate timing for the pointing request: // // BBs called during slew: int tslewmin = duration(SpireBb_StartIltPcalFlash(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,mclkdiv,biasdiv,bias_psw,bias_pmw,bias_plw,bias_ptc,phase_psw,phase_pmw,phase_plw,phase_ptc,bias_ssw,bias_slw,phase_ssw,phase_slw,debug)); // // BBs carried out when the pointing is reached: if(pointing) { int tinithold = duration(SpireBb_SpecOffsetAuto(dcuData,debug)); } else { tinithold = duration(SpireBb_SpecOffsetAuto(dcuData,debug)) + tslewmin; } // // BB carried out during pointing: int tp = duration(SpireProc_Exec_IltPcalFlash(period,mclkdiv,biasdiv,ndcumode,phot,debug)); // // BB carried out at the end: int tfinalhold = duration(SpireBb_EndIltPcalFlash(phot,isBright,version01,version02,debug)); // if(debug) { debug_print("tslewmin = " + tslewmin); debug_print("tinithold = " + tinithold); debug_print("tpointing = " + tp); debug_print("tfinalhold = " + tfinalhold); } // // ****************************************************** */ // POINTING MODE DECLARATION */ // ****************************************************** */ // // // // // Lookup boresight: // tabName = tabName05; selCol = "mode"; selVal = obsMode; tarCol = "Boresight"; version = version05; string ib = SpireProc_GetTableEntryString(tabName,selCol,selVal,tarCol,version,debug); // // Set pointing mode: // if(pointing) { int[] ts = basic_fine_pointing(true,tslewmin,tinithold,tfinalhold,ib,naifid,ra,dec,0.0,0.0,tp); } else { ts = no_pointing(true,tinithold,tfinalhold,tp); } // if(debug) { debug_print("Output timing vector from the pointing request: " + ts); } // }{ // ****************************************************** */ // POINTING STATES WITH OBSERVING MODE LOGIC */ // ****************************************************** */ // // // // // Set datarates: // string rateType = "chk"; chkrate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); ess_hk_data_rate(chkrate); // rateType = "nhk"; // nhkrate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); non_ess_hk_data_rate(nhkrate); // rateType = "sci"; scirate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); data_rate(scirate); // if(debug) { debug_print("Set CHK datarate to: " + chkrate); debug_print("Set NHK datarate to: " + nhkrate); debug_print("Set SCI datarate to: " + scirate); } // // Start the state_machine: // int[] state = [0]; // while(state[0] >= 0) { if(debug) { debug_print("Current state: " + state); } state = next_state(); if(debug) { debug_print("Next state: " + state); } // if(state[0] == 1) { // STATE = SLEW ( Spacecraft is slewing ) // // // // // Startup observation: // SpireBb_StartIltPcalFlash(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,mclkdiv,biasdiv,bias_psw,bias_pmw,bias_plw,bias_ptc,phase_psw,phase_pmw,phase_plw,phase_ptc,bias_ssw,bias_slw,phase_ssw,phase_slw,debug); // //delay(timeSlewCal); } if(state[0] == 2) { // STATE = INIT_HOLD ( spacecraft is idling at source ) // // // // // If no pointing observation do stuff here which is // done nominally during SLEW: // if(!pointing) { // // // // // Startup observation: // SpireBb_StartIltPcalFlash(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,mclkdiv,biasdiv,bias_psw,bias_pmw,bias_plw,bias_ptc,phase_psw,phase_pmw,phase_plw,phase_ptc,bias_ssw,bias_slw,phase_ssw,phase_slw,debug); // } // // // // // Set offsets: // SpireBb_SpecOffsetAuto(dcuData,debug); // // //delay(tinithold); } if(state[0] == 3) { // STATE = POINT ( spacecraft is at nominal RA,DEC (staring, raster) ) // //delay(tp); // // // // // // Execute ILT PCAL flashes: // SpireProc_Exec_IltPcalFlash(period,mclkdiv,biasdiv,ndcumode,phot,debug); // } if(state[0] == 5) { // STATE = FINAL_HOLD ( "sky" observation ends, performing final activities ) // // // // // Set scientific datarate back to zero: // data_rate(0.0); // // // // // Reconfigure at the end (incl. resetting of OBSID and BBIB): // SpireBb_EndIltPcalFlash(phot,isBright,version01,version02,debug); // } if(state[0] == -1) { // STATE = END ( end of the pointing/commanding part of the code ) // } } } // SpireBbSmecInit // // $id$ // // This building block initialises the SMEC // // The SMECshould be switched on (SpireBbSmecOn) before execution of this building block // // 29/04/2009 KJK: First Version // 18/07/2009 MP: Added change made by Sunil on 16th to header // (see SPR-SPIRE-1638) block SpireBbSmecInit SPIRE 531 { string version = "v00"; bool debug = false; }{ int t0 = time(); string hstr = ""; // hex string string tstr = ""; // time string tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SMEC Initialisation started"); SpireMsg(2," $Id$"); // // // intialise variables int ffOff = ilookup("SpireTable_SmecNominalSettings.txt",version,"ffOff"); int ffGain = ilookup("SpireTable_SmecNominalSettings.txt",version,"ffGain"); int kp = ilookup("SpireTable_SmecNominalSettings.txt",version,"kp"); int ki = ilookup("SpireTable_SmecNominalSettings.txt",version,"ki"); int kd = ilookup("SpireTable_SmecNominalSettings.txt",version,"kd"); int drvFlt = ilookup("SpireTable_SmecNominalSettings.txt",version,"drvFlt"); int rteLim = ilookup("SpireTable_SmecNominalSettings.txt",version,"rteLim"); int intLim = ilookup("SpireTable_SmecNominalSettings.txt",version,"intLim"); int smecHome = ilookup("SpireTable_SmecNominalSettings.txt",version,"Home"); int lvdtScale = ilookup("SpireTable_SmecNominalSettings.txt",version,"lvdtScale"); // // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); delay(1); // // set Step to zero SpireSetObsStep(0); // // flag the current operation SpireSetObsMode("SMEC_INIT"); delay(1); // // Move SMEC to mechanical stop SpireSendDrcuCmd(0x90550000 + ffOff,0); delay(15); // // Set Feed Forward Gain SpireSendDrcuCmd(0x90540000 + ffGain,0); // // Reset Trajectory SpireSendDrcuCmd(0x90450000,0); SpireSendDrcuCmd(0x90460000,0); delay(1); SpireSendDrcuCmd(0x90490001,0); delay(10); // // Reset Encoder SpireSendDrcuCmd(0x90490004,0); delay(1); SpireSendDrcuCmd(0x90490001,0); // // Set SMEC control loop parameters // // Set LVDT scale factor SpireSendDrcuCmd(0x905f0000 + lvdtScale,0); // Set slew rate limiter SpireSendDrcuCmd(0x90510000 + rteLim,0); // Set integration limit SpireSendDrcuCmd(0x904e0000 + intLim,0); // Set derivative filter SpireSendDrcuCmd(0x904c0000 + drvFlt,0); // Set Kd SpireSendDrcuCmd(0x904b0000 + kd,0); delay(1); // // Close loop on encoder signals SpireSendDrcuCmd(0x90440001,0); delay(2); // // Move the SMEC to 1mm SpireSendDrcuCmd(0x904503e8,0); delay(5); // // Set Kp SpireSendDrcuCmd(0x904a0000 + kp,0); // Set Ki SpireSendDrcuCmd(0x904d0000 + ki,0); delay(5); // // Now move the SMEC to Home position (allow 30 seconds before stopping MCU Eng data) SpireSendDrcuCmd(0x90450000 + smecHome,0); delay(30); // // Stop MCU Eng data, flush MCU FIFO and set MCU Eng sampling to off SpireSendDrcuCmd(0x91c10000,0); delay(2); Spire_FLUSH_FIFO(0x2000); delay(1); SpireSendDrcuCmd(0x91c40000,0); // // completion tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SMEC Init ended"); SpireMsg(1," ..SMEC Initialisation (" + (time() - t0) + " seconds)"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_Set_ScuFramerate.txt // /////////////////////////////////////////////////////////////////////////// // // Set SCU framerate (e.g. PCAL sampling rate) // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/02/15 V0.1: Initial version adapted from // SpireProc_Set_BsmFramerate (2008/11/13 V0.1) // Add HSpot printing to script. // 2009/06/05 V0.2: Replace Spire_SEND_DRCU_COMMAND with SpireSendDrcuCmd // as requested in SPR-1482. // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Set_ScuFramerate { int frate = 0; // Specifies the SCU frame rate [Dec(Hex)] bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // string tstr = ""; // // // // // Start procedure: // tstr = SpireTimeStr(time()); SpireMsg(4," " + tstr + ": SpireProc_Set_ScuFramerate started"); SpireMsg(4," $Id:$"); // // // // // Set framerate: // SpireSendDrcuCmd(0xa0830000 + frate,0); sync(); // // // // // // Debug printing: // double frateHz = 80.0 / (1.0 + double(frate)); if(debug) { debug_print("Set SCU framerate to " + frate + " [dec(Hex)]"); debug_print("Set SCU framerate to " + frateHz + " [Hz]"); } // // // // // End procedure: // tstr = SpireTimeStr(time()); SpireMsg(4," " + tstr + ": SpireProc_Set_ScuFramerate ended"); // } // SpireEngSPEC_STBYtoREDY // // $id$ // // This observation puts the instrument into the REDY mode // // The instrument should be in the SPEC_STBY mode before execution of this observation // // 07/05/2009 KJK: explicitly run StartObs and EndObs building blocks around the engineering procedure // 08/06/2009 KJK: modified to allow input of SCAL version // obs SpireEngSPEC_STBYtoREDY { string bsmVersion = "v00"; string smecVersion = "v00"; string detVersion = "v00"; string scalVersion = "v00"; bool debug = false; bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ int t = duration(SpireBbStartObs()) + duration(SpireSPEC_STBYtoREDY(bsmVersion,smecVersion,detVersion,scalVersion,debug)) + duration(SpireBbEndObs()); int[] ts = no_pointing(true,0,0,t); }{ int[] state = [0]; while(state[0] >= 0) { state = next_state(); if(state[0] == 3) { SpireBbStartObs(); SpireSPEC_STBYtoREDY(bsmVersion,smecVersion,detVersion,scalVersion,debug); SpireBbEndObs(); } } } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_CalcParam_PhotPcalFlash.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to deduce number of DCU samples, SCU samples and DCU sample // delay based on inputs period,mclkdiv and biasdiv // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/05/05 V0.1: Initial version adapted from // Proc_PCALFlashCalc.txt (v1.4 2008/01/31 20:24:35) // /////////////////////////////////////////////////////////////////////////// // int[] procedure SpireProc_CalcParam_PhotPcalFlash { int period = 4000; //PCAL Flash FULL period (high and low bias) in millisec int mclkdiv = 60; // Fetched master clock divisor int biasdiv = 3; // Fetched bias divisor }{ // // // // // Calculate bias frequency Hz: // double bias_f = 1.0E7 / (512.0 * double(mclkdiv)); // // // // // Calculate sampling rate Hz: // double s_rate = bias_f / (1.0 + double(biasdiv)); // // // // // Calculate frame time difference in ms: double framerate = 1.0 / s_rate * 1000.0; // // // // // Calculate dcusamples, scusamples, and dcudelay parameters: // int dcusamples = iround(double(period) / 2.0 / framerate) - 1; int scusamples = iround(double(period) / 2.0 / 12.5) - 1; int dcudelay = iround((double(period) / 2.0 - double(dcusamples) * framerate) * 1000.0); if(dcudelay < 0) { do { dcusamples = dcusamples - 1; dcudelay = iround((2000.0 - double(dcusamples) * framerate) * 1000.0); debug_print("New number of dcu samples is: " + dcusamples); debug_print("New dcu_sample_delay rate is: " + dcudelay); } while (dcudelay < 0); } scusamples = 0x0; // return [dcusamples,scusamples,dcudelay]; } // SpireBb_LvdtScans // // $id$ // // This building block switches on the SMEC // // The instrument should be in the REDY mode before execution of this building block // // 17/07/2009 SDS: // First Version 0.1 // // 27/07/2009 SDS: // v0.2: Fix for SPIRE SCR-1725 // Option to select version of SpireTable_SmecNominalSettings.txt // 29/07/2009 SDS: // v0.3: Hardcoded version "v00" for SpireTable_SpecModeParams.txt block SpireBb_LvdtScans SPIRE 14074 { int nScans = 32; string pString1 = "v00"; string version02 = "v00"; bool debug = false; }{ int t0 = time(); string hstr = ""; // hex string string tstr = ""; // time string tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB LvdtScans started"); SpireMsg(2," $Id$"); // // Read Kp/Ki/Kd // int kp = ilookup("SpireTable_SmecNominalSettings.txt",pString1,"kp"); int ki = ilookup("SpireTable_SmecNominalSettings.txt",pString1,"ki"); int kd = ilookup("SpireTable_SmecNominalSettings.txt",pString1,"kd"); int speed = ilookup("SpireTable_SmecNominalSettings.txt",pString1,"MoveSpeed"); int home = ilookup("SpireTable_SmecNominalSettings.txt",pString1,"Home"); int smecrate_lvdt = SpireProc_GetTableEntryInt("SpireTable_SpecModeParams.txt","mode","SEngCalObs_45","smecFrameRate","v00",debug); int smecrate_specstby = SpireProc_GetTableEntryInt("SpireTable_SpecModeParams.txt","mode","SPECSTBY","smecFrameRate","v00",debug); int bsmrate = SpireProc_GetTableEntryInt("SpireTable_CommonModeParams.txt","mode","SPECSTBY","bsmFrameRate",version02,debug); // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); delay(1); // // set Step to zero SpireSetObsStep(0); // // Set BSM sampling to 0 SpireSendDrcuCmd(0x91c20000,0); // // Set SMEC science frame rate for LVDT scans SpireSendDrcuCmd(0x91c00000 + smecrate_lvdt,0); delay(1); // // Start SMEC selected data generation in continuous mode // SpireSendDrcuCmd(0x91c3ffff,0); delay(1); SpireSendDrcuCmd(0x91c10001,0); delay(1); // // Start DCU SF data SpireSendDrcuCmd(0x843e0001,0); // Open the SMEC loop and set Kp/Ki to 0 SpireSendDrcuCmd(0x90440006,0); delay(4); SpireSendDrcuCmd(0x904a0000,0); delay(1); SpireSendDrcuCmd(0x904d0000,0); delay(1); // Move the SMEC to ZPD (8mm) - allow 20 seconds to reach SpireSendDrcuCmd(0x90490001,0); delay(1); SpireSendDrcuCmd(0x90451f40,0); delay(20); // // Stop trajectory and set Kd SpireSendDrcuCmd(0x90490000,0); delay(1); SpireSendDrcuCmd(0x904b0000 + kd,0); delay(1); // // Close the loop on LVDT and set Kp/Ki SpireSendDrcuCmd(0x90440004,0); delay(1); SpireSendDrcuCmd(0x904a0000 + kp,0); delay(1); SpireSendDrcuCmd(0x904d0000 + ki,0); delay(1); // // Move the SMEC to 4.6mm - allow 20 seconds to reach SpireSendDrcuCmd(0x904511f8,0); delay(1); SpireSendDrcuCmd(0x90490001,0); delay(20); // // Set the Scan start and End Positions to 4.6mm and 11.4mm SpireSendDrcuCmd(0x90490000,0); delay(1); SpireSendDrcuCmd(0x904611f8,0); delay(1); SpireSendDrcuCmd(0x90452c88,0); delay(1); // // Set the number of Up/Down scans SpireSendDrcuCmd(0x90480000 + nScans,0); delay(1); // Start scanning in LVDT closed loop mode SpireSendDrcuCmd(0x90490002,0); int scanwait = iround(1.025 * double(nScans) * 8000.0 / double(speed)); delay(scanwait); // // Move the SMEC to Home - allow 10 seconds to reach SpireSendDrcuCmd(0x90490001,0); delay(1); SpireSendDrcuCmd(0x90450000 + home,0); delay(10); // // Stop SMEC selected science data generation SpireSendDrcuCmd(0x91c10000,0); delay(2); // // Stop DCU SF data generation and flush DCU/MCU FIFOs SpireSendDrcuCmd(0x843e0000,0); delay(1); Spire_FLUSH_FIFO(0x3000); delay(2); // // Set BSM and SMEC sampling to default value SpireSendDrcuCmd(0x91c20000 + bsmrate,0); SpireSendDrcuCmd(0x91c00000 + smecrate_specstby,0); delay(1); // completion tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SMEC On ended"); SpireMsg(1," ..SMEC ON (" + (time() - t0) + " seconds)"); } // CVS comments : $Id: PacsPhotSlewCal.txt,v 1.10 2008/05/06 13:34:53 vanessa Exp $ // Purpose : Invoke a PACS calibration OBCP during slew to source; // leave PACS ready to start observations once in source // // CUS author : DAC // Script file : PacsPhotSlewCal.txt // // Input arguments // Type Description // // Return values // Type Name Default Description // // Description : Perform AOT prologue and then OBCP #13. // // Dependencies : // // Preconditions : // // Comments : // // History : 0.1 DAC 30-Nov-2005 (inspired by PacsSpecSlewCal) // 0.2 DAC 20-sep-2006 Clean up leftovers from SPEC script // 0.3 DAC 6-dec-2006 Adapted to simpler PHOT_fltw_move // 0.4 DAC 27-jun-2007 SPR-3339 Always move filter wheel // 1.0 DAC 10-oct-2007 SCR-3628 Added arguments to call aot_prologue // 1.1 JVP 28-apr-2008 ERROR in filter_id assignation: POS A is LW for the // photometer (remind POS A = SW for spectro) // 1.2 DAC 20-may-2008 Moved FLTW move into DO_PROLOGUE section // 2.0 SCR 4431 VDO: implemetation of data_rates int[] procedure PacsPhotSlewCal { bool verbose = true; // Debug_print or not {int,int,int,int,int,int,int,int,int}[] confPHOTblu = [{0,64,0,0,0,0,0,0,0}]; // BLUE SPU parameters {int,int,int,int,int,int,int,int,int}[] confPHOTred = [{0,64,0,0,0,0,0,0,0}]; // RED SPU parameters {int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int}[] confOBCP = [{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}]; // OBCP parameters bool doPROLOG = true; // Perform/don't AOT prologue string filter = "blue2"; // PHOT filter }{ // Array to collect OBCP times per line int duree_num = 0; int duree_SRC = 0; int duree_REF = 0; int duree_CAL = 0; int duree_OVR = 0; int time_start = time(); int[] totalDUREE = [0,0,0,0,0]; // Table of filter wheel positions as per MIB // Actually originally not blue1 = SW = POS B, and blue2 = LW = POS A for // the photmeter if(filter == "blue1") { string filterID = "POS B"; } if(filter == "blue2") { filterID = "POS A"; } // Long sequence to "unpack" default values from tuples int gain_blu = confPHOTblu[0]{0}; int comp_mode_blu = confPHOTblu[0]{3}; int glitch_det_blu = confPHOTblu[0]{4}; int nb_raw_blu = confPHOTblu[0]{6}; int gain_red = confPHOTred[0]{0}; int comp_mode_red = confPHOTred[0]{3}; int glitch_det_red = confPHOTred[0]{4}; int nb_raw_red = confPHOTred[0]{6}; int nb_cycles_obs_cal = confOBCP[0]{0}; int nb_SRC_REF = confOBCP[0]{3}; int nb_rdouts_plateau = confOBCP[0]{4}; int nb_CS1_CS2 = confOBCP[0]{5}; int chop_pos_SRC = confOBCP[0]{12}; int chop_pos_REF1 = confOBCP[0]{13}; int chop_pos_REF2 = confOBCP[0]{14}; int chop_def = confOBCP[0]{17}; int detector = confOBCP[0]{18}; int filterPOS = confOBCP[0]{19}; if(gain_blu == 1 && gain_red == 1) { string set_gain = "LOW"; } else { if(gain_blu == 0 || gain_red == 0) { set_gain = "HIGH"; } } // Issue PHOT_aot_prologue if demanded if(doPROLOG) { totalDUREE = PHOT_aot_prologue(set_gain,comp_mode_blu,comp_mode_red,nb_raw_blu,nb_raw_red,verbose); // Turn the filter wheel int timeFLTW = PHOT_fltw_move(filterID); // increment total duration and overheads totalDUREE[0] = totalDUREE[0] + timeFLTW; totalDUREE[4] = totalDUREE[4] + timeFLTW; } // Issue now OBCP4 for demanded filter // Table OBCP4params has parameter values for CAL using blue1 or blue2 // Get params for demanded filter from OBCP4params string calNAME = "OBCP4params"; // Table acces key is "cal1" or "cal2", corresponding to blue1 and blue2 // respectively. string key = "cal1"; if(filter == "blue2") { key = "cal2"; } nb_cycles_obs_cal = ilookup(calNAME,key,"nb_cycles_obs_cal"); nb_SRC_REF = ilookup(calNAME,key,"nb_SRC_REF"); nb_rdouts_plateau = ilookup(calNAME,key,"nb_rdouts_plateau"); nb_CS1_CS2 = ilookup(calNAME,key,"nb_CS1_CS2"); // Read CS positions from CHOPPERCSparams int pos_CS1 = ilookup("CHOPPERCSparams","PHOT","pos_CS1"); int pos_CS2 = ilookup("CHOPPERCSparams","PHOT","pos_CS2"); // Update OBCP[0] tuple with CAL-U values confOBCP[0]{0} = nb_cycles_obs_cal; confOBCP[0]{3} = nb_SRC_REF; confOBCP[0]{4} = nb_rdouts_plateau; confOBCP[0]{5} = nb_CS1_CS2; confOBCP[0]{15} = pos_CS1; confOBCP[0]{16} = pos_CS2; // Call now OBCP with derived parameters int[] dureeOBCP = OBCP_chopped_photometry(nb_SRC_REF,chop_pos_SRC,nb_rdouts_plateau,chop_pos_REF1,chop_pos_REF2,nb_cycles_obs_cal,nb_CS1_CS2,pos_CS1,pos_CS2,comp_mode_blu,comp_mode_red,chop_def); if(verbose) { debug_print("*** SlewCal OBCP: " + confOBCP[0]); debug_print("*** SlewCal OBCP returns: " + dureeOBCP); } // Tally total durations for(int loop0 = 0 .. 4) { totalDUREE[loop0] = totalDUREE[loop0] + dureeOBCP[loop0]; } if(verbose) { debug_print("***** SlewCal performed CAL: " + key + " requires " + totalDUREE[0] + " [sec]"); } // Leave bus scheduler in a known state (SP1707) sync(); return totalDUREE; } // SpireEngREDYtoPHOT_STBY // // $id$ // // This observation puts the instrument into the PHOT_STBY mode // // The instrument should be in the REDY mode before execution of this observation // // // 08/11/2007 KJK: explicitly run StartObs and EndObs building blocks around the engineering procedure // 27/04/2009 KJK: bsmModel, bsmVersion and debug passed as parameters // 09/06/2009 KJK: added parameter and commands to switch on PTC PID, if required // 12/07/2009 MP: Changed default stabilisationTime (SCR-SPIRE-1632) // obs SpireEngREDYtoPHOT_STBY { int jfet_heater_V = 0; // Default jfet heater voltage at switch on string ptc = "Default" in ["Default","On","Off"]; // PTC status int ptcHold = 0; // time to wait for detectors to settle before starting PTC int stabilisationTime = 120; // time (secs) to allow Detectors to stabilise before starting observations bool sampleDetectors = false; // sample detectors during the stabilisation period string bsmModel = "initial"; string bsmVersion = "v00"; string detVersion = "v00"; string vssVersion = "v00"; string ptcVersion = "v00"; bool debug = false; bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ int t = duration(SpireBbStartObs()) + duration(SpireREDYtoPHOT_STBY(jfet_heater_V,ptc,ptcHold,stabilisationTime,sampleDetectors,bsmModel,bsmVersion,detVersion,vssVersion,ptcVersion,debug)) + duration(SpireBbEndObs()); int[] ts = no_pointing(true,0,0,t); }{ int[] state = [0]; while(state[0] >= 0) { state = next_state(); if(state[0] == 3) { SpireBbStartObs(); SpireREDYtoPHOT_STBY(jfet_heater_V,ptc,ptcHold,stabilisationTime,sampleDetectors,bsmModel,bsmVersion,detVersion,vssVersion,ptcVersion,debug); SpireBbEndObs(); } } } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpirePhoto_CalGCO_FpgInitialPointing.txt // /////////////////////////////////////////////////////////////////////////// // // CUS script for: 'Phot Focal Plane Geometry (Initial Pointing)' // // in *custom_map_pointing* mode // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/06/10 V0.1: Initial version // 2008/06/19 V0.2: Exclude moving objects as input; add correct tasks to // be performed at each pointing; replace OFF after every // point with an OFF after certain time // 2008/06/19 V0.3: Add in ExpertHSPot parameters for OFF position as // described in DOC002387_SPIRE_HSpot_ICD_Issue_2_1.pdf // 2008/06/30 V0.4: Renumber version; add offset at each raster point; // use pointing mode to automatically calculate k in dry run // 2008/07/04 V0.5: Take data at GCP position; Remove StopDcuData before offset // Add OBS_STEP to identify raster points // 2008/07/25 V0.6: Major change: use custom map instead of raster pointing // 2008/07/28 V0.7: Include BSM movement; Allow nafid as input parameter; // Change sequence of raster point visits; remove bug in // assigning return of SpireProc_CalcParam_FpgInitialPointing // 2008/09/12 V0.8: Remove test number; Adapt to name change in lowlevel script // Adapt to changes in SpireBb_PhotChop (remove ver param); // Add move to BSM hold to INIT_HOLD; Restrict chop frequency // Write out error message if elasped tim > gcp_period and // gcp_period < estimated GCP visit time // 2008/09/16 V0.9: Change kgcp_old formula; Set correct defaults; Add // temporary restriction to non-SSOs // 2008/10/13 V0.10: Set 5x5 as default; Clean up input section; Leave // stepsize unrestricted; Adapt to name changes in low level // scripts. // 2008/11/06 V0.11: Adapt to name change in low level script; Add table of // pixles to visit to input; Change in debug_print // 2008/11/12 V0.12: Implement mode setting; Add isBright // Implement proper setting of MCU framerate // Change default gyro re-calibration period // 2009/02/02 V1.0: Add debug_print as input abd pass to low level scripts. // Replace call to SpireBb_SetBsmFramerate with call to // SpireBb_SetBsmFramerate. Set obsStep back to zero at // FINAL_HOLD. Use new SpireBb_EndObsAll and // SpireBb_StartObsAll. Read nominal bias frequency, bias // divider, and BSM sampling rate from new // SpireTable_DetectorSettings.txt. Implemented setting // of datarates. Implemented isBright setting. // Replace SpireBb_BsmMove2Hold with SpireBb_BsmMove. // Add safety check for off chop BSM position. // 2009/02/03 V1.1: Set limits for d1 in input. // 2009/02/17 V1.2: Use SpireBb_PhotSetMode to set to PHOTSTBY during // SLEW and FINAL_HOLD, which replaces unsetting of // framerate at end. Remove cal. table from input. // Read some VM parameters from cal. table // SpireTable_CommandLists.txt. Adapt input to updated // SpireBb_Chop. Update setting of datarates. // 2009/03/03 V1.3: Add isSerendipity, isPcal, and 8 more dummy parameters // to the script for future use. // 2009/05/06 V1.4: Add in move BSM to hold at start. Gather procedures at // start and end in separate BB. Properly compare input // BSM framerate with PHOTSTBY value. // 2009/05/11 V1.5: Allow number of raster points as input. // 2009/06/05 V1.6: Hardcode STBY 'v00' in EndBB (SPR-1477) // 2009/07/13 V1.7: Change patt from 90 to 0 (SPR-SPIRE-1643) // Sunil Sidher // 2009/07/28 V1.8: Change patt from 0 to 180 (SPIRE SPR-1746) // /////////////////////////////////////////////////////////////////////////// // Script assumes that: // // 1) Instrument is in PHOTSTBY // (i.e. bias amplitude, phase, frequency [mclkdiv,biasdiv] are nominal) // // 2) Bias frequency (mclkdiv) and sampling rate (biasdiv) are the same // for all three arrays and could be taken from following cal table: // SpireTable_PhotModeParams.txt // // 3) Home position of BSM can be read from SpireTable_BsmNominalSettings.txt // // 4) Some VM parameters for chopping are read from following cal table: // SpireTable_CommandLists.txt // /////////////////////////////////////////////////////////////////////////// // obs SpirePhoto_CalGCO_FpgInitialPointing { /* ****************************************************** */ /* USER PARAMETER DEFINITION, CUS SIGNATURE for EX-HSpot */ /* ****************************************************** */ double ra = 0.0 in [0.0,360.0]; // RA of target double dec = 0.0 in [-90.0,90.0]; // DEC of target int naifid = 0; //NAIF identifier: put '0' to use RA/DEC, or correct 'NAIFID' /* */ bool isBright = false; // Use settings for bright source (==tick) double raoff = 0.0 in [0.0,360.0]; // RA of GCP position double decoff = 0.0 in [-90.0,90.0]; // DEC of GCP position string ib = "S14_0"; // Central aperture (defined in SIAM) of raster int m = 5; // Number of points in raster along Y [odd number!] int n = 5; // Number of points in raster along Z [odd number!] double d1 = 4.0 in [2.0,480.0]; // Angular stepsize between raster pts [arcsec] int ftime = 15; // Read-out time [s] double chopf = 2.0 in [0.1,4.0]; // Chop frequency [Hz] int offChopfh = 9600; // off-source chop position (+ or - relative to hold) [Dec(Hex)] double framerate = 125.0; // Specifies the MCU framerate [Hz] int gcp_time = 20; // Time spend at GCP (gyro calibration position) [s] int gcp_period = 600; // Maximum time between successiv GCP visits [s] string version01 = "v00"; // Version in cal table SpireTable_PhotModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams string version03 = "v00"; // Version in cal table SpireTable_PhotFpgInitialPointing string version05 = "v00"; // Version in cal table SpireTable_BsmNominalSettings string model = "initial"; // Model in cal table SpireTable_BsmNominalSetting bool debug = false; // Allow (==tick) or suppress cus debug_print statements bool isSerendipity = true; // Allow (==tick) serendipity mode to be activated or prohibit (==untick) it (currently not in use)? bool isPcal = true; // Allow (==tick) regular PcalFlash in script or prohibit (==untick) it (currently not in use)?. bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ // // // // // Current restrictions: // if(naifid != 0) { error("Currently no SSO objects are allowed as input!"); } // // // // // Declare some variable: // // Photometer or FTS: bool phot = true; bool fts = !phot; // string tabName = ""; string selCol = ""; string selVal = ""; string tarCol = ""; string version = ""; double scirate = 0.0; double chkrate = 0.0; double nhkrate = 0.0; // // Hardcoded calibration tables: // string tabName01 = "SpireTable_PhotModeParams.txt"; string tabName02 = "SpireTable_CommonModeParams.txt"; string tabName03 = "SpireTable_PhotFpgInitialPointing.txt"; string tabName04 = "SpireTable_CommandLists.txt"; string tabName05 = "SpireTable_BsmNominalSettings.txt"; // // Dummy value for Spec script: // (needed but not used in phot script!) // int smecHomePosn = 3500; // SMEC home position // bool setFramerate = true; // int tslewminadd = 0; int tfinalholdadd = 0; // int obsStep = 0; // // Start timing of script: int start = time(); // // First obsstep [HEX]: int obsstep = 0x0; // // Count raster points: int raster_counter = 0; // // Angular stepsize along Z axis [arcsec]: double d2 = d1; // NOTE: Script works only for equidistant raster points in both axes: // // DCU data mode (0 == Full photometer): int dcumode = 0; // // // // // Setup mode: // // Set obsMode for QLA: string obsModeQla = "ENG_CAL_OBS02"; // Note: this needs entry in MIB table and in SpireTableInstConfigs.txt // // Set obsMode for datarates: string obsMode = "PEngCalObs"; // Note: this is currently only a maximum value // // // // // Setup parameters for BSM chopping movement: // // Select version flag and set GetTableEntry parameters: // version = version05; tabName = tabName05; selCol = "model"; // Name of column for selecting selVal = model; // Value of 'string' selector // // Read hold position from calibration table: // tarCol = "chop_0_I"; int hold_chop = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "jigg_0_I"; int hold_jigg = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // on-source Chop position [Dec(Hex)]: int onChop = hold_chop; // on-source Jiggle position: int onJigg = hold_jigg; // off-source Chop position: int offChop = hold_chop + offChopfh; // off-source Jiggle position: int offJigg = hold_jigg; // // Check chop off position: // if(offChop > 50000) { error("Off chop is larger than 50000. Reduce offChopfh"); } // // Read VM parameters from calibration table: // tabName = tabName04; selVal = "Chop"; int vmId = ilookup(tabName,selVal,"Id"); int vmIndex = ilookup(tabName,selVal,"Index"); int nParms = ilookup(tabName,selVal,"Nparms"); // // // // // Read nominal bias frequency and bias divider: // (to determine the sampling rate) // // Select version flag and set GetTableEntry parameters: version = version01; tabName = tabName01; selCol = "mode"; // Name of column for selecting selVal = obsMode; // Value of 'string' selector // tarCol = "mclkDiv"; int mclkDiv = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // tarCol = "biasDiv"; int biasDiv = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // Read PHOTSTBY framerate: // selVal = "PHTSTBY"; version = version02; tabName = tabName02; tarCol = "bsmFrameRate"; int bsmFrameRate = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); double bsmFrameRateHz = 1000000.0 / (double(bsmFrameRate) * 420.0); if(debug) { debug_print("Nominal BSM sampling rate is: " + bsmFrameRateHz + " [Hz]"); } // // Compare nominal with input BSM framerate: // int frate = SpireProc_CalcParam_BsmFramerate(framerate,debug); if(frate == bsmFrameRate) { setFramerate = false; } // // Calculate nominal sampling rate from mclkdiv and biasdiv: // double mclkDivHz = 1.0E7 / (512.0 * double(mclkDiv + 1)); double biasDivHz = 1.0 / (double(biasDiv) + 1.0) * mclkDivHz; if(debug) { debug_print("Nominal sampling rate is: " + biasDivHz + " [Hz]"); } // // // // // Compare read-out time and dwell time on GCP: // int dtime = 0; // time to be spend on GCP position if(gcp_time < ftime) { dtime = ftime; } else { dtime = gcp_time; } // // Calculate BSM chop parameters: // int[] chopparam1 = SpireProc_CalcParam_BsmSetup(ftime,chopf,biasDivHz,framerate,debug); int ncycles = chopparam1[0]; int chop_period = chopparam1[1]; int dcusample = chopparam1[2]; int dcudelay = chopparam1[3]; int bsmsample = chopparam1[4]; int[] chopparam2 = SpireProc_CalcParam_BsmSetup(dtime,chopf,biasDivHz,framerate,debug); int ncycles_2 = chopparam2[0]; int chop_period_2 = chopparam2[1]; int dcusample_2 = chopparam2[2]; int dcudelay_2 = chopparam2[3]; int bsmsample_2 = chopparam2[4]; // ****************************************************** */ // CALCULATE DURATIONS for POINTING STATES */ // ****************************************************** */ // // // // // Calculate timing for the pointing request: // // BBs called during slew: // int tslewmin = duration(SpireBb_StartFpgInitialPointing(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,setFramerate,frate,debug)); // // BBs carried out when the pointing is reached: // int tinithold = 0; // // BB carried out during pointing: // int tp_np = duration(SpireBb_Chop(vmId,vmIndex,nParms,onChop,onJigg,offChop,offJigg,ncycles,chop_period,dcumode,dcusample,dcudelay,bsmsample,obsstep,debug)) + duration(SpireBb_PhotOffsetAuto(debug)); int tp_gp = duration(SpireBb_Chop(vmId,vmIndex,nParms,onChop,onJigg,offChop,offJigg,ncycles_2,chop_period_2,dcumode,dcusample_2,dcudelay_2,bsmsample_2,obsstep,debug)) + duration(SpireBb_PhotOffsetAuto(debug)); // // BB carried out at the end: // int tfinalhold = duration(SpireBb_EndFpgInitialPointing(phot,hold_chop,hold_jigg,isBright,version01,version02,debug)); // // // // // Debug printing: if(debug) { debug_print("tslewmin = " + tslewmin); debug_print("tinithold = " + tinithold); debug_print("tpointing normal= " + tp_np); debug_print("tpointing @GCP= " + tp_gp); debug_print("tfinalhold = " + tfinalhold); } // // ****************************************************** */ // POINTING MODE DECLARATION */ // ****************************************************** */ // // // // // Fixed parameters for pointing mode: // bool fixed = false; // Pattern orientation (true==sky; false==array) double patt = 180.0; // Rotation angle of the pattern double yoffset = 0.0; // Offset of pattern in the direction of the +Y double zoffset = 0.0; // Offset of pattern in the direction of the +Z int thold = 0; // The duration of the hold when nhold>0. int nhold = 0; // Number of nods or raster points or scan lines before // // performing a hold. double pattnod = 0.0; // double chopthrow = 2.0; // int nnod = 1; // int knod = 0; // int nload = 0; // int tloadmin = 0; // // // // // // Calculate array of points: // {double[],double[],int} array = SpireProc_CalcParam_FpgInitialPointing(d1,d2,m,n,tabName03,version03,debug); double[] zarray_org = array{0}; double[] yarray_org = array{1}; int numpixel = array{2}; int nump_org = length(yarray_org); // // // // // Add GCP visit after every raster point (except first which is GCP) // and create tp (duration of fine pointing) vector new raster: // double[] yarray = [0.0]; double[] zarray = [0.0]; int run = 1; int aindex = 1; int fin = length(yarray_org); yarray[0] = yarray_org[0]; zarray[0] = zarray_org[0]; bool gcpp = false; int[] tpv = [0]; tpv[0] = tp_gp; do { if(gcpp) { yarray[aindex] = yarray_org[0]; zarray[aindex] = zarray_org[0]; tpv[aindex] = tp_gp; gcpp = false; } else { yarray[aindex] = yarray_org[run]; zarray[aindex] = zarray_org[run]; tpv[aindex] = tp_np; run = run + 1; gcpp = true; } aindex = aindex + 1; } while (run < fin); // Add GCP visit at end: yarray[aindex] = yarray_org[0]; zarray[aindex] = zarray_org[0]; tpv[aindex] = tp_gp; // // // // // if(debug) { debug_print("timing vector : " + tpv); debug_print("zarray_org: " + zarray_org); debug_print("zarray: " + zarray); } // // Calculate slew times in pointing mode: // int[] ts_tr = custom_map_pointing(false,tslewmin,tinithold,tfinalhold,ib,naifid,ra,dec,fixed,patt,yoffset,zoffset,yarray,zarray,tpv,pattnod,chopthrow,nnod,knod,tloadmin,nload,thold,nhold); // if(debug) { debug_print("Pointing vector : " + ts_tr); } // // // // // Determine maximal slew to GCP: // int nump = length(yarray); int nslews = nump; int nlslews = numpixel; int tpp = ts_tr[7]; int[] tslews = [0]; tslews[0] = 0; for(int j = 1 .. nslews - 1) { if(debug) { debug_print("entry: " + (j + 6)); } tslews[j] = ts_tr[j + 6]; } // int maxslew = 0; for(int k = 0 .. length(tslews) - 1) { maxslew = iceil(max(double(maxslew),double(tslews[k]))); } if(debug) { debug_print("nlslews: " + nlslews); debug_print("nslews: " + nslews); debug_print("tslews: " + tslews); debug_print("maxslew: " + maxslew); } // // // // // Determine slew time between small raster points: // int tppn = tslews[1]; // == slew beteen first and second raster point // // // // // Decrease frequency of GCP visits until gcp_period matched // // int kgcp = 1; int ktime = 0; int ktime_old = 0; int nslew = 0; do { ktime_old = ktime; // // Count number of slews between the mxn rasters: if(2 * kgcp + 1 > (nslew + 1) * m * n) { nslew = nslew + 1; if(debug) { debug_print("nslew: " + nslew); } } // // Calculate approximate(!) time between off visits : // [Problem: slews are not 100% predictable with single dummy run] // ktime = tp_gp + kgcp * tp_np + (kgcp - nslew) * tppn + nslew * maxslew + 2 * maxslew; // // Add safety time: // [to account for possible longer slews than in dummy run] ktime = ktime + 0; int kdiff = ktime - ktime_old; // // Print out error if gcp_period < ktime for first case // (== having a GCP after each point): if(kgcp == 1) { if(gcp_period < ktime) { debug_print("gcp_period < ktime: " + gcp_period + " < " + ktime); error("gcp_period smaller than expected times between GCP visits! Change input parameters!"); } } // if(debug) { debug_print("tpv[0]: " + tpv[0]); debug_print("tp_np: " + tp_np); debug_print("tp_gp: " + tp_gp); debug_print("tppn: " + tppn); debug_print("maxslew: " + maxslew); debug_print("nslew: " + nslew); debug_print("ktime-ktime_old: " + kdiff); debug_print("ktime loop kgcp/ktime: " + kgcp + "/" + ktime); } // // // Increment kgcp (i.e delay visit to GCP by one more raster point): if(debug) { debug_print("increment kgcp by 1"); } kgcp = kgcp + 1; if(debug) { debug_print("new kgcp: " + kgcp); } // } while (ktime < gcp_period); // // Select last kgcp for which condition was fulfilled: int kgcp_old = 1; if(kgcp > 2) { kgcp_old = kgcp - 2; } message("Return to GCP after every " + kgcp_old + " normal raster point(s)!"); // if(debug) { debug_print("values after kgcp selection loop:"); debug_print("nump: " + nump); debug_print("nslews: " + nslews); debug_print("tslews: " + tslews); debug_print("maxslew: " + maxslew); debug_print("ktime loop end: " + ktime); debug_print("kgcp loop end:" + kgcp); debug_print("ktime_old: " + ktime_old); debug_print("kgcp_old:" + kgcp_old); } // // // // // Add visits to the GCP tp raster array: // int counter = 0; double[] yarray_new = [0.0]; double[] zarray_new = [0.0]; double ygcp = yarray[0]; double zgcp = zarray[0]; if(debug) { debug_print("ygcp/zgcp: " + ygcp + "/" + zgcp); debug_print("zarray: " + zarray); } // // Start loop: int end = nump_org; int ln = 0; int stop = 0; int index = 0; bool[] raster = [true]; do { if(debug) { debug_print("stop : " + stop); debug_print("end : " + end); debug_print("index : " + index); debug_print("counter: " + counter); } if(counter > kgcp_old - 1) { yarray_new[index] = ygcp; zarray_new[index] = zgcp; ln = ln + 1; counter = 0; raster[index] = false; } else { yarray_new[index] = yarray_org[index - ln]; zarray_new[index] = zarray_org[index - ln]; if(debug) { debug_print("index -ln : " + (index - ln)); } stop = stop + 1; counter = counter + 1; raster[index] = true; } index = index + 1; } while (stop < end); // // Define first point always as regular raster point: raster[0] = true; // // Add additional visit to GCP at end: // (could give unsymmetric GCP visits but ensures a GCP at start AND end) if(debug) { debug_print("index : " + index); } if(yarray_new[index - 1] != ygcp) { yarray_new[index] = ygcp; zarray_new[index] = zgcp; raster[index] = false; } // if(debug) { debug_print("# pts without GCPs: " + length(yarray_org)); debug_print("# pts with GCPs: " + length(yarray_new)); debug_print("yarray_org: " + yarray_org); debug_print("zarray_org: " + zarray_org); debug_print("yarray_new = " + yarray_new); debug_print("zarray_new = " + zarray_new); } // // Adapt tp vector to new number of points: int[] tpv_new = [0]; for(int ind = 0 .. length(yarray_new) - 1) { if(ind == 0) { tpv_new[0] = tpv[0]; } else { if(yarray_new[ind] == ygcp) { if(zarray_new[ind] == zgcp) { tpv_new[ind] = tp_gp; } else { tpv_new[ind] = tp_np; } } else { tpv_new[ind] = tp_np; } } } if(debug) { debug_print("raster vector: " + raster); debug_print("new timing vector : " + tpv_new); debug_print("length(raster): " + length(raster)); debug_print("length(yarray_new): " + length(yarray_new)); debug_print("length(tpv_new): " + length(tpv_new)); } // // // // // Set pointing mode: // //custom_map_pointing(true, tslewmin, tinithold, tfinalhold, ib, naifid, //ra,dec,fixed,patt,yoffset,zoffset,yarray,zarray,tpv, pattnod,chopthrow, //nnod,knod,tloadmin,nload, thold, nhold); // int[] ts = custom_map_pointing(true,tslewmin,tinithold,tfinalhold,ib,naifid,ra,dec,fixed,patt,yoffset,zoffset,yarray_new,zarray_new,tpv_new,pattnod,chopthrow,nnod,knod,tloadmin,nload,thold,nhold); // if(debug) { debug_print("Output timing vector from the pointing request: " + ts); } // }{ // ****************************************************** */ // POINTING STATES WITH OBSERVING MODE LOGIC */ // ****************************************************** */ // // // // // Set datarates: // string rateType = "chk"; chkrate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); ess_hk_data_rate(chkrate); // rateType = "nhk"; // nhkrate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); non_ess_hk_data_rate(nhkrate); // rateType = "sci"; scirate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); data_rate(scirate); // if(debug) { debug_print("Set CHK datarate to: " + chkrate); debug_print("Set NHK datarate to: " + nhkrate); debug_print("Set SCI datarate to: " + scirate); } // // Start the state_machine: // int[] state = [0]; // while(state[0] >= 0) { if(debug) { debug_print("Current state: " + state); } state = next_state(); if(debug) { debug_print("Next state: " + state); } // if(state[0] == 1) { // STATE = SLEW ( Spacecraft is slewing ) // // // // // Startup observation: // SpireBb_StartFpgInitialPointing(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,setFramerate,frate,debug); // //delay(timeSlewCal); } if(state[0] == 2) { // STATE = INIT_HOLD ( spacecraft is idling at source ) // // //delay(tinithold); } if(state[0] == 3) { // STATE = POINT (spacecraft is at nominal RA,DEC (staring, raster)) // //delay(tp); // // // // // Set offsets at each raster point: // SpireBb_PhotOffsetAuto(debug); // // // // // Different timings for different raster points (normal vs. GCP): // if(raster[raster_counter] == false) { // // // // // Show time elapsed between visits to GCP: int t = time() - start; message("Time elapsed since last visit to GCP: " + t); if(debug) { debug_print("Time elapsed since last visit to GCP: " + t); } // if(t > gcp_period) { error("Elapsed time between GCP visits larger than gcp_period! Change input parameters."); } // // Reset timer: start = time(); // // // // // Run chop VM (includes data taking) and set obs step parameter: // SpireBb_Chop(vmId,vmIndex,nParms,onChop,onJigg,offChop,offJigg,ncycles_2,chop_period_2,dcumode,dcusample_2,dcudelay_2,bsmsample_2,65535,debug); // } else { // // // // // Reset timing at first raster point: if(obsstep == 0) { start = time(); } // // // // // Run chop VM (includes data taking) and set obs step parameter: // SpireBb_Chop(vmId,vmIndex,nParms,onChop,onJigg,offChop,offJigg,ncycles,chop_period,dcumode,dcusample,dcudelay,bsmsample,obsstep,debug); obsstep = obsstep + 1; // } raster_counter = raster_counter + 1; // } if(state[0] == 5) { // STATE = FINAL_HOLD ("sky" observation ends, performing final activities ) // // // // // Set scientific datarate back to zero: // data_rate(0.0); // // // // // Reconfigure at the end (incl. resetting of OBSID and BBIB): // // Hardcode STBY values for resetting (SPR-1477): // version01 = "v00"; version02 = "v00"; version03 = "v00"; model = "initial"; // SpireBb_EndFpgInitialPointing(phot,hold_chop,hold_jigg,isBright,version01,version02,debug); // } if(state[0] == -1) { // STATE = END (end of the pointing/commanding part of the code) // } } } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_Set_BsmFramerate.txt // /////////////////////////////////////////////////////////////////////////// // // Set MCU framerate (==BSM ampling rate) // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/11/13 V0.1: Initial version // 2009/02/15 V0.2: Replaced input in Hz by input in Dec(Hex), conversion done // in SpireProc_CalcParam_BsmFramerate. Replace final // delay(1) with sync(). Add Hspot printouts // 2009/06/05 V1.0: Replace Spire_SEND_DRCU_COMMAND with SpireSendDrcuCmd // as requested in SPR-1482. // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Set_BsmFramerate { int frate = 37; // Specifies the frame rate [Dec(Hex)] bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // string tstr = ""; double framerateHz = 0.0; // // // // // Start procedure: // tstr = SpireTimeStr(time()); SpireMsg(4," " + tstr + ": SpireProc_Set_BsmFramerate started"); SpireMsg(4," $Id:$"); // // // // // Calculate Hex value from user input: // if(frate != 0) { framerateHz = 1000000.0 / (double(frate) * 420.0); } else { framerateHz = 0.0; } SpireSendDrcuCmd(0x91c20000 + frate,0); delay(1); // if(debug) { debug_print("Set MCU framerate (==BSM ampling rate) to " + frate + " [dec(Hex)]"); debug_print("Set MCU framerate (==BSM ampling rate) to " + framerateHz + " [Hz]"); } // // // // // End procedure: // tstr = SpireTimeStr(time()); SpireMsg(4," " + tstr + ": SpireProc_Set_BsmFramerate ended"); // } // SpireSpectroPointLogic // // $Id: SpireSpectroPointLogic.txt,v 1.3 2006/10/16 15:49:49 kking Exp $ // // This procedure selectes the SPIRE observing mode and calculates its instrument parameters // for single pointing spectrometer observations // // This type of observation may be executed using either the SOF1 or SOF2 observing modes // // 10/03/2009 KJK: // SCR 1274, add additional dummy parameters // Update input API to include versions for all cal tables // 17/03/2009 KJK: // Updated return values to put nCycles1 in nHCycles and nCycles2 in nLCycles // Modified to set nCycles2 = 0 if only single resolution scans are requested // {{double,double,double,double,double,double}[],{double,double,double,double,double,double}[],bool,int,int,int,int,int,double,int,double} obs SpireSpectroPointLogic { double ra = 0.0 in [0.0,360.0]; // RA of Target double dec = 0.0 in [-90.0,90.0]; // DEC of Target int naifid = 0; // NAIF identifier string pointing = "single" in ["single","raster"]; // pointing type string sampling = "sparse" in ["sparse","intermediate","full"]; // spatial sampling string resolution = "H" in ["H","M","L","H+L"]; // spectral resolution bool choppingAvoidOn = false; // is chopping avoidance selected int choppingAvoidNumber = 0 in [0,3]; // the number of chopping avoid angles selected double choppingAvoidFrom1 = 0.0 in [0.0,360.0]; double choppingAvoidTo1 = 0.0 in [0.0,360.0]; double choppingAvoidFrom2 = 0.0 in [0.0,360.0]; double choppingAvoidTo2 = 0.0 in [0.0,360.0]; double choppingAvoidFrom3 = 0.0 in [0.0,360.0]; double choppingAvoidTo3 = 0.0 in [0.0,360.0]; int nRepetitions1 = 2 in [2,1200]; // number of times to repeat spectral scan pairs for single resolution scan modes and high resolution in H+L mode int nRepetitions2 = 2 in [2,1200]; // number of times to repeat spectral scan pairs for low resolution scans for 'H+L" mode double wavelength1 = -1.0; // wavelength double wavelength2 = -1.0; // wavelength double wavelength3 = -1.0; // wavelength double wavelength4 = -1.0; // wavelength double wavelength5 = -1.0; // wavelength double wavelength6 = -1.0; // wavelength double wavelength7 = -1.0; // wavelength double wavelength8 = -1.0; // wavelength bool isJyContinuum = true; // is continuum specified in Jy rather than Wm-2um-1 double lineFlux1 = -1.0; // line flux estimate double lineFlux2 = -1.0; // line flux estimate double lineFlux3 = -1.0; // line flux estimate double lineFlux4 = -1.0; // line flux estimate double lineFlux5 = -1.0; // line flux estimate double lineFlux6 = -1.0; // line flux estimate double lineFlux7 = -1.0; // line flux estimate double lineFlux8 = -1.0; // line flux estimate double contFlux1 = -1.0; // continuum flux estimate double contFlux2 = -1.0; // continuum flux estimate double contFlux3 = -1.0; // continuum flux estimate double contFlux4 = -1.0; // continuum flux estimate double contFlux5 = -1.0; // continuum flux estimate double contFlux6 = -1.0; // continuum flux estimate double contFlux7 = -1.0; // continuum flux estimate double contFlux8 = -1.0; // continuum flux estimate bool isBright = false; string spireVersion = "v00"; // Version in cal table SpireTable_SpireParms string opsVersion = "v00"; // Version in cal table SpireTable_OpsParms string flashVersion = "v00"; // Version in cal table SpireTable_FlashParms string specVersion = "v00"; // Version in cal table SpireTable_Spectrometer bool debug = false; // debug messages flag bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ // check inputs if(pointing != "single") { error("SpireSpectroPointLogic: Pointing is not set to single"); } SpireMsg(0,"Spectrometer Single Point Observation"); // ******************************************** // Calculate possible pointing parameters // ******************************************** // int nCycles1 = 0; int nCycles2 = 0; double tCycle1 = 0.0; double tCycle2 = 0.0; int scansPerCycle1 = 0; int scansPerCycle2 = 0; double osit1 = 0.0; double osit2 = 0.0; int nMaps = 0; int nFlashes = 0; double tFlash = 0.0; int nCals = 0; double tCal = 0.0; int tSlewMin = 0; int tInitHold = 0; int tFinalHold = 0; string ib = ""; // instrument boresight double yOffset = 0.0; // offset to observation position from target in Y direction (arcsecs) double zOffset = 0.0; // offset to observation position from target in Z direction (arcsecs) double deltaY = 0.0; // offset to pixel centre from boresight in Y direction (arcsecs) double deltaZ = 0.0; // offset to pixel centre from boresight in Z direction (arcsecs) int tp = 0; // time per point // double[] wavelength = [wavelength1,wavelength2,wavelength3,wavelength4,wavelength5,wavelength6,wavelength7,wavelength8]; double[] lineFlux = [lineFlux1,lineFlux2,lineFlux3,lineFlux4,lineFlux5,lineFlux6,lineFlux7,lineFlux8]; double[] contFlux = [contFlux1,contFlux2,contFlux3,contFlux4,contFlux5,contFlux6,contFlux7,contFlux8]; // // ***************************************** // select instrument ops mode // ***************************************** // string opsMode = ""; // opsMode int md = 0; // value of MODE parameter if(sampling == "sparse") { opsMode = "SOF1"; md = 0x410; } else { if(sampling == "intermediate") { opsMode = "SOF2_int"; } else { if(sampling == "full") { opsMode = "SOF2"; } else { error("SpireSpectroPoint: Unknown sampling"); } } md = 0x420; } // // ***************************************** // set up scan sets // ***************************************** // string res1 = resolution; if(resolution == "H+L") { res1 = "H"; } string res2 = "L"; if(resolution != "H+L") { nRepetitions2 = 0; } // ***************************************** // get observing parameters // ***************************************** // ib = slookup("OpsParms.txt",opsMode,"Boresight"); deltaY = dlookup("OpsParms.txt",opsMode,"DeltaY"); // offset to pixel centre from boresight in Y direction (arcsecs) deltaZ = dlookup("OpsParms.txt",opsMode,"DeltaZ"); // offset to pixel centre from boresight in Z direction (arcsecs) {int,double,int,double,int,double,int,double,int,int,double,int,double} sofObs = SpireSOF12Observing(opsMode,res1,res2,nRepetitions1,nRepetitions2,specVersion,opsVersion,flashVersion,debug); nCycles1 = sofObs{0}; tCycle1 = sofObs{1}; scansPerCycle1 = sofObs{2}; osit1 = sofObs{3}; nCycles2 = sofObs{4}; tCycle2 = sofObs{5}; scansPerCycle2 = sofObs{6}; osit2 = sofObs{7}; nMaps = sofObs{8}; nFlashes = sofObs{9}; tFlash = sofObs{10}; nCals = sofObs{11}; tCal = sofObs{12}; // {int,int,int,int,int,int} sofPoint = SpireSOF12Pointing(opsMode,res1,nCycles1,tCycle1,scansPerCycle1,res2,nCycles2,tCycle2,scansPerCycle2,nMaps,nFlashes,tFlash,specVersion,flashVersion,debug); tSlewMin = sofPoint{0}; tInitHold = sofPoint{1}; tFinalHold = sofPoint{2}; tp = sofPoint{3}; // ***************************************** // set telescope pointing mode // ***************************************** // int[] ts = basic_fine_pointing(true,tSlewMin,tInitHold,tFinalHold,ib,naifid,ra,dec,yOffset + deltaY,zOffset + deltaZ,tp); }{ // ********************************* // Return instrument parameters // ********************************* // {{double,double,double,double,double,double}[],{double,double,double,double,double,double}[]} estimates = SpireSOF12Estimate(resolution,osit1,osit2,wavelength1,wavelength2,wavelength3,wavelength4,wavelength5,wavelength6,wavelength7,wavelength8,lineFlux1,lineFlux2,lineFlux3,lineFlux4,lineFlux5,lineFlux6,lineFlux7,lineFlux8,isJyContinuum,contFlux1,contFlux2,contFlux3,contFlux4,contFlux5,contFlux6,contFlux7,contFlux8,isBright,specVersion,debug); // bool isChopped = false; // int nHCycles = nCycles1; int nMCycles = 0; int nLCycles = nCycles2; return {estimates{0},estimates{1},isChopped,nMaps,nHCycles,nMCycles,nLCycles,nCals,tCal,nFlashes,tFlash}; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////// // // SpireProc_Exec_SpecLoadCurvePcalOn.txt // /////////////////////////////////////////////////////////// // // Procedure to loop through a list of bias amplitudes // for the 'Spec Load Curve Pcal On' task // /////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/07/07 V0.1: Initial version adapted from // SpireProc_Exec_PhotLoadCurvePcalOn (2009/04/01 V0.1) // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Exec_SpecLoadCurvePcalOn { int[] nbiaslist = [0,50,100,255]; // List of raw bias levels in range (0-255) int ftime = 10; // Readout time at each bias level [s] bool dcuData = false; // Is (==tick) the DCU currently sampled? double pcal_bias = 3.8 in [0.0,7.0]; // PCAL bias level [mA] string version = "v01"; // Version in cal table SpireTable_PcalCurrentConvCoef bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Switch on PCAL: // SpireBb_PcalOn(pcal_bias,version,debug); // // // // // Start the LC bias loop: // for(int l = 0 .. length(nbiaslist) - 1) { // // // // // Safety check: // if(nbiaslist[l] > 255) { nbiaslist[l] = 255; if(debug) { debug_print("Input bias list is corrupt! Raw value > 255 requested!"); } } // // // // // Set bias amplitude: // if(l == 0) { if(debug) { debug_print("Bias already set during slew"); } } else { SpireBb_SpecFSetBiasAmpl(nbiaslist[l],nbiaslist[l],debug); } // // // // // Stop DCU data before resetting offsets: // SpireBb_StopDcuData(); // // // // // Set offsets: // SpireBb_SpecOffsetAuto(dcuData,debug); // // // // // Take data: // SpireBb_SpecFTakeData(ftime,debug); // // // // // Debug printing: // if(debug) { debug_print("Bias level " + nbiaslist[l] + " done."); } } // // // // // Switch off PCAL: // SpireBb_PcalOn(0.0,version,debug); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_BsmMove2Hold.txt // /////////////////////////////////////////////////////////////////////////// // // BB to return BSM to hold position // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/09/08 V0.1: Initial version adapted from SpireBb_PhotChop // (2008/08/04 V0.2) // 2008/10/13 V0.2: Adapt to name change of calibration file. // 2008/11/06 V0.3: Change name // 2009/01/27 V1.0: Change call to calibration file. Add debug_print as input. // Remove unsetting of BBID at end. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_BsmMove2Hold SPIRE 14017 { string model = "initial"; // Model in calibration table string version = "v00"; // Version in cal file with nominal position bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Define some variable: // string tabName = "SpireTable_BsmNominalSettings.txt"; string selCol = "model"; // Name of column for selecting string selVal = model; // Value of 'string' selector // // // // // Set the BBs to SPIRE bbid: // Spire_SET_BBID($BBID); // // // // // Return BSM to hold position // // Read hold position from calibration table: string tarCol = "chop_0_I"; int chop_hold = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "jigg_0_I"; int jigg_hold = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // if(debug) { debug_print("Setting BSM back to nominal position (chop/jigg): " + chop_hold + "/" + jigg_hold); } // // Set Jiggle Position: Spire_SEND_DRCU_COMMAND(0x91430000 + jigg_hold,0); delay(1); // // Set Chop position: Spire_SEND_DRCU_COMMAND(0x90c30000 + chop_hold,0); // // Move BSM: // Move along the chop and jiggle axes independently: // Spire_SEND_DRCU_COMMAND(0x90c60001,0); // Move along the chop and jiggle axes synchrously: Spire_SEND_DRCU_COMMAND(0x90c60000,0); delay(1); // } command PacsCcuMonitorPeriodRecycle HFKACQP2 { } { bus_schedule(SC, 6); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_StartBsmPidTuning.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to configure at the start of SpirePhoto_Cal_BsmPidTuning. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // // 2009/05/06 V0.1: Initial version adapted from // SpireBb_StartBsmAngleCal (2009/05/05 V0.1) and // SpirePhoto_Cal_BsmPidTuning (2009/04/01 V0.2). // BB includes now to move BSM to hold. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_StartBsmPidTuning SPIRE 14056 { bool phot = true; // Photometer (==tick) or FTS (==untick)? string obsModeQla = "ENG_CAL_OBS14"; string obsMode = "PEngCalObs"; bool isBright = false; // Use settings for bright source (==tick) string version01 = "v00"; // Version in cal table SpireTable_Phot/SpecModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams int hold_chop = 37632; // Chop hold position int hold_jigg = 39520; // Jiggle hold position bool setFramerate = true; // int frate = 0; // bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // int mode_id = 0; string obsmode = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB StartBsmPidTuning configuration started"); SpireMsg(2," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Startup observation: // SpireProc_Set_StartObsAll(obsModeQla); // // // // // Move BSM back to hold: // SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug); // // // // // Initialise instrument (in case to isBright): // if(phot) { SpireProc_Set_PhotMode(obsMode,isBright,version01,version02,debug); } else { SpireProc_Set_SpecMode(obsMode,isBright,version01,version02,debug); } //delay(timeSlewCal); // // // // // Set MCU framerate (==BSM ampling rate): // if(setFramerate) { SpireProc_Set_BsmFramerate(frate,debug); } // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB StartBsmPidTuning configuration ended"); SpireMsg(1," ..StartBsmPidTuning took " + (time() - t) + " seconds)"); // } // SpireSOF2End // // $Id: SpireBbSOF2End.txt,v 1.1 2006/08/10 09:38:58 kking Exp $ // // Building Block to reconfigure the instrument to SPEC_STBY mode from SOF2 mode // // 07/02/2009: KJK // Now assumes SMEC is at scan start position (SPR-591) // block SpireBbSOF2End SPIRE 8386 { string res = "H"; string specVersion = "V00"; bool debug = false; }{ string version = "v00"; int t = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SOF2 Reconfiguration started"); SpireMsg(2," $Id: SpireBbSOF2End.txt,v 1.1 2006/08/10 09:38:58 kking Exp $"); // // ..... configuration ..... // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // set STEP to zero tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP_RAW(0x0000)"); Spire_SET_OBS_STEP_RAW(0x0); // // Move mechanism to HOME position int scanStart1 = SpireProc_GetTableEntryInt("SpireTable_Spectrometer.txt","ResChar",res,"ScanStart",specVersion,debug); int smecHome = ilookup("SpireTable_SmecNominalSettings.txt",version,"Home"); SpireProc_SmecMove(smecHome,scanStart1,debug); // // Move BSM to HOLD int bsmHoldChopPosn = ilookup("BSM.txt","Hold","ChopPosn"); int bsmHoldJiggPosn = ilookup("BSM.txt","Hold","JiggPosn"); SpireBsmMove(bsmHoldChopPosn,bsmHoldJiggPosn); // // Set Mode to SPEC_STBY tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_MODE_RAW(0x0400)"); Spire_SET_OBS_MODE_RAW(0x400); // // Clear OBSID/BBID to null values tstr = SpireTimeStr(time()); message("5 " + tstr + "Cmd: Spire_SET_BBID_RAW(0x80000000)"); Spire_SET_BBID_RAW(0x80000000); int obsId = SpireNullObsid(); tstr = SpireTimeStr(time()); hstr = SpireHexStr(obsId,8); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBSID_RAW(" + hstr + ")"); Spire_SET_OBSID_RAW(obsId); // // ..... completion ..... // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SOF2 Reconfiguration ended"); SpireMsg(1," ..SOF2 Reconfiguration to SPEC_STBY mode (" + (time() - t) + " seconds)"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////// // // SpireProc_Exec_PtcPwr.txt // /////////////////////////////////////////////////////////// // // Procedure to loop through a list // /////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/03/30 V0.1: Initial version adapted from // SPIRE_IST_PTC_PWR (SDS, email 30.03.2009) // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Exec_PtcPwr { int[] ptc_curr = [0x0,0x200,0x400,0x600,0x800,0xa00,0xc00,0xe00,0xfff,0x0]; // int ftime = 1200; // Time at each PTC Heater setting int twait = 300; // Wait time between setting PTC current and resetting offsets bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Define some variables: // int nptc = length(ptc_curr); int frames = 0; // // // // // Start DCU data: // SpireBb_StartDcuData(); delay(30); // // // // // Loop over PTC heater current settings, starting DCU PF data first // for(int i = 0 .. nptc - 1) { // SpireBb_PtcHtrCurr(ptc_curr[i],debug); // Wait for twait seconds before resetting offsets delay(twait); // // // // // Stop DCU data before resetting offsets: // SpireBb_StopDcuData(); // // // // // Set offsets: // SpireBb_PhotOffsetAuto(debug); // // Take data for ftime-twait seconds, except at the start: // SpireBb_StartDcuData(); // if(i == 0) { delay(twait); } else { delay(ftime - twait); } } // // // // // Stop DCU data at end: // SpireBb_StopDcuData(); // } /////////////////////////////////////////////////////////////////////////// // // SpireProc_CalcParam_PhotFovMapCrossRaster.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to calculate the positions of a cross raster to be used // in a custom_map pointing mode // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/08/04 V0.1: Initial version adapted from // SpireProc_CalcParam_FpgInitialPointing (V0.2) // /////////////////////////////////////////////////////////////////////////// // {double[],double[],bool[]} procedure SpireProc_CalcParam_PhotFovMapCrossRaster { double d1 = 4.0 in [2.0,480.0]; // Angular stepsize along Y axis [arcsec] double d2 = 4.0 in [2.0,480.0]; // Angular stepsize along Z axis [arcsec] int m = 5 in [3,2997]; // Number of points in the Y direction [odd number!] int k = 0 in [0,999]; // Additional visits to GCP on each hand of the cross }{ // // // // // Debug? // bool debug = true; //bool debug = false; // // // // // Set fixed parameters: // int n = m; // Number of points in the Z direction [odd number!] // --> only symmetric cross raster allowed // // // // // Calculate arrays for custom_map pointing: // double[] yarray = [0.0]; double[] zarray = [0.0]; bool[] raster = [false]; // // Set center as starting point: // yarray[0] = 0.0; zarray[0] = 0.0; raster[0] = false; // // Setup: // int index = 1; int zindex = 1; int ystart = -1 * iceil(0.5 * double(m - 1)); int zstart = -1 * iceil(0.5 * double(n - 1)); int numtrue = iceil(0.5 * double(m - 1) / double(k + 1)); int nysteps = -2 * ystart + 1; int nzsteps = -2 * zstart + 1; if(debug) { debug_print("ystart/zstart: " + ystart + "/" + zstart); debug_print("numtrue: " + numtrue); } // // Y-axis: // do { if(debug) { debug_print("Setting up Y-axis"); } yarray[index] = double(ystart) * d1 + double(index - 1) * d1; zarray[index] = 0.0; // Mark GCPs: if(yarray[index] == 0.0) { raster[index] = false; } else { raster[index] = true; } index = index + 1; } while (index < nysteps + 1); // // Add visit to center at end of Y-raster: // yarray[index] = 0.0; zarray[index] = 0.0; raster[index] = false; index = index + 1; // // Z-axis: // do { if(debug) { debug_print("Setting up Z-axis"); } zarray[index] = double(zstart) * d2 + double(zindex - 1) * d2; yarray[index] = 0.0; if(zarray[index] == 0.0) { raster[index] = false; } else { raster[index] = true; } index = index + 1; zindex = zindex + 1; } while (zindex < nzsteps + 1); // // Add visit to center at end: // yarray[index] = 0.0; zarray[index] = 0.0; raster[index] = false; // // printing: // if(debug) { debug_print("yarray: " + yarray); debug_print("zarray: " + zarray); debug_print("raster: " + raster); debug_print("length(ystart/zstart/raster): " + length(yarray) + "/" + length(zarray) + "/" + length(raster)); } // // // // // Add additional visits to GCP: // double[] yarray_new = [0.0]; double[] zarray_new = [0.0]; bool[] raster_new = [false]; // int end = length(raster); int nindex = 0; int tcount = 0; for(int counter = 1 .. end) { if(debug) { debug_print("Loop number: " + counter); debug_print("end: " + end); debug_print("nindex: " + nindex); debug_print("tcount: " + tcount); } if(raster[counter - 1] == true) { if(tcount == numtrue) { // Check if next point is not a visit to GCP: //if (raster[(counter)] == true) //{ debug_print("Add visit to GCP!"); yarray_new[nindex] = 0.0; zarray_new[nindex] = 0.0; raster_new[nindex] = false; nindex = nindex + 1; //} yarray_new[nindex] = yarray[counter - 1]; zarray_new[nindex] = zarray[counter - 1]; raster_new[nindex] = true; nindex = nindex + 1; // Reset tcount tcount = 0; } else { yarray_new[nindex] = yarray[counter - 1]; zarray_new[nindex] = zarray[counter - 1]; raster_new[nindex] = true; nindex = nindex + 1; } tcount = tcount + 1; } else { // reset true counter: tcount = 0; yarray_new[nindex] = yarray[counter - 1]; zarray_new[nindex] = zarray[counter - 1]; raster_new[nindex] = false; nindex = nindex + 1; } counter = counter + 1; } // if(debug) { debug_print("yarray: " + yarray_new); debug_print("zarray: " + zarray_new); debug_print("raster: " + raster_new); debug_print("length(ystart/zstart/raster): " + length(yarray_new) + "/" + length(zarray_new) + "/" + length(raster_new)); } // return {zarray_new,yarray_new,raster_new}; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_PcalFlash.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to perform photometer PCAL flash via VM // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/11/07 V0.1: Initial version adapted from // SpireBb_PcalFlash (2009/02/13 V1.3) // // Note: VM does not reset dcusample/bsmsample at end, so this needs // to be done in the surrounding end script. // Sunil Sidher: // 2009/07/31 V0.2: Inserted command to set DCU sampling to continuous after PCAL Flash (to fix SPIRE SPR-1587) // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_PcalFlash { int vmId = 0x46; int vmIndex = 0; int nParms = 9; int pcal_lowbias = 100; int pcal_highbias = 2000; int pcal_ncycles = 8; int pcal_period = 250000; int pcal_dcumode = 3; int pcal_ndcusamples = 11; int pcal_dcudelay = 12000; int pcal_scumode = 0; int pcal_scusamples = 9; int step = 0; bool debug = false; }{ // // // // // Define some variables: // // a time string: string tstr = ""; // // // // // Start procedure: // message("4 " + time() + ": SpireProc_PcalFlash started"); message("4 $Id: $"); // // // // // Set HSK OBSTEP parameter: // SpireProc_Set_ObsStep(step,debug); // // // // // Reset all fifos: // tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_RESET_FIFOS(0x7000)"); Spire_RESET_FIFOS(0x7000); delay(1); // // // // // Setup VM: // {int}[] pcalParams = [{pcal_lowbias},{pcal_highbias},{pcal_ncycles},{pcal_period},{pcal_dcumode},{pcal_ndcusamples},{pcal_dcudelay},{pcal_scumode},{pcal_scusamples}]; tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_RUN_VM_RAW(" + vmId + "," + vmIndex + "," + nParms + "," + pcalParams + ")"); // // // // // Start VM: // Spire_RUN_VM(vmId,vmIndex,nParms,pcalParams); // // Calculate wait time: int wait_time = pcal_period * pcal_ncycles / 1000000 + 1; if(debug) { debug_print("Wait time will be :" + " " + wait_time + " " + "sec"); } // // // // // Wait for VM to finish (exclude data rate setting): // delay(wait_time); // // // // // Flush all fifos (all, in case MCU data is being generated) // tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_FLUSH_FIFOS(0x7000)"); Spire_FLUSH_FIFO(0x7000); delay(2); // // // // // Set PCAL bias to zero: // SpireSendDrcuCmd(0xa0c80000,0); SpireSendDrcuCmd(0x843d0000,0); delay(1); // // // // // Round up total duration: // sync(); // // // // // End procedure: // message("4 " + time() + ": SpireProc_Set_PcalFlash ended"); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_PhotFTakeData.txt // /////////////////////////////////////////////////////////////////////////// // // BB to start taking data with photometer arrays // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/05/02 V0.1: Initial version adapted from // PF_Data_QLA (v1.4 2008/01/31 20:24:34) // 2008/07/04 V0.2: Renumber version; Add comment to replace '?'; // add RESET_FIFO at start // 2009/01/31 V1.0: Add debug_print option. Replace delay(1) with delay(2) // after FLUSH_FIFO. Remove unsetting of BBID. // 2009/06/05 V1.1: Replace Spire_SEND_DRCU_COMMAND with SpireSendDrcuCmd // as requested in SPR-1482. // // Note: - BB assumes no DCU data is taken when started! // - BB still includes nonessential setting of data mode (0x843c0000) // /////////////////////////////////////////////////////////////////////////// // block SpireBb_PhotFTakeData SPIRE 14008 { int ftime = 0x0; //Time for data generation (if frames are continuous) bool debug = false; // Allow (==tick) or suppress cus debug_print statement }{ // // // // // Set fixed (for flight) parameters: // // int frames = 0; //Default (IST) number of frames to request // (do not use frames, but only ftime to select time) // --> frames was not used in original PF_Data_QLA script! // // // // // Set the BBs to SPIRE bbid: // Spire_SET_BBID($BBID); //delay(1); // // // // // Reset DCU (x1000) fifo: // Spire_RESET_FIFOS(0x1000); delay(1); // // // // // Set data mode to 'photometer full array': // SpireSendDrcuCmd(0x843c0000,0); //delay(1); // // // // // Start data collection: // SpireSendDrcuCmd(0x843e0001,0); // // // // // Wait for data to be taken: // delay(ftime); // // // // // Stop data collection: // SpireSendDrcuCmd(0x843e0000,0); //delay(1); // // // // // Flush DCU fifo: // Spire_FLUSH_FIFO(0x1000); delay(2); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_StopDcuData.txt // /////////////////////////////////////////////////////////////////////////// // // BB to stop generation of detector data TM packets // // Note: Script calls the procedure SpireProc_Set_StopDcuData. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/01/26 V1.0: Initial version adapted from // SpireBb_StopDcuData (2008/07/03 V0.2) merging it with // SpireBbStopDcuData.txt (KK, 02 April 2007) and removing // the un-setting of the BBID. // 2009/01/30 V1.1: Minor change in placing script comments. Added delay(1) // after SET_BBID. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_StopDcuData SPIRE 14003 { }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // // // // // Start BB: // message("4 " + time() + ": SpireBb_StopDcuData started"); message("4 $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); delay(1); // // // // // Stop data collection: // SpireProc_Set_StopDcuData(); // // // // // End BB: // SpireMsg(4," " + time() + ": BB SpireBb_StopDcuData ended"); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_CalcParam_PhaseUp.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to calculate the parameters needed for a Phot/Spec Phase Up. // It creates and returns a list of raw phases to be stepped through, // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/08/11 V0.1: Initial version renamed from // SpireProc_CalcParam_PhotPhaseUp (2008/07/03 V0.2) // which was adapted from // Mode_ILT_PERF_DPH_P.txt (v1.4 2008/01/31 20:24:33) // 2009/02/01 V1.0: Add debug_print as input // /////////////////////////////////////////////////////////////////////////// // int[] procedure SpireProc_CalcParam_PhaseUp { double target_phase = 0.0 in [0.0,360.0]; // Central phase shift (target phase) [degree] int number_steps = 1 in [1,127]; // Number of steps to one side [int] int step_size = 1 in [1,20]; // Raw step size (1 step==1.411 degrees) [dec(HEX)] bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Calculate total number of steps: // int n_steps = 2 * number_steps + 1; if(debug) { debug_print("Numbers of steps requested: " + n_steps); } // // // // // // Get the central point of the list in raw units: // int raw_target_phase = iround(target_phase * 255.0 / 360.0); if(debug) { debug_print("The requested phase is: " + target_phase); debug_print("The associated raw value is: " + raw_target_phase); } // // // // // // Get the starting point of the list in raw units: // int raw_start_phase = raw_target_phase - number_steps * step_size; if(debug) { debug_print("the raw phase @start is :" + raw_start_phase); } // // // // // // Create list of phases: // int[] raw_phase_list = [0]; double[] phase_list = [0.0]; double low_limit = 0.0; double high_limit = 360.0; double resol = 360.0 / 255.0; double k = 0.0; // for(int i = 0 .. n_steps - 1) { raw_phase_list[i] = raw_start_phase + step_size * i; phase_list[i] = double(raw_phase_list[i]) * resol; if(debug) { debug_print("the phase for step " + i + " is: " + phase_list[i]); } // // // // // Check if phase is 0 <= phase <= 2*pi: // if(phase_list[i] < low_limit) { k = 1.0; } else { if(phase_list[i] > high_limit) { k = -1.0; } else { k = 0.0; } } if(debug) { debug_print("The value of k for step" + " " + i + " " + " is :" + k); } // // Adapt raw phase list if outside 0 <= phase <= 2*pi: // raw_phase_list[i] = iround((phase_list[i] + k * 360.0) * (255.0 / 360.0)); } // if(debug) { debug_print("Final raw phase list: " + raw_phase_list); debug_print("Imput phase list in [deg]: " + phase_list); } // return raw_phase_list; } // SpirePhotoLargeScan // // $Id: SpirePhotoLargeScan.txt,v 1.15 2008/05/23 08:47:53 kking Exp $ // // Implementation of a scan map observation without chopping // // Assumptions: // 1. the instrument is in the PHOT_STBY configuration on entry // // 13/04/07: v1.11: SPR 3010 - added option to select between two scan rates // SPR 3043 - added option to select scan direction(s) // 20/04/07: v1.12: SPR 3125 - return values based on mapOsit, not SrcTime // 26/04/07: v1.13: SPR 3148 - calculate patt correctly for each mode // 27/04/07: v1.14: SPR 3150 // 14/02/07: v1.15: - moved StartDCU Data building block from optional part of initial_hold activities to be always executed // otherwise detectordata taking will not be started at all // // 04 November 2008: added data_rate commands // 10/03/2009 KJK: // SCR 1274, add additional dummy parameters // Update input API to include versions for all cal tables // 02/07/2009 KJK: // Added configuration input parameters to pass to SpirePOF5Config, SpirePOF5Pointing and SpirePOF5End // 05/07/2009 KJK: // SPR-1593 - Updated calls to SpirePOF5Pointing and SpireBbPcalFlash to use flashVersion // {int,int,int,int} obs SpirePhotoLargeScan { double ra = 0.0 in [0.0,360.0]; // RA of Target double dec = 0.0 in [-90.0,90.0]; // DEC of Target int naifid = 0; // NAIF identifier string source = "large" in ["point","small","large"]; // source type string scanDirection = "scanab" in ["scana","scanb","scanab"]; double mapSize1 = 4.0 in [4.0,1200.0]; // mapSize1 [arc minutes] double mapSize2 = 0.0 in [0.0,240.0]; // mapSize2 [arc minutes] double mapOffsetY = 0.0 in [-300.0,300.0]; // mapOffsetY [arc minutes] double mapOffsetZ = 0.0 in [-300.0,300.0]; // mapOffsetZ [arc minutes] string mapScanRate = "nominal" in ["nominal","fast"]; // selected scan rate bool mapOrientationArray = true; // is the map orientation an array (rather than array with constraints) double mapOrientationConFrom = 0.0 in [0.0,360.0]; double mapOrientationConTo = 360.0 in [0.0,360.0]; int nRepetitions = 1 in [1,100]; // number of map repeats double sourceFluxPSW = -1.0; double sourceFluxPMW = -1.0; double sourceFluxPLW = -1.0; double sourceBrightPSW = -1.0; double sourceBrightPMW = -1.0; double sourceBrightPLW = -1.0; bool isBright = false; // Use settings for bright source (==tick) bool isRasterMap = false; int nRasters = 1; // number of times to repeat map int nPoints = 1; // not used int nMaps = 1; // not used int nCycles = 1; // not used int nNodInts = 1; // not used int nLines = 1; // number of scan lines in map int nCal = 999999; // number of lines between Gyro calibrations int nFlash = 999999; // number of lines between PCAL flashes int nLinesx = 1; // number of scan lines in cross scan map int nCalx = 999999; // number of lines between Gyro calibrations in cross scan map int nFlashx = 999999; // number of lines between PCAL flashes in cross scan map string bsmModel = "initial"; string bsmVersion = "v00"; // Version in cal table SpireTable_BsmNominalSettings.txt string spireVersion = "v00"; // Version in cal table SpireTable_SpireParms string opsVersion = "v00"; // Version in cal table SpireTable_OpsParms string flashVersion = "v00"; // Version in cal table SpireTable_FlashParms string photVersion = "v00"; // Version in cal table SpireTable_PhotModeParams.txt string comVersion = "v00"; // Version in cal table SpireTable_CommonModeParams.txt bool debug = false; // debug messages flag bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ // check inputs if(source != "large") { error("SpirePhotoLargeScan: Source is not a large map"); } if(isRasterMap) { error("SpirePhotoLargeScan: Raster Map Selected"); } if(scanDirection == "scanab" && mapSize1 > 240.0) { error("SpirePhotoLargeLogic: Scan length too big (>240.0 arcmin) "); } int tSlewMin = 0; int tInitHold = 0; int tFinalHold = 0; int tHold = 0; int nHold = 0; // // ***************************************** // set up telescope pointing mode // ***************************************** // string obsMode = "POF5"; if(mapScanRate == "fast") { obsMode = obsMode + "_F"; } else { obsMode = obsMode + "_S"; } // // ***** first scan parameters ***** {double,double,int,int,int,int} pof5Obs = {0.0,0.0,0,0,0,0}; double patt = dlookup("OpsParms.txt",obsMode + "_N","Patt"); // direction of scan // observing mode parameters if(scanDirection == "scana") { nMaps = ilookup("OpsParms.txt",obsMode + "_N","NMaps"); pof5Obs = SpirePOF5Observing(obsMode + "_N",nRepetitions * nMaps,mapSize1,mapSize2); } if(scanDirection == "scanb") { nMaps = ilookup("OpsParms.txt",obsMode + "_O","NMaps"); patt = dlookup("OpsParms.txt",obsMode + "_O","Patt"); // direction of scan pof5Obs = SpirePOF5Observing(obsMode + "_O",nRepetitions * nMaps,mapSize1,mapSize2); } if(scanDirection == "scanab") { nMaps = ilookup("OpsParms.txt",obsMode + "_N","NMaps"); pof5Obs = SpirePOF5Observing(obsMode + "_N",nMaps,mapSize1,mapSize2); } double mapOsit = pof5Obs{0}; double d1 = pof5Obs{1}; int nRepeats = pof5Obs{2}; // // pointing mode input parameters: {int,int,int,int,int,double,double} pof5Point = {0,0,0,0,0,0.0,0.0}; if(scanDirection == "scanb") { pof5Point = SpirePOF5Pointing(obsMode + "_O",nRepeats,nLines,nCal,nFlash,isBright,bsmModel,bsmVersion,flashVersion,photVersion,comVersion,debug); } else { pof5Point = SpirePOF5Pointing(obsMode + "_N",nRepeats,nLines,nCal,nFlash,isBright,bsmModel,bsmVersion,flashVersion,photVersion,comVersion,debug); } tSlewMin = pof5Point{0}; tInitHold = pof5Point{1}; tFinalHold = pof5Point{2}; tHold = pof5Point{3}; nHold = pof5Point{4}; double d2 = pof5Point{5}; double rate = pof5Point{6}; // // ***** cross scan parameters ***** if(scanDirection == "scanab") { nMaps = ilookup("OpsParms.txt",obsMode + "_O","NMaps"); double mapOsitx = 0.0; // observing mode parameters {double,double,int,int,int,int} pof5Obsx = {0.0,0.0,0,0,0,0}; pof5Obsx = SpirePOF5Observing(obsMode + "_O",nMaps,mapSize2,mapSize1); mapOsitx = pof5Obsx{0}; double d1x = pof5Obsx{1}; int nRepeatsx = pof5Obsx{2}; // // pointing mode input parameters: {int,int,int,int,int,double,double} pof5Pointx = {0,0,0,0,0,0.0,0.0}; pof5Pointx = SpirePOF5Pointing(obsMode + "_O",nRepeatsx,nLinesx,nCalx,nFlashx,isBright,bsmModel,bsmVersion,flashVersion,photVersion,comVersion,debug); int nHoldx = pof5Pointx{4}; double d2x = pof5Pointx{5}; // } // // pointing mode pointing parameters string ib = slookup("OpsParms.txt",obsMode + "_N","Boresight"); // instrument boresight double deltaY = dlookup("OpsParms.txt",obsMode + "_N","DeltaY"); // offset to pixel centre from boresight in Y direction (arcsecs) double deltaZ = dlookup("OpsParms.txt",obsMode + "_N","DeltaZ"); // offset to pixel centre from boresight in Z direction (arcsecs) bool fixed = blookup("OpsParms.txt",obsMode + "_N","Fixed"); // pattern angle definition double pattx = dlookup("OpsParms.txt",obsMode + "_O","Patt"); // direction of cross scan double yOffset = mapOffsetY * 60.0 + deltaY; // offset to observation position from target in Y direction (arcsecs) double zOffset = mapOffsetZ * 60.0 + deltaZ; // offset to observation position from target in Z direction (arcsecs) // // fetch timing information // bool initFlash = blookup("SpireParms.txt",obsMode + "_N","InitFlash"); // initial flash flag bool endFlash = blookup("SpireParms.txt",obsMode + "_N","EndFlash"); // final flash flag int tFlash = duration(SpireBbPcalFlash("PFlash",flashVersion,0,debug)); // time for a PCAL flash int tSerendipity = duration(SpireBbPhotSerendipity(obsMode + "_N",0)); // minimum time for a serendipity observation // // // ****** execute telescope pointing mode ****** // int[] ts = []; if(scanDirection == "scanab") { ts = cross_scan_pointing(true,tSlewMin,tInitHold,tFinalHold,ib,naifid,ra,dec,fixed,patt,yOffset,zOffset,nLines,d1,d2,rate,tHold,nHold,nRepetitions,nMaps,pattx,nLinesx,d1x,d2x,nHoldx); } else { ts = line_scan_pointing(true,tSlewMin,tInitHold,tFinalHold,ib,naifid,ra,dec,fixed,patt,yOffset,zOffset,nLines,d1,d2,rate,tHold,nHold,nRepeats); } // }{ // ***************************************** // Display input parameters // ***************************************** SpireMsg(3," POF5 Input values:"); SpireMsg(3," ..RA: " + ra); SpireMsg(3," ..Dec: " + dec); SpireMsg(3," ..NAIF ID: " + naifid); SpireMsg(3," ..mapSize1: " + mapSize1); SpireMsg(3," ..mapSize2: " + mapSize2); SpireMsg(3," ..Y Offset: " + yOffset); SpireMsg(3," ..Z Offset: " + zOffset); SpireMsg(3," ..No of Map Repeats: " + nRepeats); SpireMsg(3," ..No of Lines: " + nLines); // SpireMsg(3," ..No of lines between Gyro Calibrations: " + nCal); SpireMsg(3," ..No of lines between Flashes: " + nFlash); SpireMsg(3," ..No of Map Repeats: " + nRepeats); SpireMsg(3," ..No of Lines in cross-scan map: " + nLines); // SpireMsg(3," ..No of lines between Gyro Calibrations in cross-scan map: " + nCal); SpireMsg(3," ..No of lines between Flashes in cross-scan map: " + nFlash); SpireMsg(3," POF5 Fixed values:"); SpireMsg(3," ..ib: " + ib); SpireMsg(3," ..patt: " + patt); SpireMsg(3," ..d2: " + d2); SpireMsg(3," ..rate: " + rate); SpireMsg(3," ..initFlash: " + initFlash); SpireMsg(3," ..endFlash: " + endFlash); if(scanDirection == "scanab") { SpireMsg(3," Cross Scan Pointing Mode Input values:"); SpireMsg(3," ..tSlewMin: " + tSlewMin); SpireMsg(3," ..tInitHold: " + tInitHold); SpireMsg(3," ..tFInalHold: " + tFinalHold); SpireMsg(3," ..nLines: " + nLines); SpireMsg(3," ..d1: " + d1); SpireMsg(3," ..tHold: " + tHold); SpireMsg(3," ..nHold: " + nHold); SpireMsg(3," ..nLinesx: " + nLinesx); SpireMsg(3," ..d1x: " + d1x); SpireMsg(3," ..nHoldx: " + nHoldx); SpireMsg(3," Cross Scan Pointing Mode Output values:"); SpireMsg(3," ..tobs: " + ts[0]); SpireMsg(3," ..tslew: " + ts[1]); SpireMsg(3," ..tacc: " + ts[2]); SpireMsg(3," ..tdec: " + ts[3]); SpireMsg(3," ..tl: " + ts[4]); SpireMsg(3," ..tll: " + ts[5]); SpireMsg(3," ..trep: " + ts[6]); SpireMsg(3," ..tlx: " + ts[7]); SpireMsg(3," ..tllx: " + ts[8]); SpireMsg(3," ..tcross: " + ts[9]); SpireMsg(3," ..trev: " + ts[10]); SpireMsg(3," ..tend: " + ts[11]); } else { SpireMsg(3," Line Scan with Hold Pointing Mode Input values:"); SpireMsg(3," ..tSlewMin: " + tSlewMin); SpireMsg(3," ..tInitHold: " + tInitHold); SpireMsg(3," ..tFInalHold: " + tFinalHold); SpireMsg(3," ..nLines: " + nLines); SpireMsg(3," ..d1: " + d1); SpireMsg(3," ..tHold: " + tHold); SpireMsg(3," ..nHold: " + nHold); SpireMsg(3," Line Scan Pointing Mode Output values:"); SpireMsg(3," ..tobs: " + ts[0]); SpireMsg(3," ..tslew: " + ts[1]); SpireMsg(3," ..tacc: " + ts[2]); SpireMsg(3," ..tdec: " + ts[3]); SpireMsg(3," ..tl: " + ts[4]); SpireMsg(3," ..tll: " + ts[5]); SpireMsg(3," ..trep: " + ts[6]); SpireMsg(3," ..tend: " + ts[7]); } // ***************************************** // execute observation // ***************************************** SpireMsg(0,"Observation Start"); SpireMsg(0," Uses observing mode POF5 (Scan Map)"); SpireMsg(3," $Id: SpirePhotoLargeScan.txt,v 1.15 2008/05/23 08:47:53 kking Exp $"); data_rate(0.0); double chkrate = dlookup("Datarates.txt","POF5","CHK"); ess_hk_data_rate(chkrate); double nhkrate = dlookup("Datarates.txt","POF5","NHK"); non_ess_hk_data_rate(nhkrate); // //??p pointing file generation ------------------------------ //??double pos = 90.0; //??double[] rdp0 = PtOffset([ra,dec,pos],zOffset,yOffset,0.0,false); //??p pointing file generation ------------------------------ // bool relative = true; int tslew = ts[1]; // slew time int tl = ts[4]; // time for line scan int tlx = ts[7]; // time for cross-scan line scan string tstr = ""; // time string int otf = 0x8000; // On Target Flag double srcTime = 0.0; // total on source integration time int nl = 0; // line counter double s = 0.0; int x = 0; int[] state = [0]; while(state[0] >= 0) { state = next_state(); if(state[0] == 1) { // *********************** SLEWING tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " Slewing to start position"); // set up observation parameters SpireBbObsConfig(0x350); // perform serendipity operation if possible if(tslew > tSerendipity + tSlewMin) { SpireBbPhotSerendipity(obsMode + "_N",tslew - tSlewMin - 2); } // configure instrument for operations SpireBbPOF5Config(obsMode + "_N",isBright,bsmModel,bsmVersion,photVersion,debug); } if(state[0] == 2) { // *********************** INITIAL HOLD tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " Initialising Instrument"); // initialise instrument SpireBbPOF5Init(); // calibrate if necessary if(initFlash || nFlash < nLines) { tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " PCAL Calibration inserted"); SpireBbPcalFlash("PFlash",flashVersion,otf,debug); } SpireBbStartDcuData("POF5"); } if(state[0] == 5) { // *********************** FINAL HOLD tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " Reconfiguring Instrument"); SpireBbStopDcuData(); // calibrate if necessary if(endFlash && nHold != nLines) { tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " PCAL Calibration inserted"); SpireBbPcalFlash("PFlash",flashVersion,otf | nl,debug); } // reconfigure back to PHOT_STBY configuration SpireBbPOF5End("PHTSTBY",isBright,bsmModel,bsmVersion,photVersion,comVersion,debug); } if(state[0] == 6) { // *********************** HOLD tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " PCAL Calibration inserted"); SpireBbStopDcuData(); SpireBbPcalFlash("PFlash",flashVersion,otf | nl,debug); SpireBbStartDcuData("POF5"); } if(state[0] == 8) { // *********************** SCAN //??p pointing file generation ------------------------------ int line = state[2]; if(scanDirection == "scanab") { x = state[4]; } else { x = 0; } int t = time(); //??p pointing file generation ------------------------------ //??p PtScanStart(rdp0,line,nCycles,d1,d2,patt,relative); tstr = SpireTimeStr(time()); if(x == 0) { SpireMsg(2," " + tstr + " Instrument scanning"); SpireMsg(2," " + tstr + " Line " + line); s = SpireBbScanLine(tl,otf | nl); wait_until(t + tl); } else { SpireMsg(2," " + tstr + " Instrument cross-scanning"); SpireMsg(2," " + tstr + " Map " + x + ", Line " + line); s = SpireBbScanLine(tlx,otf | nl); wait_until(t + tlx); } //??p pointing file generation ------------------------------ //??p PtScanStop(rdp0,line,nCycles,d1,d2,patt,relative); srcTime = srcTime + s; nl = nl + 1; SpireBbMove(0); } } assert (time() == ts[0] + ts[1]); // // finish observation tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " Instrument Reconfigured"); // // SpireMsg(0,"Observation Completed (" + time() + " seconds)"); SpireMsg(0,"Note: Total time (s) = Observation Completed time - slew time + Observatory Overheads"); if(scanDirection == "scanab") { mapOsit = mapOsit + mapOsitx; } int mOsit = iround(mapOsit); return {nRepetitions,mOsit,mOsit * nRepetitions,time() - mOsit * nRepetitions - tslew}; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_CalcParam_BsmAngleCal.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to calculate list of chop and jiggle positions to // be looped through during the 'Phot/Spec BSM Angle Calibration' tests. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/11/07 V0.1: Initial version adapted from // SpireProc_CalcParam_PhotBsmAngleCal (2008/09/08 V0.1) // 2009/01/27 V1.0: Add debug_print as input // /////////////////////////////////////////////////////////////////////////// // {int,int,int,int}[] procedure SpireProc_CalcParam_BsmAngleCal { int increment = 384; // Chop/Jiggle increment along scan axis [Dec(Hex)] int ref_chop = 0; // Chop position of BSM reference position int ref_jigg = 0; // Jiggle position of BSM reference position int home_chop = 37632; // Hold chop position of BSM int home_jigg = 39520; // Hold jiggle position of BSM int max_chop = 60000; // Maximum chop position of BSM int max_jigg = 60000; // Minimum jiggle position of BSM int min_chop = 1000; // Maximum chop position of BSM int min_jigg = 1000; // Minimum jiggle position of BSM bool chop = true; // Scan chop or jiggle axis bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // Create list of BSM positions: // // Set boundaries: if(chop) { int start = min_chop; int stop = max_chop; } else { start = min_jigg; stop = max_jigg; } // //[int,int,int,int] pos = [0,0,0,0]; //{int, string, int, int, double}[] rows = [{0,"",0,0,0.0}]; {int,int,int,int}[] pos = [{0,0,0,0}]; // int index = 0; int step = 1; int angle = start; while(angle < stop) { if(debug) { debug_print("index: " + index); debug_print("angle: " + angle); debug_print("stop: " + stop); } if(chop) { pos[index] = {angle,home_jigg,ref_chop,ref_jigg}; } else { pos[index] = {home_chop,angle,ref_chop,ref_jigg}; } // angle = start + step * increment; step = step + 1; index = index + 1; } return pos; } // CVS comments : $Id: PacsReadChopSky.txt,v 1.3 2007/04/25 15:14:04 dcesarsk Exp $ // Missionphase : // // Purpose : To read with (linear) interpolation the SKY <-> chopper // U-CAL table // // CUS author : // Script file : PacsReadChopSky.txt from AOT code // // Input arguments // type name description // string uCAL Name of the U-CAL table // double skyOff Desired sky offset following a chopper move [arcsec] // // Return values // Type Description // int chopREF Chopper command operand (ENG units) // // Description : Read the table XXX_chop_sky with "interpole" // Dependencies : // // Preconditions : // // Comments : // // Version : 0.2 // History : 0.1 04-apr-2005 DAC // 0.2 22-mar-2007 CAL-U files amended to list ENG instead // of misleading "REF" int procedure PacsReadChopSky { string uCAL = "PHOT_CHOP_sky"; // Name of the U-CAL table /* Watch out! current uCAL extends only to 360 [arcsec */ double skyOff = 0.0; // Required sky offset }{ // Open and read uCAL table with interpolate double auxRef = interpolate(uCAL,"ENG",skyOff); int ref = iround(auxRef + 0.5); if(auxRef < 0.0) { ref = iround(auxRef - 0.5); } return ref; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBbSetDetSampling.txt // /////////////////////////////////////////////////////////////////////////// // // The Building Block sets the Detector sampling parameters for the given MODE // The detectorSampling flag allows overide of the default data generation status // (i.e true means detector data will be generated irrespective of the default setting) // The parameter isPhot should be set according to the MODE // (for REDY MODE either state is acceptable) // // /////////////////////////////////////////////////////////////////////////// // // 28/04/2009 KJK: First Version // 09/06/2009 KJK: // added isPHot input parameter // removed sampleDecetors input parameter // /////////////////////////////////////////////////////////////////////////// // double block SpireBbSetDetSampling SPIRE 1603 { string opsMode = "PHTSTBY"; bool isPhot = true; string detVersion = "v00"; bool sampleDetectors = false; bool debug = false; // Allow debug_print statements }{ // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // // // Start BB: // message("4 " + time() + ": SpireBbSetDetSampling started"); message("4 $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); delay(1); // // Set sampling // // stop any DCU sampling SpireSendDrcuCmd(0x843e0000,0); // Set DCU data mode int dcuDataMode = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode",opsMode,"dcuDataMode",detVersion,debug); SpireSendDrcuCmd(0x843c0000 + dcuDataMode,0); // start sampling, if required if(sampleDetectors) { SpireSendDrcuCmd(0x843d0000,0); // continuous sampling SpireSendDrcuCmd(0x843e0001,0); // start sampling } else { // Read sampling from calibration file // Set number of samples int dcuFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode",opsMode,"dcuFrameNumber",detVersion,debug); SpireSendDrcuCmd(0x843d0000 + dcuFrameNumber,0); // Start/Stop Data Generation int dcuDataGen = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode",opsMode,"dcuDataGen",detVersion,debug); SpireSendDrcuCmd(0x843e0000 + dcuDataGen,0); } // // // End BB: // sync(); SpireMsg(4," " + time() + ": BB SpireBbSetDetSampling ended"); // // get DCU data rate double dcuDataRate = 0.0; if(opsMode == "REDY") { dcuDataRate = SpireProc_GetTableEntryDouble("SpireTable_DefaultParams.txt","mode",opsMode,"dcuDataRate",detVersion,debug); } else { if(isPhot) { dcuDataRate = SpireProc_GetTableEntryDouble("SpireTable_PhotModeParams.txt","mode",opsMode,"dcuDataRate",detVersion,debug); } else { dcuDataRate = SpireProc_GetTableEntryDouble("SpireTable_SpecModeParams.txt","mode",opsMode,"dcuDataRate",detVersion,debug); } } return dcuDataRate; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_CalcParam_SpecMultiLevelNoiseLevels.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to translate user input in Hz for bias frequency and // sampling rate into nearest Hex values for mclkdiv and biasdiv // and then select list of bias amplitudes and phases for the nearest // match to mclkdiv from the input calibration table for the FTS. // // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/09/09 V0.1: Initial version adapted from (2008/08/15 V0.3) // SpireProc_CalcParam_SpecMultiLevelNoiseLevels // 2009/02/19 V0.2: Include check for non-existing version. Add debug // parameter and pass also to low level script. Adapt to // removal of 'index' from calibration file, i.e. remove // reading of indexCol. // 2009/03/02 V0.3: Uncomment error message // /////////////////////////////////////////////////////////////////////////// // {string,int,int,int,double,double}[] procedure SpireProc_CalcParam_SpecMultiLevelNoiseLevels { double biasfreq = 160.09 in [80.0,240.0]; // Bias frequency [Hz] double samplerate = 80.05 in [1.0,80.5]; // Sampling rate [Hz] (Careful, don't exceed number of data packages to be transferred from spacecraft!) string tabName = "SpireTable_SpecMultiLevelNoiseLevels.txt"; // Calibration table name string version = "v00"; // Version parameter defined in calibration table bool debug = false; // Allow (==tick) or suppress cus debug_print statement }{ // // // // // Calculate mclkdiv and biasdiv based on user input in Hz: // bool fts = true; // FTS or photometer limits? int[] hexvalues = SpireProc_CalcParam_BiasFreqSampFreq(biasfreq,samplerate,fts,debug); int mclkdiv = hexvalues[0]; int biasdiv = hexvalues[1]; // // // // // Printout: // if(debug) { debug_print("Converted values mclkdiv/biasdiv [raw]: " + mclkdiv + " " + biasdiv); } // // // // // Setup variables: // string colName = "mclkdiv"; int[] searchCol = icolumn(tabName,colName); int size = table_size(tabName); // // // // // Determine closest match: // // Start with the first value as the closest: int closest = searchCol[0]; int diff = iround(abs(double(mclkdiv - closest))); if(debug) { debug_print("diff = " + diff); } // Run through the values in the column: for(int i = 0 .. size - 1) { int next = searchCol[i]; if(debug) { debug_print("next = " + next); } int nextDiff = iround(abs(double(mclkdiv - next))); if(debug) { debug_print("nextdiff = " + nextDiff); } if(nextDiff < diff) { closest = next; if(debug) { debug_print("closest = " + closest); } // Change diff to allow for non-monotonous mclkdiv in cal. tab. : diff = nextDiff; if(debug) { debug_print("diff = " + diff); } } } // // // // // Get all other column information: // string[] versionCol = scolumn(tabName,"version"); int[] settingCol = icolumn(tabName,"setting"); double[] sswphaseCol = dcolumn(tabName,"sswphase"); double[] slwphaseCol = dcolumn(tabName,"slwphase"); // {string,int,int,int,double,double}[] rows = [{"",0,0,0,0.0,0.0}]; int index = 0; // // // // // Cycle through values again to get all rows with closest match: // for(int j = 0 .. size - 1) { // If the key matches the closest and has the correct version tag // then we want it: if(closest == searchCol[j]) { if(versionCol[j] == version) { rows[index] = {versionCol[j],searchCol[j],biasdiv,settingCol[j],sswphaseCol[j],slwphaseCol[j]}; index = index + 1; } } } // // // // // Safety check: Make sure input version parameter is defined in cal. table: if(debug) { debug_print("rows[0]{0}: " + rows[0]{0}); } if(rows[0]{0} == "") { error("Input version parameter is not defined for selected bias frequency in " + tabName + ". Either select another version or change bias frequency!"); } // // // // // Return values: return rows; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpirePhoto_Cal_MultiLevelNoise.txt // /////////////////////////////////////////////////////////////////////////// // // CUS script for: 'Phot Multi-Level Noise' // // in *basic_fine_pointing* or *no_pointing* mode // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/06/09 V0.1: Initial version adapted from // Mode_ILT_PERF_DAB_P_Levels.txt (1.3 2008/01/31 23:35:17) // 2008/07/03 V0.2: Renumber version; SpireProc_Set_PhotNominalbias changed name // 2008/08/04 V0.3: Allow separate phase for each array (including PTC) // (== change in SpireProc_Exec_PhotMultiLevelNoise.txt) // 2008/11/11 V0.4: Allow 'no pointing' as input option; Adapt debug printing // 2008/11/12 V0.5: Implement mode setting; Add isBright // Change 'no pointing' implementation // 2008/11/14 V0.6: Change default version selector to 'v00' // 2009/01/30 V1.0: Remove test number from header. Add debug_print as input // and pass it to some low level scripts. // Use new SpireBb_EndObsAll and SpireBb_StartObsAll. // Read nominal bias frequency and bias divider from new // SpireTable_DetectorSettings.txt Implemented message // if activating isBright setting. Implemented setting // of datarates. Replace SpireProc_Set_PhotNominal by // SpireProc_Set_FreqSampAmpPhasNominal. // 2009/02/17 V1.1: Remove cal table name from input and hardcode. // New setting of datarates. Use SpireBb_PhotSetMode to set // to PHOTSTBY during SLEW and FINAL_HOLD. Unset isBright // if set. Read boresight from SpireTable_OpsParms. Fixed // bug in low level script SpireProc_Exec_PhotMultiLevelNoise, // biasfreq and samplerate were set each time in loop. // 2009/02/19 V1.2: Fixed bug, now use input version05 in script. // 2009/03/03 V1.3: Add isSerendipity, isPcal, and 8 more dummy parameters // to the script for future use. Change isBright behaviour. // Subtract isBright phase shift read from one calibration // file from the nominal phase value in the other calibration // file. // 2009/05/06 V1.4: Add in move BSM to hold at start. Gather procedures at // start and end in separate BB. // 2009/06/05 V1.5: Hardcode STBY 'v00' in EndBB (SPR-1477) // // Sunil Sidher // 2009/07/21 V1.6: Implemented isPcal flag to perform standard AOT style PCAL flashes after each bias setting // /////////////////////////////////////////////////////////////////////////// // // Script assumes that: // // 1) Instrument is in PHOTSTBY at beginning // (i.e. bias amplitude, phase, frequency [mclkdiv,biasdiv] are nominal) // // 2) Phase is adjusted with changing bias amplitude and frequency. // // 3) Levels/phases are read from CalTable: // SpireTable_PhotMultiLevelNoiseLevels.txt // // 4) Phase shift for isBright setting can be read from following // cal table: SpireTable_IsBrightPhaseShift.txt // // 5) Bias frequency and sampling rate are user inputs. // // 6) Boresight of array can be read from following cal table: // Spire_TableOpsParms.txt // /////////////////////////////////////////////////////////////////////////// // obs SpirePhoto_Cal_MultiLevelNoise { /* ****************************************************** */ /* USER PARAMETER DEFINITION, CUS SIGNATURE for EX-HSpot */ /* ****************************************************** */ /* */ double ra = 0.0 in [0.0,360.0]; // RA of target double dec = 0.0 in [-90.0,90.0]; // DEC of target bool isBright = false; // Use settings for bright source (==tick) (Note: Only phases values will be changed!) bool pointing = true; // Should telescope 'point' (==tick) or do a 'no pointing' (==untick)? /* */ double biasfreq = 130.2 in [70.0,200.0]; // Bias frequency [Hz] double samplerate = 18.6 in [1.0,20.0]; // Sampling rate [Hz] (Careful, don't exceed number of data packages to be transferred from spacecraft!) int ftime = 300; // Readout time at each bias level [s] string version01 = "v00"; // Version in cal table SpireTable_PhotModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams string version03 = "v00"; // Version in cal table SpireTable_PhotMultiLevelNoiseLevels string version05 = "v00"; // Version in cal table SpireTable_OpsParms.txt string version06 = "v00"; // Version in cal table SpireTable_IsBrightPhaseShift bool debug = false; // Allow (==tick) or suppress cus debug_print statements bool isSerendipity = true; // Allow (==tick) serendipity mode to be activated or prohibit (==untick) it (currently not in use)? bool isPcal = true; // Allow (==tick) regular PcalFlash in script or prohibit (==untick) it? bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) /* */ }{ // ****************************************************** */ // CALCULATE DURATIONS for POINTING STATES */ // ****************************************************** */ // // // // // Check for is bright setting: // if(isBright) { message("IsBright selected! PxW bias amplitude is unchanged but isBright phase-shift is subtracted."); } // // // // // Declare some variable: // // Photometer or FTS: bool phot = true; bool fts = !phot; // string tabName = ""; string selCol = ""; string selVal = ""; string tarCol = ""; string version = ""; double scirate = 0.0; double chkrate = 0.0; double nhkrate = 0.0; // // Hardcoded calibration tables: // string tabName01 = "SpireTable_PhotModeParams.txt"; string tabName02 = "SpireTable_CommonModeParams.txt"; string tabName03 = "SpireTable_PhotMultiLevelNoiseLevels.txt"; string tabName04 = "SpireTable_BsmNominalSettings.txt"; string tabName05 = "SpireTable_OpsParms.txt"; string tabName06 = "SpireTable_IsBrightPhaseShift.txt"; // // Currently hardcoded version and model parameter: // string version04 = "v00"; // Version in cal table SpireTable_BsmNominalSettings string model = "initial"; // Model in cal table SpireTable_BsmNominalSettings // // Dummy value for Spec script: // (needed but not used in phot script!) // int smecHomePosn = 3500; // SMEC home position // // // // // Setup mode: // // Set obsMode for QLA: string obsModeQla = "ENG_CAL_OBS08"; // Note: this needs entry in MIB table and in SpireTableInstConfigs.txt // // Set obsMode for datarates: string obsMode = "PEngCalObs"; // Note: this is currently only a maximum value // // // // // Read BSM home parameters: // // Select version flag and set GetTableEntry parameters: // version = version04; tabName = tabName04; selCol = "model"; // Name of column for selecting selVal = model; // Value of 'string' selector // // Read hold position from calibration table: // tarCol = "chop_0_I"; int hold_chop = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "jigg_0_I"; int hold_jigg = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // Calculate timing for the pointing request: // // BBs called during slew: int tslewmin = duration(SpireBb_StartMultiLevelNoise(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,debug)); // // BBs carried out when the pointing is reached: if(pointing) { int tinithold = 0; } else { tinithold = tslewmin; } // // BB carried out during pointing: int tp = duration(SpireProc_Exec_PhotMultiLevelNoise(biasfreq,samplerate,tabName03,version03,isBright,isPcal,tabName06,version06,ftime,debug)); // // BB carried out at the end: int tfinalhold = duration(SpireBb_EndMultiLevelNoise(phot,isBright,version01,version02,debug)); // // Debug_printing? // if(debug) { debug_print("tslewmin = " + tslewmin); debug_print("tinithold = " + tinithold); debug_print("tpointing = " + tp); debug_print("tfinalhold = " + tfinalhold); } // // ****************************************************** */ // POINTING MODE DECLARATION */ // ****************************************************** */ // // Lookup boresight: tabName = tabName05; selCol = "mode"; selVal = obsMode; tarCol = "Boresight"; version = version05; string ib = SpireProc_GetTableEntryString(tabName,selCol,selVal,tarCol,version,debug); // // Set pointing mode: // if(pointing) { int[] ts = basic_fine_pointing(true,tslewmin,tinithold,tfinalhold,ib,0,ra,dec,0.0,0.0,tp); } else { ts = no_pointing(true,tinithold,tfinalhold,tp); } // if(debug) { debug_print("Output timing vector from the pointing request: " + ts); } // }{ // ****************************************************** */ // POINTING STATES WITH OBSERVING MODE LOGIC */ // ****************************************************** */ // // // // // Set datarates: // string rateType = "chk"; chkrate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); ess_hk_data_rate(chkrate); // rateType = "nhk"; // nhkrate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); non_ess_hk_data_rate(nhkrate); // rateType = "sci"; scirate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); data_rate(scirate); // if(debug) { debug_print("Set CHK datarate to: " + chkrate); debug_print("Set NHK datarate to: " + nhkrate); debug_print("Set SCI datarate to: " + scirate); } // // Start the state_machine: // int[] state = [0]; // while(state[0] >= 0) { if(debug) { debug_print("Current state: " + state); } state = next_state(); if(debug) { debug_print("Next state: " + state); } // if(state[0] == 1) { // STATE = SLEW ( Spacecraft is slewing ) // // // // // Startup observation: // SpireBb_StartMultiLevelNoise(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,debug); // //delay(timeSlewCal); } if(state[0] == 2) { // STATE = INIT_HOLD ( spacecraft is idling at source ) // // // // // // If no pointing observation do stuff here which is // done nominally during SLEW: // if(!pointing) { // // // // // Startup observation: // SpireBb_StartMultiLevelNoise(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,debug); // } //delay(tinithold); // } if(state[0] == 3) { // STATE = POINT ( spacecraft is at nominal RA,DEC (staring, raster) ) // // // // // // Execute Multi-Level Noise task: // SpireProc_Exec_PhotMultiLevelNoise(biasfreq,samplerate,tabName03,version03,isBright,isPcal,tabName06,version06,ftime,debug); // //delay(tp); // } if(state[0] == 5) { // STATE = FINAL_HOLD ( "sky" observation ends, performing final activ.) // // // // // Set scientific datarate back to zero: // data_rate(0.0); // // // // // Reconfigure at the end (incl. resetting of OBSID and BBIB): // version01 = "v00"; version02 = "v00"; // SpireBb_EndMultiLevelNoise(phot,isBright,version01,version02,debug); // } if(state[0] == -1) { // STATE = END ( end of the pointing/commanding part of the code ) // } } } // Missionphase : PACS AVM ILT // // Purpose : Select the data mode // // Author TCL : T. Mueller // Author CUS : DAC // CUS script : PHOT_change_data_mode.txt // // Arguments : // type name default Description // string mode "Bolo_HK" Select the data mode for bolometers // // Description : This script will select the data mode for the bolometers // After switch on of the bolometers the default data mode // is "HK only", after executing the sequencer setup the // default mode is "Bolo & HK" // // Comments : Coded based on PhFPU UM, Draft 2, March 31, 2004 // // Version : 1.0 18-apr-2005 DAC Based on TM's V1.0 0f 20-apr-2004 // History : // int[] procedure PHOT_change_data_mode { string data_mode = "Bolo_HK" in ["Bolo_HK","HK_only","Test_Pat_HK"]; //Data mode for the bolometers }{ // Define variables to communicate various durations to HSPOT. // NOTE: all time variables in units of number of ramps (SPEC) or // number of readouts (BOLO). The calling program must convert this // count into actual duration in true time units [seconds]. // SRC, REF, CAL, OVR stand for time spent on SRC, REF (on sky), // CAL source, and overheads (wait for something). Total // duration is given by duree_num. If no error, this duration // must be equal to the sum of all others int duree_num = 0; int duree_SRC = 0; int duree_REF = 0; int duree_CAL = 0; int duree_OVR = 0; int time_start = time(); //------------------------------------------------ // SET BOLC Data Mode data & HK //------------------------------------------------ // PC103420 "DMC_SEND_COMMAND_BOLC" SEND COMMAND TO BOL CONTROLLER // PP071420 "BOLOMETER_COMMAND" Pacs_BOLC_SET_DATA_MODE(data_mode); // Time spent int duree_TCs = time() - time_start; duree_OVR = duree_TCs; duree_num = duree_OVR; // Return the array of times int[] time_array = [duree_num,duree_SRC,duree_REF,duree_CAL,duree_OVR]; return time_array; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_Set_StartDcuData.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to start generation of detector data (TM packets) // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/02/18 V0.1: Initial version adapted // SpireBb_StartDcuData (2008/07/03 V0.2) // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Set_StartDcuData { }{ // // // // // Start procedure: // message("4 " + time() + ": SpireProc_Set_StartDcuData started"); message("4 $Id: $"); // // // // // Reset DCU (x1000) fifo: // message("5 " + time() + "Cmd: Spire_RESET_FIFOS(0x1000)"); Spire_RESET_FIFOS(0x1000); delay(1); // // // // // Start data collection: // SpireSendDrcuCmd(0x843e0001,0); sync(); // // // // // End procedure: // message("4 " + time() + ": SpireProc_Set_StartDcuData ended"); // } // SpireNhkSampling // // $id$ // // This procedure sets the NHK sampling interval // // 11/11/2008 Removed command to stop NHSK when changing sampling rate // procedure SpireNhkSampling { int interval = 0xfa0; // NHK sampling interval (ms) }{ // default NHK parameters int pktid = 0x301; // packet id int sid = 0x301; // sid int repeat = 1; // packet repeat int tableid = 1; // table id // string tstr = ""; // time string string pstr = SpireHexStr(pktid,4); string sstr = SpireHexStr(sid,4); // // start NHK generation at new rate tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_DEFINE_NEW_HK_REPORT(" + pstr + "," + sstr + "," + interval + "," + repeat + "," + tableid + ")"); Spire_DEFINE_NEW_HK_REPORT(pktid,sid,interval,repeat,tableid); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_CalcParam_IltPcalFlash.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to deduce number of DCU samples, SCU samples and DCU sample // delay based on inputs period,mclkdiv and biasdiv in exactly the same // way as for ILT, which had a small bug in the calculation // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/08/14 V0.1: Initial version recovered from // SpireProc_CalcParam_PhotPcalFlash (2008/05/05 V0.1) // based upon // Proc_PCALFlashCalc.txt (v1.4 2008/01/31 20:24:35) // 2009/02/02 V1.0: Add debug_print as input and pass to low level scripts. // /////////////////////////////////////////////////////////////////////////// // int[] procedure SpireProc_CalcParam_IltPcalFlash { int period = 4000; //PCAL Flash FULL period (high and low bias) in millisec int mclkdiv = 149; // Fetched master clock divisor int biasdiv = 6; // Fetched bias divisor bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Calculate bias frequency Hz: // double bias_f = 1.0E7 / (512.0 * double(mclkdiv)); // // // // // Calculate sampling rate Hz: // double s_rate = bias_f / (1.0 + double(biasdiv)); // // // // // Calculate frame time difference in ms: double framerate = 1.0 / s_rate * 1000.0; // // // // // Calculate dcusamples, scusamples, and dcudelay parameters: // int dcusamples = iround(double(period) / 2.0 / framerate) - 1; int scusamples = iround(double(period) / 2.0 / 12.5) - 1; int dcudelay = iround((double(period) / 2.0 - double(dcusamples) * framerate) * 1000.0); if(dcudelay < 0) { do { dcusamples = dcusamples - 1; dcudelay = iround((2000.0 - double(dcusamples) * framerate) * 1000.0); if(debug) { debug_print("New number of dcu samples is: " + dcusamples); debug_print("New dcu_sample_delay rate is: " + dcudelay); } } while (dcudelay < 0); } scusamples = 0x0; // return [dcusamples,scusamples,dcudelay]; } // SpireCoolerRecycle // // $id$ // // This procedure executes the cooler recycle // // The instrument should be in the REDY mode before execution of this observation // // 08/11/2007 KJK: removed StartObs and EndObs building blocks from the engineering procedure // procedure SpireCoolerRecycle { }{ // execute cooler recycle mois_comment("Procedure to recycle the SPIRE Sorption Cooler"); SpireBbCoolerRecycle(); mois_comment("SPIRE Cooler Recycle Procedure Completed"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_SetBsmChopPid.txt // /////////////////////////////////////////////////////////////////////////// // // BB to set BSM PID parameters // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/03/30 V0.1: Initial version adapted from // Proc_SetChopPID.txt (SDS, email 30.03.2009) // 2009/06/05 V1.1: Commands moved to new low level procedure // SpireProc_Set_BsmChopPid.txt. Hspot message // at level 1 changed. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_SetBsmChopPid SPIRE 14034 { int kp = 1000; // Chop Kp int ki = 536; // Chop Ki int kd = 3504; // Chop Kd bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Define some variables: // string hstr = ""; // a hex string string tstr = ""; // a time string // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": SpireBb_SetBsmChopPid started"); SpireMsg(2," $Id: $"); hstr = SpireHexStr($BBID,8); SpireMsg(3," BBID = " + hstr); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); sync(); // // // // // Set PID parameters: // SpireProc_Set_BsmChopPid(kp,ki,kd,debug); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SpireBb_SetBsmChopPid ended"); SpireMsg(1," ..Set BSM PID parameters (" + (time() - t) + " secs)"); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_EndPcalLevelCheck.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to reconfigure at the end of // SpirePhoto/Spectro_Cal_PcalLevelCheck // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // // 2009/05/07 V1.1: Initial version adapted from // SpireBb_EndBsmAngleCal (2009/05/05 V1.2), // SpirePhoto_Cal_PcalLevelCheck (2009/03/04 V1.4), and // SpireSpectro_Cal_PcalLevelCheck (2009/03/04 V0.5) // Incl. set dcuFrameNumber and scuFrameNumber back // to continuous to unset setting passed to VM. // 2009/06/05 V1.2: Replace Spire_SEND_DRCU_COMMAND with SpireSendDrcuCmd // as requested in SPR-1482. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_EndPcalLevelCheck SPIRE 14065 { bool phot = true; // Photometer (==tick) or FTS (==untick)? bool isBright = false in [true,false]; // IsBright (==tick) flag string version01 = "v00"; // Version in cal.tab. SpireTable_PhotModeParams string version02 = "v00"; // Version in cal.tab. SpireTable_CommonModeParams bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // int mode_id = 0; string obsmode = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB EndPcalLevelCheck reconfiguration started"); SpireMsg(2," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Set obsstep back to 0: // tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP(0)"); Spire_SET_OBS_STEP(0); // // // // // Set instrument back to Phot/Spec-STBY: // if(phot) { SpireProc_Set_PhotMode("PHTSTBY",isBright,version01,version02,debug); } else { SpireProc_Set_SpecMode("SPECSTBY",isBright,version01,version02,debug); } // // // // // Set number of DCU frames to continuous: // int dcuFrameNumber = 0; if(phot) { dcuFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","PHTSTBY","dcuFrameNumber","v00",debug); } else { dcuFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","SPECSTBY","dcuFrameNumber","v00",debug); } // SpireSendDrcuCmd(0x843d0000 + dcuFrameNumber,0); // // // // // Set number of SCU frames to continuous: // int scuFrameNumber = 0; if(phot) { scuFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","PHTSTBY","scuFrameNumber","v00",debug); } else { scuFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","SPECSTBY","scuFrameNumber","v00",debug); } SpireSendDrcuCmd(0xa0840000 + scuFrameNumber,0); delay(1); // // // // // End observation: // SpireProc_Set_EndObsAll(phot); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB EndPcalLevelCheck reconfiguration ended"); SpireMsg(1," ..Reconfiguration to " + obsmode + "mode (" + (time() - t) + " seconds)"); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_GetTableEntryBool.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to select a double entry in a calibration table // giving a string input as selector using the versioning approach. // // Note: Currently script is restricted to a 'string' selector! // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/01/26 V0.1: Initial version adapted from // SpireProc_CalcParam_FpgInitialPointing.txt (2008/11/06 V0.3) // 2009/07/12 V1.0: Fix SPR-SPIRE-1636 (reduce number of debug printouts) // Change default values for testing. // /////////////////////////////////////////////////////////////////////////// // bool procedure SpireProc_GetTableEntryBool { string tabName = "SpireTable_SpireParams.txt"; // Name of the table to be selected from string selCol = "mode"; // Name of column for selecting string selVal = "POF5_S_N"; // Value of 'string' selector string tarCol = "InitFlash"; // Target column name string version = "v00"; // Version parameter defined in calibration table bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Define some variable: // bool boolVar = true; // // Define columns: string[] versionCol = scolumn(tabName,"version"); bool[] targetCol = bcolumn(tabName,tarCol); string[] selectorCol = scolumn(tabName,selCol); // // Read table size: int nrows = table_size(tabName); // // // // // Cycle through values to get all rows with correct version tag: // //Setup: {bool,string}[] rows = [{true,""}]; int nindex = 0; bool match = false; // for(int j = 0 .. nrows - 1) { //if(debug) { // debug_print("versionCol[j]: " + versionCol[j]); //} if(versionCol[j] == version) { rows[nindex] = {targetCol[j],selectorCol[j]}; nindex = nindex + 1; match = true; } } //if(debug) { // debug_print("selected rows: " + rows); //} // Safety check: if(!match) { error("Calibration table empty or wrong version selected!"); } // // // // // Make final selection from all rows (selected by version): // int nentries = length(rows); int counter = 0; match = false; for(int i = 0 .. nentries - 1) { //if(debug) { // debug_print("rows sliced:" + rows[i]{0} + "/" + rows[i]{1}); //} if(rows[i]{1} == selVal) { boolVar = rows[i]{0}; match = true; counter = counter + 1; } } // Safety checks: if(!match) { error("Entry " + selVal + " not found in calibration table. Call for help and wait to be rescued!"); } // if(counter > 1) { error("Selector string " + selVal + " is present at least twice in the versioned calibration table. Please report this bug to the relevant authorities!"); } // // // // // Return required value: // if(debug) { debug_print(" If you believe it of not, I found " + tarCol + "=" + boolVar + " as version " + version + " when selecting for " + selCol + "=" + selVal + " in table " + tabName); } return boolVar; } // SpireBbPOF3Init // // $Id: SpireBbPOF3Init.txt,v 1.1 2006/08/10 09:38:58 kking Exp $ // // Building Block to initialise the instrument for POF3 (jiggle map) operation // // The complete instrument setup operation is divided into two parts: // Configuration: actions that can be executed during the slew to the start // position of the S/C pointing mode. // Initialisation: actions that must be carried out at the S/C intial pointing // position before any observational operations are executed. // // This building Block implements the second part of the setup // // 04 November 2008: // added data_rate commands // added commands to setup the detector sampling // block SpireBbPOF3Init SPIRE 8241 { }{ int t = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB POF3 Initialisation started"); SpireMsg(2," $Id: SpireBbPOF3Init.txt,v 1.1 2006/08/10 09:38:58 kking Exp $"); // // ..... configuration ..... // int cmd = 0x0; // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // set STEP to On Target tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP_RAW(0x8000)"); Spire_SET_OBS_STEP_RAW(0x8000); // // set detector offsets // set DCU data mode to Auto Offset cmd = 0x843c0010; SpireSendDrcuCmd(cmd,0); // start auto offset generation cmd = 0x843e0001; SpireSendDrcuCmd(cmd,0); delay(15); // // dump detector offsets // stop auto offset generation cmd = 0x843e0000; SpireSendDrcuCmd(cmd,0); // set DCU data mode to get offset data cmd = 0x843c0018; SpireSendDrcuCmd(cmd,0); // start offset data dump cmd = 0x843e0001; SpireSendDrcuCmd(cmd,0); // set datarate double rate = 0.0; rate = dlookup("Datarates.txt","POffsets","DCU"); data_rate(rate); delay(5); // stop offset data dump cmd = 0x843e0000; SpireSendDrcuCmd(cmd,0); data_rate(0.0); // // flush data tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_FLUSH_FIFO_RAW(0x1000)"); Spire_FLUSH_FIFO_RAW(0x1000); delay(2); // // set up detectors for operations // SpireConfigDcuData("POF3"); sync(); // // ..... completion ..... // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB POF3 Initialisation ended"); SpireMsg(1," ..POF3 Initialisation (" + (time() - t) + " seconds)"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpirePhoto_CalGCO_FovMapFpgScan.txt // /////////////////////////////////////////////////////////////////////////// // // CUS script for: 'Phot FOV Mapping Line Scan (FPG Scan)' // // in * line_scan_with_off_pointing * mode // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/09/11 V0.1: Initial version, adapted from // SpirePhoto_CalGCO_FovMappingFpgScan (2008/07/29 V0.7) // Renamed script; removed test number; removed SSOs, allow // scan in z direction; add debug_print switch; add // SpireProc_Set_ObsStep to line observation // 2008/09/16 V0.2: Add counter to OFF positions and remove first timing // message. Allow scan along 60deg symmetry axis. Change // description of input. Change formula for gcp_period_min. // Add temporary restriction to non-SSOs. // 2008/11/12 V0.3: Implement mode setting; Add isBright // 2009/02/02 V1.0: Add debug_print as input and pass it to some low // level scripts. Replace call to SpireProc_Set_ObsStep // with call to SpireBb_SetObsStep. Introduce // SpireBb_WaitAtGcp at GCP and use SpireBbScanLine during // the line scanning to collect data within defined BBIDs. // Use new SpireBb_EndObsAll and SpireBb_StartObsAll. // Implemented setting of datarates. Implemented isBright // setting. Read isbright pars fr.SpireTable_DetectorSettings. // 2009/02/18 V1.1: Update to new calibration table structure for Mode setting. // New setting of datarates. Use SpireBb_PhotSetMode to set // to PHOTSTBY during SLEW and FINAL_HOLD. Change call to // SpireBb_StartDcuData. // 2009/03/04 V1.2: Add isSerendipity, isPcal, and 8 more dummy parameters // to the script for future use. Set gcp_time to 20 (desired // value for SOVT2) // 2009/05/07 V1.3: Add in move BSM to hold at start. Gather procedures at // start and end in separate BB. // 2009/06/05 V1.4: Hardcode STBY 'v00' in EndBB (SPR-1477) // /////////////////////////////////////////////////////////////////////////// // Script assumes that: // // 1) Instrument is in PHOTSTBY // (i.e. bias amplitude, phase, frequency [mclkdiv,biasdiv] are nominal) // // 2) Bias frequency (mclkdiv) and sampling rate (biasdiv) are the same // for all three arrays and could be taken from following cal table: // SpireTable_PhotModeParams.txt // // 3) That currently the gyro reconstruction is only available for // non-SSO targets. // /////////////////////////////////////////////////////////////////////////// // obs SpirePhoto_CalGCO_FovMapFpgScan { /* ****************************************************** */ /* USER PARAMETER DEFINITION, CUS SIGNATURE for EX-HSpot */ /* ****************************************************** */ double ra = 0.0 in [0.0,360.0]; // RA of target [deg] double dec = 0.0 in [-90.0,90.0]; // DEC of target [deg] int naifid = 0; // Put '0' to use RA and DEC, otherwise put correct 'NAFID' /* */ bool isBright = false; // Use settings for bright source (==tick) bool refSelected = true; // ExpHSpot (refSelected) parameter bool refByOffset = true; // ExpHSpot (refByOffset) parameter double raoff = 0.0 in [0.0,360.0]; // RA of GCP position, or relative offset [deg] double decoff = 0.0 in [-90.0,90.0]; // DEC of GCP position, or relative offset [deg] string ib = "S14_0"; // Central aperture (defined in SIAM) of raster double d1 = 500.0 in [20.0,7200.0]; // Length of the scan line along scan axis [arcsec] double d2 = 31.4 in [2.0,480.0]; // Spacing of adjacent scan lines along orthogonal axis [arcsec] int n = 9 in [1,240]; // Number of raster lines or scan lines. double rate = 30.0 in [0.1,60.0]; // Scan rate of a line scan [arcsec/s] string scan_dir = "plusY" in ["plusY","minusY","plusZ","minusZ","30degplusYZ","210degminusYZ"]; // Scan direction of first line int gcp_time = 20; // Time spend at GCP (gyro calibration position) [s] int gcp_period = 600; // Maximum time between successiv GCP visits [s] string version01 = "v00"; // Version in cal table SpireTable_PhotModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams bool debug = false; // Allow (==tick) or suppress cus debug_print statements bool isSerendipity = true; // Allow (==tick) serendipity mode to be activated or prohibit (==untick) it (currently not in use)? bool isPcal = true; // Allow (==tick) regular PcalFlash in script or prohibit (==untick) it (currently not in use)?. bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ // // // // // Current restrictions: // if(naifid != 0) { error("Currently no SSO objects are allowed as input!"); } // // // // // Declare some variable: // // Photometer or FTS: bool phot = true; bool fts = !phot; // // Start timing of script: int start = time(); int linestart = time(); // // Line counter (start at 1): int linecount = 1; // // GCP counter (start at 1): int gcpcounter = 1; // string tabName = ""; string selCol = ""; string selVal = ""; string tarCol = ""; string version = ""; double scirate = 0.0; double chkrate = 0.0; double nhkrate = 0.0; // int obsStep = 0; // // Hardcoded calibration tables: // string tabName01 = "SpireTable_PhotModeParams.txt"; string tabName02 = "SpireTable_CommonModeParams.txt"; string tabName03 = "SpireTable_BsmNominalSettings.txt"; // // Currently hardcoded version and model parameter: // string version03 = "v00"; // Version in cal table SpireTable_BsmNominalSettings string model = "initial"; // Model in cal table SpireTable_BsmNominalSettings // // Dummy value for Spec script: // (needed but not used in phot script!) // int smecHomePosn = 3500; // SMEC home position // // // // // Setup mode: // // Set obsMode for QLA: string obsModeQla = "ENG_CAL_OBS04"; // Note: this needs entry in MIB table and in SpireTableInstConfigs.txt // // Set obsMode for datarates: string obsMode = "PEngCalObs"; // Note: this is currently only a maximum value // // // // // Increase scan length to allow time to mark start/end of the scan: // int tStart = 2; int tEnd = 2; // Note: the two 2 seconds are justified in SpireBbScanLine.txt d1 = d1 + double(tStart + tEnd) * rate; // // // // // Read BSM home parameters: // // Select version flag and set GetTableEntry parameters: // version = version03; tabName = tabName03; selCol = "model"; // Name of column for selecting selVal = model; // Value of 'string' selector // // Read hold position from calibration table: // tarCol = "chop_0_I"; int hold_chop = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "jigg_0_I"; int hold_jigg = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // // ****************************************************** */ // CALCULATE DURATIONS for POINTING STATES */ // ****************************************************** */ // // // // // Calculate timing for the pointing request: // // BBs called during slew: int tslewmin = duration(SpireBb_StartFovMapFpgScan(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,debug)); // // BBs carried out when the pointing is reached: int tinithold = duration(SpireBb_PhotOffsetAuto(debug)) + duration(SpireBb_StartDcuData()); // // BB carried out during pointing: //int tp = 0; // // BB carried at off position: int top = duration(SpireBb_WaitAtGcp(gcp_time,debug)); // == Time spent at the OFF position. // // BB carried out at the end: int tfinalhold = duration(SpireBb_EndFovMapFpgScan(phot,hold_chop,hold_jigg,isBright,version01,version02,debug)) + duration(SpireBb_StopDcuData()); // // Debug_printing? // if(debug) { debug_print("tslewmin = " + tslewmin); debug_print("tinithold = " + tinithold); //debug_print("tpointing = " + tp); debug_print("tfinalhold = " + tfinalhold); } // // ****************************************************** */ // POINTING MODE DECLARATION */ // ****************************************************** */ // // // // // Fixed parameters for pointing mode: // bool fixed = false; // Pattern orientation (true==sky; false==array) double yoff = 0.0; // Offset of pattern in the direction of the +Y double zoff = 0.0; // Offset of pattern in the direction of the +Z int nrepeat = 1; // [1,1200] Number of repetitions of the pattern. int thold = 0; // The duration of the hold when nhold>0. int nhold = 0; // Number of nods or raster points or scan lines before // // performing a hold. int nload = 0; // The number of slews (e.g. nods) before performing // // a load operation int tloadmin = 0; // The minimum duration of a load operation. // // // // // Select scan direction: // double patt = 90.0; // Rotation angle of the pattern // if(scan_dir == "plusY") { patt = 90.0; } if(scan_dir == "minusY") { patt = 270.0; } if(scan_dir == "plusZ") { patt = 0.0; } if(scan_dir == "minusZ") { patt = 180.0; } if(scan_dir == "30degplusYZ") { patt = 30.0; } if(scan_dir == "210degminusYZ") { patt = 210.0; } // // // // // Select the number (k) of scan lines before performing a measurement // at the GCP: // // Start with k=1: // int k = 1; // // Calculate times in pointing mode: // int[] ts_tr = line_scan_with_off_pointing(false,tslewmin,tinithold,tfinalhold,ib,naifid,ra,dec,fixed,patt,yoff,zoff,n,d1,d2,rate,k,top,raoff,decoff,nrepeat,thold,nhold,tloadmin,nload); // returns: {tobs, tslew, tacc, tdec, tl, tll, tsop, tload, tend} if(debug) { debug_print("Pointing vector for k=1: " + ts_tr); } int tacc = ts_tr[2]; // acceleration time int tdec = ts_tr[3]; // deceleration time int tl = ts_tr[4]; // time for actual scan of single line in map area int tll = ts_tr[5]; // turnaround time bewteen 2 lines int tsop = ts_tr[6]; // slew time from/to OFF position // Note: 'tsop' includes acceleration/deceleration time // // Calculate/check minimum time between successive visits to GCP position: // int gcp_period_min = tl + 2 * tsop + top; if(debug) { debug_print("gcp_period_min: " + gcp_period_min); } if(gcp_period_min > gcp_period) { error("Maximum time between successiv GCP visits smaller than minimum time between two possible visits!"); } // // Loop to find best k: // // Calculate time between two offset positions: int tboff = k * tl + (k - 1) * tll + (k - 1) * (tacc + tdec) + 2 * tsop + gcp_time; if(debug) { debug_print("Time between two offset positions: " + tboff); } // do { k = k + 1; // // Calculate new time between two offset positions: tboff = k * tl + (k - 1) * tll + 0 * (tacc + tdec) + 2 * tsop + gcp_time; if(debug) { debug_print("k is now: " + k); debug_print("New time between two offset positions: " + tboff); } } while (tboff < gcp_period); // // Set best k: // if(k > 1) { // use previous k values k = k - 1; } if(k > n) { // k must not be larger than number of lines k = n; } if(debug) { debug_print("selected k is: " + k); } // // // // // Set pointing mode: // //int[] ts = line_scan_with_off_pointing(true,tslewmin,tih,tfh,ib,naifid, // ra,dec,fixed,patt,yoff,zoff,n,d1,d2,rate,k,top,raoff,decoff,nrepeat, // thold,nhold,tloadmin,nload); // int[] ts = line_scan_with_off_pointing(true,tslewmin,tinithold,tfinalhold,ib,naifid,ra,dec,fixed,patt,yoff,zoff,n,d1,d2,rate,k,top,raoff,decoff,nrepeat,thold,nhold,tloadmin,nload); // // // // // // Fill in timings of actual pointing mode: tacc = ts[2]; // acceleration time tdec = ts[3]; // deceleration time tl = ts[4]; // time for actual scan of single line in map area tll = ts[5]; // turnaround time bewteen 2 lines tsop = ts[6]; // slew time from/to OFF position // Note: 'tsop' includes acceleration/deceleration time if(debug) { debug_print("Output timing vector from the pointing request: " + ts); debug_print("Time for actual scan of single line in requested area: " + tl); } // // // // // }{ // ****************************************************** */ // POINTING STATES WITH OBSERVING MODE LOGIC */ // ****************************************************** */ // // // // // Set datarates: // string rateType = "chk"; chkrate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); ess_hk_data_rate(chkrate); // rateType = "nhk"; // nhkrate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); non_ess_hk_data_rate(nhkrate); // rateType = "sci"; scirate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); data_rate(scirate); // if(debug) { debug_print("Set CHK datarate to: " + chkrate); debug_print("Set NHK datarate to: " + nhkrate); debug_print("Set SCI datarate to: " + scirate); } // // // Start the state_machine: // int[] state = [0]; // while(state[0] >= 0) { if(debug) { debug_print("Current state: " + state); } state = next_state(); if(debug) { debug_print("Next state: " + state); } // if(state[0] == 1) { // STATE = SLEW ( Spacecraft is slewing ) // // // // // Startup observation: // SpireBb_StartFovMapFpgScan(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,debug); // //delay(timeSlewCal); } if(state[0] == 2) { // STATE = INIT_HOLD (spacecraft is idling at source) // //delay(tinithold); // // // // // Set offsets: // SpireBb_PhotOffsetAuto(debug); // // // // // Start data generation before scan: // SpireBb_StartDcuData(); // } if(state[0] == 4) { // STATE = OFF position // // // // // Show time elapsed between visits to GCP: // int t = time() - start; if(gcpcounter > 1) { message("Time elapsed since last visit to GCP: " + t); if(debug) { debug_print("Time elapsed since last visit to GCP: " + t); } } gcpcounter = gcpcounter + 1; // // Reset timer: start = time(); // // // // // Wait at GCP: // SpireBb_WaitAtGcp(gcp_time,debug); // } if(state[0] == 5) { // STATE = FINAL_HOLD ( "sky" observation ends, performing final activities ) // // // // // Stop data generation after scan: // SpireBb_StopDcuData(); // // // // // Set scientific datarate back to zero: // data_rate(0.0); // // // // // Reconfigure at the end (incl. resetting of OBSID and BBIB): // // Hardcode STBY values for resetting (SPR-1477): // version01 = "v00"; version02 = "v00"; version03 = "v00"; model = "initial"; // SpireBb_EndFovMapFpgScan(phot,hold_chop,hold_jigg,isBright,version01,version02,debug); // } if(state[0] == 6) { //delay(thold); } if(state[0] == 8) { // STATE = ( line ) // // // // // // Start timing: // int tscan = time(); // // // // // Debug printing // if(debug) { debug_print("state[0]: " + state[0]); debug_print("state[1]: " + state[1]); debug_print("state[2]: " + state[2]); debug_print("linecount: " + linecount); } // if(linecount == 1) { linestart = time(); } else { int tline = time() - linestart; if(debug) { debug_print("Time elapsed since first line: " + tline); } } // // // // // Wait while scan is performed: // SpireBbScanLine(tl,linecount); linecount = linecount + 1; // } if(state[0] == 9) { //delay(tloadmin); } if(state[0] == -1) { // STATE = END ( end of the pointing/commanding part of the code ) // } } } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_EndFpgInitialPointing.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to reconfigure at the end of // SpirePhoto/Spectro_CalGCO_FpgInitialPointing. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // // 2009/05/05 V1.0: Initial version adapted from // SpireBb_EndBsmAngleCal (2009/05/05 V1.2), // SpirePhoto_CalGCO_FpgInitialPointing (2009/03/03 V1.3), and // SpireSpectro_CalGCO_FpgInitialPointing (2009/03/03 V0.4) // 2009/05/07 V1.1: Set dcuFrameNumber and mcuFrameNumber back to continuous // to unset setting passed to VM. // 2009/06/05 V1.2: Replace Spire_SEND_DRCU_COMMAND with SpireSendDrcuCmd // as requested in SPR-1482. // 2009/07/03 V1.3: Set SMEC framerate back to SPEC_STBY. It was switched off // for this test during SpireBb_StartFpgInitialPointing.txt // /////////////////////////////////////////////////////////////////////////// // block SpireBb_EndFpgInitialPointing SPIRE 14055 { bool phot = true; // Photometer (==tick) or FTS (==untick)? int hold_chop = 37632; // Chop hold position [Dec(Hex)] int hold_jigg = 39520; // Jiggle hod position [Dec(Hex)] bool isBright = false in [true,false]; // IsBright (==tick) flag string version01 = "v00"; // Version in cal.tab. SpireTable_PhotModeParams string version02 = "v00"; // Version in cal.tab. SpireTable_CommonModeParams bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // int mode_id = 0; string obsmode = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB EndFpgInitialPointing reconfiguration started"); SpireMsg(2," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Set obsstep back to 0: // tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP(0)"); Spire_SET_OBS_STEP(0); // // // // // Set instrument back to Phot/Spec-STBY: // if(phot) { SpireProc_Set_PhotMode("PHTSTBY",isBright,version01,version02,debug); } else { SpireProc_Set_SpecMode("SPECSTBY",isBright,version01,version02,debug); } // // // // // Move BSM back to hold: // SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug); // // // // // Set number of DCU frames to continuous: // int dcuFrameNumber = 0; if(phot) { dcuFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","PHTSTBY","dcuFrameNumber","v00",debug); } else { dcuFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","SPECSTBY","dcuFrameNumber","v00",debug); } // SpireSendDrcuCmd(0x843d0000 + dcuFrameNumber,0); // // // // // Set number of MCU frames to continuous: // int mcuFrameNumber = 0; if(phot) { mcuFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","PHTSTBY","mcuFrameNumber","v00",debug); } else { mcuFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","SPECSTBY","mcuFrameNumber","v00",debug); } SpireSendDrcuCmd(0x91c30000 + mcuFrameNumber,0); delay(1); // // // // // Set SMEC framerate (== SMEC sampling rate) back to SPEC_STBY: // (Note, hardcoded version to go back to STBY) // if(!phot) { int smecFrameRate = SpireProc_GetTableEntryInt("SpireTable_SpecModeParams.txt","mode","SPECSTBY","smecFrameRate","v00",debug); SpireProc_Set_SmecFramerate(smecFrameRate,debug); } // // // // // End observation: // SpireProc_Set_EndObsAll(phot); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB EndFpgInitialPointing reconfiguration ended"); SpireMsg(1," ..Reconfiguration to " + obsmode + "mode (" + (time() - t) + " seconds)"); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_PcalOn.txt // /////////////////////////////////////////////////////////////////////////// // // BB to set on PCAL to input PCAL bias level. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/04/01 V0.1: Initial version adapted from // SpireBb_PcalFlash (2009/02/18 V1.4) // // Note, by setting pcal_bias to 0.0 the same script switches OFF PCAL. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_PcalOn SPIRE 14040 { double pcal_bias = 3.8 in [0.0,7.0]; // PCAL bias level [mA] string version = "v01"; // Version in cal table SpireTable_PcalCurrentConvCoef bool debug = false; }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB PcalOn started"); SpireMsg(2," $Id:$"); // // // // // Set the BBID and STEP: // // Set BBID: hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // // // // Set PCAL bias: // SpireProc_PcalOn(pcal_bias,version,debug); // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB PcalOn ended"); SpireMsg(1," ..PcalOn (" + (time() - t) + " seconds)"); } // Reset default CCU monitoring period after cooler recycling // command SpireCcuMonitorPeriodDefault HFKACQP1 { } { bus_schedule(SC, 6); } /////////////////////////////////////////////////////////////////////////// // // SpireProc_CalcParam_FovMapCrossRaster.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to calculate the positions of a cross raster to be used // in a custom_map pointing mode for photometer and spectrometer. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/03/16 V1.0: Initial version renamed from // SpireProc_CalcParam_PhotFovMapCrossRaster (2008/08/04 V0.1) // Move debug option to input. // /////////////////////////////////////////////////////////////////////////// // {double[],double[],bool[]} procedure SpireProc_CalcParam_FovMapCrossRaster { double d1 = 4.0 in [2.0,480.0]; // Angular stepsize along Y axis [arcsec] double d2 = 4.0 in [2.0,480.0]; // Angular stepsize along Z axis [arcsec] int m = 5 in [3,2997]; // Number of points in the Y direction [odd number!] int k = 0 in [0,999]; // Additional visits to GCP on each hand of the cross bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Set fixed parameters: // int n = m; // Number of points in the Z direction [odd number!] // --> only symmetric cross raster allowed // // // // // Calculate arrays for custom_map pointing: // double[] yarray = [0.0]; double[] zarray = [0.0]; bool[] raster = [false]; // // Set center as starting point: // yarray[0] = 0.0; zarray[0] = 0.0; raster[0] = false; // // Setup: // int index = 1; int zindex = 1; int ystart = -1 * iceil(0.5 * double(m - 1)); int zstart = -1 * iceil(0.5 * double(n - 1)); int numtrue = iceil(0.5 * double(m - 1) / double(k + 1)); int nysteps = -2 * ystart + 1; int nzsteps = -2 * zstart + 1; if(debug) { debug_print("ystart/zstart: " + ystart + "/" + zstart); debug_print("numtrue: " + numtrue); } // // Y-axis: // do { if(debug) { debug_print("Setting up Y-axis"); } yarray[index] = double(ystart) * d1 + double(index - 1) * d1; zarray[index] = 0.0; // Mark GCPs: if(yarray[index] == 0.0) { raster[index] = false; } else { raster[index] = true; } index = index + 1; } while (index < nysteps + 1); // // Add visit to center at end of Y-raster: // yarray[index] = 0.0; zarray[index] = 0.0; raster[index] = false; index = index + 1; // // Z-axis: // do { if(debug) { debug_print("Setting up Z-axis"); } zarray[index] = double(zstart) * d2 + double(zindex - 1) * d2; yarray[index] = 0.0; if(zarray[index] == 0.0) { raster[index] = false; } else { raster[index] = true; } index = index + 1; zindex = zindex + 1; } while (zindex < nzsteps + 1); // // Add visit to center at end: // yarray[index] = 0.0; zarray[index] = 0.0; raster[index] = false; // // printing: // if(debug) { debug_print("yarray: " + yarray); debug_print("zarray: " + zarray); debug_print("raster: " + raster); debug_print("length(ystart/zstart/raster): " + length(yarray) + "/" + length(zarray) + "/" + length(raster)); } // // // // // Add additional visits to GCP: // double[] yarray_new = [0.0]; double[] zarray_new = [0.0]; bool[] raster_new = [false]; // int end = length(raster); int nindex = 0; int tcount = 0; for(int counter = 1 .. end) { if(debug) { debug_print("Loop number: " + counter); debug_print("end: " + end); debug_print("nindex: " + nindex); debug_print("tcount: " + tcount); } if(raster[counter - 1] == true) { if(tcount == numtrue) { // Check if next point is not a visit to GCP: //if (raster[(counter)] == true) //{ debug_print("Add visit to GCP!"); yarray_new[nindex] = 0.0; zarray_new[nindex] = 0.0; raster_new[nindex] = false; nindex = nindex + 1; //} yarray_new[nindex] = yarray[counter - 1]; zarray_new[nindex] = zarray[counter - 1]; raster_new[nindex] = true; nindex = nindex + 1; // Reset tcount tcount = 0; } else { yarray_new[nindex] = yarray[counter - 1]; zarray_new[nindex] = zarray[counter - 1]; raster_new[nindex] = true; nindex = nindex + 1; } tcount = tcount + 1; } else { // reset true counter: tcount = 0; yarray_new[nindex] = yarray[counter - 1]; zarray_new[nindex] = zarray[counter - 1]; raster_new[nindex] = false; nindex = nindex + 1; } counter = counter + 1; } // if(debug) { debug_print("yarray: " + yarray_new); debug_print("zarray: " + zarray_new); debug_print("raster: " + raster_new); debug_print("length(ystart/zstart/raster): " + length(yarray_new) + "/" + length(zarray_new) + "/" + length(raster_new)); } // return {zarray_new,yarray_new,raster_new}; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpirePhoto_Cal_LoadCurvePcalOn.txt // /////////////////////////////////////////////////////////////////////////// // // CUS script for: 'Phot Load Curve with PCAL on' // // in *basic_fine_pointing* or *no_pointing* mode // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/04/01 V0.1: Initial version adapted from // SpirePhoto_Cal_StdLoadCurve (2009/03/04 V1.3) // 2009/05/06 V0.2: Add in move BSM to hold at start. Gather procedures at // start and end in separate BB. // 2009/06/05 V1.0: Hardcode STBY 'v00' in EndBB (SPR-1477) // /////////////////////////////////////////////////////////////////////////// // // Script assumes that: // // 1) Instrument is in PHOTSTBY at beginning // (i.e. bias amplitude, phase, frequency [mclkdiv,biasdiv] are nominal) // // 2) Phase is kept constant (from input) during this test, i.e no // adjustment of the phase with changing bias amplitude and frequency // // 3) Bias frequency, sampling rate, and phase are input parameters // // 4) Boresight of array can be read from following cal table: // SpireTable_OpsParms.txt // // 5) PCAL bias calibration coefficients are read from following cal table: // SpireTable_PcalCurrentConvCoef.txt // // 6) List of bias amplitudes are read from same calibration file as for the // SpirePhoto_Cal_StdLoadCurve, i.e. SpireTable_StdLoadCurveLevels.txt // /////////////////////////////////////////////////////////////////////////// // obs SpirePhoto_Cal_LoadCurvePcalOn { /* ****************************************************** */ /* USER PARAMETER DEFINITION, CUS SIGNATURE for EX-HSpot */ /* ****************************************************** */ /* */ double ra = 0.0 in [0.0,360.0]; // RA of target double dec = 0.0 in [-90.0,90.0]; // DEC of target int naifid = 0; // NAIF identifier bool isBright = false; // Use settings for bright source (==tick) bool pointing = true; // Should telescope 'point' (==tick) or do a 'no pointing' (==untick)? /* */ double biasfreq = 130.2 in [70.0,200.0]; // Bias frequency [Hz] double samplerate = 18.6 in [1.0,20.0]; // Sampling rate [Hz] (Careful, don't exceed number of data packages to be transferred from spacecraft!) double phasedeg_psw = 180.7 in [0.0,360.0]; // PSW Bias phase [deg] double phasedeg_pmw = 180.7 in [0.0,360.0]; // PMW Bias phase [deg] double phasedeg_plw = 180.7 in [0.0,360.0]; // PLW Bias phase [deg] double phasedeg_ptc = 180.7 in [0.0,360.0]; // PTC Bias phase [deg] int ftime = 10; // Readout time at each bias level [s] double pcal_bias = 3.8 in [0.0,7.0]; // PCAL bias level [mA] string version01 = "v00"; // Version in cal table SpireTable_PhotModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams string version03 = "v00"; // Version in cal table SpireTable_StdLoadCurveLevels string version05 = "v00"; // Version in cal table SpireTable_OpsParms.txt string version09 = "v01"; // Version in cal table SpireTable_PcalCurrentConvCoef bool debug = false; // Allow (==tick) or suppress cus debug_print statements bool isSerendipity = true; // Allow (==tick) serendipity mode to be activated or prohibit (==untick) it (currently not in use)? bool isPcal = true; // Allow (==tick) regular PcalFlash in script or prohibit (==untick) it (currently not in use)?. bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ // ****************************************************** */ // CALCULATE DURATIONS for POINTING STATES */ // ****************************************************** */ // // // // // Check for is bright setting: // if(isBright) { isBright = false; error("IsBright does not make sense here. Try again (e.g. subtract the phase shift manually from the input)!"); } // // // // // Declare some variable: // // Photometer or FTS: bool phot = true; bool fts = !phot; // string tabName = ""; string selCol = ""; string selVal = ""; string tarCol = ""; string version = ""; double scirate = 0.0; double chkrate = 0.0; double nhkrate = 0.0; // int obsStep = 0; // // Hardcoded calibration tables: // string tabName01 = "SpireTable_PhotModeParams.txt"; string tabName02 = "SpireTable_CommonModeParams.txt"; string tabName03 = "SpireTable_StdLoadCurveLevels.txt"; string tabName04 = "SpireTable_BsmNominalSettings.txt"; string tabName05 = "SpireTable_OpsParms.txt"; string tabName09 = "SpireTable_PcalCurrentConvCoef.txt"; // // Currently hardcoded version and model parameter: // string version04 = "v00"; // Version in cal table SpireTable_BsmNominalSettings string model = "initial"; // Model in cal table SpireTable_BsmNominalSettings // // Dummy value for Spec script: // (needed but not used in phot script!) // int smecHomePosn = 3500; // SMEC home position int ssw_bias = 45; // int slw_bias = 45; // int ssw_phase = 128; // int slw_phase = 128; // // // // // // Setup mode: // // Set obsMode for QLA: string obsModeQla = "ENG_CAL_OBS15"; // Note: this needs entry in MIB table and in SpireTableInstConfigs.txt // // Set obsMode for datarates: string obsMode = "PEngCalObs"; // Note: this is currently only a maximum value // // // // // Retrieve bias levels used for the load curve: // tabName = tabName03; version = version03; int[] nbiaslist = SpireProc_CalcParam_LoadCurve(tabName,version,debug); // // Lookup first bias level: int psw_bias = nbiaslist[0]; int pmw_bias = nbiaslist[0]; int plw_bias = nbiaslist[0]; int ptc_bias = nbiaslist[0]; // // // // // Convert user input to Hex values: // // for bias frequency and sample rate: // int[] hexvalues = SpireProc_CalcParam_BiasFreqSampFreq(biasfreq,samplerate,fts,debug); int mclkdiv = hexvalues[0]; int biasdiv = hexvalues[1]; if(debug) { debug_print("Hex values of mclkdiv/biasdiv are: " + mclkdiv + " " + biasdiv); } // // for bias phase: // int[] phasehex = SpireProc_CalcParam_PhotPhaseConvert(phasedeg_psw,phasedeg_pmw,phasedeg_plw,phasedeg_ptc,debug); int psw_phase = phasehex[0]; int pmw_phase = phasehex[1]; int plw_phase = phasehex[2]; int ptc_phase = phasehex[3]; // // // // // Read BSM home parameters: // // Select version flag and set GetTableEntry parameters: // version = version04; tabName = tabName04; selCol = "model"; // Name of column for selecting selVal = model; // Value of 'string' selector // // Read hold position from calibration table: // tarCol = "chop_0_I"; int hold_chop = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "jigg_0_I"; int hold_jigg = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // Calculate timing for the pointing request: // // BBs called during slew: int tslewmin = duration(SpireBb_StartLoadCurvePcalOn(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,mclkdiv,biasdiv,psw_bias,pmw_bias,plw_bias,ptc_bias,psw_phase,pmw_phase,plw_phase,ptc_phase,ssw_bias,slw_bias,ssw_phase,slw_phase,debug)); // // BBs carried out when the pointing is reached: if(pointing) { int tinithold = 0; } else { tinithold = tslewmin; } // // BB carried out during pointing: int tp = duration(SpireProc_Exec_PhotLoadCurvePcalOn(nbiaslist,ftime,pcal_bias,version09,debug)); // // BB carried out at the end: int tfinalhold = duration(SpireBb_EndLoadCurvePcalOn(phot,isBright,version01,version02,debug)); // if(debug) { debug_print("tslewmin = " + tslewmin); debug_print("tinithold = " + tinithold); debug_print("tpointing = " + tp); debug_print("tfinalhold = " + tfinalhold); } // // ****************************************************** */ // POINTING MODE DECLARATION */ // ****************************************************** */ // // // // // Lookup boresight: // tabName = tabName05; selCol = "mode"; selVal = obsMode; tarCol = "Boresight"; version = version05; string ib = SpireProc_GetTableEntryString(tabName,selCol,selVal,tarCol,version,debug); // // Set pointing mode: // if(pointing) { int[] ts = basic_fine_pointing(true,tslewmin,tinithold,tfinalhold,ib,naifid,ra,dec,0.0,0.0,tp); } else { ts = no_pointing(true,tinithold,tfinalhold,tp); } // if(debug) { debug_print("Output timing vector from the pointing request: " + ts); } // }{ // ****************************************************** */ // POINTING STATES WITH OBSERVING MODE LOGIC */ // ****************************************************** */ // // // // // Set datarates: // string rateType = "chk"; chkrate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); ess_hk_data_rate(chkrate); // rateType = "nhk"; // nhkrate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); non_ess_hk_data_rate(nhkrate); // rateType = "sci"; scirate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); data_rate(scirate); // if(debug) { debug_print("Set CHK datarate to: " + chkrate); debug_print("Set NHK datarate to: " + nhkrate); debug_print("Set SCI datarate to: " + scirate); } // // Start the state_machine: // int[] state = [0]; // while(state[0] >= 0) { if(debug) { debug_print("Current state: " + state); } state = next_state(); if(debug) { debug_print("Next state: " + state); } // if(state[0] == 1) { // STATE = SLEW ( Spacecraft is slewing ) // // // // // Startup observation: // SpireBb_StartLoadCurvePcalOn(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,mclkdiv,biasdiv,psw_bias,pmw_bias,plw_bias,ptc_bias,psw_phase,pmw_phase,plw_phase,ptc_phase,ssw_bias,slw_bias,ssw_phase,slw_phase,debug); // //delay(timeSlewCal); } if(state[0] == 2) { // STATE = INIT_HOLD ( spacecraft is idling at source ) // // // // // If no pointing observation do stuff here which is // done nominally during SLEW: // if(!pointing) { // // // // // Startup observation: // SpireBb_StartLoadCurvePcalOn(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,mclkdiv,biasdiv,psw_bias,pmw_bias,plw_bias,ptc_bias,psw_phase,pmw_phase,plw_phase,ptc_phase,ssw_bias,slw_bias,ssw_phase,slw_phase,debug); // } // //delay(tinithold); // } if(state[0] == 3) { // STATE = POINT ( spacecraft is at nominal RA,DEC (staring, raster) ) // // // // // // Execute load curve with PCAL on: // SpireProc_Exec_PhotLoadCurvePcalOn(nbiaslist,ftime,pcal_bias,version09,debug); // //delay(tp); // } if(state[0] == 5) { // STATE = FINAL_HOLD ( "sky" observation ends, performing final activ.) // // // // // Set scientific datarate back to zero: // data_rate(0.0); // // // // // Reconfigure at the end (incl. resetting of OBSID and BBIB): // // Hardcode STBY values for resetting (SPR-1477): // version01 = "v00"; version02 = "v00"; // SpireBb_EndLoadCurvePcalOn(phot,isBright,version01,version02,debug); // } if(state[0] == -1) { // STATE = END ( end of the pointing/commanding part of the code ) // } } } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_PcalFlash.txt // /////////////////////////////////////////////////////////////////////////// // // BB to perform photometer PCAL flash via VM // // Note: VM does not reset dcusample/bsmsample at end, so this needs // to be done in the surrounding end script. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/11/07 V0.1: Initial version adapted from // SpireBb_PCALFlash (2008/08/12 V0.1) // Change name 'PCAL' to 'Pcal' // 2009/01/27 V1.0: (KJK) Updated for use by Cal and AOT observations. // Added more input parameters (vmId,vmIndex,nParms, // rate, step, debug). Added Hspot messages. Now reset // and flush all fifos (MCU data could be generated). // Remove 'set number of frames to continuous' this // needs to be done at the very end of the observation. // Replaced delay(1) with sync() at the end. Removed // BBID unsetting. Added more comments. Now include // setting of NHK STEP parameter. Adding setting // and unsetting of datarate. // 2009/01/30 V1.1: (MP) Adding more information to header above. // Adding delay(2) after FLUSH_FIFO. // 2009/02/11 V1.2: (KJK) Made some changes. // Fix bug in calculation of wait_time. Removed // pcal_dcudelay and reduced the 10sec to 1sec. // The 10 was a left-over from the old IST script. // Replaced call to Spire_SEND_DRCU_COMMAND with // SpireSendDrcuCmd. Ditto for Spire_SET_OBS_STEP_RAW // use now SpireProc_Set_ObsStep. // 2009/02/13 V1.3: (MP) Adding more information about changes to header above. // 2009/02/18 V1.4: (MP) Replace all commands by call to new low level // procedure SpireProc_PcalFlash. Removing the datarate // setting. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_PcalFlash SPIRE 14009 { int vmId = 0x46; int vmIndex = 0; int nParms = 9; int pcal_lowbias = 100; int pcal_highbias = 2000; int pcal_ncycles = 8; int pcal_period = 250000; int pcal_dcumode = 3; int pcal_ndcusamples = 11; int pcal_dcudelay = 12000; int pcal_scumode = 0; int pcal_scusamples = 9; int step = 0; bool debug = false; }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB PcalFlash started"); SpireMsg(2," $Id:$"); // // // // // Set the BBID and STEP: // // Set BBID: hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // // // // Reset all fifos: // SpireProc_PcalFlash(vmId,vmIndex,nParms,pcal_lowbias,pcal_highbias,pcal_ncycles,pcal_period,pcal_dcumode,pcal_ndcusamples,pcal_dcudelay,pcal_scumode,pcal_scusamples,step,debug); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB PcalFlash ended"); SpireMsg(1," ..PcalFlash (" + (time() - t) + " seconds)"); } // SpirePOF2Estimate // // $Id:$ // // This procedure calculates the estimated noise and signal/noise // for the given observing time. // // for input values, a value less than 0 indicates value unknown // // // 20/04/07: v1.3: SCR3054 // v1.4: SCR3012 // 07/02/09: Updated to select sensitivity tables depending on value of isBright // // {string,double,double,double,double,bool}[] procedure SpirePOF2Estimate { double osit = 0.0; // on-source integration time double sourceFluxPSW = -1.0; double sourceFluxPMW = -1.0; double sourceFluxPLW = -1.0; bool isBright = false; }{ SpireMsg(3," Calculating POF2 noise estimates"); SpireMsg(3," $Id:$"); SpireMsg(3," Input:"); SpireMsg(3," Osit: " + osit); SpireMsg(3," PSWFlux: " + sourceFluxPSW); SpireMsg(3," PMWFlux: " + sourceFluxPMW); SpireMsg(3," PLWFlux: " + sourceFluxPLW); SpireMsg(3," isBright: " + isBright); // // fetch the flux uncertainty information for POF2 string tabName = "Phot_Sensitivities.txt"; if(isBright) { tabName = "Phot_BrightSensitivities.txt"; } double psw_func = dlookup(tabName,"POF2","PSWFluxUnc"); double pmw_func = dlookup(tabName,"POF2","PMWFluxUnc"); double plw_func = dlookup(tabName,"POF2","PLWFluxUnc"); // fetch confusion limits double psw_conf = dlookup(tabName,"POF2","PSWConfLim"); double pmw_conf = dlookup(tabName,"POF2","PMWConfLim"); double plw_conf = dlookup(tabName,"POF2","PLWConfLim"); SpireMsg(3," Input Sensitivity Values:"); SpireMsg(3," Band: PSW PMW PLW"); SpireMsg(3," Flux Uncertainty: " + psw_func + " " + pmw_func + " " + plw_func); SpireMsg(3," Conf Limit: " + psw_conf + " " + plw_conf + " " + plw_conf); // // calculate noise estimates {string,double,double,double,double,bool}[] estimates = [{"250",sourceFluxPSW,-1.0,-1.0,psw_conf,false},{"350",sourceFluxPMW,-1.0,-1.0,pmw_conf,false},{"500",sourceFluxPLW,-1.0,-1.0,plw_conf,false}]; estimates[0]{2} = psw_func / sqrt(osit); if(estimates[0]{2} < psw_conf) { estimates[0]{5} = true; } if(sourceFluxPSW >= 0.0) { estimates[0]{3} = sourceFluxPSW / estimates[0]{2}; if(estimates[0]{3} > 200.0) { estimates[0]{3} = 200.0; } } estimates[1]{2} = pmw_func / sqrt(osit); if(estimates[1]{2} < pmw_conf) { estimates[1]{5} = true; } if(sourceFluxPMW >= 0.0) { estimates[1]{3} = sourceFluxPMW / estimates[1]{2}; if(estimates[1]{3} > 200.0) { estimates[1]{3} = 200.0; } } estimates[2]{2} = plw_func / sqrt(osit); if(estimates[2]{2} < plw_conf) { estimates[2]{5} = true; } if(sourceFluxPLW >= 0.0) { estimates[2]{3} = sourceFluxPLW / estimates[2]{2}; if(estimates[2]{3} > 200.0) { estimates[2]{3} = 200.0; } } // // return values SpireMsg(3," Output Estimates:"); SpireMsg(3," Band: " + estimates[0]{0} + " " + estimates[1]{0} + " " + estimates[2]{0}); SpireMsg(3," Source Flux " + estimates[0]{1} + " " + estimates[1]{1} + " " + estimates[2]{1}); SpireMsg(3," 1 Sigma Noise: " + estimates[0]{2} + " " + estimates[1]{2} + " " + estimates[2]{2}); SpireMsg(3," Signal/Noise: " + estimates[0]{3} + " " + estimates[1]{3} + " " + estimates[2]{3}); SpireMsg(3," Conf Level: " + estimates[0]{4} + " " + estimates[1]{4} + " " + estimates[2]{4}); SpireMsg(3," Conf Flag: " + estimates[0]{5} + " " + estimates[1]{5} + " " + estimates[2]{5}); // return estimates; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////// // // SpireProc_Set_PhotPhase // /////////////////////////////////////////////////////////// // // Procedure to configure the photometer detector phases // /////////////////////////////////////////////////////////// // // KJK: // 2009/02/11 V0.1: Initial version adapted from // SpireBb_PhotFSetPhase (MP 2009/01/27 V1.0) // 2009/02/14 V0.2: (MP) Use actual phases as input instead of mode. // Added delay(1). Add some cosmetics to script. // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Set_PhotPhase { int psw_phase = 0x0 in [0,255]; //Default phase is 0 [Hex] int pmw_phase = 0x0 in [0,255]; //Default phase is 0 [Hex] int plw_phase = 0x0 in [0,255]; //Default phase is 0 [Hex] int ptc_phase = 0x0 in [0,255]; //Default phase is 0 [Hex] bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Define some variables: // string tstr = ""; // // // // // Start procedure: // tstr = SpireTimeStr(time()); SpireMsg(4," " + tstr + ": SpireProc_Set_PhotPhase started"); SpireMsg(4," $Id:$"); // // // // // Set the selected phases: // // Set the phases for the three arrays: SpireSendDrcuCmd(0x841a0000 + psw_phase,0); SpireSendDrcuCmd(0x841b0000 + pmw_phase,0); delay(1); SpireSendDrcuCmd(0x841c0000 + plw_phase,0); // // Set the phase for the PTC: SpireSendDrcuCmd(0x841d0000 + ptc_phase,0); sync(); // // // // // Debug Printing: // double psw_phase_deg = 360.0 * double(psw_phase) / 255.0; double pmw_phase_deg = 360.0 * double(pmw_phase) / 255.0; double plw_phase_deg = 360.0 * double(plw_phase) / 255.0; double ptc_phase_deg = 360.0 * double(ptc_phase) / 255.0; if(debug) { debug_print("psw phase is set to " + psw_phase + " [Dec(Hex)] " + psw_phase_deg + " [deg]"); debug_print("pmw phase is set to " + pmw_phase + " [Dec(Hex)] " + pmw_phase_deg + " [deg]"); debug_print("plw phase is set to " + plw_phase + " [Dec(Hex)] " + plw_phase_deg + " [deg]"); debug_print("ptc phase is set to " + ptc_phase + " [Dec(Hex)] " + ptc_phase_deg + " [deg]"); } // // // // // End procedure: // tstr = SpireTimeStr(time()); SpireMsg(4," " + tstr + ": SpireProc_Set_PhotPhase ended"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////// // // SpireProc_Exec_PhotMultiLevelNoise.txt // /////////////////////////////////////////////////////////// // // Procedure to loop through a list of bias amplitudes for // the 'Phot Multi-Level Noise' task setting the correct // phase included in calibration table. // /////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/06/14 V0.1: Initial version adapted from // Mode_ILT_PERF_DAB_P_Levels.txt (v1.3 2008/01/31 23:35:17) // 2008/07/03 V0.2: Renumber version; SpireBb_PhotFSetupData has extra parameter // 2008/08/04 V0.3: Allow separate phase for each array (including PTC) // 2008/09/22 V0.4: Remove test number; Adapt to change in cal table setup // 2009/01/31 V1.0: Add debug_print option (also to low level scripts). // In loop only set bias amplitude and phase at each level. // 2009/02/17 V1.1: Fixed bug biasfreq and samplerate were set each // time in loop. // 2009/03/04 V1.2: Implement isBright setting in the way of adapting // the phase at each bias amplitude level. // Sunil Sidher // 2009/07/21 V1.3: Implemented isPcal flag to perform standard AOT style PCAL flashes after each bias setting // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Exec_PhotMultiLevelNoise { double biasfreq = 130.2; // Bias frequency (Hz) double samplerate = 18.6; // Sampling frequency (Hz) string tabName01 = "SpireTable_PhotMultiLevelNoiseLevels.txt"; // Calibration table name string version01 = "v00"; // Version parameter defined in calibration table bool isBright = false; // Use settings for bright source (==tick) bool isPcal = true; // Allow (==tick) regular PcalFlash in script or prohibit (==untick) it? string tabName02 = "SpireTable_IsBrightPhaseShift.txt"; // Calibration table name string version02 = "v00"; // Version parameter defined in calibration table int ftime = 300; // Readout time at each bias level [s] bool debug = false; // Allow (==tick) or suppress cus debug_print statement }{ // // // // // Declare some variable: // // Photometer or FTS: bool phot = true; bool fts = !phot; // // // // // Read isBright phase shift from calibration table: // int photPhaseShift = ilookup(tabName02,version02,"photPhaseShift"); // // // // // Convert input and read correct levels from calibration table: // {string,int,int,int,double,double,double,double}[] level_table = SpireProc_CalcParam_PhotMultiLevelNoiseLevels(biasfreq,samplerate,tabName01,version01,debug); int size = length(level_table); if(debug) { debug_print("size = " + size); debug_print("Version selector used in calibration table: " + version01); } // // // // // Create list of bias levels and associated phases: // int[] nbiaslist = []; int[] pswnphaselist = []; int[] pmwnphaselist = []; int[] plwnphaselist = []; int[] ptcnphaselist = []; // // // // // Loop through the levels to populate lists: // for(int j = 0 .. size - 1) { if(debug) { debug_print("level_table = " + level_table[j]); } {string,int,int,int,double,double,double,double} row = level_table[j]; int mclkDiv = row{1}; int biasDiv = row{2}; nbiaslist[j] = row{3}; double pswphase = row{4}; pswnphaselist[j] = iround(pswphase * 255.0 / 360.0); double pmwphase = row{5}; pmwnphaselist[j] = iround(pmwphase * 255.0 / 360.0); double plwphase = row{6}; plwnphaselist[j] = iround(plwphase * 255.0 / 360.0); double ptcphase = row{7}; ptcnphaselist[j] = iround(ptcphase * 255.0 / 360.0); if(isBright) { pswnphaselist[j] = SpireProc_CalcParam_IsBrightPhaseShift(pswnphaselist[j],photPhaseShift,debug); pmwnphaselist[j] = SpireProc_CalcParam_IsBrightPhaseShift(pmwnphaselist[j],photPhaseShift,debug); plwnphaselist[j] = SpireProc_CalcParam_IsBrightPhaseShift(plwnphaselist[j],photPhaseShift,debug); } } if(debug) { debug_print("mclkDiv/biasDiv = " + mclkDiv + "/" + biasDiv); } // // // // // Set selected bias frequency and sampling rate before loop: // SpireBb_DcuSetFreqSamp(mclkDiv,biasDiv,phot,debug); // // // // // Start the bias loop: // for(int l = 0 .. length(nbiaslist) - 1) { // // // // // Safety checks: // if(nbiaslist[l] > 255) { nbiaslist[l] = 255; if(debug) { debug_print("Input bias amplitude list is corrupt! Raw value > 255 requested!"); } } if(pswnphaselist[l] > 255) { pswnphaselist[l] = 255; if(debug) { debug_print("Input PSW bias phase list is corrupt! Raw value > 255 requested!"); } } if(pmwnphaselist[l] > 255) { pmwnphaselist[l] = 255; if(debug) { debug_print("Input PMW bias phase list is corrupt! Raw value > 255 requested!"); } } if(plwnphaselist[l] > 255) { plwnphaselist[l] = 255; if(debug) { debug_print("Input PLW bias phase list is corrupt! Raw value > 255 requested!"); } } if(ptcnphaselist[l] > 255) { ptcnphaselist[l] = 255; if(debug) { debug_print("Input PTC bias phase list is corrupt! Raw value > 255 requested!"); } } // // // // // Set bias amplitude and phase: // if(debug) { debug_print("the biaslevel is :" + nbiaslist[l] + " PSW phase is : " + pswnphaselist[l] + " PMW phase is : " + pmwnphaselist[l] + " PLW phase is : " + plwnphaselist[l] + " PTC phase is : " + ptcnphaselist[l]); } // // Set bias amplitude: SpireBb_PhotFSetBiasAmpl(nbiaslist[l],nbiaslist[l],nbiaslist[l],nbiaslist[l],debug); // // Set phase: SpireBb_PhotFSetPhase(pswnphaselist[l],pmwnphaselist[l],plwnphaselist[l],ptcnphaselist[l],debug); // // // // // Stop DCU data before resetting offsets: // SpireBb_StopDcuData(); // // // // // // Set offsets: // SpireBb_PhotOffsetAuto(debug); // // // // // Take data: // SpireBb_PhotFTakeData(ftime,debug); // // // // // // // // // Perform standard AOT style PCAL flash if(isPcal) { SpireBbPcalFlash("PFlashEng","v00",0,false); } // Debug printing: // if(debug) { debug_print("Bias level " + nbiaslist[l] + " done."); } } // // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_CalcParam_PcalFlash.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to deduce number of DCU samples, SCU samples and DCU sample // delay based on inputs period,mclkdiv and biasdiv for a PCAL flash // // Figure to follow the calculation of the parameters: // _______________________________ // | | // | | // | | // | | // | | // -------- ---------- // cmdtime(cmdT) sampdelay (sd) // |cmdT| |sd| // |---------------------| // available time == samp_period // // x x x x x x DCU samples // |---| |-| // tsamp remaining time // // Dcudelay = remaining time + cmdT // // =====> Reordered setup: // x x x x x x // ---|cmdT|-| |-|-------- // dcudelay sampledelay // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/08/12 V0.1: Initial version renamed from // SpireProc_CalcParam_PhotPcalFlash (2008/07/29 V0.2) // in original based on // Proc_PCALFlashCalc.txt (v1.4 2008/01/31 20:24:35) // Add +1 to dcusamples (to count ticks not intervals); // Use different formula to derive dcudelay; // add extensive debug_printing + comments; change default // 2009/02/02 V1.0: Add debug_print as input // 2009/02/16 V1.1: Fix bug (sampdelay and commanding time missing) in // dcudelay calculation, detected during // FS2 testing (3.-5.02.2009). Added extended drawing to // header. Remove safety check for dcudelay < 0. // /////////////////////////////////////////////////////////////////////////// // int[] procedure SpireProc_CalcParam_PcalFlash { int period = 4000; //PCAL Flash FULL period (high and low bias) [millisec] int mclkdiv = 149; // Fetched master clock divisor int biasdiv = 6; // Fetched bias divisor bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Declare some variable: // // possible sampling start delay [microsec]: int sampdelay = 6000; // // commanding time at start of half-chop period [microsec]: int cmdtime = 8000; // // // // // // Calculate bias frequency Hz: // double bias_f = 1.0E7 / (512.0 * double(mclkdiv + 1)); // // // // // Calculate sampling rate Hz: // double samplerate = bias_f / (1.0 + double(biasdiv)); // // // // // Calculate sampling interval in [millisec]: // (Time between DCU samples) // double tsamp = 1000.0 / samplerate; if(debug) { debug_print("DCU sample interval is: " + tsamp); } // // // // // Calculate dcusample, scusamples, and dcudelay parameters: // // DCU samples to go into one PCAL half-cycle: // double dcusamp = (double(period) / 2.0 - double(sampdelay - cmdtime) / 1000.0) / tsamp; //double dcusamp = double(period) / 2.0 / tsamp; // // Number of full DCU samples per half period: // int dcusample = ifloor(dcusamp) + 1; if(debug) { debug_print("DCU samples: " + dcusample); } // int scusample = ifloor(double(period) / 2.0 / 12.5); // Note: only 1-31 samples can be requested, otherwise command // continuous frames (see below) if(debug) { debug_print("SCU samples: " + scusample); } // // // // // Calculate DCU delay: // // Delay to start sampling the DCU [microsec]: // int dcudelay = iround((dcusamp - double(dcusample - 1)) * tsamp * 1000.0) + cmdtime; //int dcudelay = iround((dcusamp - double(dcusample - 1)) * tsamp * 1000.0); if(debug) { debug_print("DCU delay is: " + dcudelay); } // // // // // // Set SCU sampling to continuous (VM takes care of starting and stoping SCU): // scusample = 0x0; // // // // // Debug printing: // if(debug) { debug_print("bias frequency Hz: " + bias_f); debug_print("sampling rate Hz: " + samplerate); debug_print("sampling interval in ms: " + tsamp); debug_print("dcusample: " + dcusample); debug_print("dcudelay [microsec]: " + dcudelay); debug_print("scusample: " + scusample); } // return [dcusample,scusample,dcudelay]; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_Chop.txt // /////////////////////////////////////////////////////////////////////////// // // BB to execute chopping/jiggling. Script returns the actual time on-source. // // Note: VM does not reset dcusample/bsmsample at end, so this needs // to be done in the surrounding end script. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/10/13 V0.1: Initial version renamed from // SpireBb_PhotChop (2008/09/08 V0.3) // Add debug printing option. // 2009/01/27 V1.0: Move debug_print as input; Remove unsetting of BBID at end. // Set the delay time after FLUSH_FIFO to 2 sec. // 2009/02/16 V1.1: Move all commands in lower level procedure // SpireProc_Set_BsmChop. Added VM table parameters // as input and removed BSM framerate from input. // Add Hspot messages. // /////////////////////////////////////////////////////////////////////////// // double block SpireBb_Chop SPIRE 14011 { int vmId = 71; // Raw VM table number [Dec(Hex)] int vmIndex = 0; // Raw VM index [Dec(Hex)] int nParms = 10; // Number of parameters passed to VM int onChop = 0; // on-source Chop position int onJigg = 0; // on-source Jiggle positio int offChop = 0; // off-source Chop position int offJigg = 0; // off-source Jiggle position int ncycles = 50; // Number of chop cycles [#] int chop_period = 500000; //period of chop cycles in [microsec] int dcumode = 0; // DCU data mode (e.g. 0 == Full photometer) int dcusample = 4; //Number of DCU samples per chop position [#] int dcudelay = 34959; //Dealy to start sampling the DCU [microsec] int bsmsample = 31; //Number of BSM samples per position [#] int step = 0; // Step number [dec] bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SpireBb_Chop started"); SpireMsg(2," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Run chop VM in procedure: // // Note: This sets the obsStep, resets the FIFOs, runs the VM, // and flushes the FIFOs. It does not set the datarate. // double srcTime = SpireProc_Set_BsmChop(vmId,vmIndex,nParms,onChop,onJigg,offChop,offJigg,ncycles,chop_period,dcumode,dcusample,dcudelay,bsmsample,step,debug); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SpireBb_Chop ended"); SpireMsg(1," ..Chop/Jigg (" + (time() - t) + " seconds)"); // return srcTime; } // SpireBbStopDcuData // // $Id: SpireBbStopDcuData.txt,v 1.3 2007/04/02 09:50:56 kking Exp $ // // Procedure to stop generation of detector data TM packets // // 30 March 2007: Added additional parameter to RESET_FIFOS cmd // 02 April 2007: Added additional parameter to RESET_FIFOS message // block SpireBbStopDcuData SPIRE 8457 { }{ message("4 " + time() + ": SpireBbStopDcuData started"); message("4 $Id: SpireBbStopDcuData.txt,v 1.3 2007/04/02 09:50:56 kking Exp $"); // // stop data collection SpireSendDrcuCmd(0x843e0000,0); // // flush data from FIFOs message("5 " + time() + "Cmd: Spire_FLUSH_FIFO(0x1000)"); Spire_FLUSH_FIFO_RAW(0x1000); delay(3); message("5 " + time() + "Cmd: Spire_RESET_FIFOS(0x1000)"); Spire_RESET_FIFOS(0x1000); // delay(1); message("4 " + time() + ": SpireBbStopDcuData ended"); // } // CVS comments : $Id: WriteOBSID.txt,v 1.7 2007/11/06 08:39:25 dcesarsk Exp $ // Missionphase : // // Purpose : Set the OBSID via DEC/MEC; show decoded OBSID on // user screen // // CUS script : Diego A. Cesarsky (diego.cesarsky@mpe.mpg.de) // Original TCL : N/A // CVS file : WriteOBSID.txt // // Input arguments // Type Name DefVal Description // int iOBSID N/A OBSID obtained from environment // // Description : Obtain OBSID from run environment and send TC to DMC // Write decoded OBSID to log file // // Dependencies : Pacs_DMC_SET_OBSID // DecodeOBSID // // Comments : // // Version : 2.0 // 0.1 23-Sep-2004 First creation // History : 0.2 28-Sep-2004 Remove set_unset; write // decoded OBSID to output log // 0.3 7-Oct-2004 Renamed to WriteOBSID to match to names of // related procedures // 0.4 12-Oct-2004 Added write to EGSE environment (need // to add write to IST environment ??) // 0.5 21-Oct-2004 Added write to CDMS // 1.0 9-May-2005 DAC Removed write to EGSE and CDMS (not // needed at Astrium) // 1.1 20-oct-2005 Added sync() as I will need the "true" // duration // 1.2 5-nov-2007 Added delay(1) before first TC to wait // for completion of bus_configure // 2.0 23-sep-2008 SCR4431 hk_data_rate // procedure WriteOBSID { int iOBSID = 0x20000000; // Observation ID }{ // Wait 1 second to allow for bus_configure delay(1); // Write OBSID to DEC/MEC and decode to output log Pacs_DMC_SET_OBSID(iOBSID); ess_hk_data_rate(0.31); non_ess_hk_data_rate(4.0); // sync the bus sync(); // Inform CUS debugger // DecodeOBSID(iOBSID); } // SpireBsmMove // // $Id: SpireBsmMove.txt,v 1.1 2006/08/10 09:38:58 kking Exp $ // // Procedure to move the BSM to a given position // // procedure SpireBsmMove { int chopPosn = 2048 in [0,65535]; int jiggPosn = 2048 in [0,65535]; }{ string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(4," " + tstr + ": SpireBsmMove started"); SpireMsg(4," $Id: SpireBsmMove.txt,v 1.1 2006/08/10 09:38:58 kking Exp $"); // SpireMsg(3," ChopPosn = " + chopPosn); SpireMsg(3," JIggPosn = " + jiggPosn); // int cmd = 0; // set Chop position cmd = 0x90c30000 + chopPosn; SpireSendDrcuCmd(cmd,0); // // set Jiggle Position cmd = 0x91430000 + jiggPosn; SpireSendDrcuCmd(cmd,0); // // move BSM cmd = 0x90c60000; SpireSendDrcuCmd(cmd,0); // tstr = SpireTimeStr(time()); SpireMsg(4," " + tstr + ": SpireBsmMove ended"); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_DcuSetFreqSamp.txt // /////////////////////////////////////////////////////////////////////////// // // BB to configure the DCU bias frequency and sampling rate. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/02/17 V0.1: Initial version adapted surrounding from // SpireBb_PhotFSetPhase (2009/02/14 V1.1) // calling SpireProc_Set_DcuFreqSamp. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_DcuSetFreqSamp SPIRE 14031 { int mclkDiv = 149; // Bias freq. (for photometer == 130.20833 Hz) int biasDiv = 6; // Sampling freq. (for photometer == 18.60119 Hz) bool phot = true; // Set for photometer (==tick) or FTS bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Define some variables: // string hstr = ""; // a hex string string tstr = ""; // a time string // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": SpireBb_DcuSetFreqSamp started"); SpireMsg(2," $Id: $"); hstr = SpireHexStr($BBID,8); SpireMsg(3," BBID = " + hstr); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); sync(); // // // // // Set the phase for the three arrays and the PTC bolometer: // SpireProc_Set_DcuFreqSamp(mclkDiv,biasDiv,phot,debug); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SpireBb_DcuSetFreqSamp ended"); SpireMsg(1," ..Set Phot phases (" + (time() - t) + " secs)"); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_CalcParam_BsmSetup.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to deduce number of chop cycles, the chop period, the number // of DCU samples, BSM samples, and the DCU delay, based on input read // out time, chop frequency, detector sampling rate, and MCU framerate. // // Figure to follow the calculation of the parameters: // _______________________________ // | | // | | // | | // | | // | | // -------- ---------- // cmdtime(cmdT) sampdelay (sd) // |cmdT| |sd| // |---------------------| // available time == samp_period // // x x x x x x DCU samples // |---| |-| // tsamp remaining time // // Dcudelay = remaining time + cmdT // // =====> Reordered setup: // x x x x x x // ---|cmdT|-| |-|-------- // dcudelay sampledelay // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/10/13 V0.1: Initial version renamed from // SpireProc_CalcParam_PhotBsmSetup.txt (2008/07/28 V0.2) // Remove sampling rate restriction. Add debug printing option. // 2009/01/27 V1.0: Add debug_print as input // 2009/02/16 V1.1: Fix bug in dcudelay calculation, detected during // FS2 testing (3.-5.02.2009). Added extended drawing to // header. According to Ken sampdelay is now 6000 and // not 7000. // 2009/06/26 V1.2: Added temporarily fix for SPR: SPIRE-1551 until // issue is fully understodd: Hardcode bsmsample to // FFFFF (65535). // 2009/07/03 V1.3: Remove temporal fix, since this will cause problems // during a spec-day and has probably during OD50. I.e // FFFFF in the VM leaves the BSM (and SMEC) data running. // /////////////////////////////////////////////////////////////////////////// // int[] procedure SpireProc_CalcParam_BsmSetup { int rtime = 15; // Readout out time (== total time: ON+OFF) [s] double chopf = 2.0; // Chop frequency [Hz] double samplerate = 18.6; // Sampling rate (18.6 phot; 80.0 spec) [Hz] double framerate = 125.0; // MCU (BSM) frame rate [Hz] bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Declare some variable: // // possible sampling start delay [microsec]: int sampdelay = 6000; // commanding time at start of half-chop period [microsec]: int cmdtime = 14000; // // // // // Calculate number of chop cycles: // // Period of chop cycles [microsec]: //// int chop_period = iround(1.0 / chopf * 1000000.0); // // Number of chop cycles: // int ncycles = iceil(double(rtime * 1000000) / double(chop_period)); // // // // // Calculate number of DCU samples: // // Sampling period per half-cycle [microsec]: // int samp_period = chop_period / 2 - sampdelay - cmdtime; // // Time between DCU samples: // double tsamp = 1.0 / samplerate * 1000.0; // [millisec] // // DCU samples to go into one chop half-cycle: // double dcusamp = double(samp_period) / 1000.0 / tsamp; // // Number of full DCU samples to go into one chop half-cycle: // int dcusample = ifloor(dcusamp) + 1; //Number of DCU samples per chop position // // // // // Calculate DCU delay: // //Dealy to start sampling the DCU [microsec]: int dcudelay = iround((dcusamp - double(dcusample - 1)) * tsamp * 1000.0) + cmdtime; // // // // // BSM (MCU) samples: // // Time between MCU samples: // double tbsm = 1.0 / framerate * 1000.0; // [millisec] // // BSM (MCU) samples to go into one chop half-cycle: // double bsmsamp = double(samp_period) / 1000.0 / tbsm; // // Number of full BSM (MCU) samples to go into one chop half-cycle: // int bsmsample = ifloor(bsmsamp); // // Number of BSM samples per position: // // temporarily fix for SPR: SPIRE-1551 // hardcode bsmsample to FFFFF (65535). // bsmsample = 65535; // // // // // Debug printing: // if(debug) { debug_print("chop_period [millisec]: " + double(chop_period) / 1000.0); debug_print("samp_period [millisec]: " + double(samp_period) / 1000.0); debug_print("ncycles: " + ncycles); debug_print("Readout time [s]: " + double(ncycles * chop_period) / 1000000.0); debug_print("tsamp [millisec]: " + tsamp); debug_print("dcusamp: " + dcusamp); debug_print("dcusample: " + dcusample); debug_print("dcudelay [microsec]: " + dcudelay); debug_print("tbsm: " + tbsm); debug_print("bsmsamp: " + bsmsamp); debug_print("bsmsample: " + bsmsample); } // return [ncycles,chop_period,dcusample,dcudelay,bsmsample]; } // SpireBbPeakup // // Execute a Peakup observation // // K.J. King // // 11/11/2008 KJK: first version // 17/07/2009 MP: Stopped MCU science data and set DCU mode to continuous // following SCR-SPIRE-1644. // // block SpireBbPeakup SPIRE 8458 { string peakupMode = "PPeakup" in ["PPeakup","SPeakup"]; // Peakup Mode int step = 0; }{ int t = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB Photometer Peakup started"); SpireMsg(2," $Id:$"); // // ..... configuration ..... // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // set STEP hstr = SpireHexStr(step,4); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP_RAW(" + hstr + ")"); Spire_SET_OBS_STEP_RAW(step); // // Time synchronisation tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_RESET_DRCU_COUNTERS_RAW()"); Spire_RESET_DRCU_COUNTERS_RAW(); delay(2); // // position SMEC, if necessary // if(peakupMode == "SPeakup") { // Move SMEC to HOME position int home = ilookup("SMEC.txt","HOME","ivalue"); SpireSendDrcuCmd(0x90450000 + home,0); // set position SpireSendDrcuCmd(0x90490001,0); // move SpireSendDrcuCmd(0x90490000,0); // hold position delay(2); } // // Set up detector sampling // if(peakupMode == "SPeakup") { SpireConfigDcuData("SPeakup"); } else { SpireConfigDcuData("PPeakup"); } // // execute peakup // int dcuDataMode = ilookup("Peakup.txt",peakupMode,"DcuDataMode"); int pixel = ilookup("Peakup.txt",peakupMode,"Pixel"); int chopTable = ilookup("Peakup.txt",peakupMode,"ChopTable"); int chopTableIndex = ilookup("Peakup.txt",peakupMode,"ChopTableIndex"); int startChopPosn = ilookup("Peakup.txt",peakupMode,"StartChopPosn"); int chopPosnIncr = ilookup("Peakup.txt",peakupMode,"ChopPosnIncr"); int nChopPosns = ilookup("Peakup.txt",peakupMode,"NChopPosns"); int startJiggPosn = ilookup("Peakup.txt",peakupMode,"StartJiggPosn"); int jiggPosnIncr = ilookup("Peakup.txt",peakupMode,"JiggPosnIncr"); int nJiggPosns = ilookup("Peakup.txt",peakupMode,"NJiggPosns"); int chopOffset = ilookup("Peakup.txt",peakupMode,"ChopOffset"); int jiggOffset = ilookup("Peakup.txt",peakupMode,"JiggOffset"); int nChopCycles = ilookup("Peakup.txt",peakupMode,"NChopCycles"); int chopCyclePeriod = ilookup("Peakup.txt",peakupMode,"ChopCyclePeriod"); int nBsmFrames = ilookup("Peakup.txt",peakupMode,"NBsmFrames"); int nDcuFrames = ilookup("Peakup.txt",peakupMode,"NDcuFrames"); int dcuFrameDelay = ilookup("Peakup.txt",peakupMode,"DcuFrameDelay"); int chopScale = ilookup("Peakup.txt",peakupMode,"ChopScale"); int jiggScale = ilookup("Peakup.txt",peakupMode,"JiggScale"); int outputType = ilookup("Peakup.txt",peakupMode,"OutputType"); {int}[] parms = [{dcuDataMode},{pixel},{chopTable},{chopTableIndex},{startChopPosn},{chopPosnIncr},{nChopPosns},{startJiggPosn},{jiggPosnIncr},{nJiggPosns},{chopOffset},{jiggOffset},{nChopCycles},{chopCyclePeriod},{nBsmFrames},{nDcuFrames},{dcuFrameDelay},{chopScale},{jiggScale},{outputType}]; tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_PERFORM_PEAKUP_RAW(" + parms + ")"); Spire_PERFORM_PEAKUP_RAW(dcuDataMode,pixel,chopTable,chopTableIndex,startChopPosn,chopPosnIncr,nChopPosns,startJiggPosn,jiggPosnIncr,nJiggPosns,chopOffset,jiggOffset,nChopCycles,chopCyclePeriod,nBsmFrames,nDcuFrames,dcuFrameDelay,chopScale,jiggScale,outputType); // set datarate double rate = 0.0; rate = dlookup("Datarates.txt",peakupMode,"DCU"); rate = rate + dlookup("Datarates.txt",peakupMode,"BSM"); data_rate(rate); delay((nChopPosns + nJiggPosns) * (chopCyclePeriod * nChopCycles / 1000000) + 2); data_rate(0.0); // delay(60); // // // // // Stop MCU science data collection: // SpireSendDrcuCmd(0x91c10000,0); // // // // // Set DCU sampling to continuous after VM: // SpireSendDrcuCmd(0x843d0000,0); sync(); // // // ..... completion ..... // // flush data tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_FLUSH_FIFO_RAW(0x5000)"); Spire_FLUSH_FIFO_RAW(0x5000); delay(2); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB Photometer Peakup ended"); SpireMsg(1," ..Photometer Peakup (" + (time() - t) + " seconds)"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_Set_StopDcuData.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to stop generation of detector data TM packets // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/01/26 V1.0: Initial version adapted from // SpireBb_StopDcuData.txt (2008/07/03 V0.2) merging it with // SpireStopDcuData.txt (KK, v1.3 2007/04/02) // Script has now no (unnecessary) RESET_FIFO after the // FLUSH_FIFO and the delay time after FLUSH_FIFO is // set to 2. Script no longer sets the data rates. // 2009/01/30 V1.1: Name in messages commands corrected. /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Set_StopDcuData { }{ // // // // // Start procedure: // message("4 " + time() + ": SpireProc_Set_StopDcuData started"); message("4 $Id: $"); // // // // // Stop data collection: // message("5 " + time() + "Cmd: Spire_SEND_DRCU_COMMAND(0x843e0000,0)"); Spire_SEND_DRCU_COMMAND(0x843e0000,0); // // // // // Flush DCU (x1000) fifo: // message("5 " + time() + "Cmd: Spire_FLUSH_FIFO(0x1000)"); Spire_FLUSH_FIFO(0x1000); delay(2); // // // // // End procedure: // message("4 " + time() + ": SpireProc_Set_StopDcuData ended"); // } // SpireSpectroPoint // // $Id: SpireSpectroPoint.txt,v 1.6 2008/05/23 08:48:39 kking Exp $ // // The high level script for the Spire Spectrometer Single-pointing observing mode // // This type of observation may be executed using either the SOF1 or SOF2 observing modes // // 15/02/08 Added otf flag to step for intermediate PCAL flashes // // 04 November 2008: added data_rate commands // // 04/03/09: MP Fixed bug in call to // SpireProc_GetTableEntryString("SpireTable_OpsParms.txt","mode"...) // 10/03/2009 KJK: // SCR 1274, add additional dummy parameters // Update input API to include versions for all cal tables // 17/03/2009 KJK: // Update API to read NCycles1 from NHCycles and NCycles2 from NLCycles // 18/03/2009 KJK: // Added inpuit of instrument boresight // {int,int,double,int,double,int,int,int} obs SpireSpectroPoint { double ra = 0.0 in [0.0,360.0]; // RA of Target double dec = 0.0 in [-90.0,90.0]; // DEC of Target int naifid = 0; // NAIF identifier string boresight = ""; // Instrument Boresight string pointing = "single" in ["single","raster"]; // pointing type string sampling = "sparse" in ["sparse","intermediate","full"]; // spatial sampling string resolution = "H" in ["H","M","L","C","H+L"]; // spectral resolution bool choppingAvoidOn = false; // is chopping avoidance selected int choppingAvoidNumber = 0 in [0,3]; // the number of chopping avoid angles selected double choppingAvoidFrom1 = 0.0 in [0.0,360.0]; double choppingAvoidTo1 = 0.0 in [0.0,360.0]; double choppingAvoidFrom2 = 0.0 in [0.0,360.0]; double choppingAvoidTo2 = 0.0 in [0.0,360.0]; double choppingAvoidFrom3 = 0.0 in [0.0,360.0]; double choppingAvoidTo3 = 0.0 in [0.0,360.0]; int nRepetitions1 = 2 in [2,1200]; // number of times to repeat spectral scan pairs for single resolution scan modes and high resolution in H+L mode int nRepetitions2 = 2 in [2,1200]; // number of times to repeat spectral scan pairs for low resolution scans for 'H+L" mode double wavelength1 = -1.0; // wavelength double wavelength2 = -1.0; // wavelength double wavelength3 = -1.0; // wavelength double wavelength4 = -1.0; // wavelength double wavelength5 = -1.0; // wavelength double wavelength6 = -1.0; // wavelength double wavelength7 = -1.0; // wavelength double wavelength8 = -1.0; // wavelength bool isJyContinuum = true; // is continuum specified in Jy rather than Wm-2um-1 double lineFlux1 = -1.0; // line flux estimate double lineFlux2 = -1.0; // line flux estimate double lineFlux3 = -1.0; // line flux estimate double lineFlux4 = -1.0; // line flux estimate double lineFlux5 = -1.0; // line flux estimate double lineFlux6 = -1.0; // line flux estimate double lineFlux7 = -1.0; // line flux estimate double lineFlux8 = -1.0; // line flux estimate double contFlux1 = -1.0; // continuum flux estimate double contFlux2 = -1.0; // continuum flux estimate double contFlux3 = -1.0; // continuum flux estimate double contFlux4 = -1.0; // continuum flux estimate double contFlux5 = -1.0; // continuum flux estimate double contFlux6 = -1.0; // continuum flux estimate double contFlux7 = -1.0; // continuum flux estimate double contFlux8 = -1.0; // continuum flux estimate bool isBright = false; // Use settings for bright source (==tick) bool isChopped = false; int nMaps = 1; int nHCycles = 0; // total number of cycles at each pointing and jiggle position for first resolution int nMCycles = 0; // Not Used int nLCycles = 0; // total number of cycles at each pointing and jiggle position for second resolution (in H+L mode) int nCals = 0; double tCal = 999999.0; // time between Gyro calibrations within a jiggle point operation int nFlashes = 0; double tFlash = 999999.0; // time between PCAL flashes within a jiggle point operation string spireVersion = "v00"; // Version in cal table SpireTable_SpireParms string opsVersion = "v00"; // Version in cal table SpireTable_OpsParms string flashVersion = "v00"; // Version in cal table SpireTable_FlashParms string specVersion = "v00"; // Version in cal table SpireTable_Spectrometer bool debug = false; // debug messages flag bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ string version = "v00"; // check inputs if(pointing != "single") { error("SpireSpectroPoint: Pointing is not set to single"); } SpireMsg(0,"Spectrometer Single Point Observation"); // double[] wavelength = [wavelength1,wavelength2,wavelength3,wavelength4,wavelength5,wavelength6,wavelength7,wavelength8]; double[] lineFlux = [lineFlux1,lineFlux2,lineFlux3,lineFlux4,lineFlux5,lineFlux6,lineFlux7,lineFlux8]; double[] contFlux = [contFlux1,contFlux2,contFlux3,contFlux4,contFlux5,contFlux6,contFlux7,contFlux8]; // // ***************************************** // select instrument ops mode // ***************************************** // string opsMode = ""; // opsMode int md = 0; // value of MODE parameter if(sampling == "sparse") { opsMode = "SOF1"; md = 0x410; } else { if(sampling == "intermediate") { opsMode = "SOF2_int"; } else { if(sampling == "full") { opsMode = "SOF2"; } else { error("SpireSpectroPoint: Unknown sampling"); } } md = 0x420; } // // ***************************************** // set up scan sets // ***************************************** // string res1 = resolution; string res2 = "L"; int nCycles1 = nHCycles; int nCycles2 = nLCycles; if(resolution == "H+L") { res1 = "H"; } // ***************************************** // get observing parameters // ***************************************** // double tScan1 = SpireProc_GetTableEntryDouble("SpireTable_Spectrometer.txt","ResChar",res1,"ScanTime",specVersion,debug); double tScan2 = SpireProc_GetTableEntryDouble("SpireTable_Spectrometer.txt","ResChar",res2,"ScanTime",specVersion,debug); int scansPerCycle1 = SpireProc_GetTableEntryInt("SpireTable_OpsParms.txt","mode",opsMode,"N" + res1 + "Scans",opsVersion,debug); int scansPerCycle2 = SpireProc_GetTableEntryInt("SpireTable_OpsParms.txt","mode",opsMode,"N" + res2 + "Scans",opsVersion,debug); double tCycle1 = tScan1 * double(scansPerCycle1); double tCycle2 = tScan2 * double(scansPerCycle2); // int jiggleTable = SpireProc_GetTableEntryInt("SpireTable_OpsParms.txt","mode",opsMode,"TableId",opsVersion,debug); // Jiggle Table ID int jiggleSize = SpireProc_GetTableEntryInt("SpireTable_OpsParms.txt","mode",opsMode,"TableSize",opsVersion,debug); // Jiggle Table length int tSerendipity = duration(SpireBbSpecSerendipity(opsMode,0)); // minimum time for a serendipity observation bool initFlash = blookup("SpireParms.txt",opsMode,"InitFlash"); // initial flash flag bool endFlash = blookup("SpireParms.txt",opsMode,"EndFlash"); // final flash flag double perScanOsit1 = SpireProc_GetTableEntryDouble("SpireTable_Spectrometer.txt","ResChar",res1,"Osit",specVersion,debug); // effective on source integration time per scan double perScanOsit2 = SpireProc_GetTableEntryDouble("SpireTable_Spectrometer.txt","ResChar",res2,"Osit",specVersion,debug); // effective on source integration time per scan // int nScans1 = nCycles1 * scansPerCycle1; int nScans2 = nCycles2 * scansPerCycle2; // int scanStart1 = SpireProc_GetTableEntryInt("SpireTable_Spectrometer.txt","ResChar",res1,"ScanStart",specVersion,debug); int smecHome = ilookup("SpireTable_SmecNominalSettings.txt",version,"Home"); // // ***************************************** // set telescope pointing mode // ***************************************** // // Lookup boresight, if not provided string ib = boresight; if(boresight == "") { ib = SpireProc_GetTableEntryString("SpireTable_OpsParms.txt","mode",opsMode,"Boresight",opsVersion,debug); } double deltaY = SpireProc_GetTableEntryDouble("SpireTable_OpsParms.txt","mode",opsMode,"DeltaY",opsVersion,debug); // offset to pixel centre from boresight in Y direction (arcsecs) double deltaZ = SpireProc_GetTableEntryDouble("SpireTable_OpsParms.txt","mode",opsMode,"DeltaZ",opsVersion,debug); // offset to pixel centre from boresight in Z direction (arcsecs) // double yOffset = 0.0; // offset to observation position from target in Y direction (arcsecs) double zOffset = 0.0; // offset to observation position from target in Z direction (arcsecs) // {int,int,int,int,int,int} sofPoint = SpireSOF12Pointing(opsMode,res1,nCycles1,tCycle1,scansPerCycle1,res2,nCycles2,tCycle2,scansPerCycle2,nMaps,nFlashes,tFlash,specVersion,flashVersion,debug); int tSlewMin = sofPoint{0}; int tInitHold = sofPoint{1}; int tFinalHold = sofPoint{2}; int tp = sofPoint{3}; // int[] ts = basic_fine_pointing(true,tSlewMin,tInitHold,tFinalHold,ib,naifid,ra,dec,yOffset + deltaY,zOffset + deltaZ,tp); // int tobs = ts[0]; int tslew = ts[1]; int tend = ts[2]; // }{ SpireMsg(0,"Observation Start"); SpireMsg(0," Uses observing mode " + opsMode); SpireMsg(3," $Id: SpireSpectroPoint.txt,v 1.6 2008/05/23 08:48:39 kking Exp $"); //??p pointing file generation ------------------------------ double pos = 90.0; //??p double[] rdp0 = PtOffset([ra,dec,pos],zOffset,yOffset,0.0,false); //??p pointing file generation ------------------------------ // // ***************************************** // Display input parameters // ***************************************** SpireMsg(3," Input values:"); SpireMsg(3," ..RA: " + ra); SpireMsg(3," ..Dec: " + dec); SpireMsg(3," ..NAIF ID: " + naifid); SpireMsg(3," ..Pointing: " + pointing); SpireMsg(3," ..Sampling: " + sampling); SpireMsg(3," ..Resolution: " + resolution); SpireMsg(3," ..Y Offset: " + yOffset); SpireMsg(3," ..Z Offset: " + zOffset); SpireMsg(3," ..nMaps: " + nMaps); SpireMsg(3," ..nHCycles: " + nHCycles); SpireMsg(3," ..nMCycles: " + nMCycles); SpireMsg(3," ..nLCycles: " + nLCycles); SpireMsg(3," ..tCal: " + tCal); SpireMsg(3," ..tFlash: " + tFlash); SpireMsg(3," Fixed values:"); SpireMsg(3," ..ib: " + ib); SpireMsg(3," ..initFlash: " + initFlash); SpireMsg(3," ..endFlash: " + endFlash); SpireMsg(3," ..tCycle1: " + tCycle1); SpireMsg(3," ..tCycle2: " + tCycle2); SpireMsg(3," Pointing Mode Input values:"); SpireMsg(3," ..tSlewMin: " + tSlewMin); SpireMsg(3," ..tInitHold: " + tInitHold); SpireMsg(3," ..tFInalHold: " + tFinalHold); SpireMsg(3," ..tp: " + tp); SpireMsg(3," Fine Pointing Mode Output values:"); SpireMsg(3," ..tobs: " + tobs); SpireMsg(3," ..slew: " + tslew); SpireMsg(3," ..tend: " + tend); // ***************************************** // execute observation // ***************************************** // data_rate(0.0); double chkrate = dlookup("Datarates.txt","Scan","CHK"); ess_hk_data_rate(chkrate); double nhkrate = dlookup("Datarates.txt","Scan","NHK"); non_ess_hk_data_rate(nhkrate); string tstr = ""; // time string int otf = 0x8000; // On Target Flag double srcTime = 0.0; // total on source integration time int t = 0; // int[] state = [0]; while(state[0] >= 0) { state = next_state(); if(state[0] == 1) { // ********************* SLEWING tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " Slewing to start position"); t = time(); // set up observation parameters SpireBb_StartObsAll(opsMode); // perform serendipity operation if possible if(tslew > tSerendipity + tSlewMin) { SpireBbSpecSerendipity("SSer",tslew - tSlewMin - 2); } // configure instrument for operations if(opsMode == "SOF1") { SpireBbSOF1Config(res1,specVersion,debug); } else { SpireBbSOF2Config(res1,specVersion,debug); } } if(state[0] == 2) { // ********************* INITIAL HOLD tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " Telescope at start position"); SpireMsg(0," Slew (" + (time() - t) + " secs)"); SpireMsg(2," " + tstr + " Initialising Instrument"); t = time(); // initialise instrument if(opsMode == "SOF1") { SpireBbSOF1Init(); } else { SpireBbSOF2Init(); } // calibrate if necessary if(initFlash || double(tp) > tFlash) { tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " PCAL Calibration inserted"); SpireProc_SFlash("SFlash",smecHome,scanStart1,otf,flashVersion,debug); } } if(state[0] == 3) { // ********************* POINTING //??p pointing file generation ------------------------------ //??p PtOutput(rdp0); //??p pointing file generation ------------------------------ tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " New Pointing"); int nPoints = 0; int step = 0; t = time(); double s = 0.0; // for(int j = 0 .. jiggleSize - 1) { step = j; SpireBbBsmMove(jiggleTable,j,step); if(j > 0) { if(nFlashes > 0 || j % nPoints == 0) { SpireProc_SFlash("SFlash",scanStart1,scanStart1,otf | step,flashVersion,debug); } } s = SpirePointSpectrum(res1,nCycles1,tCycle1,scansPerCycle1,res2,nCycles2,tCycle2,scansPerCycle2,tFlash,otf | step,specVersion,flashVersion,debug); srcTime = srcTime + s; if(j == 0) { nPoints = ifloor(tFlash / double(time() - t)); if(nPoints == 0) { nPoints = jiggleSize; } } } } if(state[0] == 5) { // ******************** FINAL HOLD tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " Reconfiguring Instrument"); t = time(); // calibrate if necessary if(endFlash || double(tp) > tFlash) { tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " PCAL Calibration inserted"); SpireProc_SFlash("SFlash",scanStart1,smecHome,otf | step,flashVersion,debug); } // reconfigure back to SPEC_STBY configuration if(opsMode == "SOF1") { SpireBbSOF1End(res1,specVersion,debug); } else { SpireBbSOF2End(res1,specVersion,debug); } // } } tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " Instrument Reconfigured"); SpireMsg(0," Instrument Reset (" + (time() - t) + " secs)"); // SpireMsg(0,"Observation Completed (" + time() + " seconds)"); SpireMsg(0,"Note: Total time (s) = Observation Completed time - slew time + Observatory Overheads"); assert (time() == ts[0] + ts[1]); // return {1,jiggleSize,perScanOsit1,nScans1,perScanOsit2,nScans2,iround(srcTime),time() - iround(srcTime) - tslew}; } // SpirePOF5Estimate // // $Id:$ // // This procedure calculates the estimated noise and signal/noise // for the given observing time. // // for input values, a value less than 0 indicates value unknown // // 18/01/07: v1.4: updated to work for different opsMOdes and use Teff to calculate sensitivity // 20/04/07: v1.5: added rate as an input parameter // v1.6: SCR3054 // v1.7: SCR3012 // 07/02/09: Updated to select sensitivity tables depending on value of isBright // // {string,double,double,double,double,bool,double,double,double}[] procedure SpirePOF5Estimate { string obsMode = "POF5_F_scana"; double tau = 1.0; // integration time factor (number of map repeats) double scanRate = 0.0; double sourceFluxPSW = -1.0; double sourceFluxPMW = -1.0; double sourceFluxPLW = -1.0; double sourceBrightPSW = -1.0; double sourceBrightPMW = -1.0; double sourceBrightPLW = -1.0; bool isBright = false; }{ SpireMsg(3," Calculating POF5 noise estimates"); SpireMsg(3," $Id:$"); SpireMsg(3," Input:"); SpireMsg(3," ObsMode: " + obsMode); SpireMsg(3," Integration time factor: " + tau); SpireMsg(3," PSW Flux density: " + sourceFluxPSW); SpireMsg(3," PMW Flux density: " + sourceFluxPMW); SpireMsg(3," PLW Flux density: " + sourceFluxPLW); SpireMsg(3," PSW Surface Brightness: " + sourceBrightPSW); SpireMsg(3," PMW Surface Brightness: " + sourceBrightPMW); SpireMsg(3," PLW Surface Brightness: " + sourceBrightPLW); SpireMsg(3," isBright: " + isBright); // // calculate effective integration times // string tabName = "Phot_Sensitivities.txt"; if(isBright) { tabName = "Phot_BrightSensitivities.txt"; } double psw_teff = dlookup(tabName,obsMode,"PSWTeff"); psw_teff = psw_teff / scanRate; double pmw_teff = dlookup(tabName,obsMode,"PMWTeff"); pmw_teff = pmw_teff / scanRate; double plw_teff = dlookup(tabName,obsMode,"PLWTeff"); plw_teff = plw_teff / scanRate; // // generate sensitivities // // fetch the flux uncertainty information for the obsMode double psw_func = dlookup(tabName,obsMode,"PSWFluxUnc") / sqrt(psw_teff); double pmw_func = dlookup(tabName,obsMode,"PMWFluxUnc") / sqrt(pmw_teff); double plw_func = dlookup(tabName,obsMode,"PLWFluxUnc") / sqrt(plw_teff); // fetch the surface brightness uncertainty information for the obsMode double psw_bunc = dlookup(tabName,obsMode,"PSWBrightUnc") / sqrt(psw_teff); double pmw_bunc = dlookup(tabName,obsMode,"PMWBrightUnc") / sqrt(pmw_teff); double plw_bunc = dlookup(tabName,obsMode,"PLWBrightUnc") / sqrt(plw_teff); // fetch confusion limits double psw_conf = dlookup(tabName,obsMode,"PSWConfLim"); double pmw_conf = dlookup(tabName,obsMode,"PMWConfLim"); double plw_conf = dlookup(tabName,obsMode,"PLWConfLim"); SpireMsg(3," Input Sensitivity Values:"); SpireMsg(3," Band: PSW PMW PLW"); SpireMsg(3," Flux Uncertainty: " + psw_func + " " + pmw_func + " " + plw_func); SpireMsg(3," Surface Brightness Uncertainty: " + psw_bunc + " " + pmw_bunc + " " + plw_bunc); SpireMsg(3," Conf Limit: " + psw_conf + " " + pmw_conf + " " + plw_conf); // // calculate noise estimates {string,double,double,double,double,bool,double,double,double}[] estimates = [{"250",sourceFluxPSW,-1.0,-1.0,psw_conf,false,sourceBrightPSW,-1.0,-1.0},{"350",sourceFluxPMW,-1.0,-1.0,pmw_conf,false,sourceBrightPMW,-1.0,-1.0},{"500",sourceFluxPLW,-1.0,-1.0,plw_conf,false,sourceBrightPLW,-1.0,-1.0}]; estimates[0]{2} = psw_func / sqrt(tau); if(estimates[0]{2} < psw_conf) { estimates[0]{5} = true; } if(sourceFluxPSW >= 0.0) { estimates[0]{3} = sourceFluxPSW / estimates[0]{2}; if(estimates[0]{3} > 200.0) { estimates[0]{3} = 200.0; } } estimates[0]{7} = psw_bunc / sqrt(tau); if(sourceBrightPSW >= 0.0) { estimates[0]{8} = sourceBrightPSW / estimates[0]{7}; if(estimates[0]{8} > 200.0) { estimates[0]{8} = 200.0; } } estimates[1]{2} = pmw_func / sqrt(tau); if(estimates[1]{2} < pmw_conf) { estimates[1]{5} = true; } if(sourceFluxPMW >= 0.0) { estimates[1]{3} = sourceFluxPMW / estimates[1]{2}; if(estimates[1]{3} > 200.0) { estimates[1]{3} = 200.0; } } estimates[1]{7} = pmw_bunc / sqrt(tau); if(sourceBrightPMW >= 0.0) { estimates[1]{8} = sourceBrightPMW / estimates[1]{7}; if(estimates[1]{8} > 200.0) { estimates[1]{8} = 200.0; } } estimates[2]{2} = plw_func / sqrt(tau); if(estimates[2]{2} < plw_conf) { estimates[2]{5} = true; } if(sourceFluxPLW >= 0.0) { estimates[2]{3} = sourceFluxPLW / estimates[2]{2}; if(estimates[2]{3} > 200.0) { estimates[2]{3} = 200.0; } } estimates[2]{7} = plw_bunc / sqrt(tau); if(sourceBrightPLW >= 0.0) { estimates[2]{8} = sourceBrightPLW / estimates[2]{7}; if(estimates[2]{8} > 200.0) { estimates[2]{8} = 200.0; } } // // return values SpireMsg(3," Output Estimates:"); SpireMsg(3," Band: " + estimates[0]{0} + " " + estimates[1]{0} + " " + estimates[2]{0}); SpireMsg(3," Source Flux " + estimates[0]{1} + " " + estimates[1]{1} + " " + estimates[2]{1}); SpireMsg(3," 1 Sigma Flux Noise: " + estimates[0]{2} + " " + estimates[1]{2} + " " + estimates[2]{2}); SpireMsg(3," Flux Signal/Noise: " + estimates[0]{3} + " " + estimates[1]{3} + " " + estimates[2]{3}); SpireMsg(3," Conf Level: " + estimates[0]{4} + " " + estimates[1]{4} + " " + estimates[2]{4}); SpireMsg(3," Conf Flag: " + estimates[0]{5} + " " + estimates[1]{5} + " " + estimates[2]{5}); SpireMsg(3," 1 Sigma Brightness Noise: " + estimates[0]{7} + " " + estimates[1]{7} + " " + estimates[2]{7}); SpireMsg(3," Brightness Signal/Noise: " + estimates[0]{8} + " " + estimates[1]{8} + " " + estimates[2]{8}); // return estimates; } // SpireBbCcuMonitorPeriodDefault // // $Id:$ // // Building Block to set CCU monitoring period for cooler recycling // block SpireBbCcuMonitorPeriodDefault SPIRE 11777 { }{ SpireCcuMonitorPeriodDefault(); sync(); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_EndPhaseUp.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to reconfigure at the end of // SpirePhoto/Spectro_Cal_PhaseUp. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // // 2009/05/05 V1.0: Initial version adapted from // SpireBb_EndBsmAngleCal (2009/05/05 V1.2), // SpirePhoto_Cal_PhaseUp (2009/03/30 V1.4), and // SpireSpectro_Cal_PhaseUp (2009/03/04 V0.5) // /////////////////////////////////////////////////////////////////////////// // block SpireBb_EndPhaseUp SPIRE 14049 { bool phot = true; // Photometer (==tick) or FTS (==untick)? bool isBright = false in [true,false]; // IsBright (==tick) flag string version01 = "v00"; // Version in cal.tab. SpireTable_PhotModeParams string version02 = "v00"; // Version in cal.tab. SpireTable_CommonModeParams bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // int mode_id = 0; string obsmode = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB EndPhaseUp reconfiguration started"); SpireMsg(2," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Set instrument back to Phot/Spec-STBY: // if(phot) { SpireProc_Set_PhotMode("PHTSTBY",isBright,version01,version02,debug); } else { SpireProc_Set_SpecMode("SPECSTBY",isBright,version01,version02,debug); } // // // // // End observation: // SpireProc_Set_EndObsAll(phot); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB EndPhaseUp reconfiguration ended"); SpireMsg(1," ..Reconfiguration to " + obsmode + "mode (" + (time() - t) + " seconds)"); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireSpectro_Cal_MultiLevelNoise.txt // /////////////////////////////////////////////////////////////////////////// // // CUS script for: 'Spec Multi-Level Noise' // // in *basic_fine_pointing* or *no_pointing* mode // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/06/09 V0.1: Initial version adapted from // SpirePhoto_Cal_MultiLevelNoise (2008/08/04 V0.3) // 2008/11/11 V0.2: Allow 'no pointing' as input option; Adapt debug printing // 2008/11/12 V0.3: Implement mode setting; Add isBright // Change 'no pointing' implementation // 2009/02/19 V0.4: Add debug_print as input and pass it to low level scripts. // Use new SpireBb_EndObsAll and SpireBb_StartObsAll. // Read nominal bias frequency and bias divider from new // SpireTable_SpecModeParams. Implemented message // if activating isBright setting. Implemented setting // of datarates. Remove cal table name from input and // hardcode. Use SpireBb_SpecSetMode to set to SPECSTBY // during SLEW and FINAL_HOLD. Unset isBright if set. // Read boresight from SpireTable_OpsParms. Fixed bug in // low level script SpireProc_Exec_SpecMultiLevelNoise, // biasfreq and samplerate were set each time in loop. // 2009/03/04 V0.5: Add isSerendipity, isPcal, and 8 more dummy parameters // to the script for future use. Change isBright behaviour. // Subtract isBright phase shift read from one calibration // file from the nominal phase value in the other calibration // file. // 2009/05/06 V0.6: Add in move BSM/SMEC to hold/home at start. Add new // SpireBb_SmecHold to account for the fact that // SpireBb_SmecMove2Home does not stop SMEC. // Gather procedures at start and end in separate BB. // // Sunil Sidher // 2009/07/21 V0.7: Implemented isPcal flag to perform standard AOT style PCAL flashes after each bias setting // /////////////////////////////////////////////////////////////////////////// // // Script assumes that: // // 1) Instrument is in SPECSTBY at beginning // (i.e. bias amplitude, phase, frequency [mclkdiv,biasdiv] are nominal) // // 2) Phase is adjusted with changing bias amplitude and frequency. // // 3) Levels/phases are read from CalTable: // SpireTable_SpecMultiLevelNoiseLevels.txt // // 4) Phase shift for isBright setting can be read from following // cal table: SpireTable_IsBrightPhaseShift.txt // // 5) Bias frequency and sampling rate are user inputs // // 6) Boresight of array can be read from following cal table: // Spire_TableOpsParms.txt // /////////////////////////////////////////////////////////////////////////// // obs SpireSpectro_Cal_MultiLevelNoise { /* ****************************************************** */ /* USER PARAMETER DEFINITION, CUS SIGNATURE for EX-HSpot */ /* ****************************************************** */ /* */ double ra = 0.0 in [0.0,360.0]; // RA of target double dec = 0.0 in [-90.0,90.0]; // DEC of target bool isBright = false; // Use settings for bright source (==tick) (Note: Only phases values will be changed!) bool pointing = true; // Should telescope 'point' (==tick) or do a 'no pointing' (==untick)? /* */ double biasfreq = 160.09 in [80.0,240.0]; // Bias frequency [Hz] double samplerate = 80.05 in [1.0,80.5]; // Sampling rate [Hz] (Careful, don't exceed number of data packages to be transferred from spacecraft!) int ftime = 300; // Readout time at each bias level [s] string version01 = "v00"; // Version in cal table SpireTable_SpecModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams string version03 = "v00"; // Version in cal table SpireTable_SpecMultiLevelNoiseLevels string version05 = "v00"; // Version in cal table SpireTable_OpsParms.txt string version06 = "v00"; // Version in cal table SpireTable_IsBrightPhaseShift bool debug = false; // Allow (==tick) or suppress cus debug_print statements bool isSerendipity = true; // Allow (==tick) serendipity mode to be activated or prohibit (==untick) it (currently not in use)? bool isPcal = true; // Allow (==tick) regular PcalFlash in script or prohibit (==untick) it?. bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) /* */ }{ // // // // // Check for is bright setting: // if(isBright) { message("IsBright selected! SxW bias amplitude is unchanged but isBright phase-shift is subtracted."); } // // // // // Declare some variable: // // Photometer or FTS: bool phot = false; bool fts = !phot; // string tabName = ""; string selCol = ""; string selVal = ""; string tarCol = ""; string version = ""; double scirate = 0.0; double chkrate = 0.0; double nhkrate = 0.0; // // Hardcoded calibration tables: // string tabName01 = "SpireTable_SpecModeParams.txt"; string tabName02 = "SpireTable_CommonModeParams.txt"; string tabName03 = "SpireTable_SpecMultiLevelNoiseLevels.txt"; string tabName04 = "SpireTable_BsmNominalSettings.txt"; string tabName05 = "SpireTable_OpsParms.txt"; string tabName06 = "SpireTable_IsBrightPhaseShift.txt"; string tabName09 = "SpireTable_SmecNominalSettings.txt"; // // Currently hardcoded version and model parameter: // string version09 = "v00"; // Version in cal table SpireTable_SmecNominalSettings string version04 = "v00"; // Version in cal table SpireTable_BsmNominalSettings string model = "initial"; // Model in cal table SpireTable_BsmNominalSettings // // // // // Setup mode: // string obsModeQla = "ENG_CAL_OBS37"; // Note: this needs entry in MIB table and in SpireTableInstConfigs.txt // // Set obsMode for datarates: string obsMode = "SEngCalObs"; // Note: this is currently only a maximum value // // // // // Read BSM home parameters: // // Select version flag and set GetTableEntry parameters: // version = version04; tabName = tabName04; selCol = "model"; // Name of column for selecting selVal = model; // Value of 'string' selector // // Read hold position from calibration table: // tarCol = "chop_0_I"; int hold_chop = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "jigg_0_I"; int hold_jigg = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // // // // Read SMEC home position from calibration file: // tarCol = "Home"; tabName = tabName09; selVal = version09; int smecHomePosn = ilookup(tabName,selVal,tarCol); // // ****************************************************** */ // CALCULATE DURATIONS for POINTING STATES */ // ****************************************************** */ // // // // // Calculate timing for the pointing request: // // BBs called during slew: int tslewmin = duration(SpireBb_StartMultiLevelNoise(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,debug)); // // BBs carried out when the pointing is reached: if(pointing) { int tinithold = 0; } else { tinithold = tslewmin; } // // BB carried out during pointing: int tp = duration(SpireProc_Exec_SpecMultiLevelNoise(biasfreq,samplerate,tabName03,version03,isBright,isPcal,tabName06,version06,ftime,debug)); // // BB carried out at the end: int tfinalhold = duration(SpireBb_EndMultiLevelNoise(phot,isBright,version01,version02,debug)); // if(debug) { debug_print("tslewmin = " + tslewmin); debug_print("tinithold = " + tinithold); debug_print("tpointing = " + tp); debug_print("tfinalhold = " + tfinalhold); } // // ****************************************************** */ // POINTING MODE DECLARATION */ // ****************************************************** */ // // // // // Lookup boresight: // tabName = tabName05; selCol = "mode"; selVal = obsMode; tarCol = "Boresight"; version = version05; string ib = SpireProc_GetTableEntryString(tabName,selCol,selVal,tarCol,version,debug); // // Set pointing mode: // if(pointing) { int[] ts = basic_fine_pointing(true,tslewmin,tinithold,tfinalhold,ib,0,ra,dec,0.0,0.0,tp); } else { ts = no_pointing(true,tinithold,tfinalhold,tp); } // if(debug) { debug_print("Output timing vector from the pointing request: " + ts); } // }{ // ****************************************************** */ // POINTING STATES WITH OBSERVING MODE LOGIC */ // ****************************************************** */ // // // // // Set datarates: // string rateType = "chk"; chkrate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); ess_hk_data_rate(chkrate); // rateType = "nhk"; // nhkrate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); non_ess_hk_data_rate(nhkrate); // rateType = "sci"; scirate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); data_rate(scirate); // if(debug) { debug_print("Set CHK datarate to: " + chkrate); debug_print("Set NHK datarate to: " + nhkrate); debug_print("Set SCI datarate to: " + scirate); } // // // Start the state_machine: // int[] state = [0]; // while(state[0] >= 0) { if(debug) { debug_print("Current state: " + state); } state = next_state(); if(debug) { debug_print("Next state: " + state); } // // if(state[0] == 1) { // STATE = SLEW ( Spacecraft is slewing ) // // // // // Startup observation: // SpireBb_StartMultiLevelNoise(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,debug); // //delay(timeSlewCal); } if(state[0] == 2) { // STATE = INIT_HOLD ( spacecraft is idling at source ) // // // // // // If no pointing observation do stuff here which is // done nominally during SLEW: // if(!pointing) { // // // // // Startup observation: // SpireBb_StartMultiLevelNoise(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,debug); // } // //delay(tinithold); // } if(state[0] == 3) { // STATE = POINT ( spacecraft is at nominal RA,DEC (staring, raster) ) // // // // // // Execute Multi-Level Noise task: // SpireProc_Exec_SpecMultiLevelNoise(biasfreq,samplerate,tabName03,version03,isBright,isPcal,tabName06,version06,ftime,debug); // //delay(tp); // } if(state[0] == 5) { // STATE = FINAL_HOLD ( "sky" observation ends, performing final activ.) // // // // // Set scientific datarate back to zero: // data_rate(0.0); // // // // // Reconfigure at the end (incl. resetting of OBSID and BBIB): // SpireBb_EndMultiLevelNoise(phot,isBright,version01,version02,debug); // } if(state[0] == -1) { // STATE = END ( end of the pointing/commanding part of the code ) // } } } // Missionphase : EQM IMT // // Purpose : Setup SPU for photometry data flow // // Author : Bart Vandenbussche // // Arguments : // // Description : Configures photometry compression /reduction mode and (optionally) starts // reduction/compression // // Dependencies : // // Comments : // // Version : 1.4.4 // // History : 1.0 18-Apr-2005 BV - first version after Thomas' tcl script\ // and Diego's SPEC_spu_setup // 1.1 19-apr-2005 DAC Use Array2grp_1 to generate TC operands // 1.2 09-aug-2006 TM update of WRT_DET_CST_PHOT parameters // 1.3 23-aug-2006 TM update for SPU HLSW UM, issue 12.8 // 1.4 28-mar-2007 DAC Update for SPUv13.x // 1.4.1 29-mar-2007 Set scm = 1 (new compression scheme) // 1.4.2 4-apr-2007 SCM back to zero // 1.4.3 10-apr-2007 SCM back to 1 // 1.4.4 11-apr-2007 SCM back to 0 // 1.4.5 16-jun-2007 SCM back to 1 // 1.4.6 23-feb-2008 TM: update for new SPU OBSW (shift 1, option to do bit rounding) // 1.4.7 24-mar-2009 DAC Rename spr1&spr2 per SPU UM 13.95a // int procedure PHOT_spu_setup { int comp_mode_blu = 0; // Compression blue: default=0, double=1, half=2, lossless=4, transp=7, buffer=9 int comp_mode_red = 0; // Compression blue: default=0, double=1, half=2, lossless=4, transp=7, buffer=9 int nraw_blu = 3; // Number of raw channels transmitted in the blue SPU int nraw_red = 3; // Number of raw channels transmitted in the red SPU bool startSPU = true; // Start SPU or not [true,false] }{ // Duration accumulator (accumulated time expressed in milliseconds) // (no longer used) int duration_msec = 0; // Stop the Long and Short SPUs Pacs_SPUS_STOP_REDUCT_COMPR(); Pacs_SPUL_STOP_REDUCT_COMPR(); // Set the SPU compression modes int[] aux = [comp_mode_blu,comp_mode_red]; int check_sum = checksum("int",aux); // Issue the TC {int}[] comp_par = Array2grp_1(aux); Pacs_DMC_WRT_SPU_TRAN_MODE(comp_par,check_sum); // Setting of start index of raw channels for SPUS and SPUL string spus_obs_mode = "PHOT"; string spul_obs_mode = "PHOT"; int spus_startraw = 1; int spul_startraw = 1; Pacs_SPUS_RAW_CHAN_TRAN_MODE(spus_obs_mode,nraw_blu,spus_startraw); Pacs_SPUL_RAW_CHAN_TRAN_MODE(spul_obs_mode,nraw_red,spul_startraw); // Photo "Ottensamer" block ("S" SPU) // PPF: Pre-Processing Flag (0: no PP, 1: addition, 2: subtraction, // 3: multiplication, 4: division) int ppf = 0; // PPP: Pre-Processing Parameter int ppp = 0; // Threshold for glitch detection in photometry int tfp = 1000; // Threshold for chopper position deviation in photometry int tcp = 100; // Glitch detection for photometry (1: no glitch detection) int gdfp = 1; // Override samples to average int navg = 0; // resolution reduction parameter 2 (rnd: number of bits for optional rounding: // low gain: 0, high gain: 1-2, RO's recommendation: 2 in high gain) int rnd = 0; // resolution reduction parameter 3 (rnds: rounding strategy: best option 0) int rnds = 0; // Lossless scheme int scm = 1; // lossless compression algorithm (0,1,2,3,4) int lcal = 4; // PACS Codec Order (3,4) int pcod = 3; // dpre: delete pre (number of readouts to be discarded in group at beginning) int dpre = 0; // dpost: delete post (number of readouts to be discarded at the end of a group) int dpost = 0; // syncd: synchronisation delay: number of readouts delayed to start averaging int syncd = 1; // Spare elements: 10 spare element; hardcoded as 0,0,... in operand // Create operand aux = [ppf,ppp,tfp,tcp,gdfp,navg,rnd,rnds,scm,lcal,pcod,dpre,dpost,syncd,0,0,0,0,0,0,0,0,0,0]; check_sum = checksum("int",aux); // Convert to grp_1 syntax {int}[] spu_par = Array2grp_1(aux); // Issue TC Pacs_SPUS_WRT_DET_CST_PHOT(spu_par,check_sum); delay(1); // Photo "Ottensamer" block ("L" SPU) // PPF: Pre-Processing Flag (0: no PP, 1: addition, 2: subtraction, // 3: multiplication, 4: division) ppf = 0; // PPP: Pre-Processing Parameter ppp = 0; // Threshold for glitch detection in photometry tfp = 1000; // Threshold for chopper position deviation in photometry tcp = 100; // Glitch detection for photometry (1: no glitch detection) gdfp = 1; // Override samples to average navg = 0; // resolution reduction parameter 2 (rnd: number of bits for optional rounding: // low gain: 0, high gain: 1-2, RO's recommendation: 2 in high gain) rnd = 0; // resolution reduction parameter 3 (rnds: rounding strategy: best option 0) rnds = 0; // Lossless compression scheme scm = 1; // lossless compression algoithm (0,1,2,3,4) lcal = 4; // PACS Codec Order (3,4) pcod = 3; // dpre: delete pre (number of readouts to be discarded in group at beginning) dpre = 0; // dpost: delete post (number of readouts to be discarded at the end of a group) dpost = 0; // syncd: synchronisation delay: number of readouts delayed to start averaging syncd = 1; // Spare elements: 10 spare element; hardcoded as 0,0,... in operand // Create operand aux = [ppf,ppp,tfp,tcp,gdfp,navg,rnd,rnds,scm,lcal,pcod,dpre,dpost,syncd,0,0,0,0,0,0,0,0,0,0]; check_sum = checksum("int",aux); // Convert to grp_1 syntax spu_par = Array2grp_1(aux); // Issue TC Pacs_SPUL_WRT_DET_CST_PHOT(spu_par,check_sum); delay(1); // Send time stamps // DMC_WRT_TIME: Write the time sent by the DPU into the DMC buffer // (No action on this one?) // DPU sends the time to DEC/MEC Pacs_DPU_SEND_TIME(); // DMC_SET_TIME: Set the time previously written by the write time command Pacs_DMC_SET_TIME(); // Start reduction/compression if commanded to do so if(startSPU) { Pacs_SPUS_START_REDUCT_COMPR(); Pacs_SPUL_START_REDUCT_COMPR(); } return duration_msec; } // SpireBbSdetOff // // $id$ // // This building block switches off the photometer detectors // // 07/05/2009 KJK: // First Version // block SpireBbSdetOff SPIRE 1551 { }{ int t0 = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SdetOff started"); SpireMsg(2," $Id:$"); // int cmd = 0x0; // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // Set STEP to 0 SpireSetObsStep(0x0); delay(1); // // Set MODE to SDET_OFF SpireSetObsMode("SDET_OFF"); delay(1); // // Switch off SSW VDD and VSS SpireSendDrcuCmd(0x84370001,0); for(int i = 0 .. 1) { SpireSendDrcuCmd(0x84350000 + 0x10000 * i,0); delay(1); } // // Switch off SLW VDD and VSS SpireSendDrcuCmd(0x84370000,0); SpireSendDrcuCmd(0x84340000,0); delay(1); // // Set DEMOD PHASE TO ZERO SpireSendDrcuCmd(0x843a0000,0); SpireSendDrcuCmd(0x843b0000,0); delay(1); // // Set BIAS TO ZERO SpireSendDrcuCmd(0x84310000,0); SpireSendDrcuCmd(0x84320000,0); delay(1); // // Switch OFF SLIAs SpireSendDrcuCmd(0xa0870004,0); delay(4); // // completion tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SdetOff ended"); SpireMsg(1," ..SDET Switch Off (" + (time() - t0) + " seconds)"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_SmecScan.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to scan SMEC // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/03/25 V0.1: Initial version adapted from // SpireBb_SmecScan (2008/11/03 V0.1) // SpireBbFtsScan (KJK, 2009/01/01) // /////////////////////////////////////////////////////////////////////////// // Script assumes that: // // 1) SMEC scan parameters can be read from calibration table: // SpireTable_Spectrometer.txt // // 2) SMEC is at scanStart at the start of the procedure. // // 3) To have the SMEC also at the scanStart at the end of a scan // the input number of scans will be doubled, regardless of // using SAWTOOTH or TRIANGUAR scan mode. Note, this could means // that depending on the mode one could get a different S/N (up // to a factor of ~2). // // 4) Script assumes that DCU and MCU data collection is already // switched on, it will be switched off outside where also // the FIFOs will be flushed. // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_SmecScan { string resolution = "L" in ["L","M","H","C"]; // Resolution (low, medium, high,calibration) int nscans = 1; // Number of SMEC scans (back+forth == 1) string version = "v00"; // Version in cal table SpireTable_Spectrometer bool debug = false; // Allow (==tick) or suppress cus debug_print statement }{ // // // // // Define some variables: // string tstr = ""; string selCol = ""; string selVal = ""; string tarCol = ""; // // Hardcoded calibration tables: // string tabName = "SpireTable_Spectrometer.txt"; // // // // // // Start procedure: // tstr = SpireTimeStr(time()); SpireMsg(4," " + tstr + ": SpireProc_Setup_SmecScan started"); SpireMsg(4," $Id:$"); // // // // // Retrieve required SMEC parameters from calibration tables: // int scanStart = SpireProc_GetTableEntryInt("SpireTable_Spectrometer.txt","ResChar",resolution,"ScanStart",version,debug); int scanEnd = SpireProc_GetTableEntryInt("SpireTable_Spectrometer.txt","ResChar",resolution,"ScanEnd",version,debug); int scanFSpeed = SpireProc_GetTableEntryInt("SpireTable_Spectrometer.txt","ResChar",resolution,"ScanFSpeed",version,debug); int scanRSpeed = SpireProc_GetTableEntryInt("SpireTable_Spectrometer.txt","ResChar",resolution,"ScanRSpeed",version,debug); // string waveform = SpireProc_GetTableEntryString("SpireTable_Spectrometer.txt","ResChar",resolution,"Waveform",version,debug); // if(debug) { debug_print("scanStart: " + scanStart); debug_print("scanEnd: " + scanEnd); debug_print("scanFSpeed: " + scanFSpeed); debug_print("scanRSpeed: " + scanRSpeed); // debug_print("waveform: " + waveform); } // // // // // Adjust nscans to obtain correct number of scans: // (to always start and end at scanStart) // nscans = nscans * 2; // // // // // Calculate the scan 'forward','reverse' travel times: // int scanFTime = iceil(double(scanEnd - scanStart) * (double(nscans) / 2.0) / double(scanFSpeed)); int scanRTime = iceil(double(scanEnd - scanStart) * (double(nscans) / 2.0) / double(scanRSpeed)); // if(debug) { debug_print("scanFTime: " + scanFTime); debug_print("scanRTime: " + scanRTime); } // // // // // Specify number of scans // SpireSendDrcuCmd(0x90480000 + nscans,0); // // // // // Start scanning: // SpireSendDrcuCmd(0x90490002,0); delay(scanFTime + scanRTime + nscans * 1 + 2); // Note, allow 1 sec for turnaraound at end of each scan. // Note, add 2 sec at the very end as a saftey margin. // Note, nscans is already included in scanFTime and scanRTime. // // // // // End procedure: // tstr = SpireTimeStr(time()); if(debug) { debug_print("tstr: " + tstr); } SpireMsg(4," " + tstr + ": SpireProc_Setup_SmecScan ended"); // } //CLName: JM64 //VMVersion: 2.8 //CLVersion: 1.3 //CLCVSId: $ID$ //TableId: 0x33 //TableLength: 0x80 //Date: 090722103224 // // Created by Sunil Sidher on 22/07/2009 in response to SPIRE SCR-1670 // Normally the JM64 table is created as a BB (Number 3045) but here it is created as a procedure to prevent nesting of BBs // procedure SpireProc_Load_JmTable { }{ int t_min = 1; //set table command call for table id 0x33 Spire_SET_TABLE(0x33,0x80); delay(t_min); //update table command call for table index 0x0000 Spire_UPDATE_TABLE(0x33,0x0,38,[{0xa192d122},{0xa1924608},{0xa922d27e},{0xa922486a},{0xb0b2d122},{0xb0b24608},{0xbfd2d122},{0xbfd24608},{0xb842d27e},{0xb842486a},{0xb0b2d3ce},{0xb0b24acf},{0xb842d513},{0xb8424d37},{0xb0b2d64d},{0xb0b24fa1},{0xb0b2d89c},{0xb0b2547c},{0xa922d9b1},{0xa92256ec},{0xa192d89c},{0xa192547c},{0xa922d77a},{0xa922520d},{0xa192d64d},{0xa1924fa1},{0xa922d513},{0xa9224d37},{0xa192d3ce},{0xa1924acf},{0x9a02d27e},{0x9a02486a},{0x9271d122},{0x92714608},{0x8ae1d27e},{0x8ae1486a},{0x9271d3ce},{0x92714acf}]); delay(t_min); Spire_UPDATE_TABLE(0x33,0x26,38,[{0x9a02d513},{0x9a024d37},{0x9271d64d},{0x92714fa1},{0x9a02d77a},{0x9a02520d},{0x9a02d9b1},{0x9a0256ec},{0x9271d89c},{0x9271547c},{0x8ae1d9b1},{0x8ae156ec},{0x8ae1d77a},{0x8ae1520d},{0x8351d64d},{0x83514fa1},{0x8ae1d513},{0x8ae14d37},{0x8351d3ce},{0x83514acf},{0x7bc1d27e},{0x7bc1486a},{0x8351d122},{0x83514608},{0x8ae1cfbb},{0x8ae143a9},{0xa922cfbb},{0xa92243a9},{0xb0b2ce49},{0xb0b2414d},{0xb842cfbb},{0xb84243a9},{0xbfd2ce49},{0xbfd2414d},{0xb842cccd},{0xb8423ef5},{0xb0b2cb46},{0xb0b23ca1}]); delay(t_min); Spire_UPDATE_TABLE(0x33,0x4c,38,[{0xb842c9b5},{0xb8423a50},{0xb0b2c81a},{0xb0b23804},{0xb0b2c4c7},{0xb0b23378},{0xa922c675},{0xa92235bc},{0xa192c4c7},{0xa1923378},{0xa192c81a},{0xa1923804},{0xa922c9b5},{0xa9223a50},{0xa192cb46},{0xa1923ca1},{0xa922cccd},{0xa9223ef5},{0xa192ce49},{0xa192414d},{0x9271ce49},{0x9271414d},{0x8ae1cccd},{0x8ae13ef5},{0x8351ce49},{0x8351414d},{0x7bc1cfbb},{0x7bc143a9},{0x7bc1cccd},{0x7bc13ef5},{0x8351cb46},{0x83513ca1},{0x8ae1c9b5},{0x8ae13a50},{0x8351c81a},{0x83513804},{0x8ae1c675},{0x8ae135bc}]); delay(t_min); Spire_UPDATE_TABLE(0x33,0x72,14,[{0x9271c4c7},{0x92713378},{0x9a02c675},{0x9a0235bc},{0x9271c81a},{0x92713804},{0x9a02c9b5},{0x9a023a50},{0x9271cb46},{0x92713ca1},{0x9a02cccd},{0x9a023ef5},{0x9a02cfbb},{0x9a0243a9}]); delay(t_min); } // SpireBbSOF1Config // // $Id:$ // // Building Block to configure the instrument for SOF1 operations // // The complete instrument setup operation is divided into two parts: // Configuration: actions that can be executed during the slew to the start // position of the S/C pointing mode. // Initialisation: actions that must be carried out at the S/C intial pointing // position before any observational operations are executed. // // This building Block implements the first part of the setup: // It assumes the instrument is in the SPECSTBY mode (with SMEC at Home position) // Reset SMEC encoder , in case it has lost steps // Move SMEC to scan start position // // 28 January 2009 V1.1 KJK // Remove Mode setting - now carried out in SpireBb_StartObsAll // Remove DRCU Counter resetting - now carried out in SpireBb_StartObsAll // Use SpireProc_SmecMove to move into position - assuming SMEC is at Home position // block SpireBbSOF1Config SPIRE 8368 { string res = "H"; string specVersion = "v00"; bool debug = false; }{ string version = "v00"; int t = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SOF1 Configuration started"); SpireMsg(2," $Id:$"); // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // ..... configuration ..... // // Reset SMEC encoder // // Move mechanism to zero position int smecHome = ilookup("SpireTable_SmecNominalSettings.txt",version,"Home"); SpireProc_SmecMove(0,smecHome,debug); // Reset encoder SpireSendDrcuCmd(0x90490004,0); // hold position SpireSendDrcuCmd(0x90490000,0); delay(1); // // Move mechanism to scan start position ready to scan int scanStart1 = SpireProc_GetTableEntryInt("SpireTable_Spectrometer.txt","ResChar",res,"ScanStart",specVersion,debug); SpireProc_SmecMove(scanStart1,0,debug); // // ..... completion ..... // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SOF1 Configuration ended"); SpireMsg(1," ..SOF1 Configuration (" + (time() - t) + " seconds)"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_StartPtcPwr.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to configure at the start of SpirePhoto_Cal_PtcPwr. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // // 2009/05/06 V0.1: Initial version adapted from // SpireBb_StartBsmAngleCal (2009/05/05 V0.1) and // SpirePhoto_Cal_PtcPwr (2009/03/30 V0.1). // BB includes now to move BSM to hold. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_StartPtcPwr SPIRE 14058 { bool phot = true; // Photometer (==tick) or FTS (==untick)? string obsModeQla = "ENG_CAL_OBS13"; string obsMode = "PEngCalObs"; bool isBright = false; // Use settings for bright source (==tick) string version01 = "v00"; // Version in cal table SpireTable_Phot/SpecModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams int hold_chop = 37632; // Chop hold position int hold_jigg = 39520; // Jiggle hold position bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // int mode_id = 0; string obsmode = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB StartPtcPwr configuration started"); SpireMsg(2," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Startup observation: // SpireProc_Set_StartObsAll(obsModeQla); // // // // // Move BSM back to hold: // SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug); // // // // // Initialise instrument (in case to isBright): // if(phot) { SpireProc_Set_PhotMode(obsMode,isBright,version01,version02,debug); } else { SpireProc_Set_SpecMode(obsMode,isBright,version01,version02,debug); } //delay(timeSlewCal); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB StartPtcPwr configuration ended"); SpireMsg(1," ..StartPtcPwr took " + (time() - t) + " seconds)"); // } // SpireBbPOF2Config // // $Id:$ // // Building Block to configure the instrument for POF2 (7-point jiggle) operation // // The complete instrument setup operation is divided into two parts: // Configuration: actions that can be executed during the slew to the start // position of the S/C pointing mode. // Initialisation: actions that must be carried out at the S/C intial pointing // position before any observational operations are executed. // // This building Block implements the first part of the setup // // 09/02/09: KJK // - Removed setting of Mode and resetting DRCU counters - // These are now implemented in SpireBb_StartObsAll // - Add possible bright-source setting // 14/02/09: MP // - Replace calls to SpireProc_Set_PhotPhase/Bias with // call to SpireProc_Set_PhotBright // 04/03/09: MP // - Fixed bug in call to SpireProc_Set_PhotBright // 02/07/09: KJK // - renamed version to photVersion // block SpireBbPOF2Config SPIRE 8224 { string obsMode = "POF2"; bool isBright = false in [true,false]; string photVersion = "v00"; bool debug = false in [true,false]; }{ int t = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB POF2 Configuration started"); SpireMsg(2," $Id:$"); // // ..... configuration ..... // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // set bright-source biases and phases - if needed // if(isBright) { SpireProc_Set_PhotBright(obsMode,photVersion,debug); } // // ..... completion ..... // delay(2); // to allow hsk to stabilise // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB POF2 Configuration ended"); SpireMsg(1," ..POF2 Configuration (" + (time() - t) + " seconds)"); } // SpirePOF5Observing_PV // // $Id: SpirePOF5Observing.txt,v 1.8 2007/04/20 12:29:27 kking Exp $ // // This is the procedure to calculate // instrument observing parameters for the Scan Map observing mode // // Note: // This procedure assumes that 2 seconds are required at the start of the scan to allow // setting of the BB and STEP. // It also assumes that 2 seconds are required at the end of the scan to // reset the STEP parameter // // 13/04/07: SCR3010 - changed default obsMode // 17/07/08: DAC. Accept patt as input to override CAL-U value // {double,double,int,int,int,int} procedure SpirePOF5Observing_PV { string obsMode = "POF5_S_N"; int nRepeats = 1; // requested number of map repeats double mapWidth = 0.0; // requested map width (arcmins) double mapHeight = 0.0; // requested map height (arcmin) double patt = 0.0; // scan pattern rotation }{ SpireMsg(2," Observing mode POF5 Observing Parameters "); SpireMsg(2," $Id: SpirePOF5Observing.txt,v 1.8 2007/04/20 12:29:27 kking Exp $"); // // fetch operating parameters double flashTime = double(ilookup("SpireParms.txt",obsMode,"FlashTime")); // Optimum time between flashes double calTime = double(ilookup("SpireParms.txt",obsMode,"CalTime")); // Minimum time between gyro calibrations string ib = slookup("OpsParms.txt",obsMode,"Boresight"); // instrument boresight // No longer obtained from ObsParams.txt // double patt = dlookup("OpsParms.txt",obsMode,"Patt"); // direction of nod double d2 = dlookup("OpsParms.txt",obsMode,"D2"); // line separation double hLoss = dlookup("OpsParms.txt",obsMode,"HLoss"); // map height loss double lLoss = dlookup("OpsParms.txt",obsMode,"LLoss"); // map length loss double scanRate = dlookup("OpsParms.txt",obsMode,"ScanRate"); // line scan rate bool initFlash = blookup("SpireParms.txt",obsMode,"InitFlash"); // initial flash flag bool endFlash = blookup("SpireParms.txt",obsMode,"EndFlash"); // final flash flag // // ***************************************** // Display input parameters // ***************************************** SpireMsg(3," POF5 Observing Input values:"); SpireMsg(3," ..nRepeats: " + nRepeats); SpireMsg(3," ..mapWidth: " + mapWidth); SpireMsg(3," ..mapHeight: " + mapHeight); SpireMsg(3," POF5 Fixed values:"); SpireMsg(3," ..ib: " + ib); SpireMsg(3," ..patt: " + patt); SpireMsg(3," ..d2: " + d2); SpireMsg(3," ..hLoss: " + hLoss); SpireMsg(3," ..lLoss: " + lLoss); SpireMsg(3," ..scanRate: " + scanRate); SpireMsg(3," ..flashTime: " + flashTime); SpireMsg(3," ..calTime: " + calTime); SpireMsg(3," ..initFlash: " + initFlash); SpireMsg(3," ..endFlash: " + endFlash); // // calculate observing parameters SpireMsg(2," Calculated Parameters:"); // // number of lines in a map int nLines = iceil((mapHeight * 60.0 - hLoss) / d2) + 1; SpireMsg(3," Required number of scan lines in map: " + nLines); // // observing scanLength double scanLength = mapWidth * 60.0 + lLoss; // // integration time per line (covering user requested length) double lineOsit = scanLength / scanRate; SpireMsg(3," Integration time per scan line: " + lineOsit); // // increase scan length to allow time to start the scan int tStart = 2; int tEnd = 2; scanLength = scanLength + double(tStart + tEnd) * scanRate; SpireMsg(3," Required scan length: " + scanLength); // // time per line double lineTime = scanLength / scanRate; // // total observing time int d = duration(SpireBbScanLine(iceil(lineTime),0)); double totalTime = double(nRepeats) * double(nLines) * double(d); SpireMsg(3," Total observing time: " + totalTime); // // number of lines per Gyro calibration // Note: this only takes into account on source observing time, not movement between lines, // which is assumed to be a small fraction of the observing time, and so the value obtained is approximate int nCals = ifloor(totalTime / calTime); // SpireMsg(3," Number of Gyro Calibrations: " + nCals); int nCal = iceil(totalTime / lineTime); // default is no gyro calibrations during observation if(nCals > 0) { nCal = iceil(double(nLines) * double(nRepeats) / double(nCals + 1)); } if(nLines % nCal == 0) { nCal = nCal + 1; } // SpireMsg(3," Number of Gyro Calibrations(adjusted): " + nCals); // SpireMsg(3," Number of nod lines per Gyro calibration: " + nCal); // // number of lines per PCAL calibration // Note: this only takes into account on source observing time, not movement between lines, // which is assumed to be a small fraction of the observing time, and so the value obtained is approximate int nFlashes = ifloor(totalTime / flashTime); SpireMsg(3," Number of Flashes: " + nFlashes); int nFlash = iceil(totalTime / lineTime); // default is no flashes during observation if(nFlashes > 0) { nFlash = iceil(double(nLines) * double(nRepeats) / double(nFlashes + 1)); } if(nLines % nFlash == 0) { nFlash = nFlash + 1; } SpireMsg(3," Number of Flashes(adjusted): " + nFlashes); SpireMsg(3," Number of nod lines per PCAL calibration: " + nFlash); return {lineOsit * double(nLines),scanLength,nRepeats,nLines,nCal,nFlash}; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpirePhoto_CalGCO_TransRespoAndDynBeamProf.txt // /////////////////////////////////////////////////////////////////////////// // // CUS script for: 'Phot Transient Response and Dynamic Beam Profile' // // in * line_scan_with_off_pointing * mode // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/02/03 V1.0: Initial version renamed from (2008/11/12 V0.2) // SpirePhoto_CalGCO_PhotTransRespoAndDynBeamProf. // Add debug_print as input and pass it to some low // level scripts. Replace call to SpireProc_Set_ObsStep // with call to SpireBb_SetObsStep. Introduce // SpireBb_WaitAtGcp at GCP and use SpireBbScanLine during // the line scanning to collect data within defined BBIDs. // Use new SpireBb_EndObsAll and SpireBb_StartObsAll. // Read nominal bias frequency and bias divider from new // SpireTable_DetectorSettings.txt. Implemented setting // of datarates. Implemented isBright setting. // 2009/02/18 V1.1: Update to new calibration table structure for Mode setting. // New setting of datarates. Use SpireBb_PhotSetMode to set // to PHOTSTBY during SLEW and FINAL_HOLD. Change call to // SpireBb_StartDcuData. // 2009/03/04 V1.2: Add isSerendipity, isPcal, and 8 more dummy parameters // to the script for future use. Set gcp_time to // 20 (desired value for SOVT2). // 2009/05/07 V1.3: Add in move BSM to hold at start. Gather procedures at // start and end in separate BB. // 2009/06/05 V1.4: Change default gcp_time to 20 (SPR-1478). SPR-1477: // Hardcode STBY 'v00' in EndBB. // /////////////////////////////////////////////////////////////////////////// // Script assumes that: // // 1) Instrument is in PHOTSTBY // (i.e. bias amplitude, phase, frequency [mclkdiv,biasdiv] are nominal) // // 2) Bias frequency (mclkdiv) and sampling rate (biasdiv) are the same // for all three arrays and could be taken from following cal table: // SpireTable_PhotModeParams.txt // // 3) That currently the gyro reconstruction is only available for // non-SSO targets. // /////////////////////////////////////////////////////////////////////////// // obs SpirePhoto_CalGCO_TransRespoAndDynBeamProf { /* ****************************************************** */ /* USER PARAMETER DEFINITION, CUS SIGNATURE for EX-HSpot */ /* ****************************************************** */ double ra = 0.0 in [0.0,360.0]; // RA of target [deg] double dec = 0.0 in [-90.0,90.0]; // DEC of target [deg] int naifid = 0; // Put '0' to use RA and DEC, otherwise put correct 'NAFID' /* */ bool isBright = false; // Use settings for bright source (==tick) bool refSelected = true; // ExpHSpot (refSelected) parameter bool refByOffset = true; // ExpHSpot (refByOffset) parameter double raoff = 0.0 in [0.0,360.0]; // RA of GCP position, or relative offset [deg] double decoff = 0.0 in [-90.0,90.0]; // DEC of GCP position, or relative offset [deg] string ib = "S14_0"; // Central aperture (defined in SIAM) of raster double d1 = 500.0 in [20.0,7200.0]; // Length of the scan line along scan axis [arcsec] double rate = 30.0 in [0.1,60.0]; // Scan rate of a line scan [arcsec/s] string scan_dir = "Y" in ["Y","Z"]; // Scan direction int nrepeat = 1 in [1,1200]; // Number of forth+back scans (repetitions) int gcp_time = 20; // Time spend at GCP (gyro calibration position) [s] int gcp_period = 600; // Maximum time between successiv GCP visits [s] string version01 = "v00"; // Version in cal table SpireTable_PhotModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams bool debug = false; // Allow (==tick) or suppress cus debug_print statements bool isSerendipity = true; // Allow (==tick) serendipity mode to be activated or prohibit (==untick) it (currently not in use)? bool isPcal = true; // Allow (==tick) regular PcalFlash in script or prohibit (==untick) it (currently not in use)?. bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ // // // // // Current restrictions: // if(naifid != 0) { error("Currently no SSO objects are allowed as input!"); } // // // // // Declare some variable: // // Photometer or FTS: bool phot = true; bool fts = !phot; // // Start timing of script: int start = time(); int linestart = time(); // // Line counter (start at 1): int linecount = 1; // // GCP counter (start at 1): int gcpcounter = 1; // string tabName = ""; string selCol = ""; string selVal = ""; string tarCol = ""; string version = ""; double scirate = 0.0; double chkrate = 0.0; double nhkrate = 0.0; // int obsStep = 0; // // Hardcoded calibration tables: // string tabName01 = "SpireTable_PhotModeParams.txt"; string tabName02 = "SpireTable_CommonModeParams.txt"; string tabName03 = "SpireTable_BsmNominalSettings.txt"; // // Currently hardcoded version and model parameter: // string version03 = "v00"; // Version in cal table SpireTable_BsmNominalSettings string model = "initial"; // Model in cal table SpireTable_BsmNominalSettings // // // // // Setup mode: // // Set obsMode for QLA: string obsModeQla = "ENG_CAL_OBS06"; // Note: this needs entry in MIB table and in SpireTableInstConfigs.txt // // Set obsMode for datarates: string obsMode = "PEngCalObs"; // Note: this is currently only a maximum value // // // // // Increase scan length to allow time to mark start/end of the scan: // int tStart = 2; int tEnd = 2; // Note: the two 2 seconds are justified in SpireBbScanLine.txt d1 = d1 + double(tStart + tEnd) * rate; // // // // // // Read BSM home parameters: // // Select version flag and set GetTableEntry parameters: // version = version03; tabName = tabName03; selCol = "model"; // Name of column for selecting selVal = model; // Value of 'string' selector // // Read hold position from calibration table: // tarCol = "chop_0_I"; int hold_chop = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "jigg_0_I"; int hold_jigg = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // ****************************************************** */ // CALCULATE DURATIONS for POINTING STATES */ // ****************************************************** */ // // // // // Calculate timing for the pointing request: // // BBs called during slew: int tslewmin = duration(SpireBb_StartTransRespoAndDynBeamProf(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,debug)); // // BBs carried out when the pointing is reached: int tinithold = duration(SpireBb_PhotOffsetAuto(debug)) + duration(SpireBb_StartDcuData()); // // BB carried out during pointing: //int tp = 0; // // BB carried at off position: int top = duration(SpireBb_WaitAtGcp(gcp_time,debug)); // == Time spent at the OFF position. // // BB carried out at the end: int tfinalhold = duration(SpireBb_EndTransRespoAndDynBeamProf(phot,isBright,version01,version02,debug)) + duration(SpireBb_StopDcuData()); // // Debug_printing: // if(debug) { debug_print("tslewmin = " + tslewmin); debug_print("tinithold = " + tinithold); //debug_print("tpointing = " + tp); debug_print("tfinalhold = " + tfinalhold); } // // ****************************************************** */ // POINTING MODE DECLARATION */ // ****************************************************** */ // // // // // Fixed parameters for pointing mode: // bool fixed = false; // Pattern orientation (true==sky; false==array) double yoff = 0.0; // Offset of pattern in the direction of the +Y double zoff = 0.0; // Offset of pattern in the direction of the +Z double d2 = 0.0; // Spacing of adjacent scan lines [arcsec] int n = 2; // Number of raster lines or scan lines. int k = 2; // Number of scan lines before before going to the OFF position int thold = 0; // The duration of the hold when nhold>0. int nhold = 0; // Number of nods or raster points or scan lines before // // performing a hold. int nload = 0; // The number of slews (e.g. nods) before performing // // a load operation int tloadmin = 0; // The minimum duration of a load operation. // // // // // Select scan direction: // double patt = 90.0; // Rotation angle of the pattern // if(scan_dir == "Y") { patt = 90.0; } if(scan_dir == "Z") { patt = 0.0; } // // // // // Set pointing mode: // //int[] ts = line_scan_with_off_pointing(true,tslewmin,tih,tfh,ib,naifid, // ra,dec,fixed,patt,yoff,zoff,n,d1,d2,rate,k,top,raoff,decoff,nrepeat, // thold,nhold,tloadmin,nload); // int[] ts = line_scan_with_off_pointing(true,tslewmin,tinithold,tfinalhold,ib,naifid,ra,dec,fixed,patt,yoff,zoff,n,d1,d2,rate,k,top,raoff,decoff,nrepeat,thold,nhold,tloadmin,nload); // // // // // // Fill in timings of actual pointing mode: int tacc = ts[2]; // acceleration time int tdec = ts[3]; // deceleration time int tl = ts[4]; // time for actual scan of single line in map area int tll = ts[5]; // turnaround time bewteen 2 lines int tsop = ts[6]; // slew time from/to OFF position // Note: 'tsop' includes acceleration/deceleration time if(debug) { debug_print("Output timing vector from the pointing request: " + ts); debug_print("Time for actual scan of single line in requested area: " + tl); } // // // // // }{ // ****************************************************** */ // POINTING STATES WITH OBSERVING MODE LOGIC */ // ****************************************************** */ // // // // // Set datarates: // string rateType = "chk"; chkrate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); ess_hk_data_rate(chkrate); // rateType = "nhk"; // nhkrate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); non_ess_hk_data_rate(nhkrate); // rateType = "sci"; scirate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); data_rate(scirate); // if(debug) { debug_print("Set CHK datarate to: " + chkrate); debug_print("Set NHK datarate to: " + nhkrate); debug_print("Set SCI datarate to: " + scirate); } // // Start the state_machine: // int[] state = [0]; // while(state[0] >= 0) { if(debug) { debug_print("Current state: " + state); } state = next_state(); if(debug) { debug_print("Next state: " + state); } // if(state[0] == 1) { // STATE = SLEW ( Spacecraft is slewing ) // // // // // Startup observation: // SpireBb_StartTransRespoAndDynBeamProf(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,debug); // //delay(timeSlewCal); } if(state[0] == 2) { // STATE = INIT_HOLD (spacecraft is idling at source) // //delay(tinithold); // // // // // Set offsets: // SpireBb_PhotOffsetAuto(debug); // // // // // Start data generation before scan: // SpireBb_StartDcuData(); // } if(state[0] == 4) { // STATE = OFF position // // // // // Show time elapsed between visits to GCP: // int t = time() - start; if(gcpcounter > 1) { message("Time elapsed since last visit to GCP: " + t); if(t > gcp_period) { error("Time between visits to GCP > gcp_period! Pray to the Lord or modify the script!"); } if(debug) { debug_print("Time elapsed since last visit to GCP: " + t); } } gcpcounter = gcpcounter + 1; // // Reset timer: start = time(); // // // // // Wait at GCP: // SpireBb_WaitAtGcp(gcp_time,debug); // } if(state[0] == 5) { // STATE = FINAL_HOLD ( "sky" observation ends, performing final activities ) // // // // // Stop data generation after scan: // SpireBb_StopDcuData(); // // // // // Set scientific datarate back to zero: // data_rate(0.0); // // // // // Reconfigure at the end (incl. resetting of OBSID and BBIB): // // Hardcode STBY values for resetting (SPR-1477): // version01 = "v00"; version02 = "v00"; // SpireBb_EndTransRespoAndDynBeamProf(phot,isBright,version01,version02,debug); // } if(state[0] == 6) { //delay(thold); } if(state[0] == 8) { // STATE = ( line ) // // // // // // Start timing: // int tscan = time(); // // // // // Debug printing // if(debug) { debug_print("state[0]: " + state[0]); debug_print("state[1]: " + state[1]); debug_print("state[2]: " + state[2]); debug_print("linecount: " + linecount); } // if(linecount == 1) { linestart = time(); } else { int tline = time() - linestart; if(debug) { debug_print("Time elapsed since first line: " + tline); } } // // // // // Wait while scan is performed: // SpireBbScanLine(tl,linecount); linecount = linecount + 1; // } if(state[0] == 9) { //delay(tloadmin); } if(state[0] == -1) { // STATE = END ( end of the pointing/commanding part of the code ) // } } } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_EndFovMapCrossRaster.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to reconfigure at the end of // SpirePhoto/Spectro_CalGCO_FovMapCrossRaster. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // // 2009/05/05 V0.1: Initial version adapted from // SpireBb_EndBsmPcalFlash (2009/05/05 V0.1), // SpirePhoto_CalGCO_FovMapCrossRaster (2009/03/17 V1.0), and // SpireSpectro_CalGCO_FovMapCrossRaster (2008/09/17 V0.1). // 2009/05/07 V0.2: Set dcuFrameNumber and mcuFrameNumber back to continuous // to unset setting passed to VM. // 2009/06/05 V1.0: Replace Spire_SEND_DRCU_COMMAND with SpireSendDrcuCmd // as requested in SPR-1482. // 2009/07/12 V1.1: Set SMEC framerate back to nominal (SPR-SPIRE-1551). // /////////////////////////////////////////////////////////////////////////// // block SpireBb_EndFovMapCrossRaster SPIRE 14045 { bool phot = true; // Photometer (==tick) or FTS (==untick)? int hold_chop = 37632; // Chop hold position [Dec(Hex)] int hold_jigg = 39520; // Jiggle hod position [Dec(Hex)] bool isBright = false in [true,false]; // IsBright (==tick) flag string version01 = "v00"; // Version in cal.tab. SpireTable_PhotModeParams string version02 = "v00"; // Version in cal.tab. SpireTable_CommonModeParams bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // int mode_id = 0; string obsmode = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB EndFovMapCrossRaster reconfiguration started"); SpireMsg(2," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Set obsstep back to 0: // tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP(0)"); Spire_SET_OBS_STEP(0); // // // // // Set instrument back to Phot/Spec-STBY: // if(phot) { SpireProc_Set_PhotMode("PHTSTBY",isBright,version01,version02,debug); } else { SpireProc_Set_SpecMode("SPECSTBY",isBright,version01,version02,debug); } // // // // // Move BSM back to hold: // SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug); // // // // // Set number of DCU frames to continuous: // int dcuFrameNumber = 0; if(phot) { dcuFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","PHTSTBY","dcuFrameNumber","v00",debug); } else { dcuFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","SPECSTBY","dcuFrameNumber","v00",debug); } // SpireSendDrcuCmd(0x843d0000 + dcuFrameNumber,0); // // // // // Set number of MCU frames to continuous: // int mcuFrameNumber = 0; if(phot) { mcuFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","PHTSTBY","mcuFrameNumber","v00",debug); } else { mcuFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","SPECSTBY","mcuFrameNumber","v00",debug); } SpireSendDrcuCmd(0x91c30000 + mcuFrameNumber,0); delay(1); // // // // // Set SMEC framerate (== SMEC sampling rate) back to SPEC_STBY: // (Note, hardcoded version to go back to STBY) // if(!phot) { int smecFrameRate = SpireProc_GetTableEntryInt("SpireTable_SpecModeParams.txt","mode","SPECSTBY","smecFrameRate","v00",debug); SpireProc_Set_SmecFramerate(smecFrameRate,debug); } // // // // // End observation: // SpireProc_Set_EndObsAll(phot); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB EndFovMapCrossRaster reconfiguration ended"); SpireMsg(1," ..Reconfiguration to " + obsmode + "mode (" + (time() - t) + " seconds)"); // } // CVS file : CONF_phot_fltw.txt // Missionphase : FMILT_3 & Later // // Purpose : CONFigure the PHOT filter wheel servo loop // // Description : // // Dependencies : // // Preconditions : // // Comments : // // Version : 1.0 // History : 0.1 4-jul-2006 DAC // 1.0 11-Jun-2007 PR New scheme due to new format of configuration command // (DMC UM v.4.3) // : procedure CONF_phot_fltw { }{ string calUname = "CONFFWPHOT"; // FWPHOT CALIBRATION TABLE string calUrow = "FMILT"; // INSTRUMENT VERSION int rate = ilookup(calUname,calUrow,"Rate"); int current = ilookup(calUname,calUrow,"Drive_current"); int threshold_A = ilookup(calUname,calUrow,"Threshold_A"); int threshold_B = ilookup(calUname,calUrow,"Threshold_B"); int status_A = ilookup(calUname,calUrow,"Status_A"); int status_B = ilookup(calUname,calUrow,"Status_B"); {int}[] parlist = [{rate},{current},{threshold_A},{threshold_B},{status_A},{status_B}]; int[] aux = [rate,current,threshold_A,threshold_B,status_A,status_B]; int check_sum = checksum("int",aux); Pacs_DMC_WRT_FWPHOT_CONF_PAR(parlist,check_sum); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_Set_PhotBright.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to configure instrument for bright source observation // while being in any of the photometer modes. // /////////////////////////////////////////////////////////////////////////// // // KJK: // 2009/02/07 V0.1: Initial version renamed from // SpireProc_Set_BrightSettings (MP, 2009/01/27 V0.1) // Added "_b" to obs mode to select bright settings. // 2009/02/14 V0.2: (MP) Replaced calls to bias and phase BB with // call to bias and phase procedure. Added some cosmetics // to script. Replace call to SpireTable_DetectorSettings // with call to new SpireTable_PhotModeParams. // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Set_PhotBright { string obsMode = "POF2"; // Mode in cal file with detector settings string version = "v00"; // Version in cal file with detector settings bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Declare some variable: // string tarCol = ""; string tstr = ""; // // Hardcoded name of calibration table: string tabName = "SpireTable_PhotModeParams.txt"; // // // // // Start procedure: // tstr = SpireTimeStr(time()); SpireMsg(4," " + tstr + ": SpireProc_Set_PhotBright started"); SpireMsg(4," $Id:$"); // // // // // Read settings (currently phase and bias) from calibration table: // // Name of column for selecting: string selCol = "mode"; // // Value of 'string' selector: string selVal = obsMode + "_b"; // tarCol = "pswBias"; int psw_bias = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "pmwBias"; int pmw_bias = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "plwBias"; int plw_bias = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "ptcBias"; int ptc_bias = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "pswPhase"; int psw_phase = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "pmwPhase"; int pmw_phase = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "plwPhase"; int plw_phase = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "ptcPhase"; int ptc_phase = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // // // // Set the selected bias values: // SpireProc_Set_PhotBias(psw_bias,pmw_bias,plw_bias,ptc_bias,debug); // // // // // Set the selected phase values: // SpireProc_Set_PhotPhase(psw_phase,pmw_phase,plw_phase,ptc_phase,debug); // // // // // End procedure: // tstr = SpireTimeStr(time()); SpireMsg(4," " + tstr + ": SpireProc_Set_PhotBright ended"); } // Missionphase : // // Purpose : Perform Setup Photometry according to TM's input: // Scripts: // a) tm_phot_dpu_dmc_setup.tcl // b) tm_phot_mec_setup.tcl // c) tm_phot_sequencer_setup.tcl // d) tm_phot_polar_bestM7_setup.tcl // (Setting of optimal polarisations in the cold 0.3K) // e) tm_phot_change_datamode.tcl <"Bolo & HK"> // f) tm_phot_change_seq_mode.tcl <"Sbolo-Sref"> // g) PACS_Phot_Gain_high.tcl // (gain setting <"high">) // h) tm_phot_spu_setup.tcl // // // CUS author : DAC // Script file : PHOT_setup.txt // // Input arguments // type name description // // Return values // Type Name Default Description // // Description : // // Dependencies : // // Preconditions : // // Comments : // // Version : 3.0 // History: // 0.1 DAC 22-apr-2005 // 0.2 DAC 25-apr-2005 New default: Do not start SPU // 1.0 TM 12-apr-2006, update for FM with new settings // 1.1 TM 08-aug-2006, new procedure to read bias tables in [V] // 1.2 TM 10-oct-2006, autonomy function added // 2.0 DAC 17-oct-2006 Use BIAS tables in volts, eliminate useless // timing calculation, call with BIAS table name and // initial filter position, initial CS temperatures // 2.1 TM 08-Nov-2006 add the switch on of the groups // 2.2 TM 08-Nov-2006 autonomy function 17 added // 2.3 TM 08-Nov-2006 autonomy functions modified again (moved to PHOT_switchon_groups) // 2.4 TM 10-Nov-2006 default bias table changed, low gain // 2.5 13-nov-2006 Use RAW bias tables // 2.6 15-nov-2006 Using volts again // 2.7 8-dec-2006 Add temperature autonomy function // 2.8 5-mar-2007 update for chopper, CSs // 2.9 4-apr-2007 TM: number of raw channels set to zero // 3.0 9-apr-2007 TM & KO: update of AFs // 3.1 9-apr-2007 TM & KO: AF 15 taken out again // 3.2 21-aug-2007 SRC-3507 Indicate end of BB // Sync bus at end of script // 3.3 06-oct-2008 TM & VDP: PHOT_change_seq_mode set to Sref_only // 3.4 12-nov-2008 KO: gotoDirect option added // int[] block PHOT_setup PACS 200 { string calUfile = "BOLObias_preILT_standard_low"; //BIAS table name string fltPOS = "POS A" in ["POS A","POS B"]; // Filter wheel position double set_CS1 = 48.0; // CS1 settings (ohms) double set_CS2 = 58.0; // CS2 settings (ohms) bool gotoDirect = true in [true,false]; // DDCS setting to Direct setting }{ // Register BBID with environment WriteBBID($BBID); // Define variables to communicate various durations to HSPOT. int time_start = time(); PHOT_dpu_dmc_setup("BOTH Array",4); // Place filter wheel PHOT_dmc_setup(fltPOS,0,set_CS1,set_CS2); // switch on groups and enable AF 17 PHOT_switchon_groups(); // Set polarisations PHOT_set_bias_volt(calUfile,1); PHOT_set_bias_volt(calUfile,2); PHOT_set_bias_volt(calUfile,3); PHOT_set_bias_volt(calUfile,4); PHOT_set_bias_volt(calUfile,5); PHOT_set_bias_volt(calUfile,6); // Set sequencer PHOT_seq_setup(); // Set data mode PHOT_change_data_mode("Bolo_HK"); // PHOT_change_seq_mode("Sb_Sref"); New setup post-SOVT1 // Now we set the direct mode post-SOVT1 int operand = 0; if(gotoDirect) { //********************************************************* // Sequence mode : blocking on VDEC_X for the direct mode //********************************************************* // // Set all groups bol bias 09 (CKRLH) to 0.0 volt (0) Pacs_DMC_SEND_COMMAND_BOLC(0x90000); // Set all groups bol bias 12 (VDECX-L) to 2.0 volt (2298) Pacs_DMC_SEND_COMMAND_BOLC(0xc08fa); // Set seq mode Sref_only (hexadecimal value to avoid the commanding confusion) //Pacs_BOLC_SET_SEQ_MODE("Sref_only"); //# P 09 01 00 01 operand = 0x9010001; Pacs_DMC_SEND_COMMAND_BOLC(operand); delay(1); } else { // Set seq mode Sb_Sref (hexadecimal value to avoid the commanding confusion) //Pacs_BOLC_SET_SEQ_MODE("Sb_Sref"); //# P 09 01 00 00 operand = 0x9010000; Pacs_DMC_SEND_COMMAND_BOLC(operand); delay(1); } // Set gain LOW PHOT_set_gain("LOW"); // Set SPU but do not start it yet PHOT_spu_setup(0,0,0,0,false); // Time spent int duree_TCs = time() - time_start; int duree_num = duree_TCs; // Return the array of times int[] time_array = [duree_num,0,0,0,0]; // // enable AF 12 (to check for the protection biases) Pacs_DPU_SET_FUNCT("EVENT_BOL_BIAS","ENABLE"); // enable AF 14 to check for TEMP_EV < 0.3 K Pacs_DPU_SET_FUNCT("EVENT_BOL_T_FPU","ENABLE"); // enable AF 15 (to check for the VSS currents of groups and BUs) // Pacs_DPU_SET_FUNCT("EVENT_BOL_I_RO","ENABLE"); // Mark end of BB WriteEndBB(); // Sync bus sync(); return time_array; } // SpireBbChop // // execute chopping operations // // returns the actual time on-source // // K.J. King // double block SpireBbChop SPIRE 8449 { string opsMode = "" in ["POF1","SOF3","SOF4"]; int onChop = 0; // on-source Chop position int onJigg = 0; // on-source Jiggle position int offChop = 0; // off-source Chop position int offJigg = 0; // off-source Jiggle position int step = 0; // step number }{ int t = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB Chop started"); SpireMsg(2," $Id: SpireBbChop.txt,v 1.1 2006/08/10 09:38:57 kking Exp $"); // // ..... configuration ..... // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // set STEP hstr = SpireHexStr(step,4); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP_RAW(" + hstr + ")"); Spire_SET_OBS_STEP_RAW(step); // // execute chop // int id = ilookup("CommandLists.txt","Chop","Id"); // number of table containing the jiggle command list int index = ilookup("CommandLists.txt","Chop","Index"); // istart point in table containing the jiggle command list int nParms = ilookup("CommandLists.txt","Chop","Nparms"); // number of parameters to the jiggle command list int nChops = ilookup("OpsParms.txt",opsMode,"NChops"); // number of chop cycles per jiggle position int tChop = ilookup("Chopping.txt",opsMode,"Period"); // period of chop cycle int dcuFrame = ilookup("Chopping.txt",opsMode,"DcuFrame"); // DCU Sample Mode int nDcu = ilookup("Chopping.txt",opsMode,"DcuSamples"); // number of DCU Samples per chop position int tDelay = ilookup("Chopping.txt",opsMode,"DcuDelay"); // delay to start of DCU sampling int nBsm = ilookup("Chopping.txt",opsMode,"BsmSamples"); // number of BSM samples per chop position {int}[] parms = [{onChop},{onJigg},{offChop},{offJigg},{nChops},{tChop},{dcuFrame},{nDcu},{tDelay},{nBsm}]; tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_RUN_VM_RAW(" + id + "," + index + "," + nParms + "," + parms + ")"); Spire_RUN_VM_RAW(id,index,nParms,parms); // int nOps = nChops; double opsTime = double(nOps) * double(tChop) / 1000000.0; // time to perform a chopping operation delay(iceil(opsTime)); // double srcTime = double(nOps) * double(tChop - tDelay * 2) / 1000000.0; // effective integration time per chopoperation // // ..... completion ..... // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB Chop ended"); SpireMsg(1," ..Jiggle (" + (time() - t) + " seconds)"); // return srcTime; } // SpireSpectroPcalFlash // // $id$ // // This observation executes a PCAL Flash // // The instrument should be in the SPECSTBY mode before execution of this procedure // and the parameter passed to the observation should correspond to the initial state. // // 17/03/2009 KJK: // SCR 0946 created from SpireEngPcalFlash and SpirePhotoPcalFlash // 05/07/2009 KJK: // SPR-1593 - Updated input parameters in call to SpirePcalFlash // obs SpireSpectroPcalFlash { double ra = 0.0 in [0.0,360.0]; // RA of target double dec = 0.0 in [-90.0,90.0]; // DEC of target int naifid = 0; // NAIF identifier string boresight = ""; // instrument boresight to use bool pointing = true; // Should telescope 'point' (==tick) or do a 'no pointing' (==untick)? bool isBright = false; string opsVersion = "v00"; // Version in cal table SpireTable_OpsParms string flashVersion = "v00"; // Version in cal table SpireTable_FlashParms bool debug = false; // debug messages flag bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ string obsMode = "SOF8"; bool isPhot = false; string version01 = "v00"; // Version in cal table SpireTable_SpecModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams string version06 = "v00"; // Version in cal table SpireTable_IsBrightPhaseShift // // Calculate timing for the pointing request: // // BBs called during slew: // int tslewmin = duration(SpireBb_StartObsAll(obsMode)) + duration(SpireBb_SpecSetMode("SFlash",isBright,version01,version02,debug)); // // BBs carried out when the pointing is reached: // if(pointing) { int tinithold = duration(SpireBb_SpecOffsetAuto(false,debug)); } else { tinithold = duration(SpireBb_SpecOffsetAuto(false,debug)) + duration(SpireBb_StartObsAll(obsMode)) + duration(SpireBb_SpecSetMode("SFlash",isBright,version01,version02,debug)); } // // BB carried out during pointing: // int tp = duration(SpirePcalFlash("SFlash",flashVersion,debug)); // // BB carried out at the end: // int tfinalhold = duration(SpireBb_EndObsAll(isPhot)) + duration(SpireBb_SpecSetMode("SPECSTBY",isBright,version01,version02,debug)) + duration(SpireBb_SetObsStep(0,debug)); // // Debug printing: // if(debug) { debug_print("tslewmin = " + tslewmin); debug_print("tinithold = " + tinithold); debug_print("tpointing = " + tp); debug_print("tfinalhold = " + tfinalhold); } // // Lookup boresight, if not provided // string ib = boresight; if(boresight == "") { ib = SpireProc_GetTableEntryString("SpireTable_OpsParms.txt","mode",obsMode,"Boresight",opsVersion,debug); } // // Set pointing mode: // if(pointing) { int[] ts = basic_fine_pointing(true,tslewmin,tinithold,tfinalhold,ib,naifid,ra,dec,0.0,0.0,tp); } else { ts = no_pointing(true,tinithold,tfinalhold,tp); } // if(debug) { debug_print("Output timing vector from the pointing request: " + ts); } }{ int[] state = [0]; while(state[0] >= 0) { state = next_state(); if(state[0] == 1) { // *********************** SLEW // Start observation: SpireBb_StartObsAll(obsMode); // configure instrument SpireBb_SpecSetMode("SFlash",isBright,version01,version02,debug); } if(state[0] == 2) { // *********************** INITHOLD // If no pointing observation do stuff here which is // done nominally during SLEW: if(!pointing) { // Start observation: SpireBb_StartObsAll(obsMode); // configure instrument SpireBb_SpecSetMode("SFlash",isBright,version01,version02,debug); } // Set offsets: // SpireBb_SpecOffsetAuto(false,debug); } if(state[0] == 3) { // *********************** POINTING SpirePcalFlash("SFlash",flashVersion,debug); } if(state[0] == 5) { // *********************** FINALHOLD // reset STEP SpireBb_SetObsStep(0,debug); // // Set detectors back to SPECSTBY: SpireBb_SpecSetMode("SPECSTBY",isBright,version01,version02,debug); // // End Observation SpireBb_EndObsAll(isPhot); // } } } // SpirePointSpectrum // // $id$ // // Execute the FTS scans required at a single jiggle position, inserting flashes where required // The script assumes that the SMEC is already at the ScanStart when it is called // and retutns the SMEC to that position on completion // // 04 November 2008: // added data_rate commands // added commands to setup detector sampling, in case it is set differently (e.g. for flash mode) // 27 January 2009: KJK // updated calls to SpireBbFtsScan to provide version and debug parameters // changed inputs to take in 2 sets of scans (usually higher and lower resolution) // If only 1 set of scans is used, they should be defined in set1 // Now uses new SpireProc_SFlash Procedure, which moves SMEC to the Home position for the flash // double procedure SpirePointSpectrum { string res1 = "H" in ["H","M","C","L"]; // resolution for set 1 int nCycles1 = 0; // number of cycles to execute in set 1 double tCycle1 = 0.0; // time for a cycle in set 1 int scansPerCycle1 = 0; // number of scans in a cycle for set 1 string res2 = "L" in ["H","M","C","L"]; // resolution for set 2 int nCycles2 = 0; // number of cycles to execute in set 2 double tCycle2 = 0.0; // time for a cycle in set 2 int scansPerCycle2 = 0; // number of scans in a cycle for set 2 double tFlash = 0.0; // time between flashes int step = 0; // current step value - indicates the jiggle position string specVersion = "v00"; string flashVersion = "v00"; bool debug = false; }{ // // variables // // adjust tFlash to ensure that total time is not a multiple of tFlash leading to extra flash at end tFlash = tFlash + tCycle1; double srcTime = 0.0; // total on-source time int nFlash = 0; // number of cycles to next flash double tNext = tFlash; // time to next flash double s = 0.0; // on-source time per set of scans // // Set up detector sampling // SpireConfigDcuData("Scan"); // // execute scans for set 1 int scanStart1 = SpireProc_GetTableEntryInt("SpireTable_Spectrometer.txt","ResChar",res1,"ScanStart",specVersion,debug); while(nCycles1 > 0) { nFlash = iround(tNext / tCycle1); if(nCycles1 < nFlash) { // execute remaining set 1 scans s = SpireBbFtsScan(res1,nCycles1 * scansPerCycle1,step,specVersion,debug); nCycles1 = 0; tNext = tNext - tCycle1 * double(nCycles1); } else { // execute scans to next flash s = SpireBbFtsScan(res1,nFlash * scansPerCycle1,step,specVersion,debug); // execute flash SpireProc_SFlash("SFlash",scanStart1,scanStart1,step,flashVersion,debug); nCycles1 = nCycles1 - nFlash; tNext = tFlash; } srcTime = srcTime + s; // increment on-source time } // // execute scans for set 2 int scanStart2 = SpireProc_GetTableEntryInt("SpireTable_Spectrometer.txt","ResChar",res2,"ScanStart",specVersion,debug); while(nCycles2 > 0) { nFlash = iround(tNext / tCycle2); if(nCycles2 < nFlash) { // execute remaining set 2 scans s = SpireBbFtsScan(res2,nCycles2 * scansPerCycle2,step,specVersion,debug); nCycles2 = 0; tNext = tNext - tCycle2 * double(nCycles2); } else { // execute scans to next flash s = SpireBbFtsScan(res2,nFlash * scansPerCycle2,step,specVersion,debug); // execute flash SpireProc_SFlash("SFlash",scanStart2,scanStart2,step,flashVersion,debug); nCycles2 = nCycles2 - nFlash; tNext = tFlash; } srcTime = srcTime + s; // increment on-source time } return srcTime; } // Missionphase : CQM // // Purpose : CONFigure the CSs servo loops // // Author TCL : Helmut Feuchtgruber // CUS script : Diego A. Cesarsky // CVS file : CONF_cs.txt // // Arguments : This version uses the hardcoded parameters found in the // DEC/MEC User Manual V3.3 // // type name default Description // string whichCS "CS1" Which CS is configured // Description : // // Dependencies : // // Preconditions : // // Comments : Current version (0.2) uses hardcoded values from DEC/MEC // SUM V3.3 // // Version : 0.3 // History : 0.1 13-Oct-2004 Creation by DAC // : 0.2 27-apr-2005 DAC Added missing 7th argument // : 0.3 30-sep-2005 CS1 and CS2 were called with same variable // : int procedure CONF_cs { string whichCS = "CS1" in ["CS1","CS2","Both"]; // CS to configure }{ // Tally total duration [milliseconds] int duration_msec = 0; // Use HF's version where everything is hardcoded // Parameters for CS1 int[] aux1 = [1000000,5000,3277,1857,327,0x7fff,0]; int check_sum1 = checksum("int",aux1); {int}[] parlist1 = Array2grp_1(aux1); // Parameters for CS2 int[] aux2 = [1000000,5000,3277,1857,327,0x7fff,0]; int check_sum2 = checksum("int",aux2); {int}[] parlist2 = Array2grp_1(aux2); if(whichCS == "CS1") { Pacs_DMC_WRT_CS1_CONF_PAR(parlist1,check_sum1); } if(whichCS == "CS2") { Pacs_DMC_WRT_CS2_CONF_PAR(parlist2,check_sum2); } if(whichCS == "Both") { Pacs_DMC_WRT_CS1_CONF_PAR(parlist1,check_sum1); Pacs_DMC_WRT_CS2_CONF_PAR(parlist2,check_sum2); } // Set delay int duration_sec = Msec2sec(duration_msec); delay(duration_sec); return duration_msec; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////// // // SpireProc_Set_SpecPhase // /////////////////////////////////////////////////////////// // // Procedure to configure the spectrometer detector phases // /////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/02/15 V0.1: Initial version adapted from // SpireProc_Set_PhotPhase (KJK, 2009/02/14 V0.2) and // SpireBb_SpecFSetPhase (2008/08/11 V0.1) // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Set_SpecPhase { int ssw_phase = 0x0 in [0,255]; //Default phase is 0 [Hex] int slw_phase = 0x0 in [0,255]; //Default phase is 0 [Hex] bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Define some variables: // string tstr = ""; // // // // // Start procedure: // tstr = SpireTimeStr(time()); SpireMsg(4," " + tstr + ": SpireProc_Set_SpecPhase started"); SpireMsg(4," $Id:$"); // // // // // Set the selected phases: // // Set the phases for the two arrays: SpireSendDrcuCmd(0x843a0000 + ssw_phase,0); SpireSendDrcuCmd(0x843b0000 + slw_phase,0); sync(); // // // // // Debug Printing: // double ssw_phase_deg = 360.0 * double(ssw_phase) / 255.0; double slw_phase_deg = 360.0 * double(slw_phase) / 255.0; if(debug) { debug_print("ssw phase is set to " + ssw_phase + " [Dec(Hex)] " + ssw_phase_deg + " [deg]"); debug_print("slw phase is set to " + slw_phase + " [Dec(Hex)] " + slw_phase_deg + " [deg]"); } // // // // // End procedure: // tstr = SpireTimeStr(time()); SpireMsg(4," " + tstr + ": SpireProc_Set_SpecPhase ended"); } // SpirePOF5Pointing // // $id$ // // This procedure calculates and returns the pointing parameters for the POF5 observing mode // // 13/04/07: SCR3010 - changed default obsMode // 14/02/08: - added duration of StartDcuData Building Block to tInitHold // 02/07/2009 KJK: // - Added bsmModel, isBright, bsmVersion, photVersion, comVersion and debug input parameters // for use in calls to other scripts // 05/07/2009 KJK: // SPR-1593 - added flashVersion to input parameters // - changed call to SpireBbPcalFlash // // {int,int,int,int,int,double,double} procedure SpirePOF5Pointing { string obsMode = "POF5_S_N"; int nMaps = 1; // total number of number of maps to perform int nLines = 1; // number of lines per map int nCal = 99999; // number of lines per Gyro calibration int nFlash = 99999; // number of lines per PCAL flash bool isBright = false; string bsmModel = "initial"; string bsmVersion = "v00"; string flashVersion = "v00"; string photVersion = "v00"; string comVersion = "v00"; bool debug = false; }{ // // ***** fetch fixed operating mode parameters ***** // bool initFlash = blookup("SpireParms.txt",obsMode,"InitFlash"); // initial flash flag bool endFlash = blookup("SpireParms.txt",obsMode,"EndFlash"); // final flash flag double rate = dlookup("OpsParms.txt",obsMode,"ScanRate"); // scan rate double d2 = dlookup("OpsParms.txt",obsMode,"D2"); // scan line separation // // // ****** calculate parameters for pointing mode ****** // int tSlewMin = duration(SpireBbObsConfig(0)) + duration(SpireBbPOF5Config(obsMode,isBright,bsmModel,bsmVersion,photVersion,debug)) + 2; // // time for Initial Hold int tInitHold = duration(SpireBbPOF5Init()) + duration(SpireBbStartDcuData("POF5")) + 2; int tFlash = duration(SpireBbPcalFlash("PFlash",flashVersion,0,debug)); if(endFlash || nFlash < nLines) { tInitHold = tInitHold + tFlash; } // int tHold = tFlash + duration(SpireBbStopDcuData()) + duration(SpireBbStartDcuData("POF5")) + 2; // int nHold = 0; // default if no flashes required during scanning if(nFlash < nMaps * nLines) { nHold = nLines; // flash required every map } if(nFlash < nLines) { nHold = nFlash; // flash required within map } // // time for Final Hold int tFinalHold = duration(SpireBbPOF5End("PHTSTBY",isBright,bsmModel,bsmVersion,photVersion,comVersion,debug)) + duration(SpireBbStopDcuData()) + 2; if(endFlash && nHold != nLines) { tFinalHold = tFinalHold + tFlash; } return {tSlewMin,tInitHold,tFinalHold,tHold,nHold,d2,rate}; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_CalcParam_PhotMultiLevelNoiseLevels.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to translate user input in Hz for bias frequency and // sampling rate into nearest Hex values for mclkdiv and biasdiv // and then select list of bias amplitudes and phases for the nearest // match to mclkdiv from the input calibration table. // // Adapted from: Lookup.txt (2008-06-13 13:56) // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/06/14 V0.1: Initial version // 2008/08/04 V0.2: Allow separate phase for each array (including PTC) // 2008/08/15 V0.3: Adapt to change in call to low level script // SpireProc_CalcParam_BiasFreqSampFreq.txt // 2008/09/22 V0.4: Adapt to change in cal table setup // 2008/11/14 V0.5: Include check for non-existing version; Add debug parameter // 2009/01/31 V1.0: Add debug_print option (also to low level script). // 2009/02/17 V1.1: Extend error message. // /////////////////////////////////////////////////////////////////////////// // {string,int,int,int,double,double,double,double}[] procedure SpireProc_CalcParam_PhotMultiLevelNoiseLevels { double biasfreq = 130.2; // Bias frequency (Hz) double samplerate = 18.6; // Sampling frequency (Hz) string tabName = "SpireTable_PhotMultiLevelNoiseLevels.txt"; // Calibration table name string version = "v00"; // Version parameter defined in calibration table bool debug = false; // Allow (==tick) or suppress cus debug_print statement }{ // // // // // Calculate mclkdiv and biasdiv based on user input in Hz: // bool fts = false; // FTS or photometer limits? int[] hexvalues = SpireProc_CalcParam_BiasFreqSampFreq(biasfreq,samplerate,fts,debug); int mclkdiv = hexvalues[0]; int biasdiv = hexvalues[1]; // // // // // Debug printout: // if(debug) { debug_print("Converted values mclkdiv/biasdiv [raw]: " + mclkdiv + " " + biasdiv); } // // // // // Setup variables: // string colName = "mclkdiv"; int[] searchCol = icolumn(tabName,colName); int size = table_size(tabName); // // // // // Determine closest match: // // Start with the first value as the closest: int closest = searchCol[0]; int diff = iround(abs(double(mclkdiv - closest))); if(debug) { debug_print("diff = " + diff); } // Run through the values in the column: for(int i = 0 .. size - 1) { int next = searchCol[i]; int nextDiff = iround(abs(double(mclkdiv - next))); if(debug) { debug_print("next = " + next); debug_print("nextdiff = " + nextDiff); } if(nextDiff < diff) { closest = next; // Change diff to allow for non-monotonous mclkdiv in cal. tab. : diff = nextDiff; if(debug) { debug_print("closest = " + closest); debug_print("diff = " + diff); } } } // // // // // Get all other column information: // string[] versionCol = scolumn(tabName,"version"); int[] settingCol = icolumn(tabName,"setting"); double[] pswphaseCol = dcolumn(tabName,"pswphase"); double[] pmwphaseCol = dcolumn(tabName,"pmwphase"); double[] plwphaseCol = dcolumn(tabName,"plwphase"); double[] ptcphaseCol = dcolumn(tabName,"ptcphase"); // {string,int,int,int,double,double,double,double}[] rows = [{"",0,0,0,0.0,0.0,0.0,0.0}]; int index = 0; // // // // // // Cycle through values again to get all rows with closest match: // for(int j = 0 .. size - 1) { // If the key matches the closest and has the correct version tag // then we want it: if(closest == searchCol[j]) { if(versionCol[j] == version) { rows[index] = {versionCol[j],searchCol[j],biasdiv,settingCol[j],pswphaseCol[j],pmwphaseCol[j],plwphaseCol[j],ptcphaseCol[j]}; index = index + 1; } } } // // // // // Safety check: Make sure input version parameter is defined in cal. table: if(debug) { debug_print("rows[0]{0}: " + rows[0]{0}); } if(rows[0]{0} == "") { error("Input version parameter is not defined for selected bias frequency. Either select another version or change bias frequency!"); } // // // // // Return values: // return rows; } // $Id // Purpose : Bring PACS from any state to the standard PHOT configuration // // CUS author : KO modified from PacsEng_PHOT_orbit_prologue // // Input arguments: see after module identification // // Return values // N/A // // Comments : // // History: // 1.0 19-may-2008 KO, Created by modifying PacsEng_PHOT_orbit_prologue // 1.1 20-may-2008 KO, Debugged for pointing timing logic // 2.0 26-feb-2009 VD SpirePacsParallel Pacs Epilogue specific // obs SpirePacsEng_Parallel_PacsEpilogue { string calUfile = "BOLObias_preILT_standard_low"; //Bias table int tSET = 1; // Settling time for CS string fltPOS = "POS A"; // Filter double set_CS1 = 48.0; // set CS1 (ohms) double set_CS2 = 58.0; // set CS2 (ohms) bool gotoDirect = true in [true,false]; // DDCS setting to Direct mode }{ bool execute = true; // Initial hold int tih = imax(1,duration(WriteOBSID($OBSID))); // Final hold int tfh = imax(1,duration(WriteEndID())) + tSET; // Duration of "stable" pointing int tp = duration(PHOT_setup(calUfile,fltPOS,set_CS1,set_CS2,gotoDirect)); // Issue PointReq int[] ts = no_pointing(execute,tih,tfh,tp); }{ int[] state = [0]; while(state[0] >= 0) { state = next_state(); if(state[0] == 2) { // Obtain and set OBSID WriteOBSID($OBSID); data_rate(120.0); } if(state[0] == 3) { // Call the PHOT setup script PHOT_setup(calUfile,fltPOS,set_CS1,set_CS2,gotoDirect); } if(state[0] == 5) { // Wait for CS to stabilize delay(tSET); // Reset OBSID and BBID data_rate(0.0); WriteEndID(); } } } // SpireBbPOF5End // // $Id:$ // // Building Block to reconfigure the instrument from POF5 (scan map) mode // // 02/07/2009 KJK: // - Added bsmModel, isBright, bsmVersion, photVersion, comVersion and debug input parameters // - Added reset from possible bright-source operations // 13/07/2009 MP: // - Moved 'reset bright-source biases and phases' before unsetting // the OBSID (SPR-SPIRE-1639) // block SpireBbPOF5End SPIRE 8274 { string obsMode = "PHTSTBY"; bool isBright = false in [true,false]; string bsmModel = "initial"; string bsmVersion = "v00"; string photVersion = "v00"; string comVersion = "v00"; bool debug = false in [true,false]; }{ int t = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB POF5 Reconfiguration started"); SpireMsg(2," $Id:$"); // // ..... configuration ..... // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // set STEP to zero tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP_RAW(0x0000)"); Spire_SET_OBS_STEP_RAW(0x0); // // Move BSM to HOLD int bsmHoldChopPosn = ilookup("BSM.txt","Hold","ChopPosn"); int bsmHoldJiggPosn = ilookup("BSM.txt","Hold","JiggPosn"); SpireBsmMove(bsmHoldChopPosn,bsmHoldJiggPosn); // // reset bright-source biases and phases - if needed // if(isBright) { SpireProc_Set_PhotMode(obsMode,isBright,photVersion,comVersion,debug); } // // Set Mode to PHT_STBY tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_MODE_RAW(0x0300)"); Spire_SET_OBS_MODE_RAW(0x300); // // Clear OBSID/BBID to null values tstr = SpireTimeStr(time()); message("5 " + tstr + "Cmd: Spire_SET_BBID_RAW(0x80000000)"); Spire_SET_BBID_RAW(0x80000000); int obsId = SpireNullObsid(); tstr = SpireTimeStr(time()); hstr = SpireHexStr(obsId,8); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBSID_RAW(" + hstr + ")"); Spire_SET_OBSID_RAW(obsId); // // ..... completion ..... // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB POF5 Reconfiguration ended"); SpireMsg(1," ..POF5 Reconfiguration to PHT_STBY mode (" + (time() - t) + " seconds)"); } // SpireSpectroRaster // // $Id: SpireSpectroRaster.txt,v 1.7 2008/05/23 08:48:39 kking Exp $ // // The high level script for the Spire Spectrometer Raster observing mode // // 15/02/08 Added np to step value when pointing or hold // // 04 November 2008: added data_rate commands // 04/03/09: MP Fixed bug in call to // SpireProc_GetTableEntryString("SpireTable_OpsParms.txt","mode"....) // 10/03/2009 KJK: // SCR 1274, add additional dummy parameters // Update input API to include versions for all cal tables // 17/03/2009 KJK: // Update API to read NCycles1 from NHCycles and NCycles2 from NLCycles // 05/07/2009 KJK: // SPR-1593 - Updated calls to SpireBbPcalFlash to use flashVersion // {int,int,double,int,double,int,int,int} obs SpireSpectroRaster { double ra = 0.0 in [0.0,360.0]; // RA of Target double dec = 0.0 in [-90.0,90.0]; // DEC of Target int naifid = 0; // NAIF identifier string pointing = "raster" in ["single","raster"]; // pointing type string sampling = "sparse" in ["sparse","intermediate","full"]; // spatial sampling string resolution = "H" in ["H","M","L","C","H+L"]; // spectral resolution double mapSize1 = 0.0 in [0.0,30.0]; // arc minutes double mapSize2 = 0.0 in [0.0,30.0]; // arc minutes double mapOffsetY = 0.0 in [-300.0,300.0]; // arc minutes double mapOffsetZ = 0.0 in [-300.0,300.0]; // arc minutes bool mapOrientationArray = true; // is the map orientation an array (rather than array with constraints) double mapOrientationConFrom = 0.0 in [0.0,360.0]; double mapOrientationConTo = 360.0 in [0.0,360.0]; int nRepetitions1 = 2 in [2,1200]; // number of times to repeat spectral scan pairs for single resolution scan modes and high resolution in H+L mode int nRepetitions2 = 2 in [2,1200]; // number of times to repeat spectral scan pairs for low resolution scans for 'H+L" mode double wavelength1 = -1.0; // wavelength double wavelength2 = -1.0; // wavelength double wavelength3 = -1.0; // wavelength double wavelength4 = -1.0; // wavelength double wavelength5 = -1.0; // wavelength double wavelength6 = -1.0; // wavelength double wavelength7 = -1.0; // wavelength double wavelength8 = -1.0; // wavelength double lineFlux1 = -1.0; // line flux estimate double lineFlux2 = -1.0; // line flux estimate double lineFlux3 = -1.0; // line flux estimate double lineFlux4 = -1.0; // line flux estimate double lineFlux5 = -1.0; // line flux estimate double lineFlux6 = -1.0; // line flux estimate double lineFlux7 = -1.0; // line flux estimate double lineFlux8 = -1.0; // line flux estimate bool isJyContinuum = true; // is Jy units rather than Wm-2um-1 double contFlux1 = -1.0; // continuum flux estimate double contFlux2 = -1.0; // continuum flux estimate double contFlux3 = -1.0; // continuum flux estimate double contFlux4 = -1.0; // continuum flux estimate double contFlux5 = -1.0; // continuum flux estimate double contFlux6 = -1.0; // continuum flux estimate double contFlux7 = -1.0; // continuum flux estimate double contFlux8 = -1.0; // continuum flux estimate bool isBright = false; // Use settings for bright source (==tick) bool isChopped = false; int nRasters = 1; int nPoints = 1; int nMaps = 1; int nHCycles = 0; // total number of High resolution scans at each pointing and jiggle position(it is a multiple of int nMCycles = 0; // total number of Medium resolution scans at each pointing and jiggle position(it is a multiple of int nLCycles = 0; // total number of Low resolution scans at each pointing and jiggle position int nCals = 999999; double tCal = 999999.0; // time between Gyro calibrations within a jiggle point operation int nFlashes = 999999; double tFlash = 999999.0; // time between PCAL flashes within a jiggle point operation string spireVersion = "v00"; // Version in cal table SpireTable_SpireParms string opsVersion = "v00"; // Version in cal table SpireTable_OpsParms string flashVersion = "v00"; // Version in cal table SpireTable_FlashParms string specVersion = "v00"; // Version in cal table SpireTable_Spectrometer bool debug = false; // debug messages flag bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ string version = "v00"; // check inputs if(pointing != "raster") { error("SpireSpectroRaster: Pointing is not set to raster"); } SpireMsg(0,"Spectrometer Raster Observation"); // // // ***************************************** // select instrument ops mode // ***************************************** // string opsMode = ""; // opsMode int md = 0; // value of MODE parameter if(sampling == "sparse") { opsMode = "SOF1"; md = 0x410; } else { if(sampling == "intermediate") { opsMode = "SOF2_int"; } else { if(sampling == "full") { opsMode = "SOF2"; } else { error("SpireSpectroPoint: Unknown sampling"); } } md = 0x420; } // // ***************************************** // set up scan sets // ***************************************** // string res1 = resolution; string res2 = "L"; int nCycles1 = nHCycles; int nCycles2 = nLCycles; if(resolution == "H+L") { res1 = "H"; } // ***************************************** // get observing parameters // ***************************************** // double tScan1 = SpireProc_GetTableEntryDouble("SpireTable_Spectrometer.txt","ResChar",res1,"ScanTime",specVersion,debug); double tScan2 = SpireProc_GetTableEntryDouble("SpireTable_Spectrometer.txt","ResChar",res2,"ScanTime",specVersion,debug); int scansPerCycle1 = SpireProc_GetTableEntryInt("SpireTable_OpsParms.txt","mode",opsMode,"N" + res1 + "Scans",opsVersion,debug); int scansPerCycle2 = SpireProc_GetTableEntryInt("SpireTable_OpsParms.txt","mode",opsMode,"N" + res2 + "Scans",opsVersion,debug); double tCycle1 = tScan1 * double(scansPerCycle1); double tCycle2 = tScan2 * double(scansPerCycle2); // // int jiggleTable = SpireProc_GetTableEntryInt("SpireTable_OpsParms.txt","mode",opsMode,"TableId",opsVersion,debug); // Jiggle Table ID int jiggleSize = SpireProc_GetTableEntryInt("SpireTable_OpsParms.txt","mode",opsMode,"TableSize",opsVersion,debug); // Jiggle Table length int tSerendipity = duration(SpireBbSpecSerendipity(opsMode,0)); // minimum time for a serendipity observation bool initFlash = blookup("SpireParms.txt",opsMode,"InitFlash"); // initial flash flag bool endFlash = blookup("SpireParms.txt",opsMode,"EndFlash"); // final flash flag double perScanOsit1 = SpireProc_GetTableEntryDouble("SpireTable_Spectrometer.txt","ResChar",res1,"Osit",specVersion,debug); // effective on source integration time per scan double perScanOsit2 = SpireProc_GetTableEntryDouble("SpireTable_Spectrometer.txt","ResChar",res2,"Osit",specVersion,debug); // effective on source integration time per scan // int nScans1 = nCycles1 * scansPerCycle1; int nScans2 = nCycles2 * scansPerCycle2; // int scanStart1 = SpireProc_GetTableEntryInt("SpireTable_Spectrometer.txt","ResChar",res1,"ScanStart",specVersion,debug); int smecHome = ilookup("SpireTable_SmecNominalSettings.txt",version,"Home"); // ***************************************** // set telescope pointing mode // ***************************************** // string ib = SpireProc_GetTableEntryString("SpireTable_OpsParms.txt","mode",opsMode,"Boresight",opsVersion,debug); double deltaY = SpireProc_GetTableEntryDouble("SpireTable_OpsParms.txt","mode",opsMode,"DeltaY",opsVersion,debug); // offset to pixel centre from boresight in Y direction (arcsecs) double deltaZ = SpireProc_GetTableEntryDouble("SpireTable_OpsParms.txt","mode",opsMode,"DeltaZ",opsVersion,debug); // offset to pixel centre from boresight in Z direction (arcsecs) bool fixed = SpireProc_GetTableEntryBool("SpireTable_OpsParms.txt","mode",opsMode,"Fixed",opsVersion,debug); // pattern angle definition double pattNod = SpireProc_GetTableEntryDouble("SpireTable_OpsParms.txt","mode",opsMode,"Patt",opsVersion,debug); // direction of nod double chopThrow = SpireProc_GetTableEntryDouble("SpireTable_OpsParms.txt","mode",opsMode,"D1",opsVersion,debug); double yOffset = mapOffsetY * 60.0 + deltaY; // offset to observation position from target in Y direction (arcsecs) double zOffset = mapOffsetZ * 60.0 + deltaZ; // offset to observation position from target in Z direction (arcsecs) {int,int,int,int,int,int} sofPoint = SpireSOF12Pointing(opsMode,res1,nCycles1,tCycle1,scansPerCycle1,res2,nCycles2,tCycle2,scansPerCycle2,nMaps,nFlashes,tFlash,specVersion,flashVersion,debug); int tSlewMin = sofPoint{0}; int tInitHold = sofPoint{1}; int tFinalHold = sofPoint{2}; int tpp = sofPoint{3}; int tHold = sofPoint{4}; int nHold = sofPoint{5}; // calculate raster positions {double[],double[]} sofRaster = SpireSpecRasterPositions(opsMode,0.0,0.0,mapSize1 * 60.0,mapSize2 * 60.0); double[] yArray = sofRaster{0}; double[] zArray = sofRaster{1}; int[] tp = []; int nRasterPoints = length(yArray); if(nPoints != nRasterPoints) { error("SpireSpectroRaster: Number of raster points has changed"); } for(int n = 0 .. nRasterPoints - 1) { tp[n] = sofPoint{3}; } if(nHold > nRasterPoints) { nHold = 0; } // int[] ts = custom_map_pointing(true,tSlewMin,tInitHold,tFinalHold,ib,naifid,ra,dec,fixed,pattNod,yOffset,zOffset,yArray,zArray,tp,pattNod,chopThrow,1,0,0,0,tHold,nHold); // int tobs = ts[0]; int tslew = ts[1]; int tnod = ts[2]; int tss = ts[3]; int tload = ts[4]; int tend = ts[5]; // }{ SpireMsg(0,"Observation Start"); SpireMsg(0," Uses observing mode " + opsMode); SpireMsg(3," $Id: SpireSpectroRaster.txt,v 1.7 2008/05/23 08:48:39 kking Exp $"); // // ***************************************** // Display input parameters // ***************************************** SpireMsg(3," Input values:"); SpireMsg(3," ..RA: " + ra); SpireMsg(3," ..Dec: " + dec); SpireMsg(3," ..NAIF ID: " + naifid); SpireMsg(3," ..Pointing: " + pointing); SpireMsg(3," ..Sampling: " + sampling); SpireMsg(3," ..Resolution: " + resolution); SpireMsg(3," ..mapSize1: " + mapSize1); SpireMsg(3," ..mapSize2: " + mapSize2); SpireMsg(3," ..Y Offset: " + yOffset); SpireMsg(3," ..Z Offset: " + zOffset); SpireMsg(3," ..nRasters: " + nRasters); SpireMsg(3," ..nPoints: " + nPoints); SpireMsg(3," ..nMaps: " + nMaps); SpireMsg(3," ..nHCycles: " + nHCycles); SpireMsg(3," ..nMCycles: " + nMCycles); SpireMsg(3," ..nLCycles: " + nLCycles); SpireMsg(3," ..tCal: " + tCal); SpireMsg(3," ..tFlash: " + tFlash); SpireMsg(3," Fixed values:"); SpireMsg(3," ..ib: " + ib); SpireMsg(3," ..initFlash: " + initFlash); SpireMsg(3," ..endFlash: " + endFlash); SpireMsg(3," Pointing Mode Input values:"); SpireMsg(3," ..tSlewMin: " + tSlewMin); SpireMsg(3," ..tInitHold: " + tInitHold); SpireMsg(3," ..tFInalHold: " + tFinalHold); SpireMsg(3," ..tpp: " + tpp); SpireMsg(3," ..Y raster positions:" + yArray); SpireMsg(3," ..Z raster positions:" + zArray); SpireMsg(3," Pointing Mode Output values:"); SpireMsg(3," ..tobs: " + tobs); SpireMsg(3," ..slew: " + tslew); SpireMsg(3," ..tnod: " + tnod); SpireMsg(3," ..tss: " + tss); SpireMsg(3," ..tload: " + tload); SpireMsg(3," ..tend: " + tend); // ***************************************** // execute observation // ***************************************** // data_rate(0.0); double chkrate = dlookup("Datarates.txt","Scan","CHK"); ess_hk_data_rate(chkrate); double nhkrate = dlookup("Datarates.txt","Scan","NHK"); non_ess_hk_data_rate(nhkrate); string tstr = ""; // time string int otf = 0x8000; // On Target Flag double srcTime = 0.0; // total on source integration time int np = 0; // raster point number int t = 0; // int[] state = [0]; while(state[0] >= 0) { state = next_state(); if(state[0] == 1) { // ********************* SLEWING tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " Slewing to start position"); t = time(); // set up observation parameters SpireBb_StartObsAll(opsMode); // perform serendipity operation if possible if(tslew > tSerendipity + tSlewMin) { SpireBbSpecSerendipity(opsMode,tslew - tSlewMin - 2); } // configure instrument for operations if(opsMode == "SOF1") { SpireBbSOF1Config(res1,specVersion,debug); } else { SpireBbSOF2Config(res1,specVersion,debug); } } if(state[0] == 2) { // ********************* INITIAL HOLD tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " Telescope at start position"); SpireMsg(0," Slew (" + (time() - t) + " secs)"); SpireMsg(2," " + tstr + " Initialising Instrument"); t = time(); // initialise instrument if(opsMode == "SOF1") { SpireBbSOF1Init(); } else { SpireBbSOF2Init(); } // calibrate if necessary if(initFlash || double(tpp) > tFlash) { tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " PCAL Calibration inserted"); SpireProc_SFlash("SFlash",smecHome,scanStart1,otf,flashVersion,debug); } } if(state[0] == 3) { // ********************* POINTING //??p pointing file generation ------------------------------ //??p PtOutput(rdp0); //??p pointing file generation ------------------------------ tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " New Pointing"); int nFlash = 0; int step = 0; t = time(); double s = 0.0; // for(int j = 0 .. jiggleSize - 1) { step = np | j; SpireBbBsmMove(jiggleTable,j,step); if(j > 0) { if(nFlashes > 0 || j % nFlash == 0) { SpireBbPcalFlash("SFlash",flashVersion,otf | step,debug); } } s = SpirePointSpectrum(res1,nCycles1,tCycle1,scansPerCycle1,res2,nCycles2,tCycle2,scansPerCycle2,tFlash,otf | step,specVersion,flashVersion,debug); srcTime = srcTime + s; if(j == 0) { nFlash = ifloor(tFlash / double(time() - t)); if(nFlash == 0) { nFlash = jiggleSize; } } } np = np + 0x80; // increment bit 7 } if(state[0] == 5) { // ******************** FINAL HOLD tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " Reconfiguring Instrument"); t = time(); // calibrate if necessary if(endFlash || double(tpp) > tFlash) { tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " PCAL Calibration inserted"); SpireProc_SFlash("SFlash",scanStart1,smecHome,otf | step,flashVersion,debug); } // reconfigure back to SPEC_STBY configuration if(opsMode == "SOF1") { SpireBbSOF1End(res1,specVersion,debug); } else { SpireBbSOF2End(res1,specVersion,debug); } // } if(state[0] == 6) { // *********************** HOLD tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " PCAL Calibration inserted"); SpireBbPcalFlash("SFlash",flashVersion,otf | np,debug); } } tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " Instrument Reconfigured"); SpireMsg(0," Instrument Reset (" + (time() - t) + " secs)"); // SpireMsg(0,"Observation Completed (" + time() + " seconds)"); SpireMsg(0,"Note: Total time (s) = Observation Completed time - slew time + Observatory Overheads"); assert (time() == ts[0] + ts[1]); // return {nRasters * nRasterPoints,jiggleSize,perScanOsit1,nScans1,perScanOsit2,nScans2,iround(srcTime),time() - iround(srcTime) - tslew}; } // SpireBbSOF1End // // $Id: SpireBbSOF1End.txt,v 1.1 2006/08/10 09:38:58 kking Exp $ // // Building Block to reconfigure the instrument to SPEC_STBY mode from SOF1 mode // // 07/02/2009: KJK // Now assumes SMEC is at scan start position (SPR-591) // block SpireBbSOF1End SPIRE 8370 { string res = "H"; string specVersion = "V00"; bool debug = false; }{ string version = "v00"; int t = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SOF1 Reconfiguration started"); SpireMsg(2," $Id: SpireBbSOF1End.txt,v 1.1 2006/08/10 09:38:58 kking Exp $"); // // ..... configuration ..... // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // set STEP to zero tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP_RAW(0x0000)"); Spire_SET_OBS_STEP_RAW(0x0); // // Move mechanism to HOME position int scanStart1 = SpireProc_GetTableEntryInt("SpireTable_Spectrometer.txt","ResChar",res,"ScanStart",specVersion,debug); int smecHome = ilookup("SpireTable_SmecNominalSettings.txt",version,"Home"); SpireProc_SmecMove(smecHome,scanStart1,debug); // // Move BSM to HOLD int bsmHoldChopPosn = ilookup("BSM.txt","Hold","ChopPosn"); int bsmHoldJiggPosn = ilookup("BSM.txt","Hold","JiggPosn"); SpireBsmMove(bsmHoldChopPosn,bsmHoldJiggPosn); // // Set Mode to SPEC_STBY tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_MODE_RAW(0x0400)"); Spire_SET_OBS_MODE_RAW(0x400); // // Clear OBSID/BBID to null values tstr = SpireTimeStr(time()); message("5 " + tstr + "Cmd: Spire_SET_BBID_RAW(0x80000000)"); Spire_SET_BBID_RAW(0x80000000); int obsId = SpireNullObsid(); tstr = SpireTimeStr(time()); hstr = SpireHexStr(obsId,8); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBSID_RAW(" + hstr + ")"); Spire_SET_OBSID_RAW(obsId); // // ..... completion ..... // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SOF1 Reconfiguration ended"); SpireMsg(1," ..SOF1 Reconfiguration to SPEC_STBY mode (" + (time() - t) + " seconds)"); } string procedure SpireHexStr { int n = 0; // input value int field = 4; // number of digits in hexadecimal number in output string }{ string s = ""; int signbit = 0; int x = 0; string h = ""; // // extract sign bit if(n < 0) { signbit = 1; n = n & 0x7fffffffffffffff; } // // convert nibble by nibble for(int i = 1 .. 16) { x = n % 0x10; // get next character if(x < 10) { h = "" + x; } else { if(x == 10) { h = "a"; } if(x == 11) { h = "b"; } if(x == 12) { h = "c"; } if(x == 13) { h = "d"; } if(x == 14) { h = "e"; } if(x == 15) { h = "f"; } } // perepare next nibble n = n / 0x10; if(i == 15) { n = n + signbit * 8; } if(i == field && n != 0) { field = field + 1; } // add character to output if necessary if(i <= field) { s = h + s; } } // return "0x" + s; } // SpireSPEC_STBYtoREDY // // $id$ // // This procedure configures the instrument into the REDY mode // // The instrument should be in the SPEC_STBY mode before execution of this observation // // // 07/05/2009 KJK: First Version // 08/06/2009 KJK: added commands for starting/stopping the SCAL Command List // 02/07/2009 MP: Added report of tables and memory checksums (SPIRE-SCR-1527) // // procedure SpireSPEC_STBYtoREDY { string bsmVersion = "v00"; string smecVersion = "v00"; string detVersion = "v00"; string scalVersion = "v00"; bool debug = false; }{ // ---------------- // Configure SCAL // ---------------- // string scal = SpireProc_GetTableEntryString("SpireTable_DefaultParams.txt","mode","REDY","scalVm",scalVersion,debug); SpireBbSetScal(scal,-1,scalVersion,debug); // ---------------- // switch off detectors // ---------------- mois_comment("Procedure SPIRE SDET_OFF: to switch off the SPIRE Spectrometer"); mois_spacon("Select the TM Display for FUNCTIONAL TEST PARAMETERS"); SpireBbSdetOff(); // // setup detector sampling SpireBbSetDetSampling("REDY",true,detVersion,false,debug); mois_comment("SPIRE SPIRE_SDET_OFF Procedure Completed"); mois_tmcheck("Ensure that parameter MODE is set to SDET_OFF"); mois_tmcheck("Ensure SLIABITSTAT is set to 0"); mois_tmcheck("Ensure SPECJFETSTAT is set to 0"); mois_tmcheck("Ensure parameters SSWJFET1V to SSWJFET2V are all set to 0"); mois_tmcheck("Ensure parameter SLWJFET1V is set to 0"); mois_spacon("Select the TM Display for SFT PARAMETERS"); mois_tmcheck("SLIAP5V, SLIAP9V and SLIAM9V should all be 0"); // // ------------- // switch off SMEC // ------------- mois_comment("Procedure SPIRE_SMEC_OFF: to switch off the SPIRE SMEC"); mois_spacon("Select the TM Display for FUNCTIONAL TEST PARAMETERS"); SpireBbSmecOff(smecVersion,debug); // Setup SMEC sampling SpireBbSetSmecSampling("REDY",smecVersion,debug); mois_comment("SPIRE SPIRE_SMEC_OFF Procedure Completed"); mois_tmcheck("Check that parameter SMECENCPWR is set to 0"); mois_tmcheck("Check that parameter SMECLVDTPWR is set to 0"); mois_tmcheck("Check that parameter MODE is set to SMEC_OFF"); // // ------------- // switch off BSM // ------------- mois_comment("Procedure SPIRE_BSM_OFF: to switch off the SPIRE BSM"); mois_spacon("Select the TM Display for FUNCTIONAL TEST PARAMETERS"); SpireBbBsmOff(); // // Setup BSM sampling SpireBbSetBsmSampling("REDY",bsmVersion,debug); mois_comment("SPIRE SPIRE_BSM_OFF Procedure Completed"); mois_tmcheck("Check that parameter CHOPSENSPWR is set to 0"); mois_tmcheck("Check that parameter JIGGSENSPWR is set to 0"); mois_tmcheck("Check that parameter MODE is set to REDY"); // // SpireBbSetScuSampling("REDY","v00",debug); // // // // // Report tables and do memory checksums: // SpireBb_RepTabAndMemChecksum(); // // // set nominal housekeeping rate SpireBbSetNhkSampling("REDY","v00",debug); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_EndTransRespoAndDynBeamProf.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to reconfigure at the end of // SpirePhoto_CalGCO_TransRespoAndDynBeamProf.txt // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // // 2009/05/07 V1.0: Initial version adapted from // SpireBb_EndBsmAngleCal (2009/05/05 V1.2) and // SpirePhoto_CalGCO_TransRespoAndDynBeamProf (2009/03/04 V1.2) // /////////////////////////////////////////////////////////////////////////// // block SpireBb_EndTransRespoAndDynBeamProf SPIRE 14063 { bool phot = true; // Photometer (==tick) or FTS (==untick)? bool isBright = false in [true,false]; // IsBright (==tick) flag string version01 = "v00"; // Version in cal.tab. SpireTable_PhotModeParams string version02 = "v00"; // Version in cal.tab. SpireTable_CommonModeParams bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // int mode_id = 0; string obsmode = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB EndTransRespoAndDynBeamProf reconfiguration started"); SpireMsg(2," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Set obsstep back to 0: // tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP(0)"); Spire_SET_OBS_STEP(0); // // // // // Set instrument back to Phot/Spec-STBY: // if(phot) { SpireProc_Set_PhotMode("PHTSTBY",isBright,version01,version02,debug); } else { SpireProc_Set_SpecMode("SPECSTBY",isBright,version01,version02,debug); } // // // // // End observation: // SpireProc_Set_EndObsAll(phot); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB EndTransRespoAndDynBeamProf reconfiguration ended"); SpireMsg(1," ..Reconfiguration to " + obsmode + "mode (" + (time() - t) + " seconds)"); // } // CVS comments : $Id: DMC_phot_2_3_chop.txt,v 1.5 2007/04/25 15:14:03 dcesarsk Exp $ // Missionphase : // // Purpose : Two or three position chopping followed // by calibration readouts chopping between CS1 and CS2 // // // Author : Helmut Feuchtgruber // CUS script : Diego A. Cesarsky // CVS file : DMC_phot_2_3_chop.txt from AOT code // // Arguments : // nb_SRC_REF Number of SRC->CHOPP1->SRC->CHOPP2 cycles // chop_pos_SRC Position of chopper to see SRC // nb_rdouts_plateau Number of readouts per chopper plateau // chop_pos_REF1 Position of chopper for REF1 // chop_pos_REF2 Position of chopper for REF2 // nb_cycles_obs_cal Number of times (OBS = CAL) // nb_CS1_CS2 Number of CS1->CS2 cycles // chop_pos_CS1 Chopper position for CS1 // chop_pos_CS2 Chopper position for CS2 // // Description : Chopped observations of SRC in the manner: // SRC->REF1->SRC->REF2 // followed by a calibration sequence using the internal // blackbodies // CS1 -> CS2 // User can specify the number of source observing cycles // (nb_SRC_REF), the number of calibration cycles (nb_CS1_CS2) // and how many times the whole sequence shall be repeated // (nb_cycles_obs_cal). // The number of readouts per quiescent chopper position is // the same (nb_rdouts_plateau) within each cycle // // // Dependencies : Stand alone DEC/MEC sequence // // Comments : Follows line by line 4.1.1 in PACS-ME-LI-005 // // Version : 0.1 21-Jan-2004 Creation by DAC // History : 0.2 12-Oct-2004 Use only time related arguments // 0.3 18-Oct-2004 Normalized variable names // 0.4 9-Nov-2004 Return array containing 4 times. // time[0] = total SRC time // time[1] = total CAL time // time[2] = total overhead time // time[3] = total DMC time (by Version 0.1) // 0.5 22-nov-2006 Removed debug_print // 0.6 14-mar-2007 WAIT=1 for chopper are useful // : int[] procedure DMC_phot_2_3_chop { int nb_SRC_REF = 1; // p01 Nb of cycles SRC->REF1->SRC->REF2 int nb_rdouts_plateau = 16; // p03 Nb of readouts per chopper plateau int nb_cycles_obs_cal = 1; // p06 Nb of repetions of OBS-CAL cycle int nb_CS1_CS2 = 0; // p07 Nb of cycles CS1->CS2 }{ int duree_SRC = 0; int duree_REF = 0; int duree_CAL = 0; int duree_OVR = 0; // Start tallying the duration (measured in number of readouts) int duration_rdouts = 0; // WAIT 1 ; have a defined start duration_rdouts = duration_rdouts + 1; duree_OVR = duree_OVR + 1; // LABEL 0 ; set Label to 0 // WAIT 1 ; have a defined start duration_rdouts = duration_rdouts + 1; duree_OVR = duree_OVR + 1; // Outermost LOOP on nb_cycles_obs_cal for(int obs_cal_loop = 1 .. nb_cycles_obs_cal) { // Inner LOOP on nb_SRC_REF for(int obs_loop = 1 .. nb_SRC_REF) { // WAIT 1 ; sync. for chopper duration_rdouts = duration_rdouts + 1; duree_SRC = duree_SRC + 1; // MOVE_CHOPPER_ABSOLUTE chop_pos_SRC; chopper to chop_pos_SRC // LABEL 1 ; start quadruple // WAIT nb_rdouts_plateau ; take nb_rdouts_plateau images duration_rdouts = duration_rdouts + nb_rdouts_plateau; duree_SRC = duree_SRC + nb_rdouts_plateau; // WAIT 1 ; sync. for chopper duration_rdouts = duration_rdouts + 1; duree_SRC = duree_SRC + 1; // MOVE_CHOPPER_ABSOLUTE chop_pos_REF1; chopper to chop_pos_REF1 // LABEL 3 ; next chopper position // WAIT nb_rdouts_plateau ; take nb_rdouts_plateau images duration_rdouts = duration_rdouts + nb_rdouts_plateau; duree_REF = duree_REF + nb_rdouts_plateau; // WAIT 1 ; sync. for chopper duration_rdouts = duration_rdouts + 1; duree_SRC = duree_SRC + 1; // MOVE_CHOPPER_ABSOLUTE chop_pos_SRC; chopper to chop_pos_SRC // LABEL 1 ; first chopper position // WAIT nb_rdouts_plateau ; take nb_rdouts_plateau images duration_rdouts = duration_rdouts + nb_rdouts_plateau; duree_SRC = duree_SRC + nb_rdouts_plateau; // WAIT 1 ; sync. for chopper duration_rdouts = duration_rdouts + 1; duree_SRC = duree_SRC + 1; // MOVE_CHOPPER_ABSOLUTE chop_pos_REF2 ; move chopper to chop_pos_REF2 // LABEL 5 ; chopper position 3 // WAIT nb_rdouts_plateau ; take nb_rdouts_plateau images duration_rdouts = duration_rdouts + nb_rdouts_plateau; duree_REF = duree_REF + nb_rdouts_plateau; // End inner loop on nb_SRC_REF // END_LOOP ; end loop measurement } // Inner LOOP on nb_CS1_CS2 for(int cal_loop = 1 .. nb_CS1_CS2) { // WAIT 1 ; sync. for chopper duration_rdouts = duration_rdouts + 1; duree_CAL = duree_CAL + 1; // MOVE_CHOPPER_ABSOLUTE chop_pos_CS1 ; move chopper to CS1 // LABEL 65 ; chopper to CS1 // WAIT nb_rdouts_plateau ; take nb_rdouts_plateau images duration_rdouts = duration_rdouts + nb_rdouts_plateau; duree_CAL = duree_CAL + nb_rdouts_plateau; // WAIT 1 ; sync. for chopper duration_rdouts = duration_rdouts + 1; duree_CAL = duree_CAL + 1; // MOVE_CHOPPER_ABSOLUTE chop_pos_CS2 ; move chopper to CS2 // LABEL 129 ; chopper to CS2 // WAIT nb_rdouts_plateau ; take nb_rdouts_plateau images duration_rdouts = duration_rdouts + nb_rdouts_plateau; duree_CAL = duree_CAL + nb_rdouts_plateau; // End inner loop on nb_CS1_CS2 // END_LOOP ; end loop calibration } // End outermost loop on nb_cycles_obs_cal // END_LOOP ; end main loop } // WAIT 1 ; complete last plateau duration_rdouts = duration_rdouts + 1; duree_OVR = duree_OVR + 1; // LABEL 0 ; no sequence anymore // END_SEQUENCE // Define return array int[] time_array = [duration_rdouts,duree_SRC,duree_REF,duree_CAL,duree_OVR]; // debug_print("DMC_phot_2_3_chop: " + time_array); // Return the array of times return time_array; } // SpirePHOT_STBYtoREDY // // $id$ // // This procedure configures the instrument into the REDY mode // // The instrument should be in the PHOT_STBY mode before execution of this observation // // // 08/11/2007 KJK: removed StartObs and EndObs building blocks from the engineering procedure // 07/05/2009 KJK: // now switch off detectors before switching off the BSM // added debug as input parameter // 09/06/2009 KJK: // added ptcVersion input parameter // now sets PTC status // 02/07/2009 MP: Added report of tables and memory checksums (SPIRE-SCR-1527) // // procedure SpirePHOT_STBYtoREDY { string bsmVersion = "v00"; string detVersion = "v00"; string ptcVersion = "v00"; bool debug = false; }{ // ---------------- // Configure PTC // ---------------- // string ptc = SpireProc_GetTableEntryString("SpireTable_DefaultParams.txt","mode","REDY","ptcVm",ptcVersion,debug); SpireBbSetPtc(ptc,ptcVersion,debug); // // ---------------- // switch off detectors // ---------------- mois_comment("Procedure SPIRE PDET_OFF: to switch off the SPIRE Photometer"); mois_spacon("Select the TM Display for FUNCTIONAL TEST PARAMETERS"); SpireBbPdetOff(); // // setup detector sampling SpireBbSetDetSampling("REDY",true,detVersion,false,debug); mois_comment("SPIRE SPIRE_PDET_OFF Procedure Completed"); mois_tmcheck("Ensure that parameter MODE is set to PDET_OFF"); mois_tmcheck("Ensure PLIABITSTAT is set to 0"); mois_tmcheck("Ensure PSWJFETSTAT is set to 0"); mois_tmcheck("Ensure PMLWJFETSTAT is set to 0"); mois_tmcheck("Ensure parameters PSWJFET1V to PSWJFET6V are all set to 0"); mois_tmcheck("Ensure parameters PMWJFET1V to PSWJFET4V are all set to 0"); mois_tmcheck("Ensure parameters PLWJFET1V & PSWJFET2V are set to 0"); mois_spacon("Select the TM Display for SFT PARAMETERS"); mois_tmcheck("PLIAP5V, PLIAP9V and PLIAM9V should all be 0"); // // ---------------- // switch off BSM // ---------------- mois_comment("Procedure SPIRE_BSM_OFF: to switch off the SPIRE BSM"); mois_spacon("Select the TM Display for FUNCTIONAL TEST PARAMETERS"); SpireBbBsmOff(); // // Setup BSM sampling SpireBbSetBsmSampling("REDY",bsmVersion,debug); mois_comment("SPIRE SPIRE_BSM_OFF Procedure Completed"); mois_tmcheck("Check that parameter CHOPSENSPWR is set to 0"); mois_tmcheck("Check that parameter JIGGSENSPWR is set to 0"); mois_tmcheck("Check that parameter MODE is set to REDY"); // // SpireBbSetScuSampling("REDY","v00",debug); // // // // // // Report tables and do memory checksums: // SpireBb_RepTabAndMemChecksum(); // // set nominal housekeeping rate SpireBbSetNhkSampling("REDY","v00",debug); } // SpireBbJiggle // // execute jiggle operations // // returns the actual time on-source // // K.J. King // // 04 November 2008: added data_rate commands // double block SpireBbJiggle SPIRE 8993 { string opsMode = "" in ["POF2","POF3","POF4"]; int jiggleTable = 0; // number of jiggle table int startPosn = 0; // starting position in jiggle map int nPosns = 1; // number of jiggle positions to execute int nRepeats = 1; // number of times to repeat this jiggle operation int step = 0; // step number }{ int t = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB Jiggle started"); SpireMsg(2," $Id: SpireBbJiggle.txt,v 1.3 2006/12/05 14:16:57 kking Exp $"); // // ..... configuration ..... // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // set STEP hstr = SpireHexStr(step,4); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP_RAW(" + hstr + ")"); Spire_SET_OBS_STEP_RAW(step); // // set up detectors for operations // //SpireConfigDcuData(opsMode); // // execute jiggle // int id = ilookup("CommandLists.txt","JiggleMap","Id"); // number of table containing the jiggle command list int index = ilookup("CommandLists.txt","JiggleMap","Index"); // istart point in table containing the jiggle command list int nParms = ilookup("CommandLists.txt","JiggleMap","Nparms"); // number of parameters to the jiggle command list int nChops = ilookup("OpsParms.txt",opsMode,"NChops"); // number of chop cycles per jiggle position int tChop = ilookup("Chopping.txt",opsMode,"Period"); // period of chop cycle int dcuFrame = ilookup("Chopping.txt",opsMode,"DcuFrame"); // DCU Sample Mode int nDcu = ilookup("Chopping.txt",opsMode,"DcuSamples"); // number of DCU Samples per chop position int tDelay = ilookup("Chopping.txt",opsMode,"DcuDelay"); // delay to start of DCU sampling int nBsm = ilookup("Chopping.txt",opsMode,"BsmSamples"); // number of BSM samples per chop position // // issue VM command // {int}[] parms = [{jiggleTable},{startPosn * 2},{nPosns * 2},{nChops},{tChop},{dcuFrame},{nDcu},{tDelay},{nBsm},{nRepeats}]; tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_RUN_VM_RAW(" + id + "," + index + "," + nParms + "," + parms + ")"); Spire_RUN_VM_RAW(id,index,nParms,parms); // set datarate double rate = 0.0; rate = dlookup("Datarates.txt",opsMode,"DCU"); rate = rate + dlookup("Datarates.txt",opsMode,"BSM"); data_rate(rate); // calc time to perform a jiggle operation int nOps = nPosns * nChops * nRepeats; double opsTime = double(nOps) * double(tChop) / 1000000.0; // wait to end of jiggle operation delay(iceil(opsTime)); data_rate(0.0); // // flush data tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_FLUSH_FIFO_RAW(0x3000)"); Spire_FLUSH_FIFO_RAW(0x3000); delay(2); double srcTime = double(nOps) * double(tChop) / 1000000.0; // // effective integration time per jiggle operation // // ..... completion ..... // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB Jiggle ended"); SpireMsg(1," ..Jiggle (" + (time() - t) + " seconds)"); // return srcTime; } // SpireBbPdetOn // // $id$ // // This building block switches on the photometer detectors // // The instrument should be in the REDY mode before execution of this building block // // 21.08.2008: KK Updated to new switch on sequence using nominal and optimum JFet voltages // // 11/11/2008: KJK Updated to set offsets after switchon // // 02/12/2008 MP: now DCU data generation is stopped before setting the // detector offsets and FIFOs are flushed before resetting // the detector offset (problem raised after TB/TV as // SPIRE-SCR 1052) // // 27/04/2009 KJK: // Updated to use new NominalSettings Cal Tables // version and debug passed as parameters // // block SpireBbPdetOn SPIRE 1280 { int jfet_heater_V = 0; // By default don't switch on jfet heater string detVersion = "v00"; string vssVersion = "v00"; bool debug = false; }{ int t0 = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB PdetOn started"); SpireMsg(2," $Id$"); // int cmd = 0x0; // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // set STEP to 0 SpireSetObsStep(0x0); // // Retrieve bias settings // int biasmode = ilookup("SpireTable_DefaultParams.txt","v00","biasMode"); int mclkdiv = SpireProc_GetTableEntryInt("SpireTable_PhotModeParams.txt","mode","PHTSTBY","mclkDiv",detVersion,debug); int biasdiv = SpireProc_GetTableEntryInt("SpireTable_PhotModeParams.txt","mode","PHTSTBY","biasDiv",detVersion,debug); // // Retrive array nominal settings for PHTSTBY mode // int psw_bias = SpireProc_GetTableEntryInt("SpireTable_PhotModeParams.txt","mode","PHTSTBY","pswBias",detVersion,debug); int psw_phase = SpireProc_GetTableEntryInt("SpireTable_PhotModeParams.txt","mode","PHTSTBY","pswPhase",detVersion,debug); int pmw_bias = SpireProc_GetTableEntryInt("SpireTable_PhotModeParams.txt","mode","PHTSTBY","pmwBias",detVersion,debug); int pmw_phase = SpireProc_GetTableEntryInt("SpireTable_PhotModeParams.txt","mode","PHTSTBY","pmwPhase",detVersion,debug); int plw_bias = SpireProc_GetTableEntryInt("SpireTable_PhotModeParams.txt","mode","PHTSTBY","plwBias",detVersion,debug); int plw_phase = SpireProc_GetTableEntryInt("SpireTable_PhotModeParams.txt","mode","PHTSTBY","plwPhase",detVersion,debug); int ptc_bias = SpireProc_GetTableEntryInt("SpireTable_PhotModeParams.txt","mode","PHTSTBY","ptcBias",detVersion,debug); int ptc_phase = SpireProc_GetTableEntryInt("SpireTable_PhotModeParams.txt","mode","PHTSTBY","ptcPhase",detVersion,debug); // // --- // Building block starts // --- // Set MODE to PDET_ON SpireSetObsMode("PDET_ON"); delay(1); SpireSetObsStep(0x1); delay(1); // // Switch ON PLIAs // SpireSendDrcuCmd(0xa0870005,0); delay(1); // // Set bias mode ,bias frequency and sampling frequency // SpireSendDrcuCmd(0x84000000 + biasmode,0); SpireSendDrcuCmd(0x84190000 + mclkdiv,0); delay(1); SpireSendDrcuCmd(0x84180000 + biasdiv,0); // // Switch on with small bias (~ 1 mVrms) across the arrays // SpireSendDrcuCmd(0x84010002,0); delay(1); SpireSendDrcuCmd(0x84020002,0); SpireSendDrcuCmd(0x84030002,0); delay(1); SpireSendDrcuCmd(0x84040002,0); // // Set demodulation phase shift // SpireSendDrcuCmd(0x841a0000 + psw_phase,0); delay(1); SpireSendDrcuCmd(0x841b0000 + pmw_phase,0); SpireSendDrcuCmd(0x841c0000 + plw_phase,0); delay(1); SpireSendDrcuCmd(0x841d0000 + ptc_phase,0); delay(1); // // Automatic offset setting + get offsets // SpireSendDrcuCmd(0x843c0010,0); SpireSendDrcuCmd(0x843e0001,0); delay(2); SpireSendDrcuCmd(0x843e0000,0); SpireSendDrcuCmd(0x843c0018,0); delay(1); SpireSendDrcuCmd(0x843e0001,0); delay(3); SpireSendDrcuCmd(0x843e0000,0); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_FLUSH_FIFO_RAW(0x1000)"); Spire_FLUSH_FIFO_RAW(0x1000); delay(1); // // Start PF data generation // SpireSendDrcuCmd(0x843c0000,0); SpireSendDrcuCmd(0x843d0000,0); delay(1); SpireSendDrcuCmd(0x843e0001,0); // // If necessary switch ON jfet heater if(jfet_heater_V != 0) { SpireSendDrcuCmd(0x84110000 + jfet_heater_V,0); delay(60); SpireSendDrcuCmd(0x84110000,0); } else { delay(3); } // // Apply Startup Vss voltages // // Read the startup Vss settings // //PSW int psw_jfet_Vss1 = SpireProc_GetTableEntryInt("SpireTable_PhotVssSettings.txt","model","startup","psw_vss1",vssVersion,debug); int psw_jfet_Vss2 = SpireProc_GetTableEntryInt("SpireTable_PhotVssSettings.txt","model","startup","psw_vss2",vssVersion,debug); int psw_jfet_Vss3 = SpireProc_GetTableEntryInt("SpireTable_PhotVssSettings.txt","model","startup","psw_vss3",vssVersion,debug); int psw_jfet_Vss4 = SpireProc_GetTableEntryInt("SpireTable_PhotVssSettings.txt","model","startup","psw_vss4",vssVersion,debug); int psw_jfet_Vss5 = SpireProc_GetTableEntryInt("SpireTable_PhotVssSettings.txt","model","startup","psw_vss5",vssVersion,debug); int psw_jfet_Vss6 = SpireProc_GetTableEntryInt("SpireTable_PhotVssSettings.txt","model","startup","psw_vss6",vssVersion,debug); // PMW int pmw_jfet_Vss1 = SpireProc_GetTableEntryInt("SpireTable_PhotVssSettings.txt","model","startup","pmw_vss1",vssVersion,debug); int pmw_jfet_Vss2 = SpireProc_GetTableEntryInt("SpireTable_PhotVssSettings.txt","model","startup","pmw_vss2",vssVersion,debug); int pmw_jfet_Vss3 = SpireProc_GetTableEntryInt("SpireTable_PhotVssSettings.txt","model","startup","pmw_vss3",vssVersion,debug); int pmw_jfet_Vss4 = SpireProc_GetTableEntryInt("SpireTable_PhotVssSettings.txt","model","startup","pmw_vss4",vssVersion,debug); //PLW int plw_jfet_Vss1 = SpireProc_GetTableEntryInt("SpireTable_PhotVssSettings.txt","model","startup","plw_vss1",vssVersion,debug); int plw_jfet_Vss2 = SpireProc_GetTableEntryInt("SpireTable_PhotVssSettings.txt","model","startup","plw_vss2",vssVersion,debug); // PTC int ptc_jfet_Vss = SpireProc_GetTableEntryInt("SpireTable_PhotVssSettings.txt","model","startup","ptc_vss1",vssVersion,debug); // // Apply PSW Vss voltages followed by PSW Vdd // // PSW JFET1 SpireSendDrcuCmd(0x84050000 + psw_jfet_Vss1,0); SpireSendDrcuCmd(0x84120001,0); delay(1); // PSW JFET2 SpireSendDrcuCmd(0x84060000 + psw_jfet_Vss2,0); SpireSendDrcuCmd(0x84120003,0); delay(1); // PSW JFET3 SpireSendDrcuCmd(0x84070000 + psw_jfet_Vss3,0); SpireSendDrcuCmd(0x84120007,0); delay(1); // PSW JFET4 SpireSendDrcuCmd(0x84080000 + psw_jfet_Vss4,0); SpireSendDrcuCmd(0x8412000f,0); delay(1); // PSW JFET5 SpireSendDrcuCmd(0x84090000 + psw_jfet_Vss5,0); SpireSendDrcuCmd(0x8412001f,0); delay(1); // PSW JFET6 SpireSendDrcuCmd(0x840a0000 + psw_jfet_Vss6,0); SpireSendDrcuCmd(0x8412003f,0); delay(1); // // Apply PMW Vss voltages followed by PMW Vdd // // PMW JFET1 SpireSendDrcuCmd(0x840b0000 + pmw_jfet_Vss1,0); SpireSendDrcuCmd(0x84130001,0); delay(1); // PMW JFET2 SpireSendDrcuCmd(0x840c0000 + pmw_jfet_Vss2,0); SpireSendDrcuCmd(0x84130003,0); delay(1); // PMW JFET3 SpireSendDrcuCmd(0x840d0000 + pmw_jfet_Vss3,0); SpireSendDrcuCmd(0x84130007,0); delay(1); // PMW JFET4 SpireSendDrcuCmd(0x840e0000 + pmw_jfet_Vss4,0); SpireSendDrcuCmd(0x8413000f,0); delay(1); // // Apply PLW Vss voltages followed by PLW Vdd // // PLW JFET1 SpireSendDrcuCmd(0x840f0000 + plw_jfet_Vss1,0); SpireSendDrcuCmd(0x8413001f,0); // PLW JFET2 SpireSendDrcuCmd(0x84100000 + plw_jfet_Vss2,0); SpireSendDrcuCmd(0x8413003f,0); delay(1); // // Apply TC Vss voltage followed by Vdd // SpireSendDrcuCmd(0x84140000 + ptc_jfet_Vss,0); SpireSendDrcuCmd(0x8413007f,0); // // Wait 30 seconds before setting nominal biases // delay(30); SpireSendDrcuCmd(0x84010000 + psw_bias,0); delay(1); SpireSendDrcuCmd(0x84020000 + pmw_bias,0); delay(1); SpireSendDrcuCmd(0x84030000 + plw_bias,0); delay(1); SpireSendDrcuCmd(0x84040000 + ptc_bias,0); delay(1); // // Stop DCU data, apply automatic offset setting + get offsets // SpireSendDrcuCmd(0x843e0000,0); delay(1); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_FLUSH_FIFO_RAW(0x1000)"); Spire_FLUSH_FIFO_RAW(0x1000); delay(3); SpireSendDrcuCmd(0x843c0010,0); SpireSendDrcuCmd(0x843e0001,0); delay(2); SpireSendDrcuCmd(0x843e0000,0); SpireSendDrcuCmd(0x843c0018,0); delay(1); SpireSendDrcuCmd(0x843e0001,0); delay(3); SpireSendDrcuCmd(0x843e0000,0); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_FLUSH_FIFO_RAW(0x1000)"); Spire_FLUSH_FIFO_RAW(0x1000); delay(1); // // Start PF data generation // SpireSendDrcuCmd(0x843c0000,0); SpireSendDrcuCmd(0x843d0000,0); delay(1); SpireSendDrcuCmd(0x843e0001,0); // // Wait 30 seconds before setting the optimum Vss values // delay(30); // // Read the optimum Vss settings (lowest noise) // //PSW int psw_jfet_OVss1 = SpireProc_GetTableEntryInt("SpireTable_PhotVssSettings.txt","model","optimum","psw_vss1",vssVersion,debug); int psw_jfet_OVss2 = SpireProc_GetTableEntryInt("SpireTable_PhotVssSettings.txt","model","optimum","psw_vss2",vssVersion,debug); int psw_jfet_OVss3 = SpireProc_GetTableEntryInt("SpireTable_PhotVssSettings.txt","model","optimum","psw_vss3",vssVersion,debug); int psw_jfet_OVss4 = SpireProc_GetTableEntryInt("SpireTable_PhotVssSettings.txt","model","optimum","psw_vss4",vssVersion,debug); int psw_jfet_OVss5 = SpireProc_GetTableEntryInt("SpireTable_PhotVssSettings.txt","model","optimum","psw_vss5",vssVersion,debug); int psw_jfet_OVss6 = SpireProc_GetTableEntryInt("SpireTable_PhotVssSettings.txt","model","optimum","psw_vss6",vssVersion,debug); // // PMW int pmw_jfet_OVss1 = SpireProc_GetTableEntryInt("SpireTable_PhotVssSettings.txt","model","optimum","pmw_vss1",vssVersion,debug); int pmw_jfet_OVss2 = SpireProc_GetTableEntryInt("SpireTable_PhotVssSettings.txt","model","optimum","pmw_vss2",vssVersion,debug); int pmw_jfet_OVss3 = SpireProc_GetTableEntryInt("SpireTable_PhotVssSettings.txt","model","optimum","pmw_vss3",vssVersion,debug); int pmw_jfet_OVss4 = SpireProc_GetTableEntryInt("SpireTable_PhotVssSettings.txt","model","optimum","pmw_vss4",vssVersion,debug); // // PLW int plw_jfet_OVss1 = SpireProc_GetTableEntryInt("SpireTable_PhotVssSettings.txt","model","optimum","plw_vss1",vssVersion,debug); int plw_jfet_OVss2 = SpireProc_GetTableEntryInt("SpireTable_PhotVssSettings.txt","model","optimum","plw_vss2",vssVersion,debug); // // PTC int ptc_jfet_OVss = SpireProc_GetTableEntryInt("SpireTable_PhotVssSettings.txt","model","optimum","ptc_vss1",vssVersion,debug); // // Now set the optimum Vss values for all the JFETs // // PSW JFET1 SpireSendDrcuCmd(0x84050000 + psw_jfet_OVss1,0); // PSW JFET2 SpireSendDrcuCmd(0x84060000 + psw_jfet_OVss2,0); delay(1); // PSW JFET3 SpireSendDrcuCmd(0x84070000 + psw_jfet_OVss3,0); // PSW JFET4 SpireSendDrcuCmd(0x84080000 + psw_jfet_OVss4,0); delay(1); // PSW JFET5 SpireSendDrcuCmd(0x84090000 + psw_jfet_OVss5,0); // PSW JFET6 SpireSendDrcuCmd(0x840a0000 + psw_jfet_OVss6,0); delay(1); // PMW JFET1 SpireSendDrcuCmd(0x840b0000 + pmw_jfet_OVss1,0); // PMW JFET2 SpireSendDrcuCmd(0x840c0000 + pmw_jfet_OVss2,0); delay(1); // PMW JFET3 SpireSendDrcuCmd(0x840d0000 + pmw_jfet_OVss3,0); // PMW JFET4 SpireSendDrcuCmd(0x840e0000 + pmw_jfet_OVss4,0); delay(1); // PLW JFET1 SpireSendDrcuCmd(0x840f0000 + plw_jfet_OVss1,0); // PLW JFET2 SpireSendDrcuCmd(0x84100000 + plw_jfet_OVss2,0); delay(1); // PTC JFET Vss SpireSendDrcuCmd(0x84140000 + ptc_jfet_OVss,0); // // delay(10); // stop data collection SpireSendDrcuCmd(0x843e0000,0); // // flush data from FIFOs tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_FLUSH_FIFO_RAW(0x1000)"); Spire_FLUSH_FIFO_RAW(0x1000); delay(1); delay(3); // SpireSetObsMode("PHOTSTBY"); SpireSetObsStep(0x0); sync(); // // completion tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB PdetOn ended"); SpireMsg(1," ..PDET Switch On (" + (time() - t0) + " seconds)"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_Exec_SpecPhaseUp.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to loop through a list of phase values for // the 'Spec Phase Up' task // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/08/11 V0.1: Initial version adapted from // SpireProc_Exec_PhotPhaseUp.txt (2008/07/03 V0.2) // Mode_ILT_PERF_DPH_S.txt (v1.4 2008/01/31 20:24:33) // 2009/02/19 V0.2: Add debug_print as input and pass to low level scripts. // Do not set first phase, now done during SLEW. Add // dcuData to input. // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Exec_SpecPhaseUp { int[] raw_phase_list = [127,128,129,130,131,132,133]; // Raw phase list (0-255) [dec(HEX)] int ftime = 10; // Time at each bias level [sec] bool dcuData = false; // Is (==tick) the DCU currently sampled? bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Setup bias amplitude and frequency: // --> during slew!! // // // // // // Start the phase loop: // for(int l = 0 .. length(raw_phase_list) - 1) { // // // // // Set phases for arrays: // if(l > 0) { SpireBb_SpecFSetPhase(raw_phase_list[l],raw_phase_list[l],debug); } // // // // // Stop DCU data before resetting offsets: // SpireBb_StopDcuData(); // // // // // Set offsets: // SpireBb_SpecOffsetAuto(dcuData,debug); // // // // // Take data: // SpireBb_SpecFTakeData(ftime,debug); // // if(debug) { debug_print("Phase finished is: " + raw_phase_list[l]); } } // // } // SpireSpecRasterPositions // // $Id: SpireSpecRasterPositions.txt,v 1.3 2007/01/15 15:05:05 kking Exp $ // // A procedure to calculate the positions of spectrometer raster points to cover a given area // {double[],double[]} procedure SpireSpecRasterPositions { string opsMode = "SOF1" in ["SOF1","SOF2","SOF2_int"]; // operations mode double offsetY = 0.0; double offsetZ = 0.0; double width = 0.0; double height = 0.0; }{ double pi = asin(1.0) * 2.0; // read in raster positioning parameters double yShiftUnit = dlookup("OpsParms.txt",opsMode,"YShiftUnit"); // units for shift in Y direction double zShiftUnit = dlookup("OpsParms.txt",opsMode,"ZShiftUnit"); // units for shift in Z direction double yStep = dlookup("OpsParms.txt",opsMode,"YStep") * yShiftUnit; // step in Y direction double zStep = dlookup("OpsParms.txt",opsMode,"ZStep") * zShiftUnit; // step in Z direction double yRowSep = dlookup("OpsParms.txt",opsMode,"YRowSep") * yShiftUnit; // row separation in Y direction double zRowSep = dlookup("OpsParms.txt",opsMode,"ZRowSep") * zShiftUnit; // row separation in Z direction // // angle of rows with respect to YZ double yz_angle = atan(yStep / zStep); // // calculate the separation between points along and between rows double separation_along_row = sqrt(yStep * yStep + zStep * zStep); double separation_between_row = sqrt(yRowSep * yRowSep + zRowSep * zRowSep) * sin(yz_angle + atan(yRowSep / zRowSep)); // calculate number of raster positions corresponding to length and height // accounting for extra coverage at the ends on rows and columns int number_length = iceil((width - separation_along_row / 2.0) / separation_along_row); int number_height = iceil((height - separation_between_row / 2.0) / separation_between_row); // Check if just doing a single row. If so include the 1/2 separation on the left hand side if(number_height == 0) { number_length = iceil((width - separation_along_row) / separation_along_row); } // Check the supplied width and height are not less than 1/2 separation of raster points if(width < separation_along_row / 2.0) { number_length = 0; } if(height < separation_between_row / 2.0) { number_height = 0; } // now adjust the width, height to be the actual one covered (using // distance between rows and along rows width = double(number_length) * separation_along_row + separation_along_row / 2.0; // in the case of a single row, add an extra half separation for the left hand side. if(number_height == 0) { width = width + separation_along_row / 2.0; } // do not add "separation_between_row/2.0" here because this does not affect the starting position for height height = double(number_height) * separation_between_row; // // calculate the actual parallelogram covered // get the parallelogram angle using cosine rule double a = sqrt(pow(2.0 * zRowSep,2.0) + pow(2.0 * yRowSep,2.0)); double b = sqrt(yStep * yStep + zStep * zStep); double c = sqrt(pow(yStep + 2.0 * yRowSep,2.0) + pow(2.0 * zRowSep - zStep,2.0)); double parallelogram_angle = acos((pow(b,2.0) + pow(c,2.0) - pow(a,2.0)) / (2.0 * b * c)) - pi / 2.0; // // Calculate starting position (depends on number of points in each direction) // top left corner of parallelogram double start_y = 0.0; double start_z = 0.0; if(number_height > 0) { start_y = (-width / 2.0 + height * tan(parallelogram_angle) / 2.0) * cos(yz_angle) - height / 2.0 * sin(yz_angle); start_z = height / 2.0 * cos(yz_angle) + (-width / 2.0 + height * tan(parallelogram_angle) / 2.0) * sin(yz_angle); } // This is for a single row, or a single point. // 1st row starts in centre of left side of parallelogram - but shifted by 1/2 sep_along_row if(number_height == 0) { start_y = -(width / 2.0 - separation_along_row / 2.0) * cos(yz_angle); start_z = -(width / 2.0 - separation_along_row / 2.0) * sin(yz_angle); } // // create raster offsets arrays double[] yRasterOffsets = []; double[] zRasterOffsets = []; int direction = 0; int w = 0; for(int h = 0 .. number_height) { for(int i = 0 .. number_length) { // alternate rows go in opposite directions direction = (h + 1) / 2 - h / 2; w = direction * (number_length - i) - (direction - 1) * i; yRasterOffsets[i + h * (number_length + 1)] = start_y + double(w) * yStep + double(h) * yRowSep + double((h + 1) / 2) * yStep; zRasterOffsets[i + h * (number_length + 1)] = start_z + double(w) * zStep - double(h) * zRowSep + double((h + 1) / 2) * zStep; } } return {yRasterOffsets,zRasterOffsets}; } // SpirePhotoPcalFlash // // $id$ // // This observation executes a PCAL Flash // // The instrument should be in the PHOTSTBY mode before execution of this procedure // and the parameter passed to the observation should correspond to the initial state. // // 17/03/2009 KJK: // SCR 0946 created from SpireEngPcalFlash // 05/07/2009 KJK: // SPR-1593 - Updated input parameters in call to SpirePcalFlash // obs SpirePhotoPcalFlash { double ra = 0.0 in [0.0,360.0]; // RA of target double dec = 0.0 in [-90.0,90.0]; // DEC of target int naifid = 0; // NAIF identifier string boresight = ""; // instrument boresight to use bool pointing = true; // Should telescope 'point' (==tick) or do a 'no pointing' (==untick)? bool isBright = false; // Use settings for bright source (==tick) string opsVersion = "v00"; // Version in cal table SpireTable_OpsParms string flashVersion = "v00"; // Version in cal table SpireTable_FlashParms bool debug = false; // debug messages flag bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ string obsMode = "POF8"; bool isPhot = true; string version01 = "v00"; // Version in cal table SpireTable_PhotModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams string version06 = "v00"; // Version in cal table SpireTable_IsBrightPhaseShift // // Calculate timing for the pointing request: // // BBs called during slew: // int tslewmin = duration(SpireBb_StartObsAll(obsMode)) + duration(SpireBb_PhotSetMode("PFlash",isBright,version01,version02,debug)); // // BBs carried out when the pointing is reached: // if(pointing) { int tinithold = duration(SpireBb_PhotOffsetAuto(debug)); } else { tinithold = duration(SpireBb_PhotOffsetAuto(debug)) + duration(SpireBb_StartObsAll(obsMode)) + duration(SpireBb_PhotSetMode("PFlash",isBright,version01,version02,debug)); } // // BB carried out during pointing: // int tp = duration(SpirePcalFlash("PFlash",flashVersion,debug)); // // BB carried out at the end: // int tfinalhold = duration(SpireBb_EndObsAll(isPhot)) + duration(SpireBb_PhotSetMode("PHTSTBY",isBright,version01,version02,debug)) + duration(SpireBb_SetObsStep(0,debug)); // // Debug printing: // if(debug) { debug_print("tslewmin = " + tslewmin); debug_print("tinithold = " + tinithold); debug_print("tpointing = " + tp); debug_print("tfinalhold = " + tfinalhold); } // // Lookup boresight, if not provided // string ib = boresight; if(boresight == "") { ib = SpireProc_GetTableEntryString("SpireTable_OpsParms.txt","mode",obsMode,"Boresight",opsVersion,debug); } // // Set pointing mode: // if(pointing) { int[] ts = basic_fine_pointing(true,tslewmin,tinithold,tfinalhold,ib,naifid,ra,dec,0.0,0.0,tp); } else { ts = no_pointing(true,tinithold,tfinalhold,tp); } // if(debug) { debug_print("Output timing vector from the pointing request: " + ts); } }{ int[] state = [0]; while(state[0] >= 0) { state = next_state(); if(state[0] == 1) { // *********************** SLEW // Start observation: SpireBb_StartObsAll(obsMode); // configure instrument SpireBb_PhotSetMode("PFlash",isBright,version01,version02,debug); } if(state[0] == 2) { // *********************** INITHOLD // If no pointing observation do stuff here which is // done nominally during SLEW: if(!pointing) { // Start observation: SpireBb_StartObsAll(obsMode); // configure instrument SpireBb_PhotSetMode("PFlash",isBright,version01,version02,debug); } // Set offsets: // SpireBb_PhotOffsetAuto(debug); } if(state[0] == 3) { // *********************** POINTING SpirePcalFlash("PFlash",flashVersion,debug); } if(state[0] == 5) { // *********************** FINALHOLD // reset STEP SpireBb_SetObsStep(0,debug); // // Set detectors back to PHOTSTBY: SpireBb_PhotSetMode("PHTSTBY",isBright,version01,version02,debug); // // End Observation SpireBb_EndObsAll(isPhot); // } } } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_StartFovMapCrossRaster.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to configure at the start of // SpirePhoto/Spectro_CalGCO_FovMapCrossRaster. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // // 2009/05/05 V0.1: Initial version adapted from // SpireBb_StartBsmPcalFlash (2009/05/05 V0.1), // SpirePhoto_CalGCO_FovMapCrossRaster (2009/03/17 V1.0), and // SpireSpectro_CalGCO_FovMapCrossRaster (2008/09/17 V0.1). // BB includes now to move BSM/SMEC to hold/home. // 2009/07/12 V1.0: Fix bug in passing of SMEC home position (SPR-SPIRE-1612) // Set SMEC framerate to zero to get all BSM samples // (SPR-SPIRE-1551). // // Notes: // 1) Scripts assumes that SpireBb_SpecOffsetAuto is run // during INITHOLD or at first POINTING. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_StartFovMapCrossRaster SPIRE 14044 { bool phot = true; // Photometer (==tick) or FTS (==untick)? string obsModeQla = "ENG_CAL_OBS03"; string obsMode = "PEngCalObs"; bool isBright = false; // Use settings for bright source (==tick) string version01 = "v00"; // Version in cal table SpireTable_Phot/SpecModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams int hold_chop = 37632; // Chop hold position int hold_jigg = 39520; // Jiggle hold position bool setFramerate = true; // Set BSM framerate (==tick)? int frate = 0; // BSM framerate int smecHomePosn = 3500; // SMEC home position bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // int mode_id = 0; string obsmode = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB StartFovMapCrossRaster configuration started"); SpireMsg(2," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Startup observation: // SpireProc_Set_StartObsAll(obsModeQla); // // // // // In case move SMEC to home: // if(!phot) { // // Calculate available time for possible movement: // int tmove = duration(SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug)) + duration(SpireProc_Set_SpecMode(obsMode,isBright,version01,version02,debug)) + duration(SpireBb_SpecOffsetAuto(false,debug)); if(setFramerate) { tmove = tmove + duration(SpireProc_Set_BsmFramerate(frate,debug)); } // // Calculate max offset for which time is available: // int smecMaxOff = tmove * 500; // Note, 500 is maximum possible SMEC speed. int smecStart = smecHomePosn + smecMaxOff; // Note, formula above only reasonable // when smecHomePosn small compared to 39500 // Safety check: if(smecStart > 39500) { smecStart = 39500; } if(debug) { debug_print("smecStart: " + smecStart); debug_print("smecHomePosn: " + smecHomePosn); debug_print("tmove: " + tmove); } // // Move from maximal offset to home: // SpireProc_SmecMove2Home(smecHomePosn,smecHomePosn + smecMaxOff,debug); } // // // // // Move BSM back to hold: // SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug); // // // // // Initialise instrument (in case to isBright): // if(phot) { SpireProc_Set_PhotMode(obsMode,isBright,version01,version02,debug); } else { SpireProc_Set_SpecMode(obsMode,isBright,version01,version02,debug); } //delay(timeSlewCal); // // // // // Set user requested framerate: // if(setFramerate) { SpireProc_Set_BsmFramerate(frate,debug); } // // // // // Set SMEC framerate (== SMEC sampling rate) to zero: // if(!phot) { SpireProc_Set_SmecFramerate(0,debug); } // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB StartFovMapCrossRaster configuration ended"); SpireMsg(1," ..StartFovMapCrossRaster took " + (time() - t) + " seconds)"); // } // SpireBbSdetOn // // $id$ // // This building block switches on the spectrometer detectors // // The instrument should be in the REDY mode before execution of this building block // // 29/04/2009 KJK: First Version // 08/06/2009 KJK: Updated to set MODE to SDET_ON // Read DcuDataMode from SpireTable_DefaultParams and use it // Read biasMode correctly from SpireTable_DefaultParams // Now finally sets up detectors according to SpireTable_DefaultParams // block SpireBbSdetOn SPIRE 1550 { int jfet_heater_V = 0; // By default don't switch on jfet heater string detVersion = "v00"; string vssVersion = "v00"; bool debug = false; }{ int t0 = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SdetOn started"); SpireMsg(2," $Id$"); // int cmd = 0x0; // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // set STEP to 0 SpireSetObsStep(0x0); // // Retrieve detector settings // int dcuDataMode = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","SPECSTBY","dcuDataMode",detVersion,debug); int biasmode = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","SPECSTBY","biasMode",detVersion,debug); int mclkdiv = SpireProc_GetTableEntryInt("SpireTable_SpecModeParams.txt","mode","SPECSTBY","mclkDiv",detVersion,debug); int biasdiv = SpireProc_GetTableEntryInt("SpireTable_SpecModeParams.txt","mode","SPECSTBY","biasDiv",detVersion,debug); // // Retrive array nominal settings for PHTSTBY mode // int ssw_bias = SpireProc_GetTableEntryInt("SpireTable_SpecModeParams.txt","mode","SPECSTBY","sswBias",detVersion,debug); int ssw_phase = SpireProc_GetTableEntryInt("SpireTable_SpecModeParams.txt","mode","SPECSTBY","sswPhase",detVersion,debug); int slw_bias = SpireProc_GetTableEntryInt("SpireTable_SpecModeParams.txt","mode","SPECSTBY","slwBias",detVersion,debug); int slw_phase = SpireProc_GetTableEntryInt("SpireTable_SpecModeParams.txt","mode","SPECSTBY","slwPhase",detVersion,debug); // // --- // Building block starts // --- // Set MODE to SDET_ON SpireSetObsMode("SDET_ON"); delay(1); SpireSetObsStep(0x1); delay(1); // // Switch ON PLIAs // SpireSendDrcuCmd(0xa0870006,0); delay(1); // // Set bias mode ,bias frequency and sampling frequency // SpireSendDrcuCmd(0x84300000 + biasmode,0); SpireSendDrcuCmd(0x84390000 + mclkdiv,0); SpireSendDrcuCmd(0x84380000 + biasdiv,0); delay(1); // // Switch on with small bias (~ 1 mVrms) across the arrays // SpireSendDrcuCmd(0x84310002,0); SpireSendDrcuCmd(0x84320002,0); delay(1); // // Set demodulation phase shift // SpireSendDrcuCmd(0x843a0000 + ssw_phase,0); SpireSendDrcuCmd(0x843b0000 + slw_phase,0); delay(1); // // Automatic offset setting + get offsets // SpireSendDrcuCmd(0x843c0014,0); SpireSendDrcuCmd(0x843e0001,0); delay(2); SpireSendDrcuCmd(0x843e0000,0); SpireSendDrcuCmd(0x843c001c,0); SpireSendDrcuCmd(0x843e0001,0); delay(3); SpireSendDrcuCmd(0x843e0000,0); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_FLUSH_FIFO_RAW(0x1000)"); Spire_FLUSH_FIFO_RAW(0x1000); delay(1); // // Start SF data generation // SpireSendDrcuCmd(0x843c0000 + dcuDataMode,0); SpireSendDrcuCmd(0x843d0000,0); SpireSendDrcuCmd(0x843e0001,0); delay(1); // // If necessary switch ON jfet heater if(jfet_heater_V != 0) { SpireSendDrcuCmd(0x84330000 + jfet_heater_V,0); delay(60); SpireSendDrcuCmd(0x84330000,0); } else { delay(3); } // // Apply Startup Vss voltages // // Read the startup Vss settings // int ssw_jfet_Vss1 = SpireProc_GetTableEntryInt("SpireTable_SpecVssSettings.txt","model","startup","ssw_vss1",vssVersion,debug); int ssw_jfet_Vss2 = SpireProc_GetTableEntryInt("SpireTable_SpecVssSettings.txt","model","startup","ssw_vss2",vssVersion,debug); int slw_jfet_Vss1 = SpireProc_GetTableEntryInt("SpireTable_SpecVssSettings.txt","model","startup","slw_vss",vssVersion,debug); // // Apply Vss voltages followed by PVdd // // SSW JFET1 SpireSendDrcuCmd(0x84350000 + ssw_jfet_Vss1,0); SpireSendDrcuCmd(0x84370002,0); delay(1); // SSW JFET2 SpireSendDrcuCmd(0x84360000 + ssw_jfet_Vss2,0); SpireSendDrcuCmd(0x84370006,0); delay(1); // SLW JFET SpireSendDrcuCmd(0x84340000 + slw_jfet_Vss1,0); SpireSendDrcuCmd(0x84370007,0); delay(1); // // Wait 30 seconds before setting nominal biases // delay(30); SpireSendDrcuCmd(0x84310000 + ssw_bias,0); delay(1); SpireSendDrcuCmd(0x84320000 + slw_bias,0); delay(1); // // Stop DCU data, apply automatic offset setting + get offsets // SpireSendDrcuCmd(0x843e0000,0); delay(1); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_FLUSH_FIFO_RAW(0x1000)"); Spire_FLUSH_FIFO(0x1000); delay(3); SpireSendDrcuCmd(0x843c0014,0); SpireSendDrcuCmd(0x843e0001,0); delay(2); SpireSendDrcuCmd(0x843e0000,0); SpireSendDrcuCmd(0x843c001c,0); SpireSendDrcuCmd(0x843e0001,0); delay(3); SpireSendDrcuCmd(0x843e0000,0); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_FLUSH_FIFO_RAW(0x1000)"); Spire_FLUSH_FIFO(0x1000); delay(1); // // Start SF data generation // SpireSendDrcuCmd(0x843c0000 + dcuDataMode,0); SpireSendDrcuCmd(0x843d0000,0); SpireSendDrcuCmd(0x843e0001,0); // // Wait 30 seconds before setting the optimum Vss values // delay(30); // // Read the optimum Vss settings (lowest noise) // int ssw_jfet_OVss1 = SpireProc_GetTableEntryInt("SpireTable_SpecVssSettings.txt","model","optimum","ssw_vss1",vssVersion,debug); int ssw_jfet_OVss2 = SpireProc_GetTableEntryInt("SpireTable_SpecVssSettings.txt","model","optimum","ssw_vss2",vssVersion,debug); int slw_jfet_OVss1 = SpireProc_GetTableEntryInt("SpireTable_SpecVssSettings.txt","model","optimum","slw_vss",vssVersion,debug); // // Now set the optimum Vss values for all the JFETs // // SSW JFET1 SpireSendDrcuCmd(0x84350000 + ssw_jfet_OVss1,0); // PSW JFET2 SpireSendDrcuCmd(0x84360000 + ssw_jfet_OVss2,0); delay(1); // SLW JFET SpireSendDrcuCmd(0x84340000 + slw_jfet_OVss1,0); // // delay(10); // setup DCU data sampling SpireSendDrcuCmd(0x843c0000 + dcuDataMode,0); int dcuFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","SPECSTBY","dcuFrameNumber",detVersion,debug); SpireSendDrcuCmd(0x843d0000 + dcuFrameNumber,0); int dcuDataGen = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","SPECSTBY","dcuDataGen",detVersion,debug); SpireSendDrcuCmd(0x843e0000 + dcuDataGen,0); // // flush data from FIFOs tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_FLUSH_FIFO_RAW(0x1000)"); Spire_FLUSH_FIFO_RAW(0x1000); delay(3); // SpireSetObsMode("SPECSTBY"); SpireSetObsStep(0x0); sync(); // // completion tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SdetOn ended"); SpireMsg(1," ..SDET Switch On (" + (time() - t0) + " seconds)"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////// // // SpireProc_Exec_BsmAngleCal.txt // /////////////////////////////////////////////////////////// // // Procedure to loop through a list of BSM positions for // the 'Phot/Spec BSM Angle Calibration' tests // /////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/11/07 V0.1: Initial version adapted from // SpireProc_Exec_PhotBsmAngleCal (2008/10/13 V0.2) // Adapt to change in name of low level script. Allow // selecting FTS or photometer. // 2008/11/13 V0.2: Implement proper setting of MCU/BSM framerate // 2009/01/27 V1.0: Add debug_print as input (to this and low level scripts) // 2009/01/30 V1.1: Replaced cal to procedure SpireProc_Set_BsmFramerate // with call to BB (see SPR-5890). Remove unsetting of // MCU/BSM framerate. This will be now done during FINAL_HOLD. // 2009/02/15 V1.2: Remove setting of BSM framerate. This will be now done // during SLEW. // 2009/02/16 V1.3: Adapt call to updated SpireBb_Chop. Add some VM parameters // as new inputs. // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Exec_BsmAngleCal { int increment = 384; // Chop/Jiggle increment along scan axis [Dec(Hex)] int ref_chop = 0; // Chop position of BSM reference position [Dec(Hex)] int ref_jigg = 0; // Jiggle position of BSM reference position [Dec(Hex)] int home_chop = 37632; // Hold chop position of BSM int home_jigg = 39520; // Hold jiggle position of BSM int max_chop = 60000; // Maximum chop position of BSM int max_jigg = 60000; // Minimum jiggle position of BSM int min_chop = 1000; // Maximum chop position of BSM int min_jigg = 1000; // Minimum jiggle position of BSM int vmId = 71; // Raw VM table number [Dec(Hex)] int vmIndex = 0; // Raw VM index [Dec(Hex)] int nParms = 10; // Number of parameters passed to VM double chopf = 2.0; // Chop frequency [Hz] int ftime = 15; // Read-out time [s] double framerate = 125.0; // Specifies the MCU framerate [Hz] (photometer) double biasdivHz = 18.6; // Sampling rate [Hz] (photometer) bool fts = true; // FTS or photometer (for dcumode) bool chop = true; // Scan chop or jiggle axis bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Declare some variable: // if(fts) { // DCU data mode (4 == Full spectrometer): int dcumode = 4; } else { // DCU data mode (0 == Full photometer): dcumode = 0; } // // // // // Calculate BSM positions: // {int,int,int,int}[] pos = SpireProc_CalcParam_BsmAngleCal(increment,ref_chop,ref_jigg,home_chop,home_jigg,max_chop,max_jigg,min_chop,min_jigg,chop,debug); int n = length(pos); if(debug) { debug_print("length: " + n); } // // // // // Calculate BSM chop parameters: // int[] chopparam1 = SpireProc_CalcParam_BsmSetup(ftime,chopf,biasdivHz,framerate,debug); int ncycles = chopparam1[0]; int chop_period = chopparam1[1]; int dcusample = chopparam1[2]; int dcudelay = chopparam1[3]; int bsmsample = chopparam1[4]; // // // // // Execute loop of chopping operations: // int obsstep = 0x0; // First obsstep [HEX] for(int i = 0 .. n - 1) { {int,int,int,int} nextpos = pos[i]; SpireBb_Chop(vmId,vmIndex,nParms,nextpos{0},nextpos{1},nextpos{2},nextpos{3},ncycles,chop_period,dcumode,dcusample,dcudelay,bsmsample,obsstep,debug); obsstep = obsstep + 1; } } // Missionphase : // // Purpose : Read a BOLObias calibration table and command bias // voltages for the given group, viz. // VDL-BU for Group 3. Will also establish VDD_PROT_BLU // and VDD_PROT_CL before setting bias voltages // // Author : Diego A. Cesarsky // CUS script : Diego A. Cesarsky // CVS file : PHOT_set_bias_volt.txt // // Arguments : // string calTableName The Cal table name, f.i. BOLObias or BOLOsafe // string BiasGR The group number, BiasGRn (n:1, 2, ..6) // // Description : Read Bias U-CAL tables in volts. // Since BIAS are to be set in a predetermined order, the // array biasOrder lists the preconised ordering. // Prior to commanding the voltage generators, two voltages // have to be switched ON with the operand // // 0x0001 + 0x10000*BiasNum + 0x1000000*GroupNum // // and this for BiasNum 23, 22 and 21 // // Dependencies : // // Preconditions : // // Comments : // // Version : 0.3 // History : 0.1 07-aug-2006; 1st version DAC // 0.1.1 22-aug-2006, KO, waitFor set to 1s everywhere // 0.2 17-oct-2006 DAC Had forgotten GND-BU // 0.3 13-nov-2006 DAC&TM Wait 3 sec after GND-BU // procedure PHOT_set_bias_volt { string calTableName = "PHOT_bias_low_direct"; // The U-Cal table [volts] int groupNb = 1 in [1,6]; // Requested group }{ // Construct BiasGR entry string biasGR = "BiasGR" + groupNb; // Switch ON the requested group (bias numbers 22 and 21) int biasHexa = 0x1; int biasNb = 22; int operand = groupNb * 0x1000000 + biasNb * 0x10000 + biasHexa; Pacs_DMC_SEND_COMMAND_BOLC(operand); int waitFor = 1; delay(waitFor); biasNb = 21; operand = groupNb * 0x1000000 + biasNb * 0x10000 + biasHexa; Pacs_DMC_SEND_COMMAND_BOLC(operand); waitFor = 1; delay(waitFor); biasNb = 23; operand = groupNb * 0x1000000 + biasNb * 0x10000 + biasHexa; Pacs_DMC_SEND_COMMAND_BOLC(operand); waitFor = 3; delay(waitFor); // Bias setting order string[] biasOrder = ["VDD-PROT-BU","VDD-PROT-CL","GND-BU","VGL-BU","VDL-BU","VSS-BU","VGG","VDD","VGL","VDL","VH-BLIND","VSS","VDECX-L","VDECX-H","CKRLL","CKRLH","VSMS-L","VSMS-H","VINJ","VH","VL","VRL","VCH"]; // Introduce 1 sec delay after commanding each bias waitFor = 1; // Use lookup function; get BIAS voltage for given group and Bias number // For each BIAS defined in table and for demanded group for(int index = 3 .. 22) { biasNb = ilookup(calTableName,biasOrder[index],"Bias"); double biasVolt = dlookup(calTableName,biasOrder[index],biasGR); // Branch according to group number if(groupNb == 1) { PHOT_bias_group_1(groupNb,biasNb,biasOrder[index],biasVolt); } if(groupNb == 2) { PHOT_bias_group_2(groupNb,biasNb,biasOrder[index],biasVolt); } if(groupNb == 3) { PHOT_bias_group_3(groupNb,biasNb,biasOrder[index],biasVolt); } if(groupNb == 4) { PHOT_bias_group_4(groupNb,biasNb,biasOrder[index],biasVolt); } if(groupNb == 5) { PHOT_bias_group_5(groupNb,biasNb,biasOrder[index],biasVolt); } if(groupNb == 6) { PHOT_bias_group_6(groupNb,biasNb,biasOrder[index],biasVolt); } } // to sync the bus sync(); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_CalcParam_LoadCurve.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to read list of bias levels from calibration table // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/02/02 V1.0: Initial version renamed from // SpireProc_CalcParam_StdLoadCurve 2009/02/01 V1.0 // /////////////////////////////////////////////////////////////////////////// // int[] procedure SpireProc_CalcParam_LoadCurve { string tabName = "SpireTable_StdLoadCurveLevels.txt"; // Calibration table name string version = "v00"; // Version parameter defined in calibration table bool debug = false; // Allow (==tick) or suppress cus debug_print statement }{ // // // // // Setup variables: // string colName = "version"; string tarName = "setting"; string[] searchCol = scolumn(tabName,colName); int[] tarCol = icolumn(tabName,tarName); int size = table_size(tabName); int[] nbiaslist = []; int index = 0; // // // // // Cycle through values to get all rows which match: // for(int j = 0 .. size - 1) { if(searchCol[j] == version) { nbiaslist[index] = tarCol[j]; index = index + 1; } } // // // // // Safety check: Make sure input version parameter is defined in cal. table: if(debug) { debug_print("nbiaslist: " + nbiaslist); } if(length(nbiaslist) == 0) { error("Input version parameter not defined. Select another one!"); } // // // // // Return values: // return nbiaslist; } // SpireSpectro_Cal_LvdtScans // // $id$ // // This observation closes the loop on the LVDT and performs scans // // The instrument should be in the SPECSTBY mode before execution of this procedure // and the parameter passed to the observation should correspond to the initial state. // // 2009/07/17 v0.1: SDS // // 2009/07/27 v0.2: SDS // Use pString1 parameter to select version of SpireTable_SmecNominalSettings.txt // obs SpireSpectro_Cal_LvdtScans { double ra = 0.0 in [0.0,360.0]; // RA of target double dec = 0.0 in [-90.0,90.0]; // DEC of target int naifid = 0; // NAIF identifier string boresight = ""; // instrument boresight to use bool pointing = true; // Should telescope 'point' (==tick) or do a 'no pointing' (==untick)? bool isBright = false; int nScans = 32; // Number of Up/Down LVDT scans (must be even number) string opsVersion = "v00"; // Version in cal table SpireTable_OpsParms bool debug = false; // debug messages flag bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = "v00"; // Version of SpireTable_SmecNominalSettings.txt string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ string obsMode = "SEngCalObs"; bool isPhot = false; string version01 = "v00"; // Version in cal table SpireTable_SpecModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams string version06 = "v00"; // Version in cal table SpireTable_IsBrightPhaseShift // // Currently hardcoded parameter: // Is (==tick) the DCU currently sampled? bool dcuData = false; // // // // // Setup mode: // // Set obsMode for QLA: string obsModeQla = "ENG_CAL_OBS45"; // Note: this needs entry in MIB table and in SpireTableInstConfigs.txt // // // Calculate timing for the pointing request: // // BBs called during slew: // int tslewmin = duration(SpireBb_StartObsAll(obsModeQla)) + duration(SpireBb_SpecSetMode(obsMode,isBright,version01,version02,debug)); // // BBs carried out when the pointing is reached: // if(pointing) { int tinithold = duration(SpireBb_SpecOffsetAuto(dcuData,debug)); } else { tinithold = duration(SpireBb_SpecOffsetAuto(dcuData,debug)) + duration(SpireBb_StartObsAll(obsMode)) + duration(SpireBb_SpecSetMode("SFlash",isBright,version01,version02,debug)); } // // BB carried out during pointing: // int tp = duration(SpireBb_LvdtScans(nScans,pString1,version02,debug)); // // BB carried out at the end: // int tfinalhold = duration(SpireBb_EndObsAll(isPhot)) + duration(SpireBb_SpecSetMode("SPECSTBY",isBright,version01,version02,debug)) + duration(SpireBb_SetObsStep(0,debug)); // // Debug printing: // if(debug) { debug_print("tslewmin = " + tslewmin); debug_print("tinithold = " + tinithold); debug_print("tpointing = " + tp); debug_print("tfinalhold = " + tfinalhold); } // // Lookup boresight, if not provided // string ib = boresight; if(boresight == "") { ib = SpireProc_GetTableEntryString("SpireTable_OpsParms.txt","mode",obsMode,"Boresight",opsVersion,debug); } // // Set pointing mode: // if(pointing) { int[] ts = basic_fine_pointing(true,tslewmin,tinithold,tfinalhold,ib,naifid,ra,dec,0.0,0.0,tp); } else { ts = no_pointing(true,tinithold,tfinalhold,tp); } // if(debug) { debug_print("Output timing vector from the pointing request: " + ts); } }{ int[] state = [0]; while(state[0] >= 0) { state = next_state(); if(state[0] == 1) { // *********************** SLEW // Start observation: SpireBb_StartObsAll(obsModeQla); // configure instrument SpireBb_SpecSetMode(obsMode,isBright,version01,version02,debug); } if(state[0] == 2) { // *********************** INITHOLD // If no pointing observation do stuff here which is // done nominally during SLEW: if(!pointing) { // Start observation: SpireBb_StartObsAll(obsModeQla); // configure instrument SpireBb_SpecSetMode(obsMode,isBright,version01,version02,debug); } // Set offsets: // SpireBb_SpecOffsetAuto(dcuData,debug); } if(state[0] == 3) { // *********************** POINTING SpireBb_LvdtScans(nScans,pString1,version02,debug); } if(state[0] == 5) { // *********************** FINALHOLD // reset STEP SpireBb_SetObsStep(0,debug); // // Set detectors back to SPECSTBY: SpireBb_SpecSetMode("SPECSTBY",isBright,version01,version02,debug); // // End Observation SpireBb_EndObsAll(isPhot); // } } } /////////////////////////////////////////////////////////////////////////// // $Id:$ /////////////////////////////////////////////////////////////////////////// // // SpirePhoto_Cal_BsmPidTuning.txt // /////////////////////////////////////////////////////////////////////////// // // CUS script for: 'CoP: Phot BSM Tuning' // // in *basic_fine_pointing* mode or *no_pointing* mode // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/03/30 V0.1: Initial version adapted from // SPIRE_IST_BSM_CHOP_POS1.txt (SDS, email 30.03.2009) // 2009/04/01 V0.2: Increased allowed range of BSM inputs. // 2009/05/06 V0.3: Add in move BSM to hold at start. Gather procedures at // start and end in separate BB. Set input BSM framerate // only if different from PHOTSTBY one. // 2009/06/05 V1.0: Adapt call to SpireBb_EndBsmPidTuning to account for // SPR-1476. SPR-1477: Hardcode STBY 'v00' in EndBB. // // /////////////////////////////////////////////////////////////////////////// // Script assumes that: // // 1) Instrument is in PHOTSTBY // (i.e. bias amplitude, phase, frequency [mclkdiv,biasdiv] are nominal) // // 2) Bias frequency (mclkdiv) and sampling rate (biasdiv) are the same // for all three arrays and could be taken from following cal table: // SpireTable_PhotModeParams.txt // // 3) Further mode dependent parameters can be read from: // SpireTable_CommonModeParams.txt // // 4) BSM parameters can be read from SpireTable_BsmNominalSettings.txt // /////////////////////////////////////////////////////////////////////////// // obs SpirePhoto_Cal_BsmPidTuning { /* ****************************************************** */ /* USER PARAMETER DEFINITION, CUS SIGNATURE for EX-HSpot */ /* ****************************************************** */ double ra = 0.0 in [0.0,360.0]; // RA of target double dec = 0.0 in [-90.0,90.0]; // DEC of target int naifid = 0; //NAIF identifier: put '0' to use RA/DEC, or correct 'NAIFID' bool pointing = true; // Should telescope 'point' (==tick) or do a 'no pointing' (==untick)? /* */ bool isBright = false; // Use settings for bright source (==tick) string ib = "S14_0"; // Central aperture (defined in SIAM) of raster int on_source_chop = 0xb600 in [4096,61440]; // On source chop position (==IST-POS1; IST-POS2=0xdbc4) int on_source_jiggle = 0x9a60 in [4096,61440]; // On source jiggle position (==IST-POS1; IST-POS2=0x9a60) int off_source_chop = 0x6a28 in [4096,61440]; // Off source chop position (==IST-POS1; IST-POS2=0x4414) int off_source_jiggle = 0x9a60 in [4096,61440]; // Off source jiggle position (==IST-POS1; IST-POS2=0x9a60) double chopkp_range = 1.0; // Percentage half-range for tuning Chop Kp around ILT nominal values (+/1%) double chopki_range = 10.0; // Percentage half-range for tuning Chop Ki around ILT nominal values (+/1%) double chopkd_range = 10.0; // Percentage half-range for tuning Chop Kd around ILT nominal values (+/1%) int nkp = 2; // Number of steps for Chop Kp for half-range int nki = 3; // Number of steps for Chop Ki for half-range int nkd = 3; // Number of steps for Chop Kd for half-range double chopf = 2.0 in [0.1,4.0]; // Chop frequency [Hz] double framerate = 125.0; // Specifies the MCU framerate [Hz] int ftime = 20; // Read-out time [s] string version01 = "v00"; // Version in cal table SpireTable_PhotModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams string version03 = "v00"; // Version in cal table SpireTable_BsmNominalSettings string model = "initial"; // Model in cal table SpireTable_BsmNominalSettings bool debug = false; // Allow (==tick) or suppress cus debug_print statements bool isSerendipity = true; // Allow (==tick) serendipity mode to be activated or prohibit (==untick) it (currently not in use)? bool isPcal = true; // Allow (==tick) regular PcalFlash in script or prohibit (==untick) it (currently not in use)?. bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ // ****************************************************** */ // CALCULATE DURATIONS for POINTING STATES */ // ****************************************************** */ // // // // // Declare some variable: // // FTS or photometer (for dcumode in VM set in SpireProc_Exec_BsmPidTuning): bool fts = false; // Photometer or FTS bool phot = !fts; // string version = ""; string tabName = ""; double scirate = 0.0; double chkrate = 0.0; double nhkrate = 0.0; // int obsStep = 0; int frate = 0; int tinithold = 0; bool setFramerate = true; // // Hardcoded calibration tables: // string tabName01 = "SpireTable_PhotModeParams.txt"; string tabName02 = "SpireTable_CommonModeParams.txt"; string tabName03 = "SpireTable_BsmNominalSettings.txt"; string tabName04 = "SpireTable_CommandLists.txt"; // // // // // // Setup mode: // // Set obsMode for QLA: string obsModeQla = "ENG_CAL_OBS14"; // Note: this needs entry in MIB table and in SpireTableInstConfigs.txt // // Set obsMode for setup and datarates: string obsMode = "PEngCalObs"; // Note: datarates are currently only maximum values // // // // // Setup parameters for BSM chopping movement: // // Select version flag and set GetTableEntry parameters: // version = version03; tabName = tabName03; string selCol = "model"; // Name of column for selecting string selVal = model; // Value of 'string' selector // // Read hold position from calibration table (to reconfigure at end): // string tarCol = "chop_0_I"; int hold_chop = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "jigg_0_I"; int hold_jigg = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // Read VM parameters from calibration table: // tabName = tabName04; selVal = "Chop"; int vmId = ilookup(tabName,selVal,"Id"); int vmIndex = ilookup(tabName,selVal,"Index"); int nParms = ilookup(tabName,selVal,"Nparms"); // // // // // Read nominal bias frequency and bias divider: // (to determine the sampling rate) // // Select version flag and set GetTableEntry parameters: version = version01; tabName = tabName01; selCol = "mode"; // Name of column for selecting selVal = obsMode; // Value of 'string' selector // tarCol = "mclkDiv"; int mclkdiv = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "biasDiv"; int biasdiv = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // Calculate nominal sampling rate from mclkdiv and biasdiv: // double mclkdivHz = 1.0E7 / (512.0 * double(mclkdiv + 1)); double biasdivHz = 1.0 / (double(biasdiv) + 1.0) * mclkdivHz; if(debug) { debug_print("Nominal sampling rate is: " + biasdivHz + " [Hz]"); } // // // // // Read PHOTSTBY BSM framerate: // selCol = "mode"; selVal = "PHTSTBY"; version = version02; tabName = tabName02; tarCol = "bsmFrameRate"; int bsmFrameRate = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); double bsmFrameRateHz = 1000000.0 / (double(bsmFrameRate) * 420.0); if(debug) { debug_print("Nominal BSM sampling rate is: " + bsmFrameRateHz + " [Hz]"); } // // Compare PHOTSTBY with input BSM framerate: // frate = SpireProc_CalcParam_BsmFramerate(framerate,debug); if(frate == bsmFrameRate) { setFramerate = false; } // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // Calculate timing for the pointing request: // // BBs called during slew: // int tslewmin = duration(SpireBb_StartBsmPidTuning(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,setFramerate,frate,debug)); // // BBs carried out when the pointing is reached: // if(pointing) { tinithold = duration(SpireBb_PhotOffsetAuto(debug)); } else { tinithold = duration(SpireBb_PhotOffsetAuto(debug)) + tslewmin; } // // BB carried out during pointing: // int tp = duration(SpireProc_Exec_BsmPidTuning(vmId,vmIndex,nParms,chopf,ftime,framerate,biasdivHz,fts,on_source_chop,on_source_jiggle,off_source_chop,off_source_jiggle,chopkp_range,chopki_range,chopkd_range,nkp,nki,nkd,version03,model,debug)); // // BB carried out at the end: // int tfinalhold = duration(SpireBb_EndBsmPidTuning(phot,isBright,version01,version02,version03,model,debug)); // // Debug printing?: if(debug) { debug_print("tslewmin = " + tslewmin); debug_print("tinithold = " + tinithold); debug_print("tpointing = " + tp); debug_print("tfinalhold = " + tfinalhold); } // // ****************************************************** */ // POINTING MODE DECLARATION */ // ****************************************************** */ // // // // // // Set pointing mode: // if(pointing) { int[] ts = basic_fine_pointing(true,tslewmin,tinithold,tfinalhold,ib,naifid,ra,dec,0.0,0.0,tp); } else { ts = no_pointing(true,tinithold,tfinalhold,tp); } // if(debug) { debug_print("Output timing vector from the pointing request: " + ts); } // }{ // ******************************************************* */ // POINTING STATES WITH OBSERVING MODE LOGIC AND DATARATES */ // ******************************************************* */ // // // // // Set datarates: // string rateType = "chk"; chkrate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); ess_hk_data_rate(chkrate); // rateType = "nhk"; // nhkrate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); non_ess_hk_data_rate(nhkrate); // rateType = "sci"; scirate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); data_rate(scirate); // if(debug) { debug_print("Set CHK datarate to: " + chkrate); debug_print("Set NHK datarate to: " + nhkrate); debug_print("Set SCI datarate to: " + scirate); } // // Start the state_machine: // int[] state = [0]; // while(state[0] >= 0) { if(debug) { debug_print("Current state: " + state); } state = next_state(); if(debug) { debug_print("Next state: " + state); } // if(state[0] == 1) { // STATE = SLEW ( Spacecraft is slewing ) // // // // // Startup observation: // SpireBb_StartBsmPidTuning(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,setFramerate,frate,debug); // } if(state[0] == 2) { // STATE = INIT_HOLD ( spacecraft is idling at source ) // // // // // If no pointing observation do stuff here which is // done nominally during SLEW: // if(!pointing) { // // // // // Startup observation: // SpireBb_StartBsmPidTuning(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,setFramerate,frate,debug); // } // // // // // Set offsets: // SpireBb_PhotOffsetAuto(debug); // //delay(tinithold); // } if(state[0] == 3) { // STATE = POINT ( spacecraft is at nominal RA,DEC (staring, raster) ) // // // // // // Execute BSM PID tuning: // SpireProc_Exec_BsmPidTuning(vmId,vmIndex,nParms,chopf,ftime,framerate,biasdivHz,fts,on_source_chop,on_source_jiggle,off_source_chop,off_source_jiggle,chopkp_range,chopki_range,chopkd_range,nkp,nki,nkd,version03,model,debug); // //delay(tp); // } if(state[0] == 5) { // STATE = FINAL_HOLD ( "sky" observation ends, performing final activ.) // // // // // Set scientific datarate back to zero: // data_rate(0.0); // // // // // Reconfigure at the end (incl. resetting of OBSID and BBIB): // // Hardcode STBY values for resetting (SPR-1477): // version01 = "v00"; version02 = "v00"; version03 = "v00"; model = "initial"; // SpireBb_EndBsmPidTuning(phot,isBright,version01,version02,version03,model,debug); // } if(state[0] == -1) { // STATE = END ( end of the pointing/commanding part of the code ) // } } } /////////////////////////////////////////////////////////////////////////// // // SpireProc_CalcParam_StdLoadCurve.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to read list of bias levels from calibration table // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/02/01 V1.0: Initial version adapted from top level script // SpirePhoto_Cal_StdLoadCurve (2008/11/12 V0.7) // /////////////////////////////////////////////////////////////////////////// // int[] procedure SpireProc_CalcParam_StdLoadCurve { string tabName = "SpireTable_StdLoadCurveLevels.txt"; // Calibration table name string version = "v00"; // Version parameter defined in calibration table bool debug = false; // Allow (==tick) or suppress cus debug_print statement }{ // // // // // Setup variables: // string colName = "version"; string tarName = "setting"; string[] searchCol = scolumn(tabName,colName); int[] tarCol = icolumn(tabName,tarName); int size = table_size(tabName); int[] nbiaslist = []; int index = 0; // // // // // Cycle through values to get all rows which match: // for(int j = 0 .. size - 1) { if(searchCol[j] == version) { nbiaslist[index] = tarCol[j]; index = index + 1; } } // // // // // Safety check: Make sure input version parameter is defined in cal. table: if(debug) { debug_print("nbiaslist: " + nbiaslist); } if(length(nbiaslist) == 0) { error("Input version parameter not defined. Select another one!"); } // // // // // Return values: // return nbiaslist; } // Missionphase : // // Purpose : Prepare MEC for photometry, including filterwheel, // chopper and calibration sources // // TCL author : TM // TCL file : tm_phot_mec_setup.tcl // CUS author : DAC // Script file : PHOT_dmc_setup.txt // // Input arguments // type name description // // Return values // Type Name Default Description // // Description : This script will switch on and set all required // parameters for the chopper, the photometry filter // wheel and the calibration sources. // This script should be executed just after the // switch-on procedure and the bolometer setup // // Dependencies : // // Preconditions : // // Comments : // // Version 0.8 // History // 0.1 12-apr-2005 DAC (based on TM's version 1.2) // 0.2 13-apr-2005 DAC Redefined as procedure // 0.3 20-apr-2005 DAC Use new CONF_cs // 0.4 08-aug-2006 TM, integration of diagnostic HK for fw and chopper // 0.5 10-nov-2006 DAC Use "current" chopper controller parameters // 0.6 13-nov-2006 DAC Use "Heidelberg 4deg" chopper controller parameters // 0.7 05-mar-2007 TM update for chopper and CSs // 0.8 15-Jun-2007 PR modify PHOT_fltw_conf -> CONF_phot_fltw // int[] procedure PHOT_dmc_setup { string phot_fltw_id = "POS B" in ["POS A","POS B"]; // Photometer filter ID int chop_def_pos = 0; // Chopper default position double temp_CS1 = 48.0; // Temperature for the PACS calibration source 1 double temp_CS2 = 58.0; // Temperature for the PACS calibration source 2 }{ // Define variables to communicate various durations to HSPOT. // NOTE: all time variables in units of number of ramps (SPEC) or // number of readouts (BOLO). The calling program must convert this // count into actual duration in true time units [seconds]. // SRC, REF, CAL, OVR stand for time spent on SRC, REF (on sky), // CAL source, and overheads (wait for something). Total // duration is given by duree_num. If no error, this duration // must be equal to the sum of all others int duree_num = 0; int duree_SRC = 0; int duree_REF = 0; int duree_CAL = 0; int duree_OVR = 0; int time_start = time(); //------------------- // FILTERWHEEL //------------------- // // Configure diagnostik HK for filterwheel // Read out every 5 ms // DMC_WRT_DIAG_HK_LIST // DMC_FW_PHOT_CTRL 211 // DMC_FWGRAT_HALLA 256 // DMC_FWGRAT_HALLB 257 // DMC_FWPH_CUR_POS 260 // DMC_FPU_T_SEN_ST 404 // DMC_FW_PHOT_TEMP 406 // DMC_FW_GR_VMOTA 556 // DMC_FW_GR_IMOTA 560 // DMC_FWPHOT_POS_A 563 // DMC_FW_GR_VMOTB 564 // DMC_FW_GR_IMOTB 567 // DMC_FWPHOT_POS_B 569 {int}[] parlist_fw = [{211},{256},{257},{260},{404},{406},{556},{560},{563},{564},{567},{569},{0xffff}]; int[] aux_fw = [211,256,257,260,404,406,556,560,563,564,567,569,0xffff]; int check_sum_fw = checksum("int",aux_fw); int diag_hk_length_fw = 13; int diag_hk_period_fw = 5; Pacs_DMC_WRT_DIAG_HK_LIST(diag_hk_length_fw,parlist_fw,check_sum_fw); Pacs_DMC_START_DIAG_HK(diag_hk_period_fw); // CONF_phot_fltw(); //PHOT_fltw_conf(); // PC129420 "DMC_SWON_FW_PHOTO" SWITCH ON POWER SUPPLY OF FILTER WHEEL PHOTO // PC136420 "DMC_MOVE_PHOT_FW_LOC" MOVE PHOTOMETER FILTER WHEEL TO LOCATION // PP075420 "FW_ID" // PC109420 "DMC_SWOF_GRAT_CONT" SWITCH OFF GRATING CONTROLLER PHOT_fltw_move(phot_fltw_id); delay(1); // Pacs_DMC_STOP_DIAG_HK(); delay(1); // //------------------- // CHOPPER //------------------- // // Configure diagnostik HK for chopper // Read out every 5 ms // DMC_CHOP_CTRL_ST 209 // DMC_CHOP_CUR_POS 244 // DMC_CHOP_SETPOIN 245 // DMC_CHOP_TARGET 246 // DMC_CHOP_PID_ERR 247 // DMC_CHOP_PID_ACC 248 // DMC_CHOP_MAX_DIT 249 // DMC_CHOP_OUTPUT 258 // DMC_CHOPPER_TEMP 407 // DMC_CHOP_VA 557 // DMC_CHOP_IA 561 // DMC_CHOP_VB 565 {int}[] parlist_cho = [{209},{244},{245},{246},{247},{248},{249},{258},{407},{557},{561},{565},{0xffff}]; int[] aux_cho = [209,244,245,246,247,248,249,258,407,557,561,565,0xffff]; int check_sum_cho = checksum("int",aux_cho); int diag_hk_length_cho = 13; int diag_hk_period_cho = 5; Pacs_DMC_WRT_DIAG_HK_LIST(diag_hk_length_cho,parlist_cho,check_sum_cho); Pacs_DMC_START_DIAG_HK(diag_hk_period_cho); // // DMC_WRT_CHOP_CONF_PAR (now modified for 20 parameters) CONF_chopper("CONFChopper","nom_sky"); // PC119420 "DMC_SWON_CHOP_CONT" SWITCH ON CHOPPER CONTROLLER // PC121420 "DMC_ENABLE_CHOP_CONT" ENABLE CHOPPER CONTROLLER CHOP_on_off("ON"); // PC123420 "DMC_MOVE_CHOP_ABS" MOVE CHOPPER TO AN ABSOLUTE POSITION // PP079420 "SET_POINT" Pacs_DMC_MOVE_CHOP_ABS(chop_def_pos); delay(1); // Pacs_DMC_STOP_DIAG_HK(); delay(1); // //------------------------- // PACS CALIBRATION SOURCES //------------------------- // DMC_WRT_CS1_CONF_PAR // DMC_WRT_CS2_CONF_PAR CONF_cs("Both"); // PC138420 "DMC_SWON_BB_1_CONT" SWITCH ON BLACK BODY 1 CONTROLLER // PC206420 "DMC_ENABLE_BB_1_CONT" ENABLE BB1 CONTROLLER CS_on_off("CS1","ON"); // PC140420 "DMC_SET_TEMP_BB_1" SET THE TEMPERATURE OF THE BLACK BODY 1 // PP079420 "SET_POINT" CS_temp("CS1",temp_CS1); // PC142420 "DMC_SWON_BB_2_CONT" SWITCH ON BLACK BODY 2 CONTROLLER // PC208420 "DMC_ENABLE_BB_2_CONT" ENABLE BB2 CONTROLLER CS_on_off("CS2","ON"); // PC144420 "DMC_SET_TEMP_BB_2" SET THE TEMPERATURE OF THE BLACK BODY 2 // PP079420 "SET_POINT" CS_temp("CS2",temp_CS2); //------------------------- // End of Procedure //------------------------- // Return empty array for time being... // Time spent int duree_TCs = time() - time_start; duree_OVR = duree_TCs; duree_num = duree_OVR; // Return the array of times int[] time_array = [duree_num,duree_SRC,duree_REF,duree_CAL,duree_OVR]; return time_array; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireSpectro_Cal_PhaseUp.txt // /////////////////////////////////////////////////////////////////////////// // // CUS script for: 'Spec Phase Up' // // in *basic_fine_pointing* or *no_pointing* mode // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/08/15 V0.1: Initial version adapted from // SpireSpeco_Cal_PhaseUp.txt (2008/07/03 V0.5) // Mode_ILT_PERF_DPH_S.txt (v1.4 2008/01/31 20:24:33) // 2008/11/11 V0.2: Allow 'no pointing' as input option; Adapt debug printing // 2008/11/12 V0.3: Implement mode setting; Add isBright // Change 'no pointing' implementation // 2009/02/19 V0.4: Add debug_print as input and pass it to some low level // scripts. Use new SpireBb_EndObsAll and SpireBb_StartObsAll. // Read nominal bias frequency and bias divider from new // SpireTable_SpecModeParams.txt. Implemented message // if activating isBright setting. Implemented setting // of datarates. Change Hspot description of ftime. // Use SpireBb_SpecSetMode to set to SPECSTBY during // SLEW and FINAL_HOLD. Read boresight from // SpireTable_OpsParms. Replace call to SpireBb_SpecFSetupData // by call to SpireBb_DcuSetFreqSamp, SpireBb_SpecFSetPhase, // and SpireBb_SpecFSetBiasAmpl. Correct first phase is now // set during SLEW instead of target phase. Adapt to changes // in cal of SpireProc_Exec_SpecPhaseUp. // 2009/03/04 V0.5: Add isSerendipity, isPcal, and 8 more dummy parameters // to the script for future use. Replace 'message' with // 'error' when isBright is used. // 2009/05/06 V0.6: Add in move BSM/SMEC to hold/home at start. Add new // SpireBb_SmecHold to account for the fact that // SpireBb_SmecMove2Home does not stop SMEC. // Gather procedures at start and end in separate BB. // /////////////////////////////////////////////////////////////////////////// // Script assumes that: // // 1) Instrument is in SPECSTBY at beginning // (i.e. bias amplitude, phase, frequency [mclkdiv,biasdiv] are nominal) // // 2) Phases are user input // // 3) Bias frequency and sampling rate are user inputs both in Hz. They // are translated in the script to the Hex values of mclkdiv and biasdiv. // // 4) Boresight of array can be read from following cal table: // SpireTable_OpsParms.txt // /////////////////////////////////////////////////////////////////////////// // obs SpireSpectro_Cal_PhaseUp { /* ****************************************************** */ /* USER PARAMETER DEFINITION, CUS SIGNATURE for EX-HSpot */ /* ****************************************************** */ /* */ double ra = 0.0 in [0.0,360.0]; // RA of target double dec = 0.0 in [-90.0,90.0]; // DEC of target bool isBright = false; // Use settings for bright source (==tick) bool pointing = true; // Should telescope 'point' (==tick) or do a 'no pointing' (==untick)? /* */ double biasfreq = 160.09 in [80.0,240.0]; // Bias frequency [Hz] double samplerate = 80.05 in [1.0,80.5]; // Sampling rate [Hz] (Careful, don't exceed number of data packages to be transferred from spacecraft!) double biasmV_ssw = 31.13 in [0.0,176.385]; // SSW Bias amplitude (peak2peak) [mV] double biasmV_slw = 31.13 in [0.0,176.417]; // SLW Bias amplitude (peak2peak) [mV] double target_phase = 187.5 in [0.0,360.0]; // Central phase shift (target phase) [degree] int number_steps = 5 in [1,127]; // Number of steps to one side [int] int step_size = 1 in [1,20]; // Raw step size (1 step==1.411 degrees) [dec(HEX)] int ftime = 10; // Time at each bias level [s] string version01 = "v00"; // Version in cal table SpireTable_SpecModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams string version05 = "v00"; // Version in cal table SpireTable_OpsParms.txt bool debug = false; // Allow (==tick) or suppress cus debug_print statements bool isSerendipity = true; // Allow (==tick) serendipity mode to be activated or prohibit (==untick) it (currently not in use)? bool isPcal = true; // Allow (==tick) regular PcalFlash in script or prohibit (==untick) it (currently not in use)?. bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ // // // // // Check for is bright setting: // if(isBright) { isBright = false; error("IsBright does not make sense while doing phase ups. Try again!"); } // // // // // Declare some variable: // // // Photometer or FTS: bool phot = false; bool fts = !phot; // string tabName = ""; string selCol = ""; string selVal = ""; string tarCol = ""; string version = ""; double scirate = 0.0; double chkrate = 0.0; double nhkrate = 0.0; // // Hardcoded calibration tables: // string tabName01 = "SpireTable_SpecModeParams.txt"; string tabName02 = "SpireTable_CommonModeParams.txt"; string tabName03 = "SpireTable_BsmNominalSettings.txt"; string tabName05 = "SpireTable_OpsParms.txt"; string tabName06 = "SpireTable_SmecNominalSettings.txt"; // // Currently hardcoded version and model parameter: // string version06 = "v00"; // Version in cal table SpireTable_SmecNominalSettings string version03 = "v00"; // Version in cal table SpireTable_BsmNominalSettings string model = "initial"; // Model in cal table SpireTable_BsmNominalSettings // // Dummy value for Phot script: // (needed but not used in spec script!) // int psw_bias = 62; // int pmw_bias = 62; // int plw_bias = 62; // int ptc_bias = 62; // // // Currently hardcoded parameter: // Is (==tick) the DCU currently sampled? bool dcuData = false; // // // // // Setup mode: // // Set obsMode for QLA: string obsModeQla = "ENG_CAL_OBS40"; // Note: this needs entry in MIB table and in SpireTableInstConfigs.txt // // Set obsMode for datarates: string obsMode = "SEngCalObs"; // Note: this is currently only a maximum value // // // // // Calculate a raw phase value used for the initial setup: // int target_phase_raw = iround(target_phase * 255.0 / 360.0); // // // // // Calculate list of phases: // int[] raw_phase_list = SpireProc_CalcParam_PhaseUp(target_phase,number_steps,step_size,debug); if(debug) { debug_print("Phase list [dec(HEX)]: " + raw_phase_list); } // // // // // Convert user input to Hex values: // // for bias frequency and sample rate: // int[] hexvalues = SpireProc_CalcParam_BiasFreqSampFreq(biasfreq,samplerate,fts,debug); int mclkdiv = hexvalues[0]; int biasdiv = hexvalues[1]; if(debug) { debug_print("Hex values of mclkdiv/biasdiv are: " + mclkdiv + " " + biasdiv); } // // for bias amplitude: // int[] biashex = SpireProc_CalcParam_SpecBiasConvert(biasmV_ssw,biasmV_slw,debug); int ssw_bias = biashex[0]; int slw_bias = biashex[1]; // // // // // Read BSM home parameters: // // Select version flag and set GetTableEntry parameters: // version = version03; tabName = tabName03; selCol = "model"; // Name of column for selecting selVal = model; // Value of 'string' selector // // Read hold position from calibration table: // tarCol = "chop_0_I"; int hold_chop = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "jigg_0_I"; int hold_jigg = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // // // // Read SMEC home position from calibration file: // tarCol = "Home"; tabName = tabName06; selVal = version06; int smecHomePosn = ilookup(tabName,selVal,tarCol); // // ****************************************************** */ // CALCULATE DURATIONS for POINTING STATES */ // ****************************************************** */ // // // // // Calculate timing for the pointing request: // // BBs called during slew: int tslewmin = duration(SpireBb_StartPhaseUp(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,mclkdiv,biasdiv,psw_bias,pmw_bias,plw_bias,ptc_bias,ssw_bias,slw_bias,raw_phase_list,debug)); // // BBs carried out when the pointing is reached: if(pointing) { int tinithold = 0; } else { tinithold = tslewmin; } // // BB carried out during pointing: int tp = duration(SpireProc_Exec_SpecPhaseUp(raw_phase_list,ftime,dcuData,debug)); // // BB carried out at the end: int tfinalhold = duration(SpireBb_EndPhaseUp(phot,isBright,version01,version02,debug)); // if(debug) { debug_print("tslewmin = " + tslewmin); debug_print("tinithold = " + tinithold); debug_print("tpointing = " + tp); debug_print("tfinalhold = " + tfinalhold); } // // ****************************************************** */ // POINTING MODE DECLARATION */ // ****************************************************** */ // // // // // Lookup boresight: // tabName = tabName05; selCol = "mode"; selVal = obsMode; tarCol = "Boresight"; version = version05; string ib = SpireProc_GetTableEntryString(tabName,selCol,selVal,tarCol,version,debug); // // Set pointing mode: // if(pointing) { int[] ts = basic_fine_pointing(true,tslewmin,tinithold,tfinalhold,ib,0,ra,dec,0.0,0.0,tp); } else { ts = no_pointing(true,tinithold,tfinalhold,tp); } // if(debug) { debug_print("Output timing vector from the pointing request: " + ts); } // }{ // ****************************************************** */ // POINTING STATES WITH OBSERVING MODE LOGIC */ // ****************************************************** */ // // // // // Set datarates: // string rateType = "chk"; chkrate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); ess_hk_data_rate(chkrate); // rateType = "nhk"; // nhkrate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); non_ess_hk_data_rate(nhkrate); // rateType = "sci"; scirate = SpireProc_CalcParam_SpecDataRates(rateType,obsMode,version01,version02,debug); data_rate(scirate); // if(debug) { debug_print("Set CHK datarate to: " + chkrate); debug_print("Set NHK datarate to: " + nhkrate); debug_print("Set SCI datarate to: " + scirate); } // // Start the state_machine: // int[] state = [0]; // while(state[0] >= 0) { if(debug) { debug_print("Current state: " + state); } state = next_state(); if(debug) { debug_print("Next state: " + state); } // if(state[0] == 1) { // STATE = SLEW ( Spacecraft is slewing ) // // // // // Startup observation: // SpireBb_StartPhaseUp(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,mclkdiv,biasdiv,psw_bias,pmw_bias,plw_bias,ptc_bias,ssw_bias,slw_bias,raw_phase_list,debug); // //delay(timeSlewCal); } if(state[0] == 2) { // STATE = INIT_HOLD ( spacecraft is idling at source ) // // // // // // If no pointing observation do stuff here which is // done nominally during SLEW: // if(!pointing) { // // // // // Startup observation: // SpireBb_StartPhaseUp(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,mclkdiv,biasdiv,psw_bias,pmw_bias,plw_bias,ptc_bias,ssw_bias,slw_bias,raw_phase_list,debug); // } // //delay(tinithold); // } if(state[0] == 3) { // STATE = POINT ( spacecraft is at nominal RA,DEC (staring, raster) ) // // // // // // Execute stepping through phase list: // SpireProc_Exec_SpecPhaseUp(raw_phase_list,ftime,dcuData,debug); // //delay(tp); // } if(state[0] == 5) { // STATE = FINAL_HOLD ( "sky" observation ends, performing final activ.) // // // // // Set scientific datarate back to zero: // data_rate(0.0); // // // // // Reconfigure at the end (incl. resetting of OBSID and BBIB): // SpireBb_EndPhaseUp(phot,isBright,version01,version02,debug); // } if(state[0] == -1) { // STATE = END ( end of the pointing/commanding part of the code ) // } } } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_SmecMove.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to move SMEC to a given position from a known input position // allowing for the necessary delay in time to reach position. SMEC is set // to hold its position at end of script. // /////////////////////////////////////////////////////////////////////////// // // KJK: // 2009/02/02 V0.1: Initial version // 2009/03/02 V0.2: (MP) Add header lines and some cosmetics. // 2009/03/31 V0.3: (MP) Remove final stop SMEC, i.e allow SMEC to // continue running to its position beyond the // procedure. Add stop of SMEC at start of script // to make sure there is no move command while // the SMEC is still moving. // 2009/05/05 V0.4: (MP) Add final stop SMEC back in, use // SpireProc_SmecMove2Home to startup scripts instead. // // Notes: // // 1) When SpireProc_Setup_SmecScan is used, SpireProc_SmecMove needs // to be run before. // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_SmecMove { int smecPosn = 1000; // SMEC final position (encoder value) int smecCurrPosn = 1000; // SMEC current position (encoder value) bool debug = false; }{ // // // // // Define some variables: // int t = time(); // // hex string: string hstr = ""; // // time string: string tstr = ""; // // Hardcoded name and version of calibration tables: string tabName = "SpireTable_SmecNominalSettings.txt"; string version = "v00"; // // // // // Start procedure: // tstr = SpireTimeStr(time()); SpireMsg(3," " + tstr + ": Proc SmecMove started"); SpireMsg(3," $Id: $"); // // // // // Move to position (only if we have to): // if(smecCurrPosn != smecPosn) { // // fetch SMEC movement parameters // int moveCmd = ilookup(tabName,version,"MoveCmd"); int moveSpeed = ilookup(tabName,version,"MoveSpeed"); int moveTime = (smecCurrPosn - smecPosn) / moveSpeed; if(moveTime < 0) { moveTime = moveTime * -1; } moveTime = moveTime + 2; // allow 2 sec to stabilise if(debug) { debug_print("Movement Time: " + moveTime); } // // // // // Set SMEC mode to hold its position: // SpireSendDrcuCmd(0x90490000,0); // // // // // Move to position: // // Set scan speeds: SpireSendDrcuCmd(0x90470000 + moveCmd,0); delay(1); SpireSendDrcuCmd(0x90560000 + moveCmd,0); // // Set SMEC position: SpireSendDrcuCmd(0x90450000 + smecPosn,0); delay(1); // // Move SMEC to position: SpireSendDrcuCmd(0x90490001,0); delay(moveTime); // // Set SMEC mode to hold its position: SpireSendDrcuCmd(0x90490000,0); sync(); } // // // // // End procedure: // tstr = SpireTimeStr(time()); SpireMsg(3," " + tstr + ": Proc SmecMove ended"); SpireMsg(2," Proc SmecMove (" + (time() - t) + " seconds)"); } /////////////////////////////////////////////////////////////////////////// // // SpireSpectroPeakup.txt // /////////////////////////////////////////////////////////////////////////// // // This observation executes a Peakup observation // // The instrument should be in the SPECSTBY mode before execution // of this procedure. // // The peakup offset generated takes effect with the next observation // so this observation should be concatenated with a following observation // that requires peaking up // // 17/03/2009 KJK first version // Adapted from 17/03/2009 version of SpirePhotoPeakup // /////////////////////////////////////////////////////////////////////////// // obs SpireSpectroPeakup { /* ****************************************************** */ /* USER PARAMETER DEFINITION, CUS SIGNATURE for EX-HSpot */ /* ****************************************************** */ /* */ double ra = 0.0 in [0.0,360.0]; // RA of target double dec = 0.0 in [-90.0,90.0]; // DEC of target int naifid = 0; // NAIF identifier string boresight = ""; // Instrument Boresight bool isBright = false; // Use settings for bright source (==tick) string opsVersion = "v00"; // Version in Table_OpsParms cal table bool debug = false; // debug messages flag bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ // ****************************************************** */ // CALCULATE DURATIONS for POINTING STATES */ // ****************************************************** */ // // Calculate timing for the pointing request: // // BBs called during slew: int tslewmin = duration(SpireBbStartObs()); // // BBs carried out when the pointing is reached: int tinithold = duration(SpireBb_SpecOffsetAuto(false,debug)); // // BB carried out during pointing: int tp = duration(SpirePeakup("SPeakup")); // // BB carried out at the end: int tfinalhold = duration(SpireBbEndObs()); // // Debug_printing? // if(debug) { debug_print("tslewmin = " + tslewmin); debug_print("tinithold = " + tinithold); debug_print("tpointing = " + tp); debug_print("tfinalhold = " + tfinalhold); } // // ****************************************************** */ // POINTING MODE DECLARATION */ // ****************************************************** */ // // Lookup boresight, if not provided string ib = boresight; if(boresight == "") { ib = SpireProc_GetTableEntryString("SpireTable_OpsParms.txt","mode","SOF1","Boresight",opsVersion,debug); } // // Set pointing mode: // int[] ts = basic_fine_pointing(true,tslewmin,tinithold,tfinalhold,ib,naifid,ra,dec,0.0,0.0,tp); // if(debug) { debug_print("Output timing vector from the pointing request: " + ts); debug_print("Boresight: " + ib); } // }{ // ****************************************************** */ // POINTING STATES WITH OBSERVING MODE LOGIC */ // ****************************************************** */ // // Start the state_machine: // int[] state = [0]; // while(state[0] >= 0) { if(debug) { debug_print("Current state: " + state); } state = next_state(); if(debug) { debug_print("Next state: " + state); } // if(state[0] == 1) { // STATE = SLEW ( Spacecraft is slewing ) // // // // // Startup observation: // SpireBbStartObs(); // } if(state[0] == 2) { // STATE = INIT_HOLD ( spacecraft is idling at source ) // // // // // Set offsets: // SpireBb_SpecOffsetAuto(false,debug); // // //delay(tinithold); // } if(state[0] == 3) { // STATE = POINT ( spacecraft is at nominal RA,DEC (staring, raster) ) // // // // // Execute Peakup // SpirePeakup("SPeakup"); } if(state[0] == 5) { // STATE = FINAL_HOLD ( "sky" observation ends, performing final activities ) // // // // // Reset OBSID and BBID: // SpireBbEndObs(); // } if(state[0] == -1) { // STATE = END ( end of the pointing/commanding part of the code ) // } } } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_StartPcalLevelCheck.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to configure at the start of // SpirePhoto/Spectro_Cal_PcalLevelCheck. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // // 2009/05/07 V0.1: Initial version adapted from // SpireBb_StartBsmAngleCal (2009/05/05 V0.1), // SpirePhoto_Cal_PcalLevelCheck (2009/03/04 V1.4), and // SpireSpectro_Cal_PcalLevelCheck (2009/03/04 V0.5) // BB includes now to move BSM/SMEC to hold/home. // 2009/07/10 V1.0: Fix bug SPR-SPIRE-1612 // // Notes: // 1) Scripts assumes that SpireBb_SpecOffsetAuto is run // during INITHOLD or at first POINTING. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_StartPcalLevelCheck SPIRE 14064 { bool phot = true; // Photometer (==tick) or FTS (==untick)? string obsModeQla = "ENG_CAL_OBS09"; string obsMode = "PEngCalObs"; bool isBright = false; // Use settings for bright source (==tick) string version01 = "v00"; // Version in cal table SpireTable_Phot/SpecModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams int hold_chop = 37632; // Chop hold position int hold_jigg = 39520; // Jiggle hold position int smecHomePosn = 3500; // SMEC home position bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // int mode_id = 0; string obsmode = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB StartPcalLevelCheck configuration started"); SpireMsg(2," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Startup observation: // SpireProc_Set_StartObsAll(obsModeQla); // // // // // In case move SMEC to home: // if(!phot) { // // Calculate available time for possible movement: // int tmove = duration(SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug)) + duration(SpireProc_Set_SpecMode(obsMode,isBright,version01,version02,debug)) + duration(SpireProc_Set_ObsStep(999,debug)) + duration(SpireBb_SpecOffsetAuto(false,debug)); // // Calculate max offset for which time is available: // int smecMaxOff = tmove * 500; // Note, 500 is maximum possible SMEC speed. int smecStart = smecHomePosn + smecMaxOff; // Note, formula above only reasonable // when smecHomePosn small compared to 39500 // Safety check: if(smecStart > 39500) { smecStart = 39500; } if(debug) { debug_print("smecStart: " + smecStart); debug_print("smecHomePosn: " + smecHomePosn); debug_print("tmove: " + tmove); } // // Move from maximal offset to home: // SpireProc_SmecMove2Home(smecHomePosn,smecHomePosn + smecMaxOff,debug); } // // // // // Move BSM back to hold: // SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug); // // // // // Initialise instrument (in case to isBright): // if(phot) { SpireProc_Set_PhotMode(obsMode,isBright,version01,version02,debug); } else { SpireProc_Set_SpecMode(obsMode,isBright,version01,version02,debug); } //delay(timeSlewCal); // // // // // Set NHK STEP parameter to count PCAL levels: // int obsStep = 1; SpireProc_Set_ObsStep(obsStep,debug); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB StartPcalLevelCheck configuration ended"); SpireMsg(1," ..StartPcalLevelCheck took " + (time() - t) + " seconds)"); // } // Missionphase : EQM IMT // // Purpose : Switch on/off and enable/disable a controller for a PACS // internal Calibration Source // // Author : DAC // CUS script : DAC // CVS file : CS_on_off.txt // // Arguments : // type name Description // string cal_source Either CS1 or CS2 // string on_off Either ON or OFF // // Description : Switch on/off and enable/disable controller for selected // PACS internal CS (calibration source) // // Dependencies : // // Preconditions : Configuration parameters have been uploaded for CS1 and CS2 // // Comments : Several ways exist to fill in the preconditions, // e.g. CONF_csx, or SetupSpectroscopyEQMIMT. // // Version : 1.0 // // History : 1.0 12-Apr-2005 Creation by DAC // procedure CS_on_off { string cal_source = "CS1" in ["CS1","CS2"]; string on_off = "ON" in ["ON","OFF"]; }{ // Start with internal source CS1 if(cal_source == "CS1") { if(on_off == "ON") { Pacs_DMC_SWON_BB_1_CONT(); Pacs_DMC_ENABLE_BB_1_CONT(); } if(on_off == "OFF") { Pacs_DMC_DISABLE_BB_1_CONT(); Pacs_DMC_SWOF_BB_1_CONT(); } } // Continue with CS2 if(cal_source == "CS2") { if(on_off == "ON") { Pacs_DMC_SWON_BB_2_CONT(); Pacs_DMC_ENABLE_BB_2_CONT(); } if(on_off == "OFF") { Pacs_DMC_DISABLE_BB_2_CONT(); Pacs_DMC_SWOF_BB_2_CONT(); } } // end of procedure } // SpireSOF12Observing // // $Id:$ // // This is the procedure to calculate instrument parameters for // the spectrometer single pointing observing mode // // 03/02/2009: KJK // changed input interface to accept 2 sets of scan info in order to call SpirePointSpectrum correctly // now calls SpireProc_SFlash to get PCAL flash duration (including SMEC movement times) // 04/03/09: MP Fixed bug in call to // SpireProc_GetTableEntryString("SpireTable_OpsParms.txt","mode"...) // {int,double,int,double,int,double,int,double,int,int,double,int,double} procedure SpireSOF12Observing { string opsMode = "SOF1" in ["SOF1","SOF2","SOF2_int"]; // operations mode string res1 = "H" in ["H","M","C","L"]; // resolution for set 1 string res2 = "L" in ["H","M","C","L"]; // resolution for set 2 int nRepetitions1 = 2; // number of times to repeat spectral scan pairs for 1st set of scans int nRepetitions2 = 0; // number of times to repeat spectral scan pairs for 2nd set of scans string specVersion = "v00"; string opsVersion = "v00"; string flashVersion = "v00"; bool debug = false; }{ string version = "v00"; SpireMsg(2," " + opsMode + " Observing Parameters"); SpireMsg(2," $Id:$"); // // fetch operating parameters double flashTime = double(ilookup("SpireParms.txt",opsMode,"FlashTime")); // Optimum time between flashes double calTime = double(ilookup("SpireParms.txt",opsMode,"CalTime")); // Minimum time between gyro calibrations string ib = SpireProc_GetTableEntryString("SpireTable_OpsParms.txt","mode",opsMode,"Boresight",opsVersion,debug); // instrument boresight bool initFlash = blookup("SpireParms.txt",opsMode,"InitFlash"); // initial flash flag bool endFlash = blookup("SpireParms.txt",opsMode,"EndFlash"); // final flash flag double srcTime1 = SpireProc_GetTableEntryDouble("SpireTable_Spectrometer.txt","ResChar",res1,"Osit",specVersion,debug); // effective on source integration time per scan double srcTime2 = SpireProc_GetTableEntryDouble("SpireTable_Spectrometer.txt","ResChar",res2,"Osit",specVersion,debug); // effective on source integration time per scan double scanTime1 = SpireProc_GetTableEntryDouble("SpireTable_Spectrometer.txt","ResChar",res1,"ScanTime",specVersion,debug); // time per scan double scanTime2 = SpireProc_GetTableEntryDouble("SpireTable_Spectrometer.txt","ResChar",res2,"ScanTime",specVersion,debug); // time per scan int jiggleTable = SpireProc_GetTableEntryInt("SpireTable_OpsParms.txt","mode",opsMode,"TableId",opsVersion,debug); // Jiggle Table ID int jiggleSize = SpireProc_GetTableEntryInt("SpireTable_OpsParms.txt","mode",opsMode,"TableSize",opsVersion,debug); // Jiggle Table length // // ***************************************** // Display input parameters // ***************************************** SpireMsg(3," " + opsMode + " Logic Input values:"); SpireMsg(3," ..Resolution1: " + res1); SpireMsg(3," ..Resolution2: " + res2); SpireMsg(3," ..nRepetitions1: " + nRepetitions1); SpireMsg(3," ..nRepetitions2: " + nRepetitions2); SpireMsg(3," ..specVersion: " + specVersion); SpireMsg(3," ..opsVersion: " + opsVersion); SpireMsg(3," ..flashVersion: " + flashVersion); SpireMsg(3," " + opsMode + " Fixed values:"); SpireMsg(3," ..ib: " + ib); SpireMsg(3," ..initFlash: " + initFlash); SpireMsg(3," ..endFlash: " + endFlash); SpireMsg(3," ..srcTime1: " + srcTime1); SpireMsg(3," ..srcTime2: " + srcTime2); SpireMsg(3," ..scanTime1: " + scanTime1); SpireMsg(3," ..scanTime2: " + scanTime2); SpireMsg(3," ..jiggleTable: " + jiggleTable); SpireMsg(3," ..jiggleSize: " + jiggleSize); // // ***************************************** // calculate observing parameters // ***************************************** SpireMsg(2," Calculated Parameters:"); // int nMaps = 1; // always is 1 for SOF1/2 // int nCycles1 = 0; int nCycles2 = 0; double tCycle1 = 0.0; double tCycle2 = 0.0; double osit1 = 0.0; double osit2 = 0.0; // // number of scans to perform int ms = SpireProc_GetTableEntryInt("SpireTable_OpsParms.txt","mode",opsMode,"MinScans",opsVersion,debug); double minScans = double(ms); int scansPerCycle1 = SpireProc_GetTableEntryInt("SpireTable_OpsParms.txt","mode",opsMode,"N" + res1 + "Scans",opsVersion,debug); int scansPerCycle2 = SpireProc_GetTableEntryInt("SpireTable_OpsParms.txt","mode",opsMode,"N" + res2 + "Scans",opsVersion,debug); double ns = 0.0; // number of scans // // find number of cycles to perform and the time they take // int nScans1 = 0; ns = double(nRepetitions1 * 2); if(ns < minScans) { ns = minScans; SpireMsg(1," Number of requested Set 1 scans below minimum: " + ns + " - value has been set to " + minScans); } // round number of scans to integral number of cycles nScans1 = scansPerCycle1 * ifloor(ns / double(scansPerCycle1)); if(nScans1 < scansPerCycle1) { nScans1 = scansPerCycle1; } SpireMsg(3," Required number of Set 1 scans : " + nScans1); osit1 = double(nScans1) * srcTime1; SpireMsg(3," Set 1 on source time : " + osit1); nCycles1 = nScans1 / scansPerCycle1; SpireMsg(3," Number of Set 1 cycles: " + nCycles1); tCycle1 = double(scansPerCycle1) * scanTime1; int nScans2 = 0; ns = double(nRepetitions2 * 2); if(ns < minScans) { ns = minScans; SpireMsg(1," Number of requested Set 2 scans below minimum: " + ns + " - value has been set to " + minScans); } // round number of scans to integral number of cycles nScans2 = scansPerCycle2 * ifloor(ns / double(scansPerCycle2)); if(nScans2 < scansPerCycle2) { nScans2 = scansPerCycle2; } if(nRepetitions2 == 0) { nScans2 = 0; } SpireMsg(3," Required number of Set 2 scans : " + nScans2); osit2 = double(nScans2) * srcTime2; SpireMsg(3," Set 2 on source time : " + osit2); nCycles2 = nScans2 / scansPerCycle2; SpireMsg(3," Number of Set 2 cycles: " + nCycles2); tCycle2 = double(scansPerCycle2) * scanTime2; // // estimate time on source with no flashes // double pointTime = 0.0; double totalTime = 2.0; for(int i = 0 .. jiggleSize - 1) { totalTime = totalTime + double(duration(SpireBbBsmMove(jiggleTable,i,0))); totalTime = totalTime + double(duration(SpirePointSpectrum(res1,nCycles1,tCycle1,scansPerCycle1,res2,nCycles2,tCycle2,scansPerCycle2,99999.0,0,specVersion,flashVersion,debug))); if(i == 0) { pointTime = totalTime; } } SpireMsg(3," Observing time per point: " + pointTime); SpireMsg(3," Total observing time: " + totalTime); // // calculate when Gyro calibrations and PCAL flashes are needed // during the scanning at one point // // // Gyro calibration information double tCal = calTime; int nCals = ifloor(pointTime / calTime); if(nCals > 0) { tCal = pointTime / double(nCals + 1); } // SpireMsg(3," Number of Gyro Calibrations per point: " + nCals); // SpireMsg(3," Time between Gyro calibrations: " + tCal); // // PCAL calibration information double tFlash = flashTime; int nFlashes = ifloor(pointTime / flashTime); if(nFlashes > 0) { tFlash = pointTime / double(nFlashes + 1); } SpireMsg(3," Number of Flashes per point: " + nFlashes); SpireMsg(3," Time between Flashes: " + tFlash); return {nCycles1,tCycle1,scansPerCycle1,osit1,nCycles2,tCycle2,scansPerCycle2,osit2,nMaps,nFlashes,tFlash,nCals,tCal}; } // SpireSetMode // // $id$ // // This building block sets the Observing Mode parameter // procedure SpireSetObsMode { string obsmode = "REDY"; // name of the mode }{ string hstr = ""; // hex string string tstr = ""; // time string // // find mode number int modeid = ilookup("InstrumentConfigurations.txt",obsmode,"value"); // // set it hstr = SpireHexStr(modeid,4); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_MODE_RAW(" + hstr + ")"); Spire_SET_OBS_MODE_RAW(modeid); } // // Author : DAC // CUS script : DAC // CVS file : // // Arguments : // type name Description // string cal_source Internal CAL source CS1 or CS2 // double resist_temp Desired resistance [ohm] // // Description : Set the temperature of a PACS internal Calibration source // // Dependencies : // // Preconditions : Configuration parameters have been uploaded and the // controller has been SWON & enabled // // Comments : // // Version : 1.0 // // History : 1.0 13-Apr-2005 Creation by DAC // procedure CS_temp { string cal_source = "CS1" in ["CS1","CS2"]; // Chosen calibration source double resist_temp = 80.0; // The desired resistance of CS2, in Ohms }{ // Start with CS1 if(cal_source == "CS1") { Pacs_DMC_SET_TEMP_BB_1(resist_temp); } // Continue with CS2 if(cal_source == "CS2") { Pacs_DMC_SET_TEMP_BB_2(resist_temp); } } // $Id // Purpose : Bring PACS from switched off condition to standby // for PHOT observations // // CUS author : Composed from various ILT modules // // Input arguments: see after module identification // // Return values // N/A // // Comments : // // History: // 0.1 25-jun-2007 Created from ILT modules // 0.2 9-aug-2007 Conformed to JonBr's mail (07/26/07) // 1.0 21-aug-2007 Renamed from PACS_PHOT_orbit_prologue // Use new "no_pointing" pointing request and // StateMachine logic // 1.1 20-may-2008 KO, Debugged for the pointing timing logic // 1.2 24-jun-2008 KO, calUfile, temp_CS1 and temp_CS2 put in the argument // 1.3 25-jun-2008 KO, CSs stabilisation time tSET put in the argument and the default calUfile changed to ILT // 1.4 11-nov-2008 VD&KO&TM tSet chnaged to 2100s to allow for stabilisation // 1.5 12-nov-2008 KO gotoDirect option added // 2.0 26-feb-2009 VD SpirePacsParallel pacs Prologue specific // obs SpirePacsEng_Parallel_PacsPrologue { string calUfile = "BOLObias_ILT_standard_low"; // Bias table double set_CS1 = 48.0; // CS1 settings (ohms) double set_CS2 = 58.0; // CS2 settings (ohms) int tSET = 2100; // CSs stabilisation time in seconds bool gotoDirect = true in [true,false]; // DDCS setting to Direct setting }{ // Settling time for CS string fltPOS = "POS A"; bool execute = true; // Initial hold int tih = imax(1,duration(WriteOBSID($OBSID))); // Final hold int tfh = imax(1,duration(WriteEndID())) + tSET; // Duration of "stable" pointing int tp = duration(PHOT_setup(calUfile,fltPOS,set_CS1,set_CS2,gotoDirect)); // Issue PointReq int[] ts = no_pointing(execute,tih,tfh,tp); }{ int[] state = [0]; while(state[0] >= 0) { state = next_state(); if(state[0] == 2) { // Obtain and set OBSID WriteOBSID($OBSID); data_rate(120.0); } if(state[0] == 3) { // Call the PHOT setup script PHOT_setup(calUfile,fltPOS,set_CS1,set_CS2,gotoDirect); } if(state[0] == 5) { // Wait for CS to stabilize delay(tSET); // Reset OBSID and BBID data_rate(0.0); WriteEndID(); } } } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_SmecHold.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to stop SMEC trajectory generation. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/03/31 V0.1: Initial version // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_SmecHold { bool debug = false; }{ // // // // // Define some variables: // int t = time(); // // hex string: string hstr = ""; // // time string: string tstr = ""; // // // // // // Start procedure: // tstr = SpireTimeStr(time()); SpireMsg(3," " + tstr + ": Proc SmecHold started"); SpireMsg(3," $Id: $"); // // // // // Set SMEC mode to hold its position: // SpireSendDrcuCmd(0x90490000,0); sync(); // // // // // End procedure: // tstr = SpireTimeStr(time()); SpireMsg(3," " + tstr + ": Proc SmecHold ended"); SpireMsg(2," Proc SmecHold (" + (time() - t) + " seconds)"); } // SpirePOF2Pointing // // $id$ // // This procedure calculates and returns the pointing parameters for the POF2 observing mode // // 11/02/09: KJK Updated to reflect changed configuration and reconfiguration stages // 02/07/2009 KJK: // Added configuration input parameters to pass to SpirePOF2Config and SpirePOF2End // 05/07/2009 KJK: // SPR-1593 - added flashVersion to input parameters // - changed call to SpireBbPcalFlash // {int,int,int,int,int,int} procedure SpirePOF2Pointing { int nCycles = 1; // total number of number of nod cycles to perform int nNodInts = 1; // number of nod integrations per nod position int nCal = 99999; // number of nod cycles per pointing calibration int nFlash = 99999; // number of nod cycles per PCAL flash bool isBright = false; string flashVersion = "v00"; string photVersion = "v00"; string comVersion = "v00"; bool debug = false; }{ int jiggleTable = ilookup("OpsParms.txt","POF2","TableId"); // Jiggle Table ID int jiggleSize = ilookup("OpsParms.txt","POF2","TableSize"); // Jiggle Table length int nJiggs = ilookup("OpsParms.txt","POF2","NJiggs"); // number of jiggle positions per nod position int nNodPosns = ilookup("OpsParms.txt","POF2","NNodPosns"); // number of nod positions in a nod cycle bool initFlash = blookup("SpireParms.txt","POF2","InitFlash"); // initial flash flag bool endFlash = blookup("SpireParms.txt","POF2","EndFlash"); // final flash flag // // ***** check inputs ***** int nMoves = nCycles * nNodPosns / 2; if(nMoves > 1200) { error("POFS2Pointing: number of nod switches is greater than maximum allowed (1200): " + nMoves); } // // ****** calculate parameters for pointing mode ****** // // minimum slew time int tSlewMin = duration(SpireBb_StartObsAll("POF2")) + duration(SpireBbPOF2Config("POF2",isBright,photVersion,debug)) + 2; // // time for Initial Hold int tInitHold = duration(SpireBbPOF2Init()) + 2; int tFlash = duration(SpireBbPcalFlash("PFlash",flashVersion,0,debug)); if(initFlash || nFlash < nCycles) { tInitHold = tInitHold + tFlash; } // // time for Final Hold int tFinalHold = duration(SpireBbPOF2End("PHTSTBY",isBright,photVersion,comVersion,debug)) + duration(SpireBb_EndObsAll(true)) + 2; if(endFlash || nFlash < nCycles) { tFinalHold = tFinalHold + tFlash; } // // time at hold position int tHold = tFlash + 2; // // number of nods per hold int nHold = 0; if(nFlash < nCycles) { nHold = nFlash * nNodPosns / 2; } // // time per point int tp = duration(SpireBbJiggle("POF2",jiggleTable,0,nJiggs,nNodInts,0)) + duration(SpireBbMove(0)) + 2; // return {tSlewMin,tInitHold,tFinalHold,tp,tHold,nHold}; } // SpireBbBsmOn // // $id$ // // This building block switches on the BSM // // The instrument should be in the REDY mode before execution of this building block // // 27/04/2009 KJK: // Updated to use new NominalSettings Cal Tables // model, version and debug passed as parameters // 07/05/2009 KJK: // Added opsMode as input parameter to allow setting of mode dependant parameters // block SpireBbBsmOn SPIRE 256 { string opsMode = "PHTSTBY"; string model = "initial"; string version = "v00"; bool debug = false; }{ int t0 = time(); string hstr = ""; // hex string string tstr = ""; // time string tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB BSM On started"); SpireMsg(2," $Id$"); // // intialise variables int chop_ff_gain = SpireProc_GetTableEntryInt("SpireTable_BsmNominalSettings.txt","model",model,"chop_ff_gain",version,debug); int jigg_ff_gain = SpireProc_GetTableEntryInt("SpireTable_BsmNominalSettings.txt","model",model,"jigg_ff_gain",version,debug); // // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); delay(1); // // set Step to zero SpireSetObsStep(0); // // Flag the current operation SpireSetObsMode("BSM_ON"); delay(1); // // Switch ON chop and jiggle sensors SpireSendDrcuCmd(0x90c00001,0); SpireSendDrcuCmd(0x91400001,0); delay(1); // // Force open loop in both axis SpireSendDrcuCmd(0x90c20003,0); SpireSendDrcuCmd(0x91420003,0); // // Set Chop and jiggle ff gain SpireSendDrcuCmd(0x90cd0000 + chop_ff_gain,0); SpireSendDrcuCmd(0x914d0000 + jigg_ff_gain,0); // // Set Movement Mode SpireSendDrcuCmd(0x90c60000,0); // // Set Chop and Jiggle Target Positions to centre POSITIONS SpireSendDrcuCmd(0x90c38000,0); SpireSendDrcuCmd(0x91438000,0); sync(); // // completion tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB BSM On ended"); SpireMsg(1," ..BSM ON (" + (time() - t0) + " seconds)"); } // SpireREDYtoSPEC_STBY // // $id$ // // This procedure configures the instrument into the SPEC_STBY mode // // The instrument should be in the REDY mode before execution of this observation // // 28/04/2009 KJK: first version // 08/06/2009 KJK: added commands for starting/stopping the SCAL Command List // 02/07/2009 MP: Added report of tables and memory checksums (SPIRE-SCR-1527) // 12/07/2009 MP: Changed default stabilisationTime (SCR-SPIRE-1632) // 13/07/2009 MP: Introduce wait time after SMEC on as input (SCR-SPIRE-1638) // procedure SpireREDYtoSPEC_STBY { int jfet_heater_V = 0; // Default jfet heater voltage at switch on string scal = "Default" in ["Default","SCAL2","SCAL4","None"]; // SCAL status int scalTemp = -1; // SCAL temperature, if you want to override the default int stabilisationTime = 120; // time (secs) to allow SCAL/Detectors to stabilise before starting observations int smecWait = 1200; // Wait time after switch-on of SMEC [s] bool sampleDetectors = false; // sample detectors during the stabilisation period string bsmModel = "initial"; string bsmVersion = "v00"; string smecVersion = "v00"; string detVersion = "v00"; string vssVersion = "v00"; string scalVersion = "v00"; bool debug = false; }{ // set nominal housekeeping rate SpireBbSetNhkSampling("SPECSTBY","v00",debug); // // // // // Report tables and do memory checksums: // SpireBb_RepTabAndMemChecksum(); // // // ----------- // configure BSM // ----------- // // switch on BSM mois_comment("Procedure SPIRE_BSM_ON: to switch on the SPIRE BSM"); mois_spacon("Select the TM Display for FUNCTIONAL TEST PARAMETERS"); mois_tmcheck("Check that parameter CHOPSENSPWR is set to 0"); mois_tmcheck("Check that parameter JIGGSENSPWR is set to 0"); SpireBbBsmOn("SPECSTBY",bsmModel,bsmVersion,debug); mois_comment("SPIRE SPIRE_BSM_ON Procedure Completed"); mois_tmcheck("Check that parameter CHOPSENSPWR is set to 1"); mois_tmcheck("Check that parameter JIGGSENSPWR is set to 1"); mois_tmcheck("Check that parameter MODE is set to BSM_ON"); // // initialise BSM mois_comment("Procedure SPIRE_BSM_INIT: to initialise the SPIRE BSM"); mois_spacon("Select the TM Display for FUNCTIONAL TEST PARAMETERS"); mois_spacon("Ensure that SPIRE_BSM_ON procedure has been run before continuing"); mois_tmcheck("Ensure that parameter MODE is set to BSM_ON"); SpireBbBsmChopInit("SPECSTBY",bsmModel,bsmVersion,debug); SpireBbBsmJiggInit("SPECSTBY",bsmModel,bsmVersion,debug); // Setup BSM sampling SpireBbSetBsmSampling("SPECSTBY",bsmVersion,debug); mois_comment("SPIRE SPIRE_BSM_INIT Procedure Completed"); mois_tmcheck("Check that parameter MODE is set to BSM_INIT"); // // ------------- // configure SMEC // ------------- // // switch on SMEC mois_comment("Procedure SPIRE_SMEC_ON: to switch on the SPIRE SMEC"); mois_spacon("Select the TM Display for FUNCTIONAL TEST PARAMETERS"); mois_tmcheck("Check that parameter SMECENCPWR is set to 0"); mois_tmcheck("Check that parameter SMECLVDTPWR is set to 0"); SpireBbSmecOn(smecVersion,debug); mois_tmcheck("Check that parameter SMECENCPWR is set to 1"); mois_tmcheck("Check that parameter SMECLVDTPWR is set to 1"); mois_tmcheck("Check that parameter MODE is set to SMEC_ON"); // // // // // Wait time after SMEC on before SMEC initialisation: // delay(smecWait); // // initialise SMEC mois_comment("Procedure SPIRE_SMEC_INIT: to initialise the SPIRE SMEC"); mois_spacon("Select the TM Display for FUNCTIONAL TEST PARAMETERS"); SpireBbSmecInit(smecVersion,debug); mois_tmcheck("Check that parameter MODE is set to SMEC_INIT"); // // Setup SMEC sampling SpireBbSetSmecSampling("SPECSTBY",smecVersion,debug); // // ---------------- // configure Detectors // ---------------- // mois_comment("Procedure SPIRE_SDET_ON: to switch on the SPIRE Spectrometer"); mois_spacon("Select the TM Display for FUNCTIONAL TEST PARAMETERS"); mois_tmcheck("Ensure that parameter MODE is set to SMEC_INIT"); mois_tmcheck("Ensure SLIABITSTAT is set to 0"); mois_tmcheck("Ensure SPECJFETSTAT is set to 0"); mois_tmcheck("Ensure parameters SSWJFET1V to SSWJFET2V are all set to 0"); mois_tmcheck("Ensure parameter SLWJFET1V is set to 0"); mois_spacon("Select the TM Display for SFT PARAMETERS"); mois_tmcheck("SLIAP5V, SLIAP9V and SLIAM9V should all be set to 0"); SpireBbSdetOn(jfet_heater_V,detVersion,vssVersion,debug); mois_tmcheck("Ensure SLIABITSTAT is set to 1"); mois_tmcheck("SLIAP5V should be ~5V"); mois_tmcheck("SLIAP9V should be ~11.5V"); mois_tmcheck("SLIAM9V should be ~-11.5V"); mois_spacon("Select the TM Display for FUNCTIONAL TEST PARAMETERS"); mois_tmcheck("Ensure SPECJFETSTAT is set to 7"); mois_tmcheck("Ensure parameters SSWJFET1V & SSWJFET2V are all < 0 - nominally within ~ -1V and -3V"); mois_tmcheck("Ensure parameter SLWJFET1V is < 0 - nominally within ~ -1V and -3V"); mois_tmcheck("Ensure that parameter MODE is set to SPECSTBY"); // // ---------------- // configure SCU // ---------------- // SpireBbSetScuSampling("SPECSTBY","v00",debug); // // ---------------- // Configure SCAL // ---------------- // if(scal == "Default") { // read default status scal = SpireProc_GetTableEntryString("SpireTable_DefaultParams.txt","mode","SPECSTBY","scalVm",scalVersion,debug); } SpireBbSetScal(scal,scalTemp,scalVersion,debug); // // ---------------- // Stabilisation // ---------------- if(sampleDetectors) { SpireBbSetDetSampling("SPECSTBY",false,detVersion,sampleDetectors,debug); } delay(stabilisationTime); // // ----------------------- // Setup final detector sampling // ----------------------- SpireBbSetDetSampling("SPECSTBY",false,detVersion,false,debug); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBbSetScuSampling.txt // /////////////////////////////////////////////////////////////////////////// // // The Building Block sets the SCU sampling // // /////////////////////////////////////////////////////////////////////////// // // 28/04/2009 KJK: First Version // 07/05/2009 KJK: // Now only set sampling parameters if the data is to be generated (these values are not available for REDY mode) // /////////////////////////////////////////////////////////////////////////// // double block SpireBbSetScuSampling SPIRE 1604 { string opsMode = "PHTSTBY"; string version = "v00"; bool debug = false; // Allow debug_print statements }{ // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // // // Start BB: // message("4 " + time() + ": SpireBbSetScuSampling started"); message("4 $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); delay(1); // // set default datarate double scuDataRate = 0.0; // set default TM Packet 12 sampling rate int scuDataModeRate = 0; // // // if generating data, setup sampling first int scuDataGen = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode",opsMode,"scuDataGen","v00",debug); if(scuDataGen == 1) { // if starting data generation // Set number of samples int scuFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode",opsMode,"scuFrameNumber","v00",debug); SpireSendDrcuCmd(0xa0840000 + scuFrameNumber,0); // read datarate scuDataRate = SpireProc_GetTableEntryDouble("SpireTable_CommonModeParams.txt","mode",opsMode,"bsmDataRate",version,debug); // read sampling type rate scuDataModeRate = SpireProc_GetTableEntryInt("SpireTable_CommonModeParams.txt","mode",opsMode,"scuFrameRate",version,debug); } // Start/Stop Data Generation SpireSendDrcuCmd(0xa0830000 + scuDataModeRate,0); SpireSendDrcuCmd(0xa0820000 + scuDataGen,0); // // End BB: // sync(); SpireMsg(4," " + time() + ": BB SpireBbSetScuSampling ended"); return scuDataRate; } // SpireBbPOF3Config // // $Id:$ // // Building Block to configure the instrument for POF3 ( jiggle map) operation // // The complete instrument setup operation is divided into two parts: // Configuration: actions that can be executed during the slew to the start // position of the S/C pointing mode. // Initialisation: actions that must be carried out at the S/C intial pointing // position before any observational operations are executed. // // This building Block implements the first part of the setup // // 11/02/09: KJK // - Removed setting of Mode and resetting DRCU counters - // These are now implemented in SpireBb_StartObsAll // - Add possible bright-source setting // 14/02/09: MP // - Replace calls to SpireProc_Set_PhotPhase/Bias with // call to SpireProc_Set_PhotBright // 04/03/09: MP // - Fixed bug in call to SpireProc_Set_PhotBright // 22/07/2009 SDS: // SCR-1670 - Added option to load new JM64 table which has +/- 126 arcseconds chop throw // 28/07/2009 SDS: // SCR-1728 - Reads and sets the Chop PID parameters from model jm64 in the SpireTable_BsmNominalSettings.txt table // block SpireBbPOF3Config SPIRE 8240 { string obsMode = "POF3"; bool isBright = false in [true,false]; bool pBool1 = false; // Load 64-Point Jiggle Map Table? string chopVersion = "v00"; //Version of the SpireTable_BsmNominalSettings.txt table string photVersion = "v00"; bool debug = false in [true,false]; }{ int t = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB POF3 Configuration started"); SpireMsg(2," $Id: $"); // // ..... configuration ..... // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // // set bright-source biases and phases - if needed // if(isBright) { SpireProc_Set_PhotBright(obsMode,photVersion,debug); } // // If pBool1 is true then load the JM64 table // if(pBool1) { SpireProc_Load_JmTable(); } // // ..... completion ..... // delay(2); // // Read the Chop PID parameters int chopkp = SpireProc_GetTableEntryInt("SpireTable_BsmNominalSettings.txt","model","jm64","chop_kp",chopVersion,debug); int chopki = SpireProc_GetTableEntryInt("SpireTable_BsmNominalSettings.txt","model","jm64","chop_ki",chopVersion,debug); int chopkd = SpireProc_GetTableEntryInt("SpireTable_BsmNominalSettings.txt","model","jm64","chop_kd",chopVersion,debug); // // // // Set PID parameters to nominal JM64 values: // SpireProc_Set_BsmChopPid(chopkp,chopki,chopkd,debug); // // // // to allow hsk to stabilise // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB POF3 Configuration ended"); SpireMsg(1," ..POF3 Configuration (" + (time() - t) + " seconds)"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBbSetNhkSampling.txt // /////////////////////////////////////////////////////////////////////////// // // The Building Block sets the NHK sampling // // /////////////////////////////////////////////////////////////////////////// // // 28/04/2009 KJK: First Version // /////////////////////////////////////////////////////////////////////////// // double block SpireBbSetNhkSampling SPIRE 1600 { string opsMode = "PHTSTBY"; string version = "v00"; bool debug = false; // Allow debug_print statements }{ // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // // // Start BB: // message("4 " + time() + ": SpireBbSetNhkSampling started"); message("4 $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); delay(1); // // Set sampling // int nhkSampling = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode",opsMode,"nhkSampling",version,debug); SpireNhkSampling(nhkSampling); // // End BB: // sync(); SpireMsg(4," " + time() + ": BB SpireBbSetNhkSampling ended"); double nhkDataRate = SpireProc_GetTableEntryDouble("SpireTable_DefaultParams.txt","mode",opsMode,"nhkDataRate",version,debug); return nhkDataRate; } // SpireBbStartObs // // $Id: SpireBbStartObs.txt,v 1.2 2007/10/26 10:19:51 kking Exp $ // // Building Block to configure an engineering observation // // 22 Oct 2007: // Correct parameter used for setting of STEP to 1 // Add delay of 1 sec before setting OBSID to allow time for busconfig to be performed // // 17/11/2008 KJK: added sync() statement to round up total duration // block SpireBbStartObs SPIRE 2 { }{ int t = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB Start Obs started"); SpireMsg(2," $Id: SpireBbStartObs.txt,v 1.2 2007/10/26 10:19:51 kking Exp $"); hstr = SpireHexStr($BBID,8); SpireMsg(3," BBID = " + hstr); // // Wait for busconfig to be performed delay(1); // // set OBSID hstr = SpireHexStr($OBSID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + " Cmd: Spire_SET_OBSID_RAW(" + hstr + ")"); Spire_SET_OBSID_RAW($OBSID); // // set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); delay(1); // // set STEP to one tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP_RAW(0x0001)"); Spire_SET_OBS_STEP_RAW(0x1); delay(1); // // reset DRCU counters tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_RESET_DRCU_COUNTERS()"); Spire_RESET_DRCU_COUNTERS(); delay(1); // // set STEP to zero tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP_RAW(0x0000)"); Spire_SET_OBS_STEP_RAW(0x0); // sync(); // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB Start Obs ended"); SpireMsg(1," ..Observation Configuration (" + (time() - t) + " secs)"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_Set_BsmChopPid.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to set BSM PID parameters // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/06/05 V1.0: First version re-configured from // SpireBb_SetBsmChopPid (2009/03/30 V0.1) which was // originally adapted from // Proc_SetChopPID.txt (SDS, email 30.03.2009) // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Set_BsmChopPid { int kp = 1000; // Chop Kp int ki = 536; // Chop Ki int kd = 3504; // Chop Kd bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Define some variables: // string hstr = ""; // a hex string string tstr = ""; // a time string // // // // // Start procedure: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(3," " + tstr + ": SpireProc_Set_BsmChopPid started"); SpireMsg(3," $Id: $"); // // // // // Set PID parameters: // // Set Chop Kp parameter: SpireSendDrcuCmd(0x90c80000 + kp,0); // // Set Chop Ki parameter: SpireSendDrcuCmd(0x90ca0000 + ki,0); delay(1); // // Set Chop Kd parameter: SpireSendDrcuCmd(0x90c90000 + kd,0); sync(); // // // // // End procedure: // tstr = SpireTimeStr(time()); SpireMsg(3," " + tstr + ": SpireProc_Set_BsmChopPid ended"); // } command PacsCcuMonitorPeriodDefault HFKACQP1 { } { bus_schedule(SC, 6); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_SetObsStep.txt // /////////////////////////////////////////////////////////////////////////// // // BB to set NHK STEP parameter // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/02/02 V1.0: Initial version to give BB surrounding for // SpireProc_Set_ObsStep procedure. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_SetObsStep SPIRE 14027 { int obsStep = 0; // Obs step parameter [dec] bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // // // // // Start BB: // message("4 " + time() + ": SpireBb_SetObsStep started"); message("4 $Id: $"); // // // // // Set ObsStep: // SpireProc_Set_ObsStep(obsStep,debug); // // // // // End BB: // SpireMsg(4," " + time() + ": BB SpireBb_SetObsStep ended"); // } // Missionphase : // // Purpose : Loading the sequencer to build up the signal (OBMO) // for normal DDCS mode // // // TCL author : TM // TCL file : tm_phot_sequencer_setup.tcl // CUS author : DAC // Script file : PHOT_seq_setup.txt // // Input arguments // type name description // // Return values // Type Name Default Description // // Description : This script will set the sequencer, which is building // up the final signal and it sets the data mode // to "Bolo & HK". // This script should be executed just after the // switch-on procedure, the BOLC initialisation // and the bias SETTING (polarizer) // The purpose of this scenario is to configure the BOLC // sequencer. // The sequencer will provide clock signals for detector // readout and for BOLC analog synchronous operation // (switching between S and Sref, triggering A to D conversion) // // Dependencies : // // Preconditions : // // Comments : // // Version : 0.2 // History : 0.1 13-apr-2005 DAC. Based on TM's V1.0 from 20-apr-2004 // : 0.2 13-apr-2006 TM, updated for new sequencer, cleaning // of commands in the end (2_Load_of_new_sequencer.txt) int[] procedure PHOT_seq_setup { }{ // Define variables to communicate various durations to HSPOT. // NOTE: all time variables in units of number of ramps (SPEC) or // number of readouts (BOLO). The calling program must convert this // count into actual duration in true time units [seconds]. // SRC, REF, CAL, OVR stand for time spent on SRC, REF (on sky), // CAL source, and overheads (wait for something). Total // duration is given by duree_num. If no error, this duration // must be equal to the sum of all others int duree_num = 0; int duree_SRC = 0; int duree_REF = 0; int duree_CAL = 0; int duree_OVR = 0; int time_start = time(); //-------------------------------------- // BOLC sequencer initialisation (OBMO) //-------------------------------------- // // PC103420 "DMC_SEND_COMMAND_BOLC" SEND COMMAND TO BOL CONTROLLER // PP071420 "BOLOMETER_COMMAND" // // Sequence of command to load the BOLC programmable sequencer: // The timing is defined according to timing diagram given by P.Agnese // Set_clock_mux stop // P 09 00 00 00 Pacs_BOLC_SET_CLOCK_MUX("STOP"); // Set seq param table 0 time 0 clk 20 // P 0C 00 0014 Pacs_BOLC_FINE_TIME_SETTING(0x14); // Set seq param table 1 time 35 clk 52 // P 0C 01 11B4 Pacs_BOLC_FINE_TIME_SETTING(0x111b4); // Set seq param table 2 time 144 clk 116 // P 0C 02 4874 Pacs_BOLC_FINE_TIME_SETTING(0x24874); // Set seq param table 3 time 153 clk 100 // P 0C 03 4CE4 Pacs_BOLC_FINE_TIME_SETTING(0x34ce4); // Set seq param table 4 time 159 clk 108 // P 0C 04 4FEC Pacs_BOLC_FINE_TIME_SETTING(0x44fec); // Set seq param table 5 time 280 clk 44 // P 0C 05 8C2C Pacs_BOLC_FINE_TIME_SETTING(0x58c2c); // Set seq param table 6 time 290 clk 36 // P 0C 06 9124 Pacs_BOLC_FINE_TIME_SETTING(0x69124); // Set seq param table 7 time 294 clk 52 // P 0C 07 9334 Pacs_BOLC_FINE_TIME_SETTING(0x79334); // Set seq param table 8 time 314 clk 20 // P 0C 08 9B14 Pacs_BOLC_FINE_TIME_SETTING(0x89b14); // Set seq param table 9 time 322 clk 0 // P 0C 09 A100 Pacs_BOLC_FINE_TIME_SETTING(0x9a100); // Set clock mux sequencer // P 09 00 00 01 Pacs_BOLC_SET_CLOCK_MUX("Sequencer"); //----------------- // End of Procedure //----------------- // Time spent int duree_TCs = time() - time_start; duree_OVR = duree_TCs; duree_num = duree_OVR; // Return the array of times int[] time_array = [duree_num,duree_SRC,duree_REF,duree_CAL,duree_OVR]; return time_array; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////// // // SpireProc_Set_SpecBias // /////////////////////////////////////////////////////////// // // Procedure to configure the spectrometer detector biases // /////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/02/15 V0.1: Initial version adapted from // SpireProc_Set_PhotBias (KJK, 2009/02/15 V0.2) and // SpireBb_SpecFSetBiasAmpl (MP, 2008/08/12 V0.1) // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Set_SpecBias { int ssw_bias = 0; // SSW bias amplitud int slw_bias = 0; // SLW bias amplitud bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Define some variables: // string tstr = ""; // // // // // Start procedure: // tstr = SpireTimeStr(time()); SpireMsg(4," " + tstr + ": SpireProc_Set_SpecBias started"); SpireMsg(4," $Id:$"); // // // // // Set the selected bias values: // // Set the bias levels for the three arrays: SpireSendDrcuCmd(0x84310000 + ssw_bias,0); SpireSendDrcuCmd(0x84320000 + slw_bias,0); sync(); // // // // // End procedure: // tstr = SpireTimeStr(time()); SpireMsg(4," " + tstr + ": SpireProc_Set_SpecBias ended"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_WaitAtGcp.txt // /////////////////////////////////////////////////////////////////////////// // // BB to wait input time setting NHK parameter SSTEP at start and end // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/03/03 V1.0: Initial version adapted from // SpireBb_StopDcuData (2009/01/30 V1.1) // /////////////////////////////////////////////////////////////////////////// // block SpireBb_WaitAtGcp SPIRE 14029 { int gcp_time = 15; // Time spend at GCP (gyro calibration position) [s] bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // // Determine time to set ObsStep: int osTime = duration(SpireProc_Set_ObsStep(9999,debug)); // // // // // Start BB: // message("4 " + time() + ": SpireBb_WaitAtGcp started"); message("4 $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); delay(1); // // // // // Set Step parameter at start: // SpireProc_Set_ObsStep(65535,debug); // // // // // Wait: // delay(gcp_time - 2 * osTime - 1); // // // // // Set Step parameter at end: // SpireProc_Set_ObsStep(0,debug); // // // // // End BB: // SpireMsg(4," " + time() + ": BB SpireBb_WaitAtGcp ended"); // } // Missionphase : // // Purpose : Enable/disable the chopper electronics // // Author CUS : Diego A. Cesarsky (diego.cesarsky@mpe.mpg.de) // // Author TCL : N/A // // Original TCL : N/A // // Input arguments // Type Name DefVal Description // string on_off "ON" ON: Enable chopper, OFF: Disable // // Description : // // Dependencies : // // Comments : // // Version : 0.3 // History : 0.1 23-Aug-2004 First creation // 0.2 13-apr-2005 DAC Renamed and modified // Enable_disable_chopper procedure // 0.3 8-mar-2007 Added 10sec delay between SWON and ENABLE // (HD's e-mail) // : // procedure CHOP_on_off { string on_off = "ON" in ["ON","OFF"]; //Enable/Disable chopper }{ if(on_off == "ON") { Pacs_DMC_SWON_CHOP_CONT(); delay(10); Pacs_DMC_ENABLE_CHOP_CONT(); } // Disable if(on_off == "OFF") { Pacs_DMC_DISABLE_CHOP_CONT(); Pacs_DMC_SWOF_CHOP_CONT(); } } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_SetBsmFramerate.txt // /////////////////////////////////////////////////////////////////////////// // // BB to set MCU framerate (==BSM ampling rate) // // Note: Script calls the procedure SpireProc_Set_BsmFramerate.txt // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/01/30 V1.0: Initial version // 2009/02/15 V1.1: Replaced input in Hz by input in Dec(Hex), conversion done // in SpireProc_CalcParam_BsmFramerate. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_SetBsmFramerate SPIRE 14025 { int frate = 37; // Specifies the frame rate [Dec(Hex)] bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // // // // // Start BB: // message("4 " + time() + ": SpireBb_SetBsmFramerate started"); message("4 $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); delay(1); // // // // // Set framerate: // SpireProc_Set_BsmFramerate(frate,debug); // // // // // End BB: // SpireMsg(4," " + time() + ": BB SpireBb_SetBsmFramerate ended"); // } // SpirePcalFlash // // $id$ // // This procedure executes a PCAL Flash // // The instrument should be in the PHOTSTBY or SPECSTBY modes before execution of this procedure // and the parameter passed to the procedure should correspond to the initial state // // 09/11/2007 KJK Updated to return MODE to correct value at end of observation // 05/07/2009 KJK: // SPR-1593 - Added flashVersion and debug to input parameters // - Updated call to SpireBbPcalFlash to provide flashVersion and debug // procedure SpirePcalFlash { string flashMode = "PFlash" in ["PFlash","SFlash"]; // Flash mode string flashVersion = "v00"; bool debug = false; }{ // Set Mode to PCAL Flash SpireSetObsMode(flashMode); delay(1); // // execute PCAL Flash SpireBbPcalFlash(flashMode,flashVersion,0,debug); // // reset Mode if(flashMode == "PFlash") { SpireSetObsMode("PHOTSTBY"); } else { SpireSetObsMode("SPECSTBY"); } delay(1); } // CVS comments : $Id: PHOT_aot_prologue.txt,v 1.8 2008/05/06 13:34:53 vanessa Exp $ // Purpose : SetUp of BOLO preceding AOT (but after orbit_prologue) // // CUS author : DAC // Script file : PHOT_aot_prologue.txt // // Input arguments // type name description // // Return values // Type Description // // Description : Conditions and starts SPU // // Dependencies : // // Preconditions : // // Comments : // // History : 0.1 18-jan-2006 DAC // 0.2 21-aug-2007 SRC-3507 Indicate end of BB // 1.0 10-oct-2007 Added input variables after SCR-3628 // 2.0 06-may-2008 Added Gain setup: LOW/HIGH gain obs. // 2.1 23-spe-2008 SCR 4431 data_rate int[] block PHOT_aot_prologue PACS 211 { string set_gain = "LOW"; int comp_mode_blu = 0; int comp_mode_red = 0; int nraw_blu = 3; int nraw_red = 3; bool verbose = true; }{ int timeStart = time(); // Register start of BB WriteBBID($BBID); // Define the elements of time_array int duree_sec = 0; int duree_SRC = 0; int duree_REF = 0; int duree_CAL = 0; int duree_OVR = 0; // Setup SPU bool startSPU = true; PHOT_spu_gain_setup(set_gain,comp_mode_blu,comp_mode_red,nraw_blu,nraw_red,startSPU); data_rate(120.0); // Mark end of BB WriteEndBB(); // Synch bus sync(); // Accumulated duree [milliseconds] int duree_msec = 0; duree_sec = time() - timeStart; // Do nothing for time being if(verbose) { debug_print("PHOT_aot_prologue: " + duree_sec + " [sec]"); } return [duree_sec,duree_SRC,duree_REF,duree_CAL,duree_OVR]; } // CVS comments : $Id: OBCP_chopped_photometry.txt,v 1.6 2007/08/22 10:18:28 dcesarsk Exp $ // Missionphase : PACS AVM ILT Orbit-Operations // // Purpose : OnBoardControlProcedure to perform // chopped photometry // Chopped observations of SRC in the manner: // SRC->REF1->SRC->REF2 // followed by a calibration sequence using the internal // blackbodies // CS1 -> CS2 // User can specify the number of source observing cycles // (nb_SRC_REF), the number of calibration cycles (nb_CS1_CS2) // and how many times the whole sequence shall be repeated // (nb_cycles_obs_cal). // The number of readouts per quiescent chopper position is // the same (nb_rdouts_plateau) within each cycle // // OBCP author : Helmut Feuchtgruber // CUS script : Diego A. Cesarsky // CVS file : OBCP_chopped_photometry.txt from AOT code // // Arguments: // Type Name Description // int nb_SRC_REF p01 Number of observations in OBS loop // int chop_pos_SRC p02 Chopper position for SRC // int nb_rdouts_plateau p03 Number of readouts per chopper position // int chop_pos_REF1 p04 Chopper position for BKG1 // int chop_pos_REF2 p05 Chopper position for BKG2 (may be equal to BKG1) // int nb_cycles_obs_cal p06 Number of obs/cal cycles // int nb_CS1_CS2 p07 Number of observations in CAL loop // int chop_pos_CS1 p08 Chopper position for CS1 // int chop_pos_CS2 p09 Ditto for CS2 // int comp_mode_blu Compression mode BLUE // int comp_mode_red Ditto RED // int chop_def Chopper default position // // // Description : This script mimics the OBCP_CHOPPED_PHOTOMETRY // pseudo script, section 3.1.1 in PACS-ME-LI-005 // This CUS version computes the duration of the // observation, as specified by the input parameters. // It will also send the trigger TC to start the OBCP // // Dependencies : DMC_phot_2_3_chop // WriteBBID // Comments : // // Version : 1.2 21-Jan-2004 Creation by DAC // History : 0.2 23-Jan-2004 Set value for seq_time, removed seq // and seq_time as arguments // : 0.3 08-Aug-2004 Changed variable name as "duration" // is now a reserved name // : 0.4 08-Aug-2004 Rename to block OBCP_etc PACS 4 // 0.5 20-Aug-2004 Use redefined DMC script // 0.6 25-Aug-2004 The BBID is generated and TCed here // 0.7 17-Sep-2004 Use renamed DEC_phot_2_3_chop // 0.8 27-Sep-2004 Use "double" for BOL frequency and associated data // 0.9 7-Oct-2004 Use renamed WriteBBID // 0.91 18-Oct 2004 Normalized variable names // 0.92 9-Nov-2004 DMC now returns [] of times // [duration_rdouts, // duree_SRC, // duree_REF, // duree_CAL, // duree_OVR] // (expressed in nb_of_readouts) // 0.93 10-Dec-2004 True duration must include the fact that // TCs are sent 2 per second, i.e. each TC // takes 1/2 second. Use "time" function to // get actual duration. // obcp_ID is now a string // 1.0 30-Nov-2005 Use computed duration; remove debug_print // 1.1 21-aug-2007 SRC-3507 Indicate end of BB // 1.2 18-feb-2008 DAC Added sync at ebd // int[] block OBCP_chopped_photometry PACS 4 { int nb_SRC_REF = 1; // p01 Number of observations in OBS loop int chop_pos_SRC = 0; // p02 Chopper position for SRCE int nb_rdouts_plateau = 8; // p03 Number of readouts per chopper position int chop_pos_REF1 = -2000; // p04 Chopper position for BKG1 int chop_pos_REF2 = 2000; // p05 Chopper position for BB2 int nb_cycles_obs_cal = 1; // p06 Number of obs/cal cycles int nb_CS1_CS2 = 0; // p07 Number of observations in CAL loop int chop_pos_CS1 = -22680; // p08 Chopper position for CS1 int chop_pos_CS2 = 22680; // p09 Chopper position for CS2 int comp_mode_blu = 0; // Compression mode BLUE channel int comp_mode_red = 0; // Compression mode RED channel int chop_def = 0; // Chopper default position }{ // Starting time int time_start = time(); // Register start of BB WriteBBID($BBID); // Variables that may be used to define various times int duree_SRC = 0; int duree_REF = 0; int duree_CAL = 0; int duree_OVR = 0; // Obtain system parameter from PACSparams // BOL readout frequency [Hz] and readout period [msec] double bol_freq = dlookup("PACSparams","bolo_sample","freq_time"); // string bol_unit = slookup("PACSparams","bolo_sample","unit"); double bol_period = 1000.0 / bol_freq; // debug_print("Bolo sample: " + bol_freq + " " + bol_unit); // debug_print("Bolo period: " + bol_period + "[msec]"); // Obtain duration of an "internal" command [msec] int t_cmd = iceil(dlookup("PACSparams","int_cmd","freq_time")); // Obtain duration of DEC/MEC "communication jitter" [msec] int dmc_margin = iceil(dlookup("PACSparams","dmc_margin","freq_time")); // Obtain duration of OBCP "communication jitter" [msec] int obcp_margin = iceil(dlookup("PACSparams","obcp_margin","freq_time")); // Start tallying the duration of this script [msec] int duration_msec = 0; // OBCP Pseudo Code starts here (accumulate duration_msec [msec] as it goes) // Begin // DEC_WRITE_TIME (DPU_TIME in standard 48 bit format according to PS-ICD) // Here and elsewhere it is assumed that OBCP "internal" TCs take t_cmd // [msec] to be executed duration_msec = duration_msec + t_cmd; duree_OVR = duree_OVR + t_cmd; // SET_TIME duration_msec = duration_msec + t_cmd; duree_OVR = duree_OVR + t_cmd; // DEC_WRITE_SEQ_BUF(ID, LENGTH, DATA, CHECKSUM) duration_msec = duration_msec + t_cmd; duree_OVR = duree_OVR + t_cmd; // Invoke CUS version of DECMEC sequence above (DMC_PHOT_2_3_CHOP) // (only to compute duration!! Hence use only duration related parameters // in the call) // The DMC is number seq_DMC=1 and lasts seq_time [msec] // Duration "duree1" is an array with five elements int[] duree1 = DMC_phot_2_3_chop(nb_SRC_REF,nb_rdouts_plateau,nb_cycles_obs_cal,nb_CS1_CS2); // Convert duration [readouts] into [msec]; add dmc_margin int seq_time = ifloor(double(duree1[0]) * bol_period) + dmc_margin; // Convert other times as well into msec duree_SRC = ifloor(double(duree1[1]) * bol_period); duree_REF = ifloor(double(duree1[2]) * bol_period); duree_CAL = ifloor(double(duree1[3]) * bol_period); duree_OVR = duree_OVR + ifloor(double(duree1[4]) * bol_period) + dmc_margin; // Tally into accumulated duration of OBCP duration_msec = duration_msec + seq_time; // SYNCHRONIZE_ON_DETECTOR(3) duration_msec = duration_msec + t_cmd; duree_OVR = duree_OVR + t_cmd; // DEC_WRITE_TRM_CMP(ID, 1, cmp_par, CHHKSUM) duration_msec = duration_msec + t_cmd; duree_OVR = duree_OVR + t_cmd; // START_SEQUENCE duration_msec(seq_time) duration_msec = duration_msec + t_cmd; duree_OVR = duree_OVR + t_cmd; // WAIT(seq_time) // Check execution status of the sequence and in case of failure stop OBCP // and issue TM(1,8) + event // MOVE_CHOPPER_ABSOLUTE(chop_def) duration_msec = duration_msec + t_cmd; duree_OVR = duree_OVR + t_cmd; // Issue TM(1,7) // Now trigger execution of OBCP // This OBCP is number 4, requires 14 parameters and lasts seq_time [msec] string obcp_ID = "CHOPPED_PHOT"; int obcp_par_nber = 14; int seq_DMC = 1; {int,int}[] grp = [{1,seq_DMC},{2,seq_time},{3,nb_SRC_REF},{4,chop_pos_SRC},{5,nb_rdouts_plateau},{6,chop_pos_REF1},{7,chop_pos_REF2},{8,nb_cycles_obs_cal},{9,nb_CS1_CS2},{10,chop_pos_CS1},{11,chop_pos_CS2},{12,comp_mode_blu},{13,comp_mode_red},{14,chop_def}]; Pacs_DPU_START_OBCP(obcp_ID,obcp_par_nber,grp); // Add the "communication jitter" duration_msec = duration_msec + obcp_margin; duree_OVR = duree_OVR + obcp_margin; // Return total duration [sec] to calling program // Create return time array; convert into [sec] int[] time_array = [duration_msec,duree_SRC,duree_REF,duree_CAL,duree_OVR]; for(int aux = 0 .. 4) { time_array[aux] = Msec2sec(time_array[aux]); } // Set delay() delay(time_array[0]); // Mark end of BB WriteEndBB(); // Sync the bus sync(); // Return OBCP time estimates return time_array; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_CalcParam_PhotPhaseConvert.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to translate user input in deg for bias phase // into nearest Hex values for psw_phase, pmw_phase, plw_phase, and ptc_phase // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/06/09 V0.1: Initial version adapted from // SpireProc_CalcParam_PhotBiasConvert.txt (2008/06/09 V1.3) // 2008/07/03 V0.2: Renumber version; include PTC conversion // 2009/02/01 V1.0: Add debug_print as input // /////////////////////////////////////////////////////////////////////////// int[] procedure SpireProc_CalcParam_PhotPhaseConvert { double input_phase_psw = 0.0 in [0.0,360.0]; // Input PSW Bias Phase [0.0 - 360.0] [deg] double input_phase_pmw = 0.0 in [0.0,360.0]; // Input PMW Bias Phase [0.0 - 360.0] [deg] double input_phase_plw = 0.0 in [0.0,360.0]; // Input PLW Bias Phase [0.0 - 360.0] [deg] double input_phase_ptc = 0.0 in [0.0,360.0]; // Input PTC Bias Phase [0.0 - 360.0] [deg] bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Convert from deg to nearest RAW values: // double conversion_factor = 255.0 / 360.0; // int raw_phase_psw = iround(conversion_factor * input_phase_psw); int raw_phase_pmw = iround(conversion_factor * input_phase_pmw); int raw_phase_plw = iround(conversion_factor * input_phase_plw); int raw_phase_ptc = iround(conversion_factor * input_phase_ptc); // // // // // // Convert nearest RAW values back to deg: // double phase_psw = double(raw_phase_psw) / conversion_factor; double phase_pmw = double(raw_phase_pmw) / conversion_factor; double phase_plw = double(raw_phase_plw) / conversion_factor; double phase_ptc = double(raw_phase_ptc) / conversion_factor; // // // // // Debug printout: // if(debug) { debug_print("Input deg value for PSW/PMW/PLW/PTC phase amplitude: " + input_phase_psw + "/" + input_phase_pmw + "/" + input_phase_plw + "/" + input_phase_ptc); debug_print("Output Hex values for PSW/PMW/PLW/PTC: " + raw_phase_psw + "/" + raw_phase_pmw + "/" + raw_phase_plw + "/" + raw_phase_ptc); debug_print("Commanded deg values for PSW/PMW/PLW/PTC: " + phase_psw + "/" + phase_pmw + "/" + phase_plw + "/" + phase_ptc); } // // // // // Return required values: // return [raw_phase_psw,raw_phase_pmw,raw_phase_plw,raw_phase_ptc]; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_StartPhaseUp.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to configure at the start of // SpirePhoto/Spectro_Cal_PhaseUp. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // // 2009/05/05 V0.1: Initial version adapted from // SpireBb_StartBsmAngleCal (2009/05/05 V0.1), // SpirePhoto_Cal_PhaseUp (2009/03/30 V1.4), and // SpireSpectro_Cal_PhaseUp (2009/03/04 V0.5) // BB includes now to move BSM/SMEC to hold/home. // 2009/07/03 V1.0: Fix bug to allow spectrometer to use script. // 2009/07/10 V1.1: Fix bug SPR-SPIRE-1612 // // Notes: // 1) Scripts assumes that SpireBb_SpecOffsetAuto is run // during INITHOLD or at first POINTING. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_StartPhaseUp SPIRE 14048 { bool phot = true; // Photometer (==tick) or FTS (==untick)? string obsModeQla = "ENG_CAL_OBS11"; string obsMode = "PEngCalObs"; bool isBright = false; // Use settings for bright source (==tick) string version01 = "v00"; // Version in cal table SpireTable_Phot/SpecModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams int hold_chop = 37632; // Chop hold position int hold_jigg = 39520; // Jiggle hold position int smecHomePosn = 3500; // SMEC home position int mclkdiv = 149; // mclkdiv (spec ==~ 121) int biasdiv = 6; // biasdiv (spec ==~ 1) int psw_bias = 62; // int pmw_bias = 62; // int plw_bias = 62; // int ptc_bias = 62; // int ssw_bias = 45; // int slw_bias = 45; // int[] raw_phase_list = [0,0,0,0]; // bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // int mode_id = 0; string obsmode = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB StartPhaseUp configuration started"); SpireMsg(2," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Startup observation: // SpireProc_Set_StartObsAll(obsModeQla); // // // // // In case move SMEC to home: // if(!phot) { // // Calculate available time for possible movement: // int tmove = duration(SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug)) + duration(SpireProc_Set_SpecMode(obsMode,isBright,version01,version02,debug)) + duration(SpireProc_Set_DcuFreqSamp(mclkdiv,biasdiv,phot,debug)) + duration(SpireProc_Set_PhotBias(psw_bias,pmw_bias,plw_bias,ptc_bias,debug)) + duration(SpireProc_Set_PhotPhase(raw_phase_list[0],raw_phase_list[0],raw_phase_list[0],raw_phase_list[0],debug)) + duration(SpireBb_SpecOffsetAuto(false,debug)); // // Calculate max offset for which time is available: // int smecMaxOff = tmove * 500; // Note, 500 is maximum possible SMEC speed. int smecStart = smecHomePosn + smecMaxOff; // Note, formula above only reasonable // when smecHomePosn small compared to 39500 // Safety check: if(smecStart > 39500) { smecStart = 39500; } if(debug) { debug_print("smecStart: " + smecStart); debug_print("smecHomePosn: " + smecHomePosn); debug_print("tmove: " + tmove); } // // Move from maximal offset to home: // SpireProc_SmecMove2Home(smecHomePosn,smecHomePosn + smecMaxOff,debug); } // // // // // Move BSM back to hold: // SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug); // // // // // Initialise instrument (in case to isBright): // if(phot) { SpireProc_Set_PhotMode(obsMode,isBright,version01,version02,debug); } else { SpireProc_Set_SpecMode(obsMode,isBright,version01,version02,debug); } //delay(timeSlewCal); // // // // // Set requested frequency and bias ampl. plus first phase: // SpireProc_Set_DcuFreqSamp(mclkdiv,biasdiv,phot,debug); if(phot) { SpireProc_Set_PhotBias(psw_bias,pmw_bias,plw_bias,ptc_bias,debug); SpireProc_Set_PhotPhase(raw_phase_list[0],raw_phase_list[0],raw_phase_list[0],raw_phase_list[0],debug); } else { SpireProc_Set_SpecBias(ssw_bias,slw_bias,debug); SpireProc_Set_SpecPhase(raw_phase_list[0],raw_phase_list[0],debug); } // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB StartPhaseUp configuration ended"); SpireMsg(1," ..StartPhaseUp took " + (time() - t) + " seconds)"); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////// // // SpireProc_Set_PhotBias // /////////////////////////////////////////////////////////// // // Procedure to configure the photometer detector biases // /////////////////////////////////////////////////////////// // // KJK: // 2009/02/11 V0.1: Initial version // 2009/02/15 V0.2: (MP) Use actual amplitudes as input instead of mode. // Added delay(1). Add some cosmetics to script. // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Set_PhotBias { int psw_bias = 0; // PSW bias amplitud int pmw_bias = 0; // PMW bias amplitud int plw_bias = 0; // PLW bias amplitud int ptc_bias = 0; // PTC bias amplitud bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Define some variables: // string tstr = ""; // // // // // Start procedure: // tstr = SpireTimeStr(time()); SpireMsg(4," " + tstr + ": SpireProc_Set_PhotBias started"); SpireMsg(4," $Id:$"); // // // // // Set the selected bias values: // // Set the bias levels for the three arrays: SpireSendDrcuCmd(0x84010000 + psw_bias,0); SpireSendDrcuCmd(0x84020000 + pmw_bias,0); delay(1); SpireSendDrcuCmd(0x84030000 + plw_bias,0); // // Set the bias for the PTC: SpireSendDrcuCmd(0x84040000 + ptc_bias,0); sync(); // // // // // End procedure: // tstr = SpireTimeStr(time()); SpireMsg(4," " + tstr + ": SpireProc_Set_PhotBias ended"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_EndPcalLoadCurve.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to reconfigure at the end of // SpirePhoto/Spectro_Cal_PcalLoadCurve. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // // 2009/05/07 V1.0: Initial version adapted from // SpireBb_EndBsmAngleCal (2009/05/05 V1.2), // SpirePhoto_Cal_PcalLoadCurve (2009/03/04 V1.4), and // SpireSpectro_Cal_PcalLoadCurve (2009/03/04 V0.5) // Incl. setting dcuFrameNumber and scuFrameNumber back // to continuous to unset setting passed to VM. // 2009/06/05 V1.1: Replace Spire_SEND_DRCU_COMMAND with SpireSendDrcuCmd // as requested in SPR-1482. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_EndPcalLoadCurve SPIRE 14069 { bool phot = true; // Photometer (==tick) or FTS (==untick)? bool isBright = false in [true,false]; // IsBright (==tick) flag string version01 = "v00"; // Version in cal.tab. SpireTable_PhotModeParams string version02 = "v00"; // Version in cal.tab. SpireTable_CommonModeParams bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // int mode_id = 0; string obsmode = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB EndPcalLoadCurve reconfiguration started"); SpireMsg(2," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Set obsstep back to 0: // tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP(0)"); Spire_SET_OBS_STEP(0); // // // // // Set instrument back to Phot/Spec-STBY: // if(phot) { SpireProc_Set_PhotMode("PHTSTBY",isBright,version01,version02,debug); } else { SpireProc_Set_SpecMode("SPECSTBY",isBright,version01,version02,debug); } // // // // // Set number of DCU frames to continuous: // int dcuFrameNumber = 0; if(phot) { dcuFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","PHTSTBY","dcuFrameNumber","v00",debug); } else { dcuFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","SPECSTBY","dcuFrameNumber","v00",debug); } // SpireSendDrcuCmd(0x843d0000 + dcuFrameNumber,0); // // // // // Set number of SCU frames to continuous: // int scuFrameNumber = 0; if(phot) { scuFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","PHTSTBY","scuFrameNumber","v00",debug); } else { scuFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode","SPECSTBY","scuFrameNumber","v00",debug); } SpireSendDrcuCmd(0xa0840000 + scuFrameNumber,0); delay(1); // // // // // End observation: // SpireProc_Set_EndObsAll(phot); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB EndPcalLoadCurve reconfiguration ended"); SpireMsg(1," ..Reconfiguration to " + obsmode + "mode (" + (time() - t) + " seconds)"); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_StartIltPcalFlash.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to configure at the start of // SpirePhoto/Spectro_Cal_IltPcalFlash. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // // 2009/05/06 V0.1: Initial version adapted from // SpireBb_StartBsmAngleCal (2009/05/05 V0.1), // SpirePhoto_Cal_IltPcalFlash (2009/03/04 V1.4), and // SpireSpectro_Cal_IltPcalFlash (2009/03/04 V0.5) // BB includes now to move BSM/SMEC to hold/home. // 2009/05/26 V0.2: Fixed a bug in call to SpireProc_Set_Phot/SpecPhase // and SpireProc_Set_Phot/SpecBias (phase and bias mixed up). // 2009/07/10 V1.0: Fix bug SPR-SPIRE-1612 // // Notes: // 1) Scripts assumes that SpireBb_SpecOffsetAuto is run // during INITHOLD or at first POINTING. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_StartIltPcalFlash SPIRE 14046 { bool phot = true; // Photometer (==tick) or FTS (==untick)? string obsModeQla = "ENG_CAL_OBS01"; string obsMode = "PEngCalObs"; bool isBright = false; // Use settings for bright source (==tick) string version01 = "v00"; // Version in cal table SpireTable_Phot/SpecModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams int hold_chop = 37632; // Chop hold position int hold_jigg = 39520; // Jiggle hold position int smecHomePosn = 3500; // SMEC home position int mclkdiv = 149; // mclkdiv (spec ==~ 121) int biasdiv = 6; // biasdiv (spec ==~ 1) int bias_psw = 62; // int bias_pmw = 62; // int bias_plw = 62; // int bias_ptc = 62; // int phase_psw = 127; // int phase_pmw = 127; // int phase_plw = 127; // int phase_ptc = 127; // int bias_ssw = 45; // int bias_slw = 45; // int phase_ssw = 128; // int phase_slw = 128; // bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // int mode_id = 0; string obsmode = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB StartIltPcalFlash configuration started"); SpireMsg(2," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Startup observation: // SpireProc_Set_StartObsAll(obsModeQla); // // // // // In case move SMEC to home: // if(!phot) { // // Calculate available time for possible movement: // int tmove = duration(SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug)) + duration(SpireProc_Set_SpecMode(obsMode,isBright,version01,version02,debug)) + duration(SpireBb_SpecOffsetAuto(false,debug)) + duration(SpireProc_Set_DcuFreqSamp(mclkdiv,biasdiv,phot,debug)) + duration(SpireProc_Set_SpecPhase(bias_ssw,bias_slw,debug)) + duration(SpireProc_Set_SpecBias(phase_ssw,phase_slw,debug)); // // Calculate max offset for which time is available: // int smecMaxOff = tmove * 500; // Note, 500 is maximum possible SMEC speed. int smecStart = smecHomePosn + smecMaxOff; // Note, formula above only reasonable // when smecHomePosn small compared to 39500 // Safety check: if(smecStart > 39500) { smecStart = 39500; } if(debug) { debug_print("smecStart: " + smecStart); debug_print("smecHomePosn: " + smecHomePosn); debug_print("tmove: " + tmove); } // // Move from maximal offset to home: // SpireProc_SmecMove2Home(smecHomePosn,smecHomePosn + smecMaxOff,debug); } // // // // // Move BSM back to hold: // SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug); // // // // // Initialise instrument (in case to isBright): // if(phot) { SpireProc_Set_PhotMode(obsMode,isBright,version01,version02,debug); } else { SpireProc_Set_SpecMode(obsMode,isBright,version01,version02,debug); } //delay(timeSlewCal); // // // // // Set requested frequency, phase, and bias level: // if(phot) { SpireProc_Set_DcuFreqSamp(mclkdiv,biasdiv,phot,debug); SpireProc_Set_PhotPhase(phase_psw,phase_pmw,phase_plw,phase_ptc,debug); SpireProc_Set_PhotBias(bias_psw,bias_pmw,bias_plw,bias_ptc,debug); } else { SpireProc_Set_DcuFreqSamp(mclkdiv,biasdiv,phot,debug); SpireProc_Set_SpecPhase(phase_ssw,phase_slw,debug); SpireProc_Set_SpecBias(bias_ssw,bias_slw,debug); } // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB StartIltPcalFlash configuration ended"); SpireMsg(1," ..StartIltPcalFlash took " + (time() - t) + " seconds)"); // } // $Id: SpireParallelCoolerRecycle.txt,v 1.1 2008/02/06 14:59:25 dcesarsk Exp $ // // Missionphase : FM RMS // // Purpose : Pacs/Spire cooler recycling as an OBS // // Author : Diego A. Cesarsky, Ken King // // Arguments : None // // Description : Merge of Spire's and PACS cooler recycling scripts // // Dependencies : // // Comments : Spire should be in the REDY mode before execution of this // observation // Version : 0.1 // History : 0.1 22-oct-2007 DAC // : 0.2 6-feb-2008 DAC Start PACS recycling 30 min after SPIRE // Renamed SpireParallelCoolerRecycle.txt procedure SpireParallelCoolerRecycle { }{ // Start observation SpireBbStartObs(); int t0 = time(); // // execute 1st part of Spire's recycle mois_comment("Procedure to recycle SPIRE/PACS Sorption Coolers"); int howLongSpire = SpirePacsBbCoolerRecycle(); mois_comment("SPIRE Cooler Recycle Procedure Started"); // Wait 30 minutes before starting PACS delay(1800); // Now start PACS cooler procedure mois_comment("PACS Cooler Recycle Procedure Started"); //DAC 27/06/08 PACS_BOLO_cool_recycle(); BOLO_cool_recycle(0,0); // End Spire's procedure // Set MODE to REDY mois_comment("Set the SPIRE mode to REDY"); SpireSetObsMode("REDY"); // completion string tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB Cooler Recycle ended"); SpireMsg(1," ..Cooler Recycle (" + (time() - t0) + " seconds)"); // end observation SpireBbEndObs(); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_EndFovMapFpgScan.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to reconfigure at the end of // SpirePhoto/Spectro_Cal_FovMapFpgScan // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // // 2009/05/05 V1.0: Initial version adapted from // SpireBb_EndBsmAngleCal (2009/05/05 V1.2), // SpirePhoto_Cal_FovMapFpgScan (2009/03/04 V1.3), and // SpireSpectro_Cal_FovMapFpgScan (2009/03/04 V0.1) // Incl. setting dcuFrameNumber and mcuFrameNumber back // to continuous to unset setting passed to VM. // 2009/06/05 V1.1: Replace Spire_SEND_DRCU_COMMAND with SpireSendDrcuCmd // as requested in SPR-1482. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_EndFovMapFpgScan SPIRE 14067 { bool phot = true; // Photometer (==tick) or FTS (==untick)? int hold_chop = 37632; // Chop hold position [Dec(Hex)] int hold_jigg = 39520; // Jiggle hod position [Dec(Hex)] bool isBright = false in [true,false]; // IsBright (==tick) flag string version01 = "v00"; // Version in cal.tab. SpireTable_PhotModeParams string version02 = "v00"; // Version in cal.tab. SpireTable_CommonModeParams bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // int mode_id = 0; string obsmode = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB EndFovMapFpgScan reconfiguration started"); SpireMsg(2," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Set obsstep back to 0: // tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP(0)"); Spire_SET_OBS_STEP(0); // // // // // Set instrument back to Phot/Spec-STBY: // if(phot) { SpireProc_Set_PhotMode("PHTSTBY",isBright,version01,version02,debug); } else { SpireProc_Set_SpecMode("SPECSTBY",isBright,version01,version02,debug); } // // // // // Move BSM back to hold: // SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug); // // // // // Set number of DCU frames to continuous: // SpireSendDrcuCmd(0x843d0000,0); // // // // // Set number of MCU frames to continuous: // SpireSendDrcuCmd(0x91c3ffff,0); delay(1); // // // // // End observation: // SpireProc_Set_EndObsAll(phot); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB EndFovMapFpgScan reconfiguration ended"); SpireMsg(1," ..Reconfiguration to " + obsmode + "mode (" + (time() - t) + " seconds)"); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_PhotSetMode.txt // /////////////////////////////////////////////////////////////////////////// // // BB to configure some important instrument parameters // for the photometer depending on the mode. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/02/15 V0.1: Initial version // /////////////////////////////////////////////////////////////////////////// // block SpireBb_PhotSetMode SPIRE 14030 { string obsMode = "POF2"; // Obs mode as defined in calibration files bool isBright = false in [true,false]; // IsBright (==tick) flag string version01 = "v00"; // Version in cal.tab. SpireTable_PhotModeParams string version02 = "v00"; // Version in cal.tab. SpireTable_CommonModeParams bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Define some variables: // string hstr = ""; // a hex string string tstr = ""; // a time string // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": SpireBb_PhotSetMode started"); SpireMsg(2," $Id: $"); hstr = SpireHexStr($BBID,8); SpireMsg(3," BBID = " + hstr); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); sync(); // // // // // Call procedure to set parameters: // SpireProc_Set_PhotMode(obsMode,isBright,version01,version02,debug); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SpireBb_PhotSetMode ended"); SpireMsg(1," ..Set Phot phases (" + (time() - t) + " secs)"); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_SmecMove.txt // /////////////////////////////////////////////////////////////////////////// // // BB to move SMEC to input position and hold // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/11/06 V0.1: Initial version adapted from SpireBb_MoveSmec2Home // (2008/11/02 V0.1) // 2009/02/02 V0.2: (KJK) Updated to be used in all scripts // - added smecCurrposn input parameter to allow // calculation of time to move to end position from // current SMEC position // - replaced call to individual commands by call to new // procedure SpireProc_SmecMove // 2009/02/15 V0.3: (MP) Made some cosmetic changes and extended the // header entry above. // 2009/03/30 V0.4: (MP) Remove unnecessary calibration table name. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_SmecMove SPIRE 14019 { int smecEndPosn = 1000; // final SMEC position in encoder values int smecCurrPosn = 1000; // current SMEC position in encoder values bool debug = false; }{ // // // // // Define some variables: // int t = time(); // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // // // // // Start BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SmecMove started"); SpireMsg(2," $Id: $"); // // // // // Set the BBID: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // // // // Move SMEC to position: // SpireProc_SmecMove(smecEndPosn,smecCurrPosn,debug); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SmecMove ended"); SpireMsg(1," ..BB SmecMove (" + (time() - t) + " seconds)"); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////// // // SpireProc_Exec_PhotStdLoadCurve.txt // /////////////////////////////////////////////////////////// // // Procedure to loop through a list of bias amplitudes // for the 'Phot Standard Load Curve' task // /////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/06/09 V0.1: Initial version adapted from // Mode_ILT_PERF_DAB_P_CPS.txt (v1.3 2008/01/31 23:35:17) // 2008/07/04 V0.2: Renumber version; Include PTC boloms in loop; skip // first setup in SpireBb_PhotFSetupData, as it is already // done during slew // 2008/11/07 V0.3: Remove test number from script // 2009/02/01 V1.0: Add debug_print as input // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Exec_PhotStdLoadCurve { int[] nbiaslist = [0,50,100,255]; // List of raw bias levels in range (0-255) int ftime = 10; // Readout time at each bias level [s] bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // Start the LC bias loop: // for(int l = 0 .. length(nbiaslist) - 1) { // // // // // Safety check: // if(nbiaslist[l] > 255) { nbiaslist[l] = 255; if(debug) { debug_print("Input bias list is corrupt! Raw value > 255 requested!"); } } // // // // // Set bias amplitude: // if(l == 0) { if(debug) { debug_print("Bias already set during slew"); } } else { SpireBb_PhotFSetBiasAmpl(nbiaslist[l],nbiaslist[l],nbiaslist[l],nbiaslist[l],debug); } // // // // // Stop DCU data before resetting offsets: // SpireBb_StopDcuData(); // // // // // // Set offsets: // SpireBb_PhotOffsetAuto(debug); // // // // // Take data: // SpireBb_PhotFTakeData(ftime,debug); // // // // // // Debug printing: // if(debug) { debug_print("Bias level " + nbiaslist[l] + " done."); } } // // } // SpireBbCcuMonitorPeriodRecycle // // $Id:$ // // Building Block to set CCU monitoring period for cooler recycling // block SpireBbCcuMonitorPeriodRecycle SPIRE 11776 { }{ SpireCcuMonitorPeriodRecycle(); sync(); } // SpirePacsBbParallelConfig // // $Id: SpirePacsBbParallelConfig.txt,v 1.1 2006/10/11 10:23:39 kking Exp $ // // Building Block to configure the instrument for Parallel mode operation // // The complete instrument setup operation is divided into two parts: // Configuration: actions that can be executed during the slew to the start // position of the S/C pointing mode. // Initialisation: actions that must be carried out at the S/C intial pointing // position before any observational operations are executed. // // This building Block implements the first part of the setup // block SpirePacsBbParallelConfig SPIRE 8336 { }{ int t = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB Parallel Configuration started"); SpireMsg(2," $Id: SpirePacsBbParallelConfig.txt,v 1.1 2006/10/11 10:23:39 kking Exp $"); // // ..... configuration ..... // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // Set Mode to Parallel tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_MODE_RAW(0x0500)"); Spire_SET_OBS_MODE_RAW(0x500); // // Move BSM to HOLD int bsmHoldChopPosn = ilookup("BSM.txt","Hold","ChopPosn"); int bsmHoldJiggPosn = ilookup("BSM.txt","Hold","JiggPosn"); SpireBsmMove(bsmHoldChopPosn,bsmHoldJiggPosn); // // Time synchronisation tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_RESET_DRCU_COUNTERS_RAW()"); Spire_RESET_DRCU_COUNTERS_RAW(); // // ..... completion ..... // delay(2); // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB Parallel Configuration ended"); SpireMsg(1," ..Parallel Configuration (" + (time() - t) + " seconds)"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpirePhoto_Cal_BsmPcalFlash.txt // /////////////////////////////////////////////////////////////////////////// // // CUS script for: 'Phot BSM PCAL Flash' // // in *basic_fine_pointing* or *no_pointing* mode // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/12/12 V0.1: Initial version adapted from // SPIRE_IST_BSM_PCALFLASH.txt (Sunil email 09/12/08 19:10) // using as template // SpirePhoto_Cal_BsmAngleCal.txt (2008/12/10 V0.5) // 2009/02/02 V1.0: Pass debug_print to some low level scripts. // Add setting of NHK STEP parameter in // SpireProc_Exec_BsmPcalFlash. Set first STEP // already during SLEW and unset at end during FINAL_HOLD. // Use new SpireBb_EndObsAll and SpireBb_StartObsAll. // Read nominal bias frequency and bias divider from new // SpireTable_DetectorSettings.txt. Implemented setting // of datarates. Replace SpireProc_Set_PhotNominal by // SpireProc_Set_FreqSampAmpPhasNominal. Implemented // isBright (+!pointing) setting. Move BSM back to home // at end. Introduce limits for VSM input positions. // Add check to make sure c2>c1. // 2009/02/16 V1.1: Replace call to SpireTable_DetectorSettings by call to // SpireTable_PhotModeParams. Update call to // SpireProc_Exec_BsmPcalFlash with VM table parameters, // which are now read from a calibration file. // Use SpireProc_Set_PhotMode to set instrument to PHTSTBY // during SLEW and FINAL_HOLD. Use new setting of // datarates. // 2009/02/18 V1.2: Adapt to change in call to SpireProc_Exec_BsmPcalFlash // 2009/03/04 V1.3: Add isSerendipity, isPcal, and 8 more dummy parameters // to the script for future use. Allow isBright in // combination with no pointing. // 2009/05/05 V1.4: Add in move BSM to hold at start. Gather procedures at // start and end in separate BB. // 2009/06/05 V1.5: Hardcode STBY 'v00' in EndBB (SPR-1477) // /////////////////////////////////////////////////////////////////////////// // Script assumes that: // // 1) Instrument is in PHOTSTBY // (i.e. bias amplitude, phase, frequency [mclkdiv,biasdiv] are nominal) // // 2) Bias frequency (mclkdiv) and sampling rate (biasdiv) are the same // for all three arrays and could be taken from following cal table: // SpireTable_PhotModeParams.txt // // 3) Home position of BSM can be read from SpireTable_BsmNominalSettings.txt // /////////////////////////////////////////////////////////////////////////// // obs SpirePhoto_Cal_BsmPcalFlash { /* ****************************************************** */ /* USER PARAMETER DEFINITION, CUS SIGNATURE for EX-HSpot */ /* ****************************************************** */ double ra = 0.0 in [0.0,360.0]; // RA of target double dec = 0.0 in [-90.0,90.0]; // DEC of target int naifid = 0; //NAIF identifier: put '0' to use RA/DEC, or correct 'NAIFID' bool pointing = true; // Should telescope 'point' (==tick) or do a 'no pointing' (==untick)? /* */ bool isBright = false; // Use settings for bright source (==tick) string ib = "S14_0"; // Central aperture (defined in SIAM) of raster int c_start = 0x1000 in [0x1000,0xf000]; // RAW chop target start position int c_end = 0xf000 in [0x1000,0xf000]; // RAW chop target end position int c_step = 0x2000; // RAW chop target step in position string version01 = "v00"; // Version in cal table SpireTable_PhotModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams string version03 = "v00"; // Version in cal table SpireTable_BsmNominalSettings string model = "initial"; // Model in cal table SpireTable_BsmNominalSettings bool debug = false; // Allow (==tick) or suppress cus debug_print statements bool isSerendipity = true; // Allow (==tick) serendipity mode to be activated or prohibit (==untick) it (currently not in use)? bool isPcal = true; // Allow (==tick) regular PcalFlash in script or prohibit (==untick) it (currently not in use)?. bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ // ****************************************************** */ // CALCULATE DURATIONS for POINTING STATES */ // ****************************************************** */ // // // // // Check user input for chop/jiggle parameters : // if(c_end < c_start + c_step) { error("End chop is smaller than start chop plus 1*step. Try again!"); } // // // // // Declare some variable: // // Photometer or FTS: bool phot = true; bool fts = !phot; // string tabName = ""; string selCol = ""; string selVal = ""; string tarCol = ""; string version = ""; double scirate = 0.0; double chkrate = 0.0; double nhkrate = 0.0; // int obsStep = 0; // // Hardcoded calibration tables: // string tabName01 = "SpireTable_PhotModeParams.txt"; string tabName02 = "SpireTable_CommonModeParams.txt"; string tabName03 = "SpireTable_BsmNominalSettings.txt"; string tabName04 = "SpireTable_CommandLists.txt"; // // Dummy value for smecHomePosn (needed but not used in phot script!) int smecHomePosn = 3500; // SMEC home position // // // // // Setup mode: // // Set obsMode for QLA: string obsModeQla = "ENG_CAL_OBS02"; // Note: this needs entry in MIB table and in SpireTableInstConfigs.txt // // Set obsMode for datarates: string obsMode = "PEngCalObs"; // Note: this is currently only a maximum value // // // // // Read nominal bias frequency and bias divider: // // Select version flag and set GetTableEntry parameters: version = version01; tabName = tabName01; selCol = "mode"; // Name of column for selecting selVal = obsMode; // Value of 'string' selector // tarCol = "mclkDiv"; int mclkDiv = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "biasDiv"; int biasDiv = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // Calculate nominal sampling rate from mclkdiv and biasdiv: // double mclkdivHz = 1.0E7 / (512.0 * double(mclkDiv + 1)); double biasdivHz = 1.0 / (double(biasDiv) + 1.0) * mclkdivHz; if(debug) { debug_print("Nominal sampling rate is: " + biasdivHz + " [Hz]"); } // // // // // Read BSM home position: // // Select version flag and set GetTableEntry parameters: // version = version03; tabName = tabName03; selCol = "model"; // Name of column for selecting selVal = model; // Value of 'string' selector // // Read hold position from calibration table: tarCol = "chop_0_I"; int hold_chop = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "jigg_0_I"; int hold_jigg = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // Set jigg position during test to hold_jigg: int jiggPosn = hold_jigg; // // // // // Read VM parameters from calibration table: // tabName = tabName04; selVal = "Flash"; int vmId = ilookup(tabName,selVal,"Id"); int vmIndex = ilookup(tabName,selVal,"Index"); int nParms = ilookup(tabName,selVal,"Nparms"); // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // Calculate timing for the pointing request: // // BBs called during slew: int tslewmin = duration(SpireBb_StartBsmPcalFlash(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,debug)); // // BBs carried out when the pointing is reached: if(pointing) { int tinithold = duration(SpireBb_PhotOffsetAuto(debug)); } else { tinithold = duration(SpireBb_PhotOffsetAuto(debug)) + tslewmin; } // // BB carried out during pointing: int tp = duration(SpireProc_Exec_BsmPcalFlash(c_start,c_end,c_step,jiggPosn,mclkDiv,biasDiv,vmId,vmIndex,nParms,fts,debug)); // // BB carried out at the end: int tfinalhold = duration(SpireBb_EndBsmPcalFlash(phot,hold_chop,hold_jigg,isBright,version01,version02,debug)); // // Debug_printing? // if(debug) { debug_print("tslewmin = " + tslewmin); debug_print("tinithold = " + tinithold); debug_print("tpointing = " + tp); debug_print("tfinalhold = " + tfinalhold); } // // ****************************************************** */ // POINTING MODE DECLARATION */ // ****************************************************** */ // // // // // // Set pointing mode: // if(pointing) { int[] ts = basic_fine_pointing(true,tslewmin,tinithold,tfinalhold,ib,naifid,ra,dec,0.0,0.0,tp); } else { ts = no_pointing(true,tinithold,tfinalhold,tp); } // if(debug) { debug_print("Output timing vector from the pointing request: " + ts); } // }{ // ****************************************************** */ // POINTING STATES WITH OBSERVING MODE LOGIC */ // ****************************************************** */ // // // // // Set datarates: // string rateType = "chk"; chkrate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); ess_hk_data_rate(chkrate); // rateType = "nhk"; // nhkrate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); non_ess_hk_data_rate(nhkrate); // rateType = "sci"; scirate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); data_rate(scirate); // if(debug) { debug_print("Set CHK datarate to: " + chkrate); debug_print("Set NHK datarate to: " + nhkrate); debug_print("Set SCI datarate to: " + scirate); } // // Start the state_machine: // int[] state = [0]; // while(state[0] >= 0) { if(debug) { debug_print("Current state: " + state); } state = next_state(); if(debug) { debug_print("Next state: " + state); } // if(state[0] == 1) { // STATE = SLEW (Spacecraft is slewing ) // // // // // Startup observation: // SpireBb_StartBsmPcalFlash(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,debug); // //delay(timeSlewCal); } if(state[0] == 2) { // STATE = INIT_HOLD ( spacecraft is idling at source ) // // // // // If no pointing observation do stuff here which is // done nominally during SLEW: // if(!pointing) { // // // // // Startup observation: // SpireBb_StartBsmPcalFlash(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,debug); } // // // // // Set offsets: // SpireBb_PhotOffsetAuto(debug); // //delay(tinithold); // } if(state[0] == 3) { // STATE = POINT ( spacecraft is at nominal RA,DEC (staring, raster) ) // // // // // // Execute loop of BSM Pcal flashes: // SpireProc_Exec_BsmPcalFlash(c_start,c_end,c_step,jiggPosn,mclkDiv,biasDiv,vmId,vmIndex,nParms,fts,debug); // //delay(tp); // } if(state[0] == 5) { // STATE = FINAL_HOLD ( "sky" observation ends, performing final activ.) // // // // // Set scientific datarate back to zero: // data_rate(0.0); // // // // // Reconfigure at the end (incl. resetting of OBSID and BBIB): // // Hardcode STBY values for resetting (SPR-1477): // version01 = "v00"; version02 = "v00"; version03 = "v00"; model = "initial"; // SpireBb_EndBsmPcalFlash(phot,hold_chop,hold_jigg,isBright,version01,version02,debug); } if(state[0] == -1) { // STATE = END ( end of the pointing/commanding part of the code ) // } } } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpirePhoto_Cal_PcalLevelCheck.txt // /////////////////////////////////////////////////////////////////////////// // // CUS script for: 'Phot PCAL Level Ceck' // // in *basic_fine_pointing* mode // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/06/10 V0.1: Initial version adapted from // Mode_ILT_PERF_CPT_P.tcl (v 1.12 2006/03/23 17:14:58) // 2008/07/04 V0.2: Renumber version // 2008/08/01 V0.3: Change number of PCAL flash cycles and change flash levels // 2008/08/12 V0.4: Remove test number; add additional PCAL level and // check levels with ComP plan; take into account renaming // of low level script SpireProc_CalcParam_PhotPcalFlash // and calibration table SpireTable_PhotPcalCurrentConvCoef // 2008/11/11 V0.5: Allow 'no pointing' as input option; Adapt debug printing // 2008/11/12 V0.6: Implement mode setting; Add isBright // 2009/02/02 V1.0: Add debug_print as input and pass it to some low // level scripts. Add setting of NHK STEP parameter // in SpireProc_Exec_PcalLevelCheck. Set first STEP // already during SLEW and unset at end during INIT_HOLD. // Use new SpireBb_EndObsAll and SpireBb_StartObsAll. // Read nominal bias frequency and bias divider from new // SpireTable_DetectorSettings.txt. Implemented setting // of datarates. Replace SpireProc_Set_PhotNominal by // SpireProc_Set_FreqSampAmpPhasNominal. Fix bug with // implementation of 'no pointing' option. Implemented // isBright (+!pointing) setting. // 2009/02/17 V1.1: Replace call to SpireTable_DetectorSettings by call to // SpireTable_PhotModeParams. New setting of datarates. // Use SpireBb_PhotSetMode to set to PHOTSTBY during // SLEW and FINAL_HOLD. Read boresight from // SpireTable_OpsParms. Read Pcal levels from new calibration // table. Read VM table parameters now from a cal. table. // 2009/02/18 V1.2: Adapt to change in call to SpireProc_Exec_PcalLevelCheck. // 2009/02/19 V1.3: Elevate version05 to input. Fixed bug of not doing // an Offset during INIT_HOLD. // 2009/03/04 V1.4: Add isSerendipity, isPcal, and 8 more dummy parameters // to the script for future use. Allow isBright for no // pointing observation. // 2009/05/07 V1.5: Add in move BSM to hold at start. Gather procedures at // start and end in separate BB. // 2009/05/11 V1.6: Elevate Pcal flash period and number of cycles to input. // 2009/06/05 V1.7: Hardcode STBY 'v00' in EndBB (SPR-1477) // /////////////////////////////////////////////////////////////////////////// // // Script assumes that: // // 1) Instrument is in PHOTSTBY at beginning // (i.e. bias amplitude, phase, frequency [mclkdiv,biasdiv] are nominal) // // 2) Nominal bias frequency and sampling rate are read from // following calibration table: SpireTable_PhotModeParams.txt // // 3) PCAL bias calibration coefficients are read from following cal table: // SpireTable_PcalCurrentConvCoef.txt // // 4) PCAL bias levels are read from following cal table: // SpireTable_PcalLevelCheckLevels.txt // // 5) Boresight of array are read from following cal table: // SpireTable_OpsParms.txt // /////////////////////////////////////////////////////////////////////////// // obs SpirePhoto_Cal_PcalLevelCheck { /* ****************************************************** */ /* USER PARAMETER DEFINITION, CUS SIGNATURE for EX-HSpot */ /* ****************************************************** */ /* */ double ra = 0.0 in [0.0,360.0]; // RA of target double dec = 0.0 in [-90.0,90.0]; // DEC of target bool isBright = false; // Use settings for bright source (==tick) bool pointing = true; // Should telescope 'point' (==tick) or do a 'no pointing' (==untick)? /* */ int period = 4000; // PCAL Flash *FULL* period (high+low bias) [millisec] int ncycles = 15; // PCAL Flash Number of cycles string version01 = "v00"; // Version in cal table SpireTable_PhotModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams string version03 = "v00"; // Version in cal table SpireTable_PcalLevelCheckLevels string version05 = "v00"; // Version in cal table SpireTable_OpsParms.txt bool debug = false; // Allow (==tick) or suppress cus debug_print statements bool isSerendipity = true; // Allow (==tick) serendipity mode to be activated or prohibit (==untick) it (currently not in use)? bool isPcal = true; // Allow (==tick) regular PcalFlash in script or prohibit (==untick) it (currently not in use)?. bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ // // // // // Declare some variable: // // Photometer or FTS: bool phot = true; bool fts = !phot; // string tabName = ""; string selCol = ""; string selVal = ""; string tarCol = ""; string version = ""; double scirate = 0.0; double chkrate = 0.0; double nhkrate = 0.0; // int obsStep = 0; // // Hardcoded calibration tables: // string tabName01 = "SpireTable_PhotModeParams.txt"; string tabName02 = "SpireTable_CommonModeParams.txt"; string tabName03 = "SpireTable_PcalLevelCheckLevels.txt"; string tabName04 = "SpireTable_CommandLists.txt"; string tabName05 = "SpireTable_OpsParms.txt"; string tabName06 = "SpireTable_BsmNominalSettings.txt"; // // Currently hardcoded version and model parameter: // string version06 = "v00"; // Version in cal table SpireTable_BsmNominalSettings string model = "initial"; // Model in cal table SpireTable_BsmNominalSettings // // Dummy value for Spec script: // (needed but not used in phot script!) // int smecHomePosn = 3500; // SMEC home position // // // // // Setup mode: // // Set obsMode for QLA: string obsModeQla = "ENG_CAL_OBS09"; // Note: this needs entry in MIB table and in SpireTableInstConfigs.txt // // Set obsMode for datarates: string obsMode = "PEngCalObs"; // Note: this is currently only a maximum value // // // // // Read BSM home parameters: // // Select version flag and set GetTableEntry parameters: // version = version06; tabName = tabName06; selCol = "model"; // Name of column for selecting selVal = model; // Value of 'string' selector // // Read hold position from calibration table: // tarCol = "chop_0_I"; int hold_chop = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "jigg_0_I"; int hold_jigg = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // ****************************************************** */ // CALCULATE DURATIONS for POINTING STATES */ // ****************************************************** */ // // // // // Read nominal bias frequency and bias divider: // // Select version flag and set GetTableEntry parameters: version = version01; tabName = tabName01; selCol = "mode"; // Name of column for selecting selVal = obsMode; // Value of 'string' selector // tarCol = "mclkDiv"; int mclkdiv = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); tarCol = "biasDiv"; int biasdiv = SpireProc_GetTableEntryInt(tabName,selCol,selVal,tarCol,version,debug); // // Calculate nominal sampling rate from mclkdiv and biasdiv: // double mclkdivHz = 1.0E7 / (512.0 * double(mclkdiv + 1)); double biasdivHz = 1.0 / (double(biasdiv) + 1.0) * mclkdivHz; if(debug) { debug_print("Nominal sampling rate is: " + biasdivHz + " [Hz]"); } // // // // // // Read VM parameters from calibration table: // tabName = tabName04; selVal = "Flash"; int vmId = ilookup(tabName,selVal,"Id"); int vmIndex = ilookup(tabName,selVal,"Index"); int nParms = ilookup(tabName,selVal,"Nparms"); // // // // // Initialize PCAL variables with their default values: // // PCAL Flash FULL period (high and low bias) in millisec: // int period = 4000; // // Number of cycles: // V0.2: int ncycles = 7; // from V0.3 on: // int ncycles = 15; // // --> PCAL setup parameters now in calibration file or input parameters. // // DCU data mode (default = PF == 0; SF == 4) int ndcumode = 0; // // SCU sampling rate (f =80Hz/(1+scumode)) int scumode = 0; // // // // // Define/retrieve the list of PCAL biases for each of the flashes in mA: // double[] low_bias = [0.0]; // V0.2: //double[] high_bias = [1.0,2.0,3.0,4.0,5.0,6.0,7.0]; // V0.3: //double[] high_bias = [0.35,0.7,1.05,1.4,1.75,2.1,2.45,2.8,3.15,3.5,3.85,4.2,4.55,4.9,5.25,5.6,5.95,6.3,6.65,7.0]; // double[] high_bias = []; int index = 0; tabName = tabName03; selCol = "version"; selVal = version03; tarCol = "level"; string[] searchCol = scolumn(tabName,selCol); double[] targetCol = dcolumn(tabName,tarCol); int size = table_size(tabName); // // Loop through table to find matching entries: // for(int j = 0 .. size - 1) { if(searchCol[j] == selVal) { high_bias[index] = targetCol[j]; index = index + 1; } } // // Safety check: // if(length(high_bias) == 0) { error("No PCAL bias level selected! Check version with entries in calibration table SpireTable_PcalLevelCheckLevels.txt"); } // // // // // Predefine version in SpireTable_PcalCurrentConvCoef.txt: // string ver_b = "v01"; if(debug) { debug_print("The nominal version in SpireTable_PcalCurrentConvCoef.txt is v01"); } // // // // // Retrieve PCAL bias calibration coefficients: // double[] coeff = [0.0]; coeff[0] = dlookup("SpireTable_PcalCurrentConvCoef.txt",ver_b,"c_0"); coeff[1] = dlookup("SpireTable_PcalCurrentConvCoef.txt",ver_b,"c_1"); // // // // // Calculate RAW PCAL bias values for each of the flashes from mA list: // int[] raw_low_bias = [0]; int[] raw_high_bias = [0]; for(int i = 0 .. length(high_bias) - 1) { raw_low_bias[i] = 0; raw_high_bias[i] = iround((high_bias[i] * 0.0010 - coeff[0]) / coeff[1]); } if(debug) { debug_print("High bias levels in mA are: " + high_bias); debug_print("Raw high bias levels to check are: " + raw_high_bias); debug_print("Raw low bias level to check is: " + raw_low_bias); } // // // // // Deduce number of DCU samples, SCU samples and DCU sample delay based on mclkdiv and biasdiv: // int[] flash_params = SpireProc_CalcParam_PcalFlash(period,mclkdiv,biasdiv,debug); int dcusamples = flash_params[0]; int scusamples = flash_params[1]; int dcudelay = flash_params[2]; if(debug) { debug_print("//////////////////////////////////////////////////////////////"); debug_print(""); debug_print("CALCULATED DCU SAMPLES : " + dcusamples); debug_print("CALCULATED SCU SAMPLES : " + scusamples); debug_print("CALCULATED SAMP DELAY : " + dcudelay + "microsec"); debug_print(""); debug_print("//////////////////////////////////////////////////////////"); } // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // Calculate timing for the pointing request: // // BBs called during slew: int tslewmin = duration(SpireBb_StartPcalLevelCheck(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,debug)); // // BBs carried out when the pointing is reached: if(pointing) { int tinithold = duration(SpireBb_PhotOffsetAuto(debug)); } else { tinithold = duration(SpireBb_PhotOffsetAuto(debug)) + tslewmin; } // // BB carried out during pointing: int tp = duration(SpireProc_Exec_PcalLevelCheck(vmId,vmIndex,nParms,raw_low_bias,raw_high_bias,ncycles,period,ndcumode,dcusamples,dcudelay,scumode,scusamples,debug)); // // BB carried out at the end: int tfinalhold = duration(SpireBb_EndPcalLevelCheck(phot,isBright,version01,version02,debug)); // // // // // Debug printing: // if(debug) { debug_print("tslewmin = " + tslewmin); debug_print("tinithold = " + tinithold); debug_print("tpointing = " + tp); debug_print("tfinalhold = " + tfinalhold); } // // ****************************************************** */ // POINTING MODE DECLARATION */ // ****************************************************** */ // // // // // Lookup boresight: // tabName = tabName05; selCol = "mode"; selVal = obsMode; tarCol = "Boresight"; version = version05; string ib = SpireProc_GetTableEntryString(tabName,selCol,selVal,tarCol,version,debug); // // // // // Set pointing mode: // if(pointing) { int[] ts = basic_fine_pointing(true,tslewmin,tinithold,tfinalhold,ib,0,ra,dec,0.0,0.0,tp); } else { ts = no_pointing(true,tinithold,tfinalhold,tp); } // if(debug) { debug_print("Output timing vector from the pointing request: " + ts); } // }{ // ****************************************************** */ // POINTING STATES WITH OBSERVING MODE LOGIC */ // ****************************************************** */ // // // // // Set datarates: // string rateType = "chk"; chkrate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); ess_hk_data_rate(chkrate); // rateType = "nhk"; // nhkrate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); non_ess_hk_data_rate(nhkrate); // rateType = "sci"; scirate = SpireProc_CalcParam_PhotDataRates(rateType,obsMode,version01,version02,debug); data_rate(scirate); // if(debug) { debug_print("Set CHK datarate to: " + chkrate); debug_print("Set NHK datarate to: " + nhkrate); debug_print("Set SCI datarate to: " + scirate); } // // Start the state_machine: // int[] state = [0]; // while(state[0] >= 0) { if(debug) { debug_print("Current state: " + state); } state = next_state(); if(debug) { debug_print("Next state: " + state); } // if(state[0] == 1) { // STATE = SLEW ( Spacecraft is slewing ) // // // // // Startup observation: // SpireBb_StartPcalLevelCheck(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,debug); // //delay(timeSlewCal); } if(state[0] == 2) { // STATE = INIT_HOLD ( spacecraft is idling at source ) // // // // // // If no pointing observation do stuff here which is // done nominally during SLEW: // if(!pointing) { // // // // // Startup observation: // SpireBb_StartPcalLevelCheck(phot,obsModeQla,obsMode,isBright,version01,version02,hold_chop,hold_jigg,smecHomePosn,debug); // } // // // // // Set offsets: // SpireBb_PhotOffsetAuto(debug); // //delay(tinithold); // } if(state[0] == 3) { // STATE = POINT ( spacecraft is at nominal RA,DEC (staring, raster) ) // // // // // Execute sequence of PCAL flashes: // SpireProc_Exec_PcalLevelCheck(vmId,vmIndex,nParms,raw_low_bias,raw_high_bias,ncycles,period,ndcumode,dcusamples,dcudelay,scumode,scusamples,debug); // //delay(tp); // } if(state[0] == 5) { // STATE = FINAL_HOLD ( "sky" observation ends, performing final activ.) // // // // // Set scientific datarate back to zero: // data_rate(0.0); // // // // // Reconfigure at the end (incl. resetting of OBSID and BBIB): // // Hardcode STBY values for resetting (SPR-1477): // version01 = "v00"; version02 = "v00"; // SpireBb_EndPcalLevelCheck(phot,isBright,version01,version02,debug); // } if(state[0] == -1) { // STATE = END ( end of the pointing/commanding part of the code ) // } } } // SpireEngREDYtoSPEC_STBY // // $id$ // // This observation puts the instrument into the SPEC_STBY mode // // The instrument should be in the REDY mode before execution of this observation // // // 28/04/2009 KJK: first version // 08/06/2009 KJK: modified to allow input of SCAL status and a version // 12/07/2009 MP: Changed default stabilisationTime (SCR-SPIRE-1632) // 13/07/2009 MP: Introduce wait time after SMEC on as input (SCR-SPIRE-1638) // obs SpireEngREDYtoSPEC_STBY { int jfet_heater_V = 0; // Default jfet heater voltage at switch on string scal = "Default" in ["Default","SCAL2","SCAL4","None"]; // SCAL int scalTemp = -1; // SCAL temperature int stabilisationTime = 120; // time (secs) to allow Detectors to stabilise before starting observations int smecWait = 1200; // Wait time after switch-on of SMEC [s] bool sampleDetectors = false; // sample detectors during the stabilisation period string bsmModel = "initial"; string bsmVersion = "v00"; string smecVersion = "v00"; string detVersion = "v00"; string vssVersion = "v00"; string scalVersion = "v00"; bool debug = false; bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ int t = duration(SpireBbStartObs()) + duration(SpireREDYtoSPEC_STBY(jfet_heater_V,scal,scalTemp,stabilisationTime,smecWait,sampleDetectors,bsmModel,bsmVersion,smecVersion,detVersion,vssVersion,scalVersion,debug)) + duration(SpireBbEndObs()); int[] ts = no_pointing(true,0,0,t); }{ int[] state = [0]; while(state[0] >= 0) { state = next_state(); if(state[0] == 3) { SpireBbStartObs(); SpireREDYtoSPEC_STBY(jfet_heater_V,scal,scalTemp,stabilisationTime,smecWait,sampleDetectors,bsmModel,bsmVersion,smecVersion,detVersion,vssVersion,scalVersion,debug); SpireBbEndObs(); } } } // SpirePhotoSmall // // $Id:$ // // Implementation of a n-point Jiggle map observation with nodding // // Assumptions: // 1. the instrument is in the PHOT_STBY configuration on entry // 2. nodding is used // // This mode is based on a partial jiggle map operation (nominally 16 point out of 64 for the complete map), // which is executed at each nod position. // A set of two nod positions constitutes a nod cycle, which may be repeated. // The minimum observation consists of executing this set for each partial jiggle map // This may be repeated more than once to build up the required signal to noise ratio // // 04 November 2008: added data_rate commands // 10/02/2009 KJK: added new parameters to SpirePOF3Pointing, SpirePOF3Config, SpirePOF3End // 10/03/2009 KJK: // SCR 1274, add additional dummy parameters // Update input API to include versions for all cal tables // 11/05/2009 KJK: // Updated to use new calibration Tables: SpireTable_OpsParms.txt and SpireTable_SpireParams.txt // 03/07/2009 KJK: // Added configuration input parameters to pass to SpirePOF3Config, SpirePOF3Pointing and SpirePOF3End // 05/07/2009 KJK: // SPR-1593 - Updated calls to SpirePOF3Pointing and SpireBbPcalFlash to use flashVersion // 22/07/2009 SDS: // SCR-1670 - Added option to load new JM64 table which has +/- 126 arcseconds chop throw // // 27/07/2009 SDS: // Change the default value of the boolean pBool1 from true to false (Load 64-Point Jiggle Map Table?) // 28/07/2009 SDS: // Added chopVersion parameter to SpireBbPOF3end to be able to set the Chop PID parameters back to their // nominal values {int,int,int,int} obs SpirePhotoSmall { double ra = 0.0 in [0.0,360.0]; // RA of target double dec = 0.0 in [-90.0,90.0]; // DEC of target int naifid = 0; // NAIF identifier string source = "small" in ["point","small","large"]; // source type bool choppingAvoidOn = false; // is chopping avoidance selected int choppingAvoidNumber = 0 in [0,3]; // the number of chopping avoid angles selected double choppingAvoidFrom1 = 0.0 in [0.0,360.0]; double choppingAvoidTo1 = 0.0 in [0.0,360.0]; double choppingAvoidFrom2 = 0.0 in [0.0,360.0]; double choppingAvoidTo2 = 0.0 in [0.0,360.0]; double choppingAvoidFrom3 = 0.0 in [0.0,360.0]; double choppingAvoidTo3 = 0.0 in [0.0,360.0]; int nRepetitions = 1 in [1,300]; // number of map repeats double sourceFluxPSW = -1.0; double sourceFluxPMW = -1.0; double sourceFluxPLW = -1.0; double sourceBrightPSW = -1.0; double sourceBrightPMW = -1.0; double sourceBrightPLW = -1.0; bool isBright = false; // Use settings for bright source (==tick) int nMaps = 1; // total number of number of jiggle maps to perform int nCycles = 1; // number of nod cycles per map int nNodInts = 1; // number of times to repeat NJigg jiggles at each nod position int nCal = 99999; // number of nod cycles per Gyro calibration int nFlash = 999999; // number of nod cycles per PCAL flash string spireVersion = "v00"; // Version in cal table SpireTable_SpireParms string opsVersion = "v00"; // Version in cal table SpireTable_OpsParms string flashVersion = "v00"; // Version in cal table SpireTable_FlashParms string chopVersion = "v00"; // Version in cal table SpireTable_BsmNominalSettings.txt string photVersion = "v00"; // Version in cal table SpireTable_PhotModeParams.txt string comVersion = "v00"; // Version in cal table SpireTable_CommonModeParams.txt bool debug = false; // debug messages flag bool pBool1 = false; // Load 64-Point Jiggle Map Table? bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ // ***************** // check user inputs // ***************** if(source != "small") { error("SpirePhotoSmall: Source is not small"); } // ***************** // set constants // ***************** string obsMode = "POF3"; bool isPhot = true; // is a photometer observation double yOffset = 0.0; // offset to observation position from target in Y direction (arcsecs) double zOffset = 0.0; // offset to observation position from target in Z direction (arcsecs) // // ***************************************** // set up telescope pointing mode // ***************************************** // // ***** operating mode parameters ***** string ib = SpireProc_GetTableEntryString("SpireTable_OpsParms.txt","mode",obsMode,"Boresight",opsVersion,debug); // instrument boresight double deltaY = SpireProc_GetTableEntryDouble("SpireTable_OpsParms.txt","mode",obsMode,"DeltaY",opsVersion,debug); // offset to pixel centre from boresight in Y direction (arcsecs) double deltaZ = SpireProc_GetTableEntryDouble("SpireTable_OpsParms.txt","mode",obsMode,"DeltaZ",opsVersion,debug); // offset to pixel centre from boresight in Z direction (arcsecs) bool fixed = SpireProc_GetTableEntryBool("SpireTable_OpsParms.txt","mode",obsMode,"Fixed",opsVersion,debug); // pattern angle definition double pattNod = SpireProc_GetTableEntryDouble("SpireTable_OpsParms.txt","mode",obsMode,"Patt",opsVersion,debug); // direction of nod double chopThrow = SpireProc_GetTableEntryDouble("SpireTable_OpsParms.txt","mode",obsMode,"D1",opsVersion,debug); // nod separation int jiggleTable = SpireProc_GetTableEntryInt("SpireTable_OpsParms.txt","mode",obsMode,"TableId",opsVersion,debug); // Jiggle Table ID int jiggleSize = SpireProc_GetTableEntryInt("SpireTable_OpsParms.txt","mode",obsMode,"TableSize",opsVersion,debug); // Jiggle Table length int nChops = SpireProc_GetTableEntryInt("SpireTable_OpsParms.txt","mode",obsMode,"NChops",opsVersion,debug); // number of chop cycles per jiggle position int nJiggs = SpireProc_GetTableEntryInt("SpireTable_OpsParms.txt","mode",obsMode,"NJiggs",opsVersion,debug); // number of jiggle positions per nod position int nNodPosns = SpireProc_GetTableEntryInt("SpireTable_OpsParms.txt","mode",obsMode,"NNodPosns",opsVersion,debug); // number of nod positions in a nod cycle bool initFlash = SpireProc_GetTableEntryBool("SpireTable_SpireParams.txt","mode",obsMode,"InitFlash",opsVersion,debug); // initial flash flag bool endFlash = SpireProc_GetTableEntryBool("SpireTable_SpireParams.txt","mode",obsMode,"EndFlash",opsVersion,debug); // final flash flag double cycTime = SpireProc_GetTableEntryDouble("SpireTable_OpsParms.txt","mode",obsMode,"SrcTime",opsVersion,debug); // effective on source integration time per complete map // // ***** pointing mode timing parameters ***** // {int,int,int,int,int,int,int} pof3Point = SpirePOF3Pointing(nMaps,nCycles,nNodInts,nCal,nFlash,isBright,flashVersion,photVersion,comVersion,debug,pBool1,chopVersion); int tSlewMin = pof3Point{0}; int tInitHold = pof3Point{1}; int tFinalHold = pof3Point{2}; int nMoves = pof3Point{3}; int tp = pof3Point{4}; int tHold = pof3Point{5}; int nHold = pof3Point{6}; // // ***** fetch timing information ***** // int tFlash = duration(SpireBbPcalFlash("PFlash",flashVersion,0,debug)); // time for a PCAL flash int tSerendipity = duration(SpireBbPhotSerendipity("POF3",0)); // minimum time for a serendipity observation // // ****** execute telescope pointing mode ****** // int[] ts = nodding_pointing(true,tSlewMin,tInitHold,tFinalHold,ib,naifid,ra,dec,fixed,pattNod,yOffset + deltaY,zOffset + deltaZ,nMaps * nCycles * nNodPosns / 2,chopThrow,tp,tp,0,0,tHold,nHold,false); // }{ // ***************************************** // Display input parameters // ***************************************** SpireMsg(3," POF3 Input values:"); SpireMsg(3," ..RA: " + ra); SpireMsg(3," ..Dec: " + dec); SpireMsg(3," ..NAIF ID: " + naifid); SpireMsg(3," ..Y Offset: " + yOffset); SpireMsg(3," ..Z Offset: " + zOffset); SpireMsg(3," ..No of Map Repeats: " + nMaps); SpireMsg(3," ..No of Nod Cycles per Map: " + nCycles); SpireMsg(3," ..No of Ints per Nod Posn: " + nNodInts); // SpireMsg(3," ..No of Nod Cycles between Gyro Calibrations: " + nCal); SpireMsg(3," ..No of Nod Cycles between Flashes: " + nFlash); SpireMsg(3," POF3 Fixed values:"); SpireMsg(3," ..ib: " + ib); SpireMsg(3," ..deltaY: " + deltaY); SpireMsg(3," ..deltaZ: " + deltaZ); SpireMsg(3," ..fixed: " + fixed); SpireMsg(3," ..pattNod: " + pattNod); SpireMsg(3," ..chopThrow: " + chopThrow); SpireMsg(3," ..jiggleTable: " + jiggleTable); SpireMsg(3," ..jiggleSize: " + jiggleSize); SpireMsg(3," ..nChops: " + nChops); SpireMsg(3," ..nJiggs: " + nJiggs); SpireMsg(3," ..nNodInts: " + nNodInts); SpireMsg(3," ..nNodPosns: " + nNodPosns); SpireMsg(3," ..initFlash: " + initFlash); SpireMsg(3," ..endFlash: " + endFlash); SpireMsg(3," Composite Nodding Pointing Mode Input values:"); SpireMsg(3," ..tSlewMin: " + tSlewMin); SpireMsg(3," ..tInitHold: " + tInitHold); SpireMsg(3," ..tFInalHold: " + tFinalHold); SpireMsg(3," ..tp: " + tp); SpireMsg(3," ..tHold: " + tHold); SpireMsg(3," ..nHold: " + nHold); SpireMsg(3," Composite Nodding Pointing Mode Output values:"); SpireMsg(3," ..tobs: " + ts[0]); SpireMsg(3," ..tslew: " + ts[1]); SpireMsg(3," ..tnod: " + ts[2]); SpireMsg(3," ..tss: " + ts[3]); SpireMsg(3," ..tload: " + ts[4]); SpireMsg(3," ..tend: " + ts[5]); // ***************************************** // execute observation // ***************************************** SpireMsg(0,"Observation Start"); SpireMsg(0," Uses observing mode POF3 (n-point Jiggle Map)"); SpireMsg(3," $Id: SpirePhotoSmall.txt,v 1.11 2007/08/01 15:31:09 kking Exp $"); data_rate(0.0); double chkrate = dlookup("Datarates.txt","POF3","CHK"); ess_hk_data_rate(chkrate); double nhkrate = dlookup("Datarates.txt","POF3","NHK"); non_ess_hk_data_rate(nhkrate); // //??p pointing file generation ------------------------------ double pos = 90.0; //??p double[] rdp0 = PtOffset([ra,dec,pos],zOffset,yOffset,0.0,false); //??p pointing file generation ------------------------------ // int tslew = ts[1]; // slew time string tstr = ""; // time string bool holdFlag = false; // true when holding at nod position int otf = 0x8000; // On Target Flag int nf = 0x4000; // Nod Flag int step = 0x0; // value of STEP parameter double srcTime = 0.0; // total on source integration time int np = 0; // pointing counter int npart = 0; double s = 0.0; int[] state = [0]; while(state[0] >= 0) { state = next_state(); if(state[0] == 1) { // *********************** SLEWING tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " Slewing to start position"); // set up observation parameters SpireBb_StartObsAll(obsMode); // perform serendipity operation if possible if(tslew > tSerendipity + tSlewMin) { SpireBbPhotSerendipity(obsMode,tslew - tSlewMin - 2); } // configure instrument for operations SpireBbPOF3Config(obsMode,isBright,pBool1,chopVersion,photVersion,debug); } if(state[0] == 2) { // *********************** INITIAL HOLD tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " Initialising Instrument"); // initialise instrument SpireBbPOF3Init(); // calibrate if necessary if(initFlash || nFlash < nCycles) { tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " PCAL Calibration inserted"); SpireBbPcalFlash("PFlash",flashVersion,otf,debug); } } if(state[0] == 5) { // *********************** FINAL HOLD tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " Reconfiguring Instrument"); // calibrate if necessary if(endFlash || nFlash < nCycles) { tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " PCAL Calibration inserted"); SpireBbPcalFlash("PFlash",flashVersion,otf | np,debug); } // reconfigure back to PHOT_STBY configuration SpireBbPOF3End("PHTSTBY",isBright,photVersion,comVersion,chopVersion,debug); SpireBb_EndObsAll(isPhot); } if(state[0] == 6) { // *********************** HOLD tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " PCAL Calibration inserted"); SpireBbPcalFlash("PFlash",flashVersion,otf | np,debug); } if(state[0] == 3) { // *********************** POINTING //??p pointing file generation ------------------------------ //??p PtOutput(rdp0); //??p pointing file generation ------------------------------ tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " Instrument at Pointing Position"); SpireMsg(2," " + tstr + " Start Jiggles " + np); step = otf; npart = np / nNodPosns % (jiggleSize / nJiggs); s = SpireBbJiggle("POF3",jiggleTable,npart * nJiggs,nJiggs,nNodInts,step); srcTime = srcTime + s; np = np + 1; step = 0; SpireBbMove(step); } if(state[0] == 7) { // *********************** NOD //??p pointing file generation ------------------------------ //??p PtNod(rdp0,patt,d1,patt,false,false); //??p pointing file generation ------------------------------ tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " Instrument at Nod Position"); SpireMsg(2," " + tstr + " Start Jiggles " + np); step = nf | otf; npart = np / nNodPosns % (jiggleSize / nJiggs); s = SpireBbJiggle("POF3",jiggleTable,npart * nJiggs,nJiggs,nNodInts,step); srcTime = srcTime + s; np = np + 1; step = 0; SpireBbMove(step); } if(state[0] == 9) { // *********************** LOAD } } assert (time() == ts[0] + ts[1]); // // finish observation tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + " Instrument Reconfigured"); // // SpireMsg(0,"Observation Completed (" + time() + " seconds)"); SpireMsg(0,"Note: Total time (s) = Observation Completed time - slew time + Observatory Overheads"); return {nMaps,iround(cycTime),iround(srcTime),time() - iround(srcTime) - tslew}; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_CalcParam_PhotPhaseUp.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to calculate the parameters needed for a Phot Phase Up. // It creates and returns a list of raw phases to be stepped through, // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/05/02 V0.1: Initial version adapted from // Mode_ILT_PERF_DPH_P.txt (v1.4 2008/01/31 20:24:33) // 2008/07/03 V0.2: Renumber version; add new limits for step_size // /////////////////////////////////////////////////////////////////////////// // int[] procedure SpireProc_CalcParam_PhotPhaseUp { double target_phase = 0.0 in [0.0,360.0]; // Central phase shift (target phase) [degree] int number_steps = 1 in [1,127]; // Number of steps to one side [int] int step_size = 1 in [1,20]; // Raw step size (1 step==1.411 degrees) [dec(HEX)] }{ // // // // // Calculate total number of steps: // int n_steps = 2 * number_steps + 1; debug_print("Numbers of steps requested: " + n_steps); // // // // // // Get the central point of the list in raw units: // int raw_target_phase = iround(target_phase * 255.0 / 360.0); debug_print("The requested phase is: " + target_phase); debug_print("The associated raw value is: " + raw_target_phase); // // // // // // Get the starting point of the list in raw units: // int raw_start_phase = raw_target_phase - number_steps * step_size; debug_print("the raw phase @start is :" + raw_start_phase); // // // // // // Create list of phases: // int[] raw_phase_list = [0]; double[] phase_list = [0.0]; double low_limit = 0.0; double high_limit = 360.0; double resol = 360.0 / 255.0; double k = 0.0; // for(int i = 0 .. n_steps - 1) { raw_phase_list[i] = raw_start_phase + step_size * i; phase_list[i] = double(raw_phase_list[i]) * resol; debug_print("the phase for step " + i + " is: " + phase_list[i]); // // // // // Check if phase is 0 <= phase <= 2*pi: // if(phase_list[i] < low_limit) { k = 1.0; } else { if(phase_list[i] > high_limit) { k = -1.0; } else { k = 0.0; } } debug_print("The value of k for step" + " " + i + " " + " is :" + k); // // Adapt raw phase list if outside 0 <= phase <= 2*pi: // raw_phase_list[i] = iround((phase_list[i] + k * 360.0) * (255.0 / 360.0)); } // debug_print("Final raw phase list: " + raw_phase_list); debug_print("Imput phase list in [deg]: " + phase_list); return raw_phase_list; } // SpirePhotoSmallLogic // // $id$ // // This procedure calculates the instrument parameters // for photometric small map observations // // This type of observation is executed using the POF3 observing mode // // 10/03/2009 KJK: // SCR 1274, add additional dummy parameters // Update input API to include versions for all cal tables // 03/07/2009 KJK: // Added configuration input parameters to pass to SpirePOF3Config, SpirePOF3Pointing and SpirePOF3End // 05/07/2009 KJK: // SPR-1593 - Updated call to SpirePOF3Pointing // // 22/07/2009 SDS: // SCR-1670 - Added option to load new JM64 table which has +/- 126 arcseconds chop throw (pBool1) // // 28/07/2009 SDS // Now uses the SpireTable_OpsParms.txt table (previously OpsParms.txt table) {{string,double,double,double,double,bool,double,double,double}[],int,int,int,int,int} obs SpirePhotoSmallLogic { double ra = 0.0 in [0.0,360.0]; // RA of Target double dec = 0.0 in [-90.0,90.0]; // DEC of Target int naifid = 0; // NAIF identifier string source = "small" in ["point","small","large"]; // source type bool choppingAvoidOn = false; // is chopping avoidance selected int choppingAvoidNumber = 0 in [0,3]; // the number of chopping avoid angles selected double choppingAvoidFrom1 = 0.0 in [0.0,360.0]; double choppingAvoidTo1 = 0.0 in [0.0,360.0]; double choppingAvoidFrom2 = 0.0 in [0.0,360.0]; double choppingAvoidTo2 = 0.0 in [0.0,360.0]; double choppingAvoidFrom3 = 0.0 in [0.0,360.0]; double choppingAvoidTo3 = 0.0 in [0.0,360.0]; int nRepetitions = 1 in [1,300]; // number of map repeats double sourceFluxPSW = -1.0; double sourceFluxPMW = -1.0; double sourceFluxPLW = -1.0; double sourceBrightPSW = -1.0; double sourceBrightPMW = -1.0; double sourceBrightPLW = -1.0; bool isBright = false; string spireVersion = "v00"; // Version in cal table SpireTable_SpireParms string opsVersion = "v00"; // Version in cal table SpireTable_OpsParms string flashVersion = "v00"; // Version in cal table SpireTable_FlashParms string chopVersion = "v00"; // Version in cal table SpireTable_ChopParms string photVersion = "v00"; // Version in cal table SpireTable_PhotModeParams.txt string comVersion = "v00"; // Version in cal table SpireTable_CommonModeParams.txt bool debug = false; // debug messages flag bool pBool1 = false; // Load 64-Point Jiggle Map Table? bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ SpireMsg(0,"Photometric Small Map Observation"); // ***************** // check user inputs // ***************** if(source != "small") { error("SpirePhotoSmallLogic: Source is not small"); } // // ***************** // set constants // ***************** double yOffset = 0.0; // offset to observation position from target in Y direction (arcsecs) double zOffset = 0.0; // offset to observation position from target in Z direction (arcsecs) // // declare variables // int nMaps = 1; // number of maps to perform int nCycles = 1; // number of nod cycles to perform per map int nNodPosns = 1; int nNodInts = 1; int nCal = 99999; int nFlash = 99999; // // // *********************************************** // calculate parameters for POF3 observation // *********************************************** SpireMsg(1," POF3 (Small Map) mode parameters"); // // ***************** // constants // ***************** string obsMode = "POF3"; bool photstby = true; // // ***** observing mode parameters ***** {double,int,int,int,int,int} pof3Obs = SpirePOF3Observing(nRepetitions); double mapOsit = pof3Obs{0}; nMaps = pof3Obs{1}; nCycles = pof3Obs{2}; nNodInts = pof3Obs{3}; nCal = pof3Obs{4}; nFlash = pof3Obs{5}; // // ***** pointing mode timing parameters ***** {int,int,int,int,int,int,int} pof3Point = SpirePOF3Pointing(nMaps,nCycles,nNodInts,nCal,nFlash,isBright,flashVersion,photVersion,comVersion,debug,pBool1,chopVersion); int tSlewMin = pof3Point{0}; int tInitHold = pof3Point{1}; int tFinalHold = pof3Point{2}; int nMoves = pof3Point{3}; int tp = pof3Point{4}; int tHold = pof3Point{5}; int nHold = pof3Point{6}; // // ***** pointing mode pointing parameters ***** string ib = SpireProc_GetTableEntryString("SpireTable_OpsParms.txt","mode",obsMode,"Boresight",opsVersion,debug); // instrument boresight double deltaY = SpireProc_GetTableEntryDouble("SpireTable_OpsParms.txt","mode",obsMode,"DeltaY",opsVersion,debug); // offset to pixel centre from boresight in Y direction (arcsecs) double deltaZ = SpireProc_GetTableEntryDouble("SpireTable_OpsParms.txt","mode",obsMode,"DeltaZ",opsVersion,debug); // offset to pixel centre from boresight in Z direction (arcsecs) bool fixed = SpireProc_GetTableEntryBool("SpireTable_OpsParms.txt","mode",obsMode,"Fixed",opsVersion,debug); // pattern angle definition double pattNod = SpireProc_GetTableEntryDouble("SpireTable_OpsParms.txt","mode",obsMode,"Patt",opsVersion,debug); // direction of nod double chopThrow = SpireProc_GetTableEntryDouble("SpireTable_OpsParms.txt","mode",obsMode,"D1",opsVersion,debug); // int[] ts = nodding_pointing(true,tSlewMin,tInitHold,tFinalHold,ib,naifid,ra,dec,fixed,pattNod,yOffset + deltaY,zOffset + deltaZ,nMaps * nCycles * nNodPosns / 2,chopThrow,tp,tp,0,0,tHold,nHold,false); // }{ // ******************************* // return instrument parameters // ******************************* // double osit = mapOsit * double(nMaps); {string,double,double,double,double,bool,double,double,double}[] estimates = []; // estimates = SpirePOF3Estimate(osit,sourceFluxPSW,sourceFluxPMW,sourceFluxPLW,sourceBrightPSW,sourceBrightPMW,sourceBrightPLW,isBright); // SpireMsg(3," Spire Photometry Pointing Mode parameters:"); SpireMsg(3," ..estimates: " + estimates); SpireMsg(3," ..nMaps: " + nMaps); SpireMsg(3," ..nCycles: " + nCycles); SpireMsg(3," ..nNodInts: " + nNodInts); SpireMsg(3," ..nCal: " + nCal); SpireMsg(3," ..nFlash: " + nFlash); return {estimates,nMaps,nCycles,nNodInts,nCal,nFlash}; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_StartObsAll.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to configure observation at the start of all AOTs // (i.e. astronomer, engineering, and calibration ones). // // It sets the OBSIDs for the current observation, sets the BB, // resets the DRCU counter, and sets the MODE. This script includes // HSPOT messages. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/01/26 V1.0: Merged BB using SpireBb_StartupObs (2008/11/12 V0.2) and // SpireBbObsConfig(22 Oct 2007). This will also replace // part of the ObsConfig stuff done currently in // SpireBbPOF2Config (v 1.3 2007/08/02) // SpireBbPOF3Config (v 1.3 2007/08/02) // SpireBbPOF5Config (v 1.3 2007/08/02) // Script includes a delay to allow busconfig setting // befor ethe first command (SCR-1167). // 2009/01/30 V1.1: Changed entries in messages related to 'RAW' and added // SCR number to header. Replaced final delay(1) with sync(). // 2009/05/05 V1.2: Move commands into low level procedure // SpireProc_Set_StartObsAll which will be called here. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_StartObsAll SPIRE 14024 { string obsmode = "ENG_CAL_OBS"; // Parameter to specify the configuration mode }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB StartObsAll started"); SpireMsg(2," $Id: $"); hstr = SpireHexStr($BBID,8); SpireMsg(3," BBID = " + hstr); SpireMsg(3," MODE = " + obsmode); // // Wait for busconfig to be performed: delay(1); // // // // // Start observation: // SpireProc_Set_StartObsAll(obsmode); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB StartObsAll ended"); SpireMsg(1," ..Observation Configuration (" + (time() - t) + " secs)"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBbSetBsmSampling.txt // /////////////////////////////////////////////////////////////////////////// // // The Building Block sets the BSM sampling // // /////////////////////////////////////////////////////////////////////////// // // 28/04/2009 KJK: First Version // 07/05/2009 KJK: Now only set sampling parameters if the data is to be // generated (these values are not available for REDY mode) // 03/07/2009 MP: Set bsmFrameRate and mcuFrameNumber to fix SPR-SPIRE-1588 // /////////////////////////////////////////////////////////////////////////// // double block SpireBbSetBsmSampling SPIRE 1601 { string opsMode = "PHTSTBY"; string bsmVersion = "v00"; bool debug = false; // Allow debug_print statements }{ // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // // // Start BB: // message("4 " + time() + ": SpireBbSetBsmSampling started"); message("4 $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); delay(1); // // set default datarate double bsmDataRate = 0.0; // set default TM Packet 12 sampling rate int bsmFrameRate = 0; // set default bsmFrameNumber: int bsmFrameNumber = 0; // // if generating data, setup sampling first int bsmDataGen = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode",opsMode,"mcuDataGen","v00",debug); if(bsmDataGen == 1) { // if starting data generation // Set number of samples bsmFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode",opsMode,"mcuFrameNumber","v00",debug); SpireSendDrcuCmd(0x91c30000 + bsmFrameNumber,0); // read datarate bsmDataRate = SpireProc_GetTableEntryDouble("SpireTable_CommonModeParams.txt","mode",opsMode,"bsmDataRate",bsmVersion,debug); // read TM Packet 12 sampling rate bsmFrameRate = SpireProc_GetTableEntryInt("SpireTable_CommonModeParams.txt","mode",opsMode,"bsmFrameRate",bsmVersion,debug); } else { if(opsMode == "REDY") { bsmFrameRate = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode",opsMode,"bsmFrameRate",bsmVersion,debug); } else { bsmFrameRate = SpireProc_GetTableEntryInt("SpireTable_CommonModeParams.txt","mode",opsMode,"bsmFrameRate",bsmVersion,debug); } // Set number of samples bsmFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode",opsMode,"mcuFrameNumber","v00",debug); SpireSendDrcuCmd(0x91c30000 + bsmFrameNumber,0); } // Start/Stop Data Generation SpireSendDrcuCmd(0x91c20000 + bsmFrameRate,0); SpireSendDrcuCmd(0x91c10000 + bsmDataGen,0); // // End BB: // sync(); SpireMsg(4," " + time() + ": BB SpireBbSetBsmSampling ended"); return bsmDataRate; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_StartBsmPcalFlash.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to configure at the start of // SpirePhoto/Spectro_Cal_BsmPcalFlash. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // // 2009/05/05 V0.1: Initial version adapted from // SpireBb_StartBsmAngleCal (2009/05/05 V0.1), // SpirePhoto_Cal_BsmPcalFlash (2009/03/04 V1.3), and // SpireSpectro_Cal_BsmPcalFlash (2009/03/04 V0.1) // BB includes now to move BSM/SMEC to hold/home. // 2009/07/12 V1.0: Fix bug in passing of SMEC home position (SPR-SPIRE-1612) // Set SMEC framerate to zero to get all BSM samples // (SPR-SPIRE-1551). // // Notes: // 1) Scripts assumes that SpireBb_SpecOffsetAuto is run // during INITHOLD or at first POINTING. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_StartBsmPcalFlash SPIRE 14042 { bool phot = true; // Photometer (==tick) or FTS (==untick)? string obsModeQla = "ENG_CAL_OBS01"; string obsMode = "PEngCalObs"; bool isBright = false; // Use settings for bright source (==tick) string version01 = "v00"; // Version in cal table SpireTable_Phot/SpecModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams int hold_chop = 37632; // Chop hold position int hold_jigg = 39520; // Jiggle hold position int smecHomePosn = 3500; // SMEC home position bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // int mode_id = 0; string obsmode = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB StartBsmPcalFlash configuration started"); SpireMsg(2," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Startup observation: // SpireProc_Set_StartObsAll(obsModeQla); // // // // // In case move SMEC to home: // if(!phot) { // // Calculate available time for possible movement: // int tmove = duration(SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug)) + duration(SpireProc_Set_SpecMode(obsMode,isBright,version01,version02,debug)) + duration(SpireProc_Set_ObsStep(999,debug)) + duration(SpireBb_SpecOffsetAuto(false,debug)); // // Calculate max offset for which time is available: // int smecMaxOff = tmove * 500; // Note, 500 is maximum possible SMEC speed. int smecStart = smecHomePosn + smecMaxOff; // Note, formula above only reasonable // when smecHomePosn small compared to 39500 // Safety check: if(smecStart > 39500) { smecStart = 39500; } if(debug) { debug_print("smecStart: " + smecStart); debug_print("smecHomePosn: " + smecHomePosn); debug_print("tmove: " + tmove); } // // Move from maximal offset to home: // SpireProc_SmecMove2Home(smecHomePosn,smecHomePosn + smecMaxOff,debug); } // // // // // Move BSM back to hold: // SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug); // // // // // Initialise instrument (in case to isBright): // if(phot) { SpireProc_Set_PhotMode(obsMode,isBright,version01,version02,debug); } else { SpireProc_Set_SpecMode(obsMode,isBright,version01,version02,debug); } //delay(timeSlewCal); // // // // // Set NHK STEP parameter to count PCAL levels: // int obsStep = 1; SpireProc_Set_ObsStep(obsStep,debug); // // // // // Set SMEC framerate (== SMEC sampling rate) to zero: // if(!phot) { SpireProc_Set_SmecFramerate(0,debug); } // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB StartBsmPcalFlash configuration ended"); SpireMsg(1," ..StartBsmPcalFlash took " + (time() - t) + " seconds)"); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_StartMultiLevelNoise.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to configure at the start of // SpirePhoto/Spectro_Cal_MultiLevelNoise. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // // 2009/05/05 V0.1: Initial version adapted from // SpireBb_StartBsmAngleCal (2009/05/05 V0.1), // SpirePhoto_Cal_MultiLevelNoise (2009/03/03 V1.3), and // SpireSpectro_Cal_MultiLevelNoise (2009/03/04 V0.5) // BB includes now to move BSM/SMEC to hold/home. // 2009/07/10 V1.0: Fix bug SPR-SPIRE-1612 // // Notes: // 1) Scripts assumes that SpireBb_SpecOffsetAuto is run // during INITHOLD or at first POINTING. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_StartMultiLevelNoise SPIRE 14052 { bool phot = true; // Photometer (==tick) or FTS (==untick)? string obsModeQla = "ENG_CAL_OBS08"; string obsMode = "PEngCalObs"; bool isBright = false; // Use settings for bright source (==tick) string version01 = "v00"; // Version in cal table SpireTable_Phot/SpecModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams int hold_chop = 37632; // Chop hold position int hold_jigg = 39520; // Jiggle hold position int smecHomePosn = 3500; // SMEC home position bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // int mode_id = 0; string obsmode = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB StartMultiLevelNoise configuration started"); SpireMsg(2," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Startup observation: // SpireProc_Set_StartObsAll(obsModeQla); // // // // // In case move SMEC to home: // if(!phot) { // // Calculate available time for possible movement: // int tmove = duration(SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug)) + duration(SpireProc_Set_SpecMode(obsMode,isBright,version01,version02,debug)) + duration(SpireBb_SpecOffsetAuto(false,debug)); // // Calculate max offset for which time is available: // int smecMaxOff = tmove * 500; // Note, 500 is maximum possible SMEC speed. int smecStart = smecHomePosn + smecMaxOff; // Note, formula above only reasonable // when smecHomePosn small compared to 39500 // Safety check: if(smecStart > 39500) { smecStart = 39500; } if(debug) { debug_print("smecStart: " + smecStart); debug_print("smecHomePosn: " + smecHomePosn); debug_print("tmove: " + tmove); } // // Move from maximal offset to home: // SpireProc_SmecMove2Home(smecHomePosn,smecHomePosn + smecMaxOff,debug); } // // // // // Move BSM back to hold: // SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug); // // // // // Initialise instrument (in case to isBright): // if(phot) { SpireProc_Set_PhotMode(obsMode,isBright,version01,version02,debug); } else { SpireProc_Set_SpecMode(obsMode,isBright,version01,version02,debug); } //delay(timeSlewCal); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB StartMultiLevelNoise configuration ended"); SpireMsg(1," ..StartMultiLevelNoise took " + (time() - t) + " seconds)"); // } // SpireBbBsmChopInit // // $id$ // // This building block initialises the BSM chop axis // // The BSM should be switched on (SpireBbBsmOn) before execution of this building block // // 27/04/2009 KJK: // Updated to use new NominalSettings Cal Tables // model, version and debug passed as parameters // 07/05/2009 KJK: // Added opsMode as input parameter to allow setting of bsmMoveMode from DefaultParams.txt calibration table // block SpireBbBsmChopInit SPIRE 266 { string opsMode = "PHTSTBY"; string model = "initial"; string version = "v00"; bool debug = false; }{ int t0 = time(); string hstr = ""; // hex string string tstr = ""; // time string tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB BSM Chop Init started"); SpireMsg(2," $Id$"); // // // intialise variables int chopkd = SpireProc_GetTableEntryInt("SpireTable_BsmNominalSettings.txt","model",model,"chop_kd",version,debug); int chopkp = SpireProc_GetTableEntryInt("SpireTable_BsmNominalSettings.txt","model",model,"chop_kp",version,debug); int chopki = SpireProc_GetTableEntryInt("SpireTable_BsmNominalSettings.txt","model",model,"chop_ki",version,debug); int chop_t1 = SpireProc_GetTableEntryInt("SpireTable_BsmNominalSettings.txt","model",model,"chop_filt1",version,debug); int chop_hold = SpireProc_GetTableEntryInt("SpireTable_BsmNominalSettings.txt","model",model,"chop_0_I",version,debug); // // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); delay(1); // // set Step to zero SpireSetObsStep(0); // // flag the current operation SpireSetObsMode("BSM_INIT"); delay(1); // // Set Movement Mode for initialisation SpireSendDrcuCmd(0x90c60000,0); // // Set Chop Kd parameter SpireSendDrcuCmd(0x90c90000 + chopkd,0); delay(1); // // Set Chop Kp parameter SpireSendDrcuCmd(0x90c80000 + chopkp,0); delay(1); // // Set Chop Ki parameter SpireSendDrcuCmd(0x90ca0000 + chopki,0); delay(1); // // Set Chop derivative filtering parameter 1 SpireSendDrcuCmd(0x90cf0000 + chop_t1,0); delay(1); // // Remove slew rate limiter SpireSendDrcuCmd(0x90d1ffff,0); delay(1); // // Set target position to HOLD SpireSendDrcuCmd(0x90c30000 + chop_hold,0); delay(1); // // Close loop on chop axis SpireSendDrcuCmd(0x90c20001,0); delay(1); // // Set Default Movement Mode int bsmMoveMode = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode",opsMode,"bsmMoveMode",version,debug); SpireSendDrcuCmd(0x90c60000 + bsmMoveMode,0); // // completion sync(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB BSM Chop Init ended"); SpireMsg(1," ..BSM Chop Axis Initialisation (" + (time() - t0) + " seconds)"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_StopDcuMcuData.txt // /////////////////////////////////////////////////////////////////////////// // // BB to stop generation of detector data (TM packets) plus MCU // (here only BSM and SMEC) data. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/03/31 V0.1: Initial version adapted from // SpireBb_StartDcuMcuData (2009/03/31 V0.1) // /////////////////////////////////////////////////////////////////////////// // block SpireBb_StopDcuMcuData SPIRE 14038 { }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SpireBb_StopDcuMcuData started"); SpireMsg(2," $Id:$"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Start DCU data: // SpireProc_Set_StopDcuData(); SpireProc_Set_StopMcuData(); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SpireBb_StopDcuMcuData ended"); SpireMsg(1," ..StopDcuMcuData (" + (time() - t) + " seconds)"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_GetTableEntryString.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to select a double entry in a calibration table // giving a string input as selector using the versioning approach. // // Note: Currently script is restricted to a 'string' selector! // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/01/26 V0.1: Initial version adapted from // SpireProc_CalcParam_FpgInitialPointing.txt (2008/11/06 V0.3) // 2009/07/12 V1.0: Fix SPR-SPIRE-1636 (reduce number of debug printouts) // Change default values for testing. // /////////////////////////////////////////////////////////////////////////// // string procedure SpireProc_GetTableEntryString { string tabName = "SpireTable_DefaultParams.txt"; // Name of the table to be selected from string selCol = "mode"; // Name of column for selecting string selVal = "PHTSTBY"; // Value of 'string' selector string tarCol = "ptcVm"; // Target column name string version = "v00"; // Version parameter defined in calibration table bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Define some variable: // string stringVar = ""; // // Define columns: string[] versionCol = scolumn(tabName,"version"); string[] targetCol = scolumn(tabName,tarCol); string[] selectorCol = scolumn(tabName,selCol); // // Read table size: int nrows = table_size(tabName); // // // // // Cycle through values to get all rows with correct version tag: // //Setup: {string,string}[] rows = [{"",""}]; int nindex = 0; bool match = false; // for(int j = 0 .. nrows - 1) { //if(debug) { // debug_print("versionCol[j]: " + versionCol[j]); //} if(versionCol[j] == version) { rows[nindex] = {targetCol[j],selectorCol[j]}; nindex = nindex + 1; match = true; } } //if(debug) { // debug_print("selected rows: " + rows); //} // Safety check: if(!match) { error("Calibration table empty or wrong version selected!"); } // // // // // Make final selection from all rows (selected by version): // int nentries = length(rows); int counter = 0; match = false; for(int i = 0 .. nentries - 1) { //if(debug) { // debug_print("rows sliced:" + rows[i]{0} + "/" + rows[i]{1}); //} if(rows[i]{1} == selVal) { stringVar = rows[i]{0}; match = true; counter = counter + 1; } } // Safety checks: if(!match) { error("Entry " + selVal + " not found in calibration table. Call for help and wait to be rescued!"); } // if(counter > 1) { error("Selector string " + selVal + " is present at least twice in the versioned calibration table. Please report this bug to the relevant authorities!"); } // // // // // Return required value: // if(debug) { debug_print(" If you believe it of not, I found " + tarCol + "=" + stringVar + " as version " + version + " when selecting for " + selCol + "=" + selVal + " in table " + tabName); } return stringVar; } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_Set_EndObsAll.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to reconfigure at the end of all AOTs // (i.e. astronomer, engineering, and calibration ones) // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2009/05/05 V1.0: First version adapted from // SpireBb_EndObsAll (2009/01/30 V1.1) // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Set_EndObsAll { bool phot = true; // Photometer (==tick) or FTS (==untick)? }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // int mode_id = 0; string obsmode = ""; // // // // // Start procedure: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(3," " + tstr + ": Proc EndObsAll started"); SpireMsg(3," $Id: $"); // // // // // Reset ObsMODE to PHOT/SPEC-STBY: // if(phot) { // Set mode back to PHOTSTBY: obsmode = "PHOTSTBY"; mode_id = ilookup("SpireTableInstConfigs.txt",obsmode,"value"); } else { // Set mode back to SPECSTBY obsmode = "SPECSTBY"; mode_id = ilookup("SpireTableInstConfigs.txt",obsmode,"value"); } tstr = SpireTimeStr(time()); hstr = SpireHexStr(mode_id,8); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_MODE(" + hstr + ")"); Spire_SET_OBS_MODE(mode_id); delay(1); // // // // // Set the BBID(s) back to null: // tstr = SpireTimeStr(time()); message("5 " + tstr + "Cmd: Spire_SET_BBID_RAW(0x80000000)"); Spire_SET_BBID_RAW(0x80000000); // // // // // Set the OBSIDs to null: // int null_obsid = SpireNullObsid(); tstr = SpireTimeStr(time()); hstr = SpireHexStr(null_obsid,8); Spire_SET_OBSID(null_obsid); //delay(1); // // // // // Round up total duration: // sync(); // // // // // End procedure: // tstr = SpireTimeStr(time()); SpireMsg(3," " + tstr + ": Proc EndObsAll ended"); SpireMsg(2," Proc StartObsAll (" + (time() - t) + " seconds)"); } // SpireBbSpecSerendipity // // $Id: SpireBbSpecSerendipity.txt,v 1.2 2006/10/30 13:53:20 kking Exp $ // // Building Block to take serendipity data for a specified period of time // // If the time specified is less than the minimum then this BB takes the minimum time anyway // // Note: this BB assumes that the detector bias and sampling frequency and // the BSM sampling frequency have been set appropriately // // 04 November 2008: // changed to accept observing mode // changed to provide operations mode rather than data mode as a parameter to StartDcuData // block SpireBbSpecSerendipity SPIRE 8453 { string obsMode = "" in ["SOF1","SOF2","SOF2_int","SOF3","SOF4"]; int len = 0 in [0,10000]; // scan length in seconds - maximum determined by max time between Tsync }{ message("2 " + time() + ": BB Spec Serendipity started"); message("2 $Id: SpireBbSpecSerendipity.txt,v 1.2 2006/10/30 13:53:20 kking Exp $"); message("3 length = " + len); int t = time(); // // find actual length of BB int tSerendipity = ilookup("SpireParms.txt",obsMode,"TSerendipity"); // minimum time for Serendipity observation if(len < tSerendipity) { len = tSerendipity; } // // ..... configuration ..... // // set BBID message("5 " + time() + "Cmd: Spire_SET_BBID_RAW(" + $BBID + ")"); Spire_SET_BBID_RAW($BBID); // set value delay(2); // allow HSK to reflect new value // // ..... initialisation ..... // // // ..... execution ..... // // start sampling detectors SpireStartDcuData("SSer"); // // wait to end of time int tStop = duration(SpireStopDcuData()); wait_until(t + len - tStop - 2); // // stop detector sampling SpireStopDcuData(); // // ..... completion ..... // // wait_until(t + len); message("2 " + time() + ": BB Spec Serendipity ended"); message("0 Serendipity Mode (" + (time() - t) + " seconds)"); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_SpecFSetBiasAmpl.txt // /////////////////////////////////////////////////////////////////////////// // // BB to set bias amplitude of spectrometer arrays // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/08/12 V0.1: Initial version adapted from // SpireBb_PhotFSetBiasAmpl (2008/07/03 V0.3) // based on // SFBias_Ampl (v1.4 2008/01/31 20:24:37) // 2009/02/19 V0.2: Instead of using commands call SpireProc_Set_SpecBias // and add sync() after setBbId. Add HSpot messages. // Add debug_print. Remove unsetting of BBID at end. // 2009/07/04 V0.3: Fixed copy/paste bug to set bias instead of phase // detected during FS testing plus messages. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_SpecFSetBiasAmpl SPIRE 14016 { int ssw_bias = 0x2d; //Default (IST) bias amplitud (==31.1 mV) int slw_bias = 0x2d; //Default (IST) bias amplitud (==31.1 mV) bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Define some variables: // string hstr = ""; // a hex string string tstr = ""; // a time string // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": SpireBb_SpecFSetBiasAmpl started"); SpireMsg(2," $Id: $"); hstr = SpireHexStr($BBID,8); SpireMsg(3," BBID = " + hstr); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); sync(); // // // // // Set the bias levels for the two arrays: // SpireProc_Set_SpecBias(ssw_bias,slw_bias,debug); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SpireBb_SpecFSetBiasAmpl ended"); SpireMsg(1," ..Set Spec bias (" + (time() - t) + " secs)"); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireProc_Exec_IltPcalFlash.txt // /////////////////////////////////////////////////////////////////////////// // // Procedure to execute two PCAL flashes with the standard values // from ILT as fixed parameters inside the script. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/08/12 V0.1: Initial version adapted from // SpireProc_Exec_PhotIltPcalFlash (2008/05/02 V0.1) // based on // Mode_ILT_PERF_DAB_P_CPS.txt (v1.3 2008/01/31 23:35:17) // Rename script, remove 'Phot'; Move input parameters // to fixed parameters inside the script // 2008/11/07 V0.2: Adapt to change in name of low level script // 2009/02/02 V1.0: Add debug_print as input and pass to low level scripts. // Adapt input to updated SpireBb_PcalFlash with rate and step. // 2009/02/17 V1.1: Read VM parameters from calibration file. // 2009/02/18 V1.2: Adapt to change in call to SpireBb_PcalFlash. // 2009/02/19 V1.3: Add phot as new input and set the correct // high bias levels for phot and fts accordingly. // /////////////////////////////////////////////////////////////////////////// // procedure SpireProc_Exec_IltPcalFlash { int period = 4000000; //PCAL Flash FULL period (high and low bias) [microsec] int mclkdiv = 149; // Fetched master clock divisor [Hex] int biasdiv = 6; // Fetched bias divisor [Hex] int ndcumode = 0; // DCU data mode (0 == PF; 4 == SF) bool phot = true; // Photometer (==tick) or FTS IltPcalFlash values? bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Declare some variables: int pcal_low_bias_0 = 0; int pcal_high_bias_0 = 0; int pcal_low_bias_1 = 0; int pcal_high_bias_1 = 0; // // // // // Set PCAL Flash values to the once fixed used during ILT: // // Read VM parameters from calibration table: // string tabName = "SpireTable_CommandLists.txt"; string selVal = "Flash"; // Raw VM table number: int vmId = ilookup(tabName,selVal,"Id"); // Raw VM index: int vmIndex = ilookup(tabName,selVal,"Index"); // Number of parameters passed to VM: int nParms = ilookup(tabName,selVal,"Nparms"); // // Raw value of low level for 1. flash phot/spec: pcal_low_bias_0 = 4; // // Raw value of high level for 1. flash: if(phot) { pcal_high_bias_0 = 2176; } else { pcal_high_bias_0 = 2748; } // // Raw value of low level for 2. flash phot/spec: pcal_low_bias_1 = 4; // // Raw value of high level for 2. flash if(phot) { pcal_high_bias_1 = 2748; } else { pcal_high_bias_1 = 3433; } // // Number of cycles: int ncycles = 15; // // SCU sampling rate (f =80Hz/(1+scumode)): int scumode = 0; // // // // // Calculate variable (erroneous) ILT PCAL Flash values // int periodinmillisec = ifloor(double(period) / 1000.0); int[] iltvalues = SpireProc_CalcParam_IltPcalFlash(periodinmillisec,mclkdiv,biasdiv,debug); // Number of DCU and SCU samples, and DCU sample delay mclkdiv/biasdivi (149/6): int dcusamples = iltvalues[0]; // // Number of DCU and SCU samples, and DCU sample delay mclkdiv/biasdiv (149/6): int dcudelay = iltvalues[2]; // // Number of DCU and SCU samples, and DCU sample delay mclkdiv/biasdiv (149/6) int scusamples = iltvalues[1]; // Note: (0==continuous sampling) // // // // // First PCAL Flash: // // Set STEP: int obsStep = 1; // NHK Step parameter SpireBb_SetObsStep(obsStep,debug); // // Execute FLASH: SpireBb_PcalFlash(vmId,vmIndex,nParms,pcal_low_bias_0,pcal_high_bias_0,ncycles,period,ndcumode,dcusamples,dcudelay,scumode,scusamples,obsStep,debug); // Note: DCU start and stop is taken care of in the PCAL_Flash proceedure // // // // // Second PCAL Flash: // // Set STEP: obsStep = 2; // NHK Step parameter SpireBb_SetObsStep(obsStep,debug); // // Execute FLASH: SpireBb_PcalFlash(vmId,vmIndex,nParms,pcal_low_bias_1,pcal_high_bias_1,ncycles,period,ndcumode,dcusamples,dcudelay,scumode,scusamples,obsStep,debug); // } // SpireBbSetScal // // $id$ // // This building block starts or stops the SCAL PID Command List // // 08/06/2009 KJK: First Version // block SpireBbSetScal SPIRE 1610 { string scal = "None" in ["SCAL2","SCAL4","None"]; int reqTemp = -1; string version = "v00"; bool debug = false; }{ int t0 = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB Set SCAL started"); SpireMsg(2," $Id: $"); // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // // stop SCAL VM // this stops VM2 from another command list - this stops the possibility of a TC execution error if the // VM is not running int vm = ilookup("SpireTable_CommandLists.txt","SCAL","Vm"); tstr = SpireTimeStr(time()); {int}[] cl = [{0x58000000 + vm},{0x7f000000}]; SpireMsg(5," " + tstr + "Cmd: Spire_EXECUTE_COMMAND_LIST_RAW(" + 2 + "," + cl + ")"); Spire_EXECUTE_COMMAND_LIST_RAW(2,cl); delay(2); // // ensure SCAL bias is zero SpireSendDrcuCmd(0xa0ca0000,0); // set SCAL2 bias to zero SpireSendDrcuCmd(0xa0cc0000,0); // set SCAL4 bias to zero delay(2); // if(scal != "None") { // start SCAL VM, if required // // Get Command List info int tableId = ilookup("SpireTable_CommandLists.txt","SCAL","TableId"); int startIndex = ilookup("SpireTable_CommandLists.txt","SCAL","Index"); int nParams = ilookup("SpireTable_CommandLists.txt","SCAL","NParms"); // // Retrieve the input parameters if(reqTemp == -1) { reqTemp = SpireProc_GetTableEntryInt("SpireTable_CL_SCAL.txt","ScalId",scal,"ReqTemp",version,debug); } int getTempCmd = SpireProc_GetTableEntryInt("SpireTable_CL_SCAL.txt","ScalId",scal,"GetTempCmd",version,debug); int setHtrCurrCmd = SpireProc_GetTableEntryInt("SpireTable_CL_SCAL.txt","ScalId",scal,"SetHtrCurrCmd",version,debug); int loopPeriod = SpireProc_GetTableEntryInt("SpireTable_CL_SCAL.txt","ScalId",scal,"LoopPeriod",version,debug); int kp = SpireProc_GetTableEntryInt("SpireTable_CL_SCAL.txt","ScalId",scal,"Kp",version,debug); int ki = SpireProc_GetTableEntryInt("SpireTable_CL_SCAL.txt","ScalId",scal,"Ki",version,debug); int kd = SpireProc_GetTableEntryInt("SpireTable_CL_SCAL.txt","ScalId",scal,"Kd",version,debug); int kiLimit = SpireProc_GetTableEntryInt("SpireTable_CL_SCAL.txt","ScalId",scal,"KiLimit",version,debug); int lpFiltGain = SpireProc_GetTableEntryInt("SpireTable_CL_SCAL.txt","ScalId",scal,"LpFiltGain",version,debug); int lpFiltB1 = SpireProc_GetTableEntryInt("SpireTable_CL_SCAL.txt","ScalId",scal,"LpFiltB1",version,debug); int lpFiltB2 = SpireProc_GetTableEntryInt("SpireTable_CL_SCAL.txt","ScalId",scal,"LpFiltB2",version,debug); int maxDac = SpireProc_GetTableEntryInt("SpireTable_CL_SCAL.txt","ScalId",scal,"MaxDac",version,debug); int pwmFlag = SpireProc_GetTableEntryInt("SpireTable_CL_SCAL.txt","ScalId",scal,"PwmFlag",version,debug); int frameCount = SpireProc_GetTableEntryInt("SpireTable_CL_SCAL.txt","ScalId",scal,"FrameCount",version,debug); int initCount = SpireProc_GetTableEntryInt("SpireTable_CL_SCAL.txt","ScalId",scal,"InitCount",version,debug); // // start executing Command List {int}[] params = [{reqTemp},{getTempCmd},{setHtrCurrCmd},{loopPeriod},{kp},{ki},{kd},{kiLimit},{lpFiltGain},{lpFiltB1},{lpFiltB2},{maxDac},{pwmFlag},{frameCount},{initCount}]; tstr = SpireTimeStr(time()); if(vm == 1) { SpireMsg(5," " + tstr + "Cmd: Spire_RUN_VM1_RAW(" + tableId + "," + startIndex + "," + nParams + "," + params + ")"); Spire_RUN_VM1_RAW(tableId,startIndex,nParams,params); } if(vm == 2) { SpireMsg(5," " + tstr + "Cmd: Spire_RUN_VM2_RAW(" + tableId + "," + startIndex + "," + nParams + "," + params + ")"); Spire_RUN_VM2_RAW(tableId,startIndex,nParams,params); } if(vm == 3) { SpireMsg(5," " + tstr + "Cmd: Spire_RUN_VM3_RAW(" + tableId + "," + startIndex + "," + nParams + "," + params + ")"); Spire_RUN_VM3_RAW(tableId,startIndex,nParams,params); } // delay(2); } // sync(); // // completion tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB Set SCAL ended"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBbSetSmecSampling.txt // /////////////////////////////////////////////////////////////////////////// // // The Building Block sets the SMECsampling // // /////////////////////////////////////////////////////////////////////////// // // 28/04/2009 KJK: First Version // 08/06/2009 KJK: Use smecTelemetryType in SpireTable_DefaultParams to determine if selected packets are generated // rearranged to set default values for smec sampling whether or not generating data // corrceted to get REDY mode parameters from DefaultParams table // /////////////////////////////////////////////////////////////////////////// // double block SpireBbSetSmecSampling SPIRE 1602 { string opsMode = "SPECSTBY"; string smecVersion = "v00"; bool debug = false; // Allow debug_print statements }{ // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // // // Start BB: // message("4 " + time() + ": SpireBbSetSmecSampling started"); message("4 $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); delay(1); // // setup SMEC packet type // // disable SMEC selected frame definition tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_DISABLE_SELECTION(0x10)"); Spire_DISABLE_SELECTION(0x10); // int smecTelemetryType = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode",opsMode,"smecTelemetryType","v00",debug); if(smecTelemetryType == 1) { // // use SMEC selected packets // // Define contents of SMEC selected frames tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_TABLE(0xa,12)"); Spire_SET_TABLE(0xa,12); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_UPDATE_TABLE(0xa,0x0,12,[{0},{0},{1},{1},{1},{1},{1},{0},{1},{0},{0},{0}])"); Spire_UPDATE_TABLE(0xa,0x0,12,[{0},{0},{1},{1},{1},{1},{1},{0},{1},{0},{0},{0}]); delay(1); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_ENABLE_SELECTION(0x10,0x1410,0xa)"); Spire_ENABLE_SELECTION(0x10,0x1410,0xa); } // // Set number of samples int smecFrameNumber = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode",opsMode,"mcuFrameNumber","v00",debug); SpireSendDrcuCmd(0x91c30000 + smecFrameNumber,0); // // set TM Packet 10 sample rate int smecFrameRate = 0; if(opsMode == "REDY") { smecFrameRate = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode",opsMode,"smecFrameRate",smecVersion,debug); } else { smecFrameRate = SpireProc_GetTableEntryInt("SpireTable_SpecModeParams.txt","mode",opsMode,"smecFrameRate",smecVersion,debug); } SpireSendDrcuCmd(0x91c00000 + smecFrameRate,0); // // Start/Stop Data Generation int smecDataGen = SpireProc_GetTableEntryInt("SpireTable_DefaultParams.txt","mode",opsMode,"mcuDataGen","v00",debug); SpireSendDrcuCmd(0x91c10000 + smecDataGen,0); // // read datarate double smecDataRate = 0.0; if(opsMode == "REDY") { smecDataRate = SpireProc_GetTableEntryDouble("SpireTable_DefaultParams.txt","mode",opsMode,"smecDataRate",smecVersion,debug); } else { smecDataRate = SpireProc_GetTableEntryDouble("SpireTable_SpecModeParams.txt","mode",opsMode,"smecDataRate",smecVersion,debug); } // // End BB: // SpireMsg(4," " + time() + ": BB SpireBbSetSmecSampling ended"); return smecDataRate; } // SpirePeakup // // $id$ // // This procedure executes a Peakup observation // // The instrument should be in the PHOTSTBY mode before execution of this procedure. // Th epeakup offset generated takes effect with the next observation so this observation // should be concatenated with a following observation that requires peaking up // // 11/11/2008 KJK first version // procedure SpirePeakup { string peakupMode = "PPeakup" in ["PPeakup","SPeakup"]; // Peakup Mode }{ // Set Mode to Peakup SpireSetObsMode(peakupMode); delay(1); // // execute Peakup SpireBbPeakup(peakupMode,0); // // reset Mode if(peakupMode == "PPeakup") { SpireSetObsMode("PHOTSTBY"); } else { SpireSetObsMode("SPECSTBY"); } delay(1); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_EndPtcPwr.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to reconfigure at the end of SpirePhoto_Cal_PtcPwr. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // // 2009/05/05 V1.0: Initial version adapted from // SpireBb_EndBsmAngleCal (2009/05/05 V1.2) and // SpirePhoto_Cal_PtcPwr (2009/03/30 V0.1). // /////////////////////////////////////////////////////////////////////////// // block SpireBb_EndPtcPwr SPIRE 14059 { bool phot = true; // Photometer (==tick) or FTS (==untick)? bool isBright = false in [true,false]; // IsBright (==tick) flag string version01 = "v00"; // Version in cal.tab. SpireTable_PhotModeParams string version02 = "v00"; // Version in cal.tab. SpireTable_CommonModeParams bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // int mode_id = 0; string obsmode = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB EndPtcPwr reconfiguration started"); SpireMsg(2," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Set instrument back to Phot/Spec-STBY: // if(phot) { SpireProc_Set_PhotMode("PHTSTBY",isBright,version01,version02,debug); } else { SpireProc_Set_SpecMode("SPECSTBY",isBright,version01,version02,debug); } // // // // // End observation: // SpireProc_Set_EndObsAll(phot); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB EndPtcPwr reconfiguration ended"); SpireMsg(1," ..Reconfiguration to " + obsmode + "mode (" + (time() - t) + " seconds)"); // } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_StartPcalLoadCurve.txt // /////////////////////////////////////////////////////////////////////////// // // Building Block to configure at the start of // SpirePhoto/Spectro_Cal_PcalLoadCurve. // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // // 2009/05/07 V0.1: Initial version adapted from // SpireBb_StartBsmAngleCal (2009/05/05 V0.1), // SpirePhoto_Cal_PcalLoadCurve (2009/03/04 V1.4), and // SpireSpectro_Cal_PcalLoadCurve (2009/03/04 V0.5) // BB includes now to move BSM/SMEC to hold/home. // 2009/07/05 V1.0: Fix bug to allow spectrometer to use script. // 2009/07/10 V1.1: Fix bug SPR-SPIRE-1612 // // Notes: // 1) Scripts assumes that SpireBb_SpecOffsetAuto is run // during INITHOLD or at first POINTING. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_StartPcalLoadCurve SPIRE 14068 { bool phot = true; // Photometer (==tick) or FTS (==untick)? string obsModeQla = "ENG_CAL_OBS01"; string obsMode = "PEngCalObs"; bool isBright = false; // Use settings for bright source (==tick) string version01 = "v00"; // Version in cal table SpireTable_Phot/SpecModeParams string version02 = "v00"; // Version in cal table SpireTable_CommonModeParams int hold_chop = 37632; // Chop hold position int hold_jigg = 39520; // Jiggle hold position int smecHomePosn = 3500; // SMEC home position int mclkdiv = 149; // mclkdiv (spec ==~ 121) int biasdiv = 6; // biasdiv (spec ==~ 1) int psw_bias = 62; // int pmw_bias = 62; // int plw_bias = 62; // int ptc_bias = 62; // int psw_phase = 127; // int pmw_phase = 127; // int plw_phase = 127; // int ptc_phase = 127; // int ssw_bias = 45; // int slw_bias = 45; // int ssw_phase = 128; // int slw_phase = 128; // bool debug = false; // Allow debug_print statements }{ // // // // // Define some variables: // // a hex string: string hstr = ""; // // a time string: string tstr = ""; // int mode_id = 0; string obsmode = ""; // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB StartPcalLoadCurve configuration started"); SpireMsg(2," $Id: $"); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); // // // // // Startup observation: // SpireProc_Set_StartObsAll(obsModeQla); // // // // // In case move SMEC to home: // if(!phot) { // // Calculate available time for possible movement: // int tmove = duration(SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug)) + duration(SpireProc_Set_SpecMode(obsMode,isBright,version01,version02,debug)) + duration(SpireProc_Set_DcuFreqSamp(mclkdiv,biasdiv,phot,debug)) + duration(SpireProc_Set_PhotPhase(psw_phase,pmw_phase,plw_phase,ptc_phase,debug)) + duration(SpireProc_Set_PhotBias(psw_bias,pmw_bias,plw_bias,ptc_bias,debug)) + duration(SpireBb_SpecOffsetAuto(false,debug)) + duration(SpireProc_Set_ObsStep(9999,debug)); // // Calculate max offset for which time is available: // int smecMaxOff = tmove * 500; // Note, 500 is maximum possible SMEC speed. int smecStart = smecHomePosn + smecMaxOff; // Note, formula above only reasonable // when smecHomePosn small compared to 39500 // Safety check: if(smecStart > 39500) { smecStart = 39500; } if(debug) { debug_print("smecStart: " + smecStart); debug_print("smecHomePosn: " + smecHomePosn); debug_print("tmove: " + tmove); } // // Move from maximal offset to home: // SpireProc_SmecMove2Home(smecHomePosn,smecHomePosn + smecMaxOff,debug); } // // // // // Move BSM back to hold: // SpireProc_Set_BsmMove(hold_chop,hold_jigg,debug); // // // // // Initialise instrument (in case to isBright): // if(phot) { SpireProc_Set_PhotMode(obsMode,isBright,version01,version02,debug); } else { SpireProc_Set_SpecMode(obsMode,isBright,version01,version02,debug); } //delay(timeSlewCal); // // // // // Set requested frequency and phase plus first bias level: // SpireProc_Set_DcuFreqSamp(mclkdiv,biasdiv,phot,debug); if(phot) { SpireProc_Set_PhotPhase(psw_phase,pmw_phase,plw_phase,ptc_phase,debug); SpireProc_Set_PhotBias(psw_bias,pmw_bias,plw_bias,ptc_bias,debug); } else { SpireProc_Set_SpecBias(ssw_bias,slw_bias,debug); SpireProc_Set_SpecPhase(ssw_phase,slw_phase,debug); } // // // // // Set NHK STEP parameter to count PCAL levels: // int obsStep = 1; SpireProc_Set_ObsStep(obsStep,debug); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB StartPcalLoadCurve configuration ended"); SpireMsg(1," ..StartPcalLoadCurve took " + (time() - t) + " seconds)"); // } // SpireBbSOF2Config // // $Id:$ // // Building Block to configure the instrument for SOF2 operations // // The complete instrument setup operation is divided into two parts: // Configuration: actions that can be executed during the slew to the start // position of the S/C pointing mode. // Initialisation: actions that must be carried out at the S/C intial pointing // position before any observational operations are executed. // // This building Block implements the first part of the setup: // It assumes the instrument is in the SPECSTBY mode (with SMEC at Home position) // Reset SMEC encoder , in case it has lost steps // Move SMEC to scan start position // // 28 January 2009 V1.1 KJK // Remove Mode setting - now carried out in SpireBb_StartObsAll // Remove DRCU Counter resetting - now carried out in SpireBb_StartObsAll // Use SpireProc_SmecMove to move into position - assuming SMEC is at Home position // block SpireBbSOF2Config SPIRE 8384 { string res = "H"; string specVersion = "v00"; bool debug = false; }{ string version = "v00"; int t = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SOF2 Configuration started"); SpireMsg(2," $Id:$"); // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // ..... configuration ..... // // Reset SMEC encoder // // Move mechanism to zero position // fetch Home position // int smecHome = ilookup("SpireTable_SmecNominalSettings.txt",version,"Home"); SpireProc_SmecMove(0,smecHome,debug); // Reset encoder SpireSendDrcuCmd(0x90490004,0); // hold position SpireSendDrcuCmd(0x90490000,0); delay(1); // // Move mechanism to scan start position ready to scan int scanStart1 = SpireProc_GetTableEntryInt("SpireTable_Spectrometer.txt","ResChar",res,"ScanStart",specVersion,debug); SpireProc_SmecMove(scanStart1,0,debug); // // ..... completion ..... // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SOF2 Configuration ended"); SpireMsg(1," ..SOF2 Configuration (" + (time() - t) + " seconds)"); } // SpirePhotoPointLogic // // $id$ // // This procedure selectes the SPIRE observing mode and calculates its instrument parameters // for point source observations // // This type of observation may be executed using either the POF1 or POF2 observing modes // // 10/03/2009 KJK: // SCR 1274, add additional dummy parameters // Update input API to include versions for all cal tables // 02/07/2009 KJK: // Added configuration input parameters to pass to SpirePOF2Config, SpirePOF2Pointing and SpirePOF2End // 05/07/2009 KJK: // SPR-1593 - Updated call to SpirePOF2Pointing // {{string,double,double,double,double,bool}[],bool,int,int,int,int} obs SpirePhotoPointLogic { double ra = 0.0 in [0.0,360.0]; // RA of Target double dec = 0.0 in [-90.0,90.0]; // DEC of Target int naifid = 0; // NAIF identifier string source = "point" in ["point","small","large"]; // source type bool choppingAvoidOn = false; // is chopping avoidance selected int choppingAvoidNumber = 0 in [0,3]; // the number of chopping avoid angles selected double choppingAvoidFrom1 = 0.0 in [0.0,360.0]; double choppingAvoidTo1 = 0.0 in [0.0,360.0]; double choppingAvoidFrom2 = 0.0 in [0.0,360.0]; double choppingAvoidTo2 = 0.0 in [0.0,360.0]; double choppingAvoidFrom3 = 0.0 in [0.0,360.0]; double choppingAvoidTo3 = 0.0 in [0.0,360.0]; int nRepetitions = 1 in [1,600]; // number of repeats of basic observing cycle double sourceFluxPSW = -1.0; double sourceFluxPMW = -1.0; double sourceFluxPLW = -1.0; bool isBright = false; string spireVersion = "v00"; // Version in cal table SpireTable_SpireParms string opsVersion = "v00"; // Version in cal table SpireTable_OpsParms string flashVersion = "v00"; // Version in cal table SpireTable_FlashParms string chopVersion = "v00"; // Version in cal table SpireTable_ChopParms string photVersion = "v00"; // Version in cal table SpireTable_PhotModeParams.txt string comVersion = "v00"; // Version in cal table SpireTable_CommonModeParams.txt bool debug = false; // debug messages flag bool pBool1 = false; // Spare parameter (currently not in use) bool pBool2 = false; // Spare parameter (currently not in use) string pString1 = ""; // Spare parameter (currently not in use) string pString2 = ""; // Spare parameter (currently not in use) int pInt1 = 0; // Spare parameter (currently not in use) int pInt2 = 0; // Spare parameter (currently not in use) double pDouble1 = 0.0; // Spare parameter (currently not in use) double pDouble2 = 0.0; // Spare parameter (currently not in use) }{ SpireMsg(0,"Photometric Point Source Observation"); // ***************** // check user inputs // ***************** if(source != "point") { error("SpirePhotoPointLogic: Source is not a point"); } // // ***************** // set constants // ***************** double yOffset = 0.0; // offset to observation position from target in Y direction (arcsecs) double zOffset = 0.0; // offset to observation position from target in Z direction (arcsecs) // // declare variables // int nCycles = 1; int nNodPosns = 1; int nNodInts = 1; int nCal = 99999; int nFlash = 99999; int tSlewMin = 0; int tInitHold = 0; int tFinalHold = 0; int nMoves = 0; int tp = 0; int tHold = 0; int nHold = 0; // // ************************************************************* // calculate parameters for POF1 observation // ************************************************************* SpireMsg(1," POF1 (Chop without Jiggle) mode parameters"); // // !!! THIS IS NOT IMPLEMENTED YET !!! // // ************************************************************* // calculate parameters for POF2 observation // ************************************************************* SpireMsg(1," POF2 (7-pnt Jiggle Map) mode parameters"); // // // ***************** // constants // ***************** string obsmode = "POF2"; bool photstby = true; // // ***** observing mode parameters ***** {double,int,int,int,int,int} pof2Obs = SpirePOF2Observing(nRepetitions); double cycOsit = pof2Obs{0}; // osit for each nod cycle nCycles = pof2Obs{1}; // number of nod cycles to perform nNodPosns = pof2Obs{2}; nNodInts = pof2Obs{3}; nCal = pof2Obs{4}; nFlash = pof2Obs{5}; // // ***** pointing mode timing parameters ***** {int,int,int,int,int,int} pof2Point = SpirePOF2Pointing(nCycles,nNodInts,nCal,nFlash,isBright,flashVersion,photVersion,comVersion,debug); tSlewMin = pof2Point{0}; tInitHold = pof2Point{1}; tFinalHold = pof2Point{2}; tp = pof2Point{3}; tHold = pof2Point{4}; nHold = pof2Point{5}; // // ***** pointing mode pointing parameters ***** string ib = slookup("OpsParms.txt",obsmode,"Boresight"); // instrument boresight double deltaY = dlookup("OpsParms.txt",obsmode,"DeltaY"); // offset to pixel centre from boresight in Y direction (arcsecs) double deltaZ = dlookup("OpsParms.txt",obsmode,"DeltaZ"); // offset to pixel centre from boresight in Z direction (arcsecs) bool fixed = blookup("OpsParms.txt",obsmode,"Fixed"); // pattern angle definition double pattNod = dlookup("OpsParms.txt",obsmode,"Patt"); // direction of nod double chopThrow = dlookup("OpsParms.txt",obsmode,"D1"); // // int[] ts = nodding_pointing(true,tSlewMin,tInitHold,tFinalHold,ib,naifid,ra,dec,fixed,pattNod,yOffset + deltaY,zOffset + deltaZ,nCycles * nNodPosns / 2,chopThrow,tp,tp,0,0,tHold,nHold,false); // // ***** choose observing mode ***** // bool isJiggleMap = true; SpireMsg(1," Using POF2 (7-pnt Jiggle Map) Observing Mode"); }{ // ******************************* // return instrument parameters // ******************************* // {string,double,double,double,double,bool}[] estimates = []; // if(isJiggleMap) { double osit = cycOsit * double(nCycles); estimates = SpirePOF2Estimate(osit,sourceFluxPSW,sourceFluxPMW,sourceFluxPLW,isBright); nCycles = pof2Obs{1}; // number of nod cycles to perform nNodInts = pof2Obs{3}; nCal = pof2Obs{4}; nFlash = pof2Obs{5}; } else { } // SpireMsg(3," Spire Photometry Pointing Mode parameters:"); SpireMsg(3," ..estimates: " + estimates); SpireMsg(3," ..isJiggleMap: " + isJiggleMap); SpireMsg(3," ..nCycles: " + nCycles); SpireMsg(3," ..nNodInts: " + nNodInts); SpireMsg(3," ..nCal: " + nCal); SpireMsg(3," ..nFlash: " + nFlash); return {estimates,isJiggleMap,nCycles,nNodInts,nCal,nFlash}; } // Missionphase : AOT validation // // Purpose : Setup SPU for photometry data flow // // Author : VDP / Bart Vandenbussche // // Arguments : // // Description : Configures photometry compression /reduction mode and (optionally) starts // reduction/compression and GAIN // // Dependencies : // // Comments : // // Version : 2.0 // // History : 1.0 created from PHOT_spu_setup // needed to set Gain for LowGain obs // implementation: SCR4196 i.e. gain and bit rounding // compression mode etc.. // 2.0 25-feb-2009 VD implement decimation new SPU function // 2.1 24-mar-2009 DAC Renamed spr1 & spr2 to rnd & rnds; // syncd to syncdel as per SPU UM 13.95a // int procedure PHOT_spu_gain_setup { string set_gain = "LOW" in ["HIGH","LOW"]; // Gain Blue settings: default = LOW int comp_mode_blu = 0; // Compression blue: default=0, double=1, half=2, lossless=4, transp=7, buffer=9 int comp_mode_red = 0; // Compression blue: default=0, double=1, half=2, lossless=4, transp=7, buffer=9 int nraw_blu = 3; // Number of raw channels transmitted in the blue SPU int nraw_red = 3; // Number of raw channels transmitted in the red SPU bool startSPU = true; // Start SPU or not [true,false] }{ // Duration accumulator (accumulated time expressed in milliseconds) // (no longer used) if(set_gain == "LOW") { int rnd = 0; // delay start label sequence by n frames int syncdel = 1; } else { rnd = 2; syncdel = 1; } int duration_msec = 0; // Stop the Long and Short SPUs Pacs_SPUS_STOP_REDUCT_COMPR(); Pacs_SPUL_STOP_REDUCT_COMPR(); // Set gain Pacs_BOLC_SET_GAIN(set_gain); // Set the SPU compression modes int[] aux = [comp_mode_blu,comp_mode_red]; int check_sum = checksum("int",aux); // Issue the TC {int}[] comp_par = Array2grp_1(aux); Pacs_DMC_WRT_SPU_TRAN_MODE(comp_par,check_sum); // Setting of start index of raw channels for SPUS and SPUL string spus_obs_mode = "PHOT"; string spul_obs_mode = "PHOT"; int spus_startraw = 1; int spul_startraw = 1; Pacs_SPUS_RAW_CHAN_TRAN_MODE(spus_obs_mode,nraw_blu,spus_startraw); Pacs_SPUL_RAW_CHAN_TRAN_MODE(spul_obs_mode,nraw_red,spul_startraw); // Photo "Ottensamer" block ("S" SPU) // PPF: Pre-Processing Flag (0: no PP, 1: addition, 2: subtraction, // 3: multiplication, 4: division) int ppf = 0; // PPP: Pre-Processing Parameter int ppp = 0; // Threshold for glitch detection in photometry int tfp = 1000; // Threshold for chopper position deviation in photometry int tcp = 100; // Glitch detection for photometry (1: no glitch detection) int gdfp = 1; // Override samples to average int navg = 0; // resolution reduction parameter 2 RND!!! // int spr1 = 0; defined as function of the set_gain value // resolution reduction parameter 3 int rnds = 0; // Lossless scheme int scm = 1; // lossless compression algoithm (0,1,2,3,4) int lcal = 4; // PACS Codec Order (3,4) int pcod = 3; // PACS Decimation // discard samples at the beginning of each averaged groups int dpre = 0; // discard samples at the nd of each averaged groups int dpost = 0; // Spare elements: 10 spare element; hardcoded as 0,0,... in operand // Create operand aux = [ppf,ppp,tfp,tcp,gdfp,navg,rnd,rnds,scm,lcal,pcod,dpre,dpost,syncdel,0,0,0,0,0,0,0,0,0,0]; check_sum = checksum("int",aux); // Convert to grp_1 syntax {int}[] spu_par = Array2grp_1(aux); // Issue TC Pacs_SPUS_WRT_DET_CST_PHOT(spu_par,check_sum); delay(1); // Photo "Ottensamer" block ("L" SPU) // PPF: Pre-Processing Flag (0: no PP, 1: addition, 2: subtraction, // 3: multiplication, 4: division) ppf = 0; // PPP: Pre-Processing Parameter ppp = 0; // Threshold for glitch detection in photometry tfp = 1000; // Threshold for chopper position deviation in photometry tcp = 100; // Glitch detection for photometry (1: no glitch detection) gdfp = 1; // Override samples to average navg = 0; // resolution reduction parameter 2 // spr1 = 0; defined as function of the set_gain value // resolution reduction parameter 3 rnds = 0; // Lossless compression scheme scm = 1; // lossless compression algoithm (0,1,2,3,4) lcal = 4; // PACS Codec Order (3,4) pcod = 3; // PACS Decimation // discard samples at the beginning of each averaged groups dpre = 0; // discard samples at the end of each averaged groups dpost = 0; // delay start of each label sequence by n frames syncdel = 1; // Spare elements: 10 spare element; hardcoded as 0,0,... in operand // Create operand aux = [ppf,ppp,tfp,tcp,gdfp,navg,rnd,rnds,scm,lcal,pcod,dpre,dpost,syncdel,0,0,0,0,0,0,0,0,0,0]; check_sum = checksum("int",aux); // Convert to grp_1 syntax spu_par = Array2grp_1(aux); // Issue TC Pacs_SPUL_WRT_DET_CST_PHOT(spu_par,check_sum); delay(1); // Send time stamps // DMC_WRT_TIME: Write the time sent by the DPU into the DMC buffer // (No action on this one?) // DPU sends the time to DEC/MEC Pacs_DPU_SEND_TIME(); // DMC_SET_TIME: Set the time previously written by the write time command Pacs_DMC_SET_TIME(); // Start reduction/compression if commanded to do so if(startSPU) { Pacs_SPUS_START_REDUCT_COMPR(); Pacs_SPUL_START_REDUCT_COMPR(); } return duration_msec; } // SpirePacsBbParallelInit // // $Id:$ // // Building Block to initialise the instrument for Parallel operation // // The complete instrument setup operation is divided into two parts: // Configuration: actions that can be executed during the slew to the start // position of the S/C pointing mode. // Initialisation: actions that must be carried out at the S/C intial pointing // position before any observational operations are executed. // // This building Block implements the second part of the setup // // 04 November 2008: first version // block SpirePacsBbParallelInit SPIRE 8337 { }{ int t = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB Parallel Initialisation started"); SpireMsg(2," $Id:$"); // // ..... configuration ..... // int cmd = 0x0; // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // set STEP to On Target tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP_RAW(0x8000)"); Spire_SET_OBS_STEP_RAW(0x8000); // // set detector offsets // // set DCU data mode to Auto Offset cmd = 0x843c0010; SpireSendDrcuCmd(cmd,0); // start auto offset generation cmd = 0x843e0001; SpireSendDrcuCmd(cmd,0); delay(15); // // dump detector offsets // stop auto offset generation cmd = 0x843e0000; SpireSendDrcuCmd(cmd,0); // set DCU data mode to get offset data cmd = 0x843c0018; SpireSendDrcuCmd(cmd,0); // start offset data dump cmd = 0x843e0001; SpireSendDrcuCmd(cmd,0); // set datarate double rate = 0.0; rate = dlookup("Datarates.txt","POffsets","DCU"); data_rate(rate); delay(5); // stop offset data dump cmd = 0x843e0000; SpireSendDrcuCmd(cmd,0); data_rate(0.0); // // flush data tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_FLUSH_FIFO_RAW(0x1000)"); Spire_FLUSH_FIFO_RAW(0x1000); delay(2); // // set up detectors for operations // SpireConfigDcuData("Parallel"); // // ..... completion ..... // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB Parallel Initialisation ended"); SpireMsg(1," ..Parallel Initialisation (" + (time() - t) + " seconds)"); } /////////////////////////////////////////////////////////////////////////// // $Id: $ /////////////////////////////////////////////////////////////////////////// // // SpireBb_SpecFSetPhase.txt // /////////////////////////////////////////////////////////////////////////// // // BB to set phase of spectrometer arrays // /////////////////////////////////////////////////////////////////////////// // // M.Pohlen: // 2008/08/11 V0.1: Initial version adapted from // SpireBb_PhotFSetPhase (V0.3 2008/07/04) using // SF_Phase.txt (v 1.4 2008/01/31 20:24:37) // 2009/02/19 V0.2: Instead of using commands call SpireProc_Set_SpecPhase // and add sync() after setBbId. Add HSpot messages. // Add debug_print. Remove unsetting of BBID at end. // /////////////////////////////////////////////////////////////////////////// // block SpireBb_SpecFSetPhase SPIRE 14012 { int ssw_phase = 0x0 in [0,255]; //Default phase is 0 [Hex] int slw_phase = 0x0 in [0,255]; //Default phase is 0 [Hex] bool debug = false; // Allow (==tick) or suppress cus debug_print statements }{ // // // // // Define some variables: // string hstr = ""; // a hex string string tstr = ""; // a time string // // // // // Start BB: // int t = time(); tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": SpireBb_SpecFSetPhase started"); SpireMsg(2," $Id: $"); hstr = SpireHexStr($BBID,8); SpireMsg(3," BBID = " + hstr); // // // // // Set the BBs to SPIRE bbid: // hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID(" + hstr + ")"); Spire_SET_BBID($BBID); sync(); // // // // // Set the phase for the two arrays: // SpireProc_Set_SpecPhase(ssw_phase,slw_phase,debug); // // // // // End BB: // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB SpireBb_SpecFSetPhase ended"); SpireMsg(1," ..Set Phot phases (" + (time() - t) + " secs)"); // } // SpireBbPOF5Init // // $Id: SpireBbPOF5Init.txt,v 1.1 2006/08/10 09:38:58 kking Exp $ // // Building Block to initialise the instrument for POF5 (scan map) operation // // The complete instrument setup operation is divided into two parts: // Configuration: actions that can be executed during the slew to the start // position of the S/C pointing mode. // Initialisation: actions that must be carried out at the S/C intial pointing // position before any observational operations are executed. // // This building Block implements the second part of the setup // // 04 November 2008: // added data_rate commands // added commands to setup the detector sampling // block SpireBbPOF5Init SPIRE 8273 { }{ int t = time(); string hstr = ""; // hex string string tstr = ""; // time string // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB POF5 Initialisation started"); SpireMsg(2," $Id: SpireBbPOF5Init.txt,v 1.1 2006/08/10 09:38:58 kking Exp $"); // // ..... configuration ..... // int cmd = 0x0; // // Set BBID hstr = SpireHexStr($BBID,8); tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_BBID_RAW(" + hstr + ")"); Spire_SET_BBID_RAW($BBID); // // set STEP to On Target tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_SET_OBS_STEP_RAW(0x8000)"); Spire_SET_OBS_STEP_RAW(0x8000); // // set detector offsets // set DCU data mode to Auto Offset cmd = 0x843c0010; SpireSendDrcuCmd(cmd,0); // start auto offset generation cmd = 0x843e0001; SpireSendDrcuCmd(cmd,0); delay(15); // // dump detector offsets // stop auto offset generation cmd = 0x843e0000; SpireSendDrcuCmd(cmd,0); // set DCU data mode to get offset data cmd = 0x843c0018; SpireSendDrcuCmd(cmd,0); // start offset data dump cmd = 0x843e0001; SpireSendDrcuCmd(cmd,0); // set datarate double rate = 0.0; rate = dlookup("Datarates.txt","POffsets","DCU"); data_rate(rate); delay(5); // stop offset data dump cmd = 0x843e0000; SpireSendDrcuCmd(cmd,0); data_rate(0.0); // // flush data tstr = SpireTimeStr(time()); SpireMsg(5," " + tstr + "Cmd: Spire_FLUSH_FIFO_RAW(0x1000)"); Spire_FLUSH_FIFO_RAW(0x1000); delay(2); // // set up detectors for operations // SpireConfigDcuData("POF5"); sync(); // // ..... completion ..... // tstr = SpireTimeStr(time()); SpireMsg(2," " + tstr + ": BB POF5 Initialisation ended"); SpireMsg(1," ..POF5 Initialisation (" + (time() - t) + " seconds)"); }