Example of calibration observation with pointing request

Header's information

// $Id$
// Missionphase         : PACS PV Phase
//
// Purpose :            Wavelength calibration and instrumental profile
//                       with Chop/Nod
// Author                : HF
//
// Arguments            :
//
// Prerequisite         : PACS does not need to be on nor setup for spectroscopy
//
// Description          : Uses OBCP27 for executing a parameterized scan of any length,
//                        stepsize etc. Represents a generic chopped grating scan
// Comments             :
//
// Version              : 1.0
// 
// History              : 0.1 Using example from PacsCal_WaveCalNoChop
//                      : 1.0 perform calibrations during slew and 
//                         then a wavelength calibration on source
//                         usng NOD=1 and Choping

Script type declaration as observation (i.e. inc. a pointing request), and X-HSPOT readable variables

obs PacsCal_WaveCalChop {
       /* Needed variables to call WaveCalChop */
       string fltPOS = "POS A" in ["POS A","POS B"]; //Filter wheel position 0="POS A", 1="POS B"
       int grat_pos = 500000; // grating start position for scan
       int grat_time = 0; // time for grating to move to start position [msec]
       int grat_step_up = 200; // grating step size
       int nb_ramps_plateau = 1; // number of readouts per grating position
       int grat_step_dn = 200; // grating step size
       int nb_grat_steps = 50; // number of grating steps in one direction
       int order   = 2;      // Where to leave FltW (as order 1=Red, 2= or 3= Blue)                
       int nb_SRC_REF = 3;   // number of ramps (cycles) per grating position
       int nb_CS1_CS2 = 0; // nb of cycles on internal CS
       int nb_rdouts_ramp = 64; // number of readouts per ramp
       int nb_up_down = 1;  // number of grating updown scans
       int nb_raw_red = 3; // number of red pixels
       int nb_raw_blu = 3; // number of blue pixels
       int capa_red = 12; // Red capacitor
       int capa_blu = 12; // Blue capacitor
       double bias_r_blu = 0.01; // Bias "r" blue
       double bias_r_red = 0.01; // Bias "r" red
       double bias_d_blu = 0.198; // Bias "d" blue
       double bias_d_red = 0.069; // Bias "d" red
       int comp_mode_blu = 16; // compression mode for blue detector
       int detector = 1; // 1=blue 2=red (sync on detector)
       int comp_mode_red = 16; // compression mode for red detector
       int nb_samp_subramp_blu = 64; // Nb of blue samples per sub-ramp
       int nb_samp_subramp_red = 64; // Nb of red samples per sub-ramp
       int naifid = 0; //0 = Non Solar System source, >0 if fast tracking is required (Solar System sources) 
       double yoffset = 0.0;  // yoffset [arcsec]
       double zoffset = 0.0;  // xoffset [arcsec]
       double ra = 0.0;  // RA
       double dec = 0.0;  // DEC
       int nnod = 1; // number of nods (AB or BA)
       double chopthrow =  30.; // chop/nod throw
       bool verbose =  true;
}

internal variables declaration and timing computation

{

// compiting time for slw / calibration during slew time and others
//Execute the pointing request
       bool execute = true;
// Set OBSID
   int tobsid = duration(WriteOBSID($OBSID));

// Verification for grating and chopper hard limits
   int [] gratpos = [grat_pos,grat_step_up,nb_grat_steps];
   Pacs_HardLimitsCheck(gratpos,chopthrow);
//  end verif'

// Calibration time during slew
// SPEC parameters for BLU and RED               

   {int,int,int,int,int,int,int,int,int} 
   [] confSPECblu = [{0,comp_mode_blu,nb_raw_blu,0,0,0,0,0,0}];
   {int,int,int,int,int,int,int,int,int} 
   [] confSPECred = [{0,comp_mode_red,nb_raw_red,0,0,0,0,0,0}];
// OBCP parameters none is given since PacsSpecSlewCal takes them from OBCPparam                
  {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}];
   
// frstLstGratPos is the last position for the grating after the Cals done
// during Slew time... must be same as observations start position: grat_pos   
// Perform/don't AOT prologue                    

   bool doPROLOG= true;
   // "N/A" in string because of indexing 0,1,2,3
   string [] choix = ["N/A","order1","order2","order3"];    
   string order_str = ""+order;
   if ( choix[order] != "order1" ) {   
   double keyWAVE1 = dlookup("KEY_WAVES",order_str,"KeyWave1");
   double [] keyWAVE = [keyWAVE1];
   int tpacsSlewCal = duration(PacsSpecSlewCal(verbose,confSPECblu,confSPECred,confOBCP,doPROLOG,keyWAVE,order,grat_pos,choix[order]));
   } else {
   keyWAVE1 = dlookup("KEY_WAVES",order_str,"KeyWave1");
   double keyWAVE2 = dlookup("KEY_WAVES",order_str,"KeyWave2");
   keyWAVE = [keyWAVE1,keyWAVE2];   
   tpacsSlewCal = duration(PacsSpecSlewCal(verbose,confSPECblu,confSPECred,confOBCP,doPROLOG,keyWAVE,order,grat_pos,choix[order]));
   }

