;---------------------------------------------------------------------------
; Document name: hsi_dp_extend_control.pro
;
; Last Modified:
;---------------------------------------------------------------------------
;
;+
; PROJECT:
;       HESSI
;
; NAME:
;       hsi_dp_extend_control
;
; PURPOSE:
;       Sets the default values of some of the dropout controls through the eventlist 
;
; CATEGORY:
;       Utilities (hessi/util)
;
; CALLING SEQUENCE:
;       result = hsi_dp_extend_control()
;
; OUTPUTS:
;       result: a variable of type {hsi_dp_extend}, withthe
;               default values
;
; SEE ALSO:
;       
;
; HISTORY:
; Pulled from hsi_eventlist_strategy_control and extended with dp_append.. and dp_prepend controls
; that allow extending datagaps in both directions
; 26-oct-2015, richard.schwartz@nasa.gov, data gap (dropout) control parameter defaults built in hsi_data_gap_control()
;  22-feb-2017, richard.schwartz@nasa.gov, extend from 9 elements  18 to cover rear det off periods
;  with 0 livetime and no events.
; 20-Nov-2020, Kim. Changed name of structure to hsi_dp_extend_control from hsi_dp_extend

;-

function hsi_dp_extend_control

var = {hsi_dp_extend_control}
;This parameter controls the extension of the datagap beyond and before the time where the
;detector is thought to turn on.  Sometimes we have to wait longer for the
;baseline to recover, especially after 1-jan-2006 in a2d's 0, 2, 3, and 5
dp_extend_utlim = dblarr(18)+anytim('1-jan-2025')
dp_extend_sec   = fltarr(18)+.02  ;seconds

dp_extend_utlim[0] = anytim('1-may-2005')

dp_extend_utlim[1] = anytim('1-mar-2006')
dp_extend_utlim[2] = anytim('1-nov-2005')
dp_extend_utlim[3] = anytim('1-jan-2006')
dp_extend_utlim[5] = anytim('1-jul-2004')
dp_extend_sec[[0,1,2,3,5]] =.010

;
var.dp_extend_utlim = dp_extend_utlim
var.dp_extend_sec   = dp_extend_sec        ;only used for times after dp_extend_utlim

var.dp_extend_def   = fltarr(18)            ; sec to append to data gap boundary for all times
;dp_extend_def and dp_append_def are the same and the greater of the two is used
var.dp_append_def   = fltarr(18)           ; greater of dp_extend_sec, dp_extend_def and dp_append_def used
var.dp_prepend_def   = fltarr(18)             ;sec to prepend data gap boundary 
;valid event number extensions applied after default time extensions
var.dp_prepend_nvalid  = intarr(18)  ;prepend data gap boundary by this many valid events
var.dp_append_nvalid = intarr(18)  ;append data gap boundary by this many valid events
return, var
end