//Initial hold
       int tih = 0;
//Final hold
       int tendobsid = duration(WriteEndID());
       int grat_def = ilookup("SPEC_MEC_Defaults","Spectroscopy","grating");
       int tepilog = duration(SPEC_aot_epilogue(grat_pos,grat_def,verbose));
       int tfh = tendobsid + tepilog;
//Duration of stable pointing

     int tp = duration(WaveCalChop(fltPOS,grat_pos,grat_time,grat_step_up,grat_step_dn,
     nb_grat_steps,nb_CS1_CS2,nb_rdouts_ramp,nb_ramps_plateau,nb_up_down,
     capa_red,capa_blu,bias_r_blu,bias_r_red,bias_d_blu,bias_d_red,
     nb_samp_subramp_blu,nb_samp_subramp_red,nb_SRC_REF,chopthrow,
     detector));
     if ( verbose ){debug_print("Duration of WaveCalChop" +tp+"sec");}
     if (tp < 10){error ("The dwell time cannot be smaller than 10 sec, adjust parameters");}
//
//Use SPECTRO virtual aperture
    string ib = "P02_0";
//Non-solar source
    int naifid = 0;
    bool startAtB = false; // start AB cycle (true start BA)
    bool fixed = false; // NOD same direction as CHOPPING fixed ON sky
    double pattnod = 0.; // Nod along chop direction
    int tloadmin = 0;
    int nload = 0;
    int thold = 0;
    int nhold = 0;
    int tpa = tp;
    int tpb = tp;
//Issue PointReq
     int tslewmin = tobsid + tpacsSlewCal;
     if ( verbose ){debug_print("Slewing time is:"+tslewmin+"sec");}

Pointing request(s), here may be included logical statements to request different pointings

     int[] ts = nodding_pointing(execute,tslewmin,tih,tfh,ib,naifid,ra,dec,fixed,pattnod,yoffset,zoffset,nnod,chopthrow,tpa,tpb,tloadmin,nload,thold,nhold,startAtB);
//

}

State machine: each state corresponds to a telescope pointing status: an observation corresponds to a sequence of pointing state determined by the pointing request

{
       int[] state = [0];
       while(state[0] >= 0) {
         state = next_state();
           if ( state[0] == 1 ) {
           int tNOW = time();
// slew time calibration
           WriteOBSID($OBSID);
           if ( verbose ){debug_print("Slewing starts at :"+tNOW+" sec");}
          if ( choix[order] == "order1" ) {
           PacsSpecSlewCal(false,confSPECblu,confSPECred,confOBCP,doPROLOG,keyWAVE,order,grat_pos,choix[order]);
           } else {
           PacsSpecSlewCal(false,confSPECblu,confSPECred,confOBCP,doPROLOG,keyWAVE,order,grat_pos,choix[order]);
           }
           tNOW = time();
           if ( verbose ){debug_print("Slewing ends at "+tNOW+" sec");}
           } else {
           if ( state[0] == 3 ) { 
//       Call the WaveCal procedure
         tNOW = time();
           if (verbose ){debug_print("Observation on SRC starts at :"+tNOW+" sec");}
         WaveCalChop(fltPOS,grat_pos,grat_time,grat_step_up,grat_step_dn,nb_grat_steps,nb_CS1_CS2,nb_rdouts_ramp,nb_ramps_plateau,nb_up_down,capa_red,capa_blu,bias_r_blu,bias_r_red,bias_d_blu,bias_d_red,nb_samp_subramp_blu,nb_samp_subramp_red,nb_SRC_REF,chopthrow,detector);
         tNOW = time();
            if (verbose ){debug_print("Observation on SRC ends at :"+tNOW+" sec");}
             } else {
             if(state[0] == 7 ) { 
//       Call the WaveCal procedure
         tNOW = time();
         if (verbose ){debug_print("Observation at NOD starts at :"+tNOW+" sec");}

WaveCalChop(fltPOS,grat_pos,grat_time,grat_step_up,grat_step_dn,nb_grat_steps,nb_CS1_CS2,nb_rdouts_ramp,nb_ramps_plateau,nb_up_down,capa_red,capa_blu,bias_r_blu,bias_r_red,bias_d_blu,bias_d_red,nb_samp_subramp_blu,nb_samp_subramp_red,nb_SRC_REF,chopthrow,detector);
         tNOW = time();
         if (verbose ){debug_print("Observation at NOD ends at :"+tNOW+" sec");}
         } else {
           if ( state[0] == 5 ) {
         tNOW = time();
           if (verbose ){debug_print("Final Hold starts at :"+tNOW+" sec");}     
           SPEC_aot_epilogue(grat_pos,grat_def,verbose);
           WriteEndID();
         tNOW = time();
           if (verbose ){debug_print("Final Hold ends at :"+tNOW+" sec");}                 
       }
}
// End of Observation

Herschel: PacsCal_WaveCalChop (last edited 2009-07-15 14:32:36 by localhost)