version: 1
# database settings:
#     db: unit_tests
#     host: localhost
#     user: utuser
#     password: utpass
#     loginPath: unittesting
#     tunnel: False

# # SSH TUNNEL - if a tunnel is required to connect to the database(s) then add setup here
# # Note only one tunnel is setup - may need to change this to 2 tunnels in the future if 
# # code, static catalogue database and transient database are all on seperate machines.
# ssh tunnel:
#     remote user: username
#     remote ip: mydomain.co.uk
#     remote datbase host: mydatabaseName
#     port: 9002

# instrument the data belongs to; `xsh` or `soxs`
instrument: xsh

soxs-mbias:
    # number of σ deviations from the median *pixel* flux beyond which pixel is excluded from stack
    stacked-clipping-sigma: 5
    # number of σ-clipping iterations to perform before stacking
    stacked-clipping-iterations: 5
    # number of σ below the median *frame* flux beyond which pixel is added to the bad-pixel mask
    clipping-lower-sigma: 5
    # number of σ above the median *frame* flux beyond which pixel is added to the bad-pixel mask
    clipping-upper-sigma: 5   
    # number of sigma-clipping iterations to perform when added pixels to the bad-pixel mask
    clipping-iteration-count: 5

soxs-mdark:
    # number of σ deviations from the median *pixel* flux beyond which pixel is excluded from stack
    stacked-clipping-sigma: 5
    # number of σ-clipping iterations to perform before stacking
    stacked-clipping-iterations: 5
    # number of σ below the median *frame* flux beyond which pixel is added to the bad-pixel mask
    clipping-lower-sigma: 5
    # number of σ above the median *frame* flux beyond which pixel is added to the bad-pixel mask
    clipping-upper-sigma: 5   
    # number of sigma-clipping iterations to perform when added pixels to the bad-pixel mask
    clipping-iteration-count: 5

soxs-disp-solution:
    pixel-window-size: 10
    order-deg: 3
    wavelength-deg: 3
    # number of sigma-clipping iterations to perform before settings on a polynomial fit for the dispersion solution
    poly-clipping-iteration-limit: 10

    poly-fitting-residual-clipping-sigma: 5

soxs-order-centre:
    order-sample-count: 200
    slice-length: 10
    peak-sigma-limit: 3
    # degree of dispersion axis component of polynomal fit to order-centre traces
    disp-axis-deg: 5
    # degree of order component of polynomal fit to order-centre traces
    order-deg: 5
    # number of sigma-clipping iterations to perform before settings on a polynomial fit for the order-centre traces
    poly-fitting-residual-clipping-sigma: 4.0
    poly-clipping-iteration-limit: 1

soxs-spatial-solution:
    pixel-window-size: 10
    order-deg: 3
    wavelength-deg: 3
    slit-deg: 3
    poly-clipping-iteration-limit: 10
    poly-fitting-residual-clipping-sigma: 5



soxs-mflat:
    # number of σ deviations from the median *pixel* flux beyond which pixel is excluded from stack
    stacked-clipping-sigma: 5
    # number of σ-clipping iterations to perform before stacking
    stacked-clipping-iterations: 5
    # number of σ below the median *frame* flux beyond which pixel is added to the bad-pixel mask
    clipping-lower-sigma: 50
    # number of σ above the median *frame* flux beyond which pixel is added to the bad-pixel mask
    clipping-upper-sigma: 100   
    # number of sigma-clipping iterations to perform when added pixels to the bad-pixel mask
    clipping-iteration-count: 0
    # width of the slice to cut along the centre of each order when determining mean exposure level
    centre-order-window: 13
    # length of image slice to take across orders when detecting edges
    slice-length-for-edge-detection: 90
    # width of image slice to take across orders when detecting edges
    slice-width-for-edge-detection: 5
    # minimum value flux can drop to as percentage of central flux and be counted as an order edge
    min-percentage-threshold-for-edge-detection: 20
    # maximum value flux can claim to as percentage of central flux and be counted as an order edge
    max-percentage-threshold-for-edge-detection: 50
    # degree of dispersion axis component of polynomal fit to order edges
    disp-axis-deg: 3
    # degree of order component of polynomal fit to order edges
    order-deg: 3
    # number of σ deviations from the median fit residual beyond which individual data points are removed when iterating towards a fit of order edges
    poly-fitting-residual-clipping-sigma: 3.0
    # number of sigma-clipping iterations to perform before settings on a polynomial fit for the order edges
    poly-clipping-iteration-limit: 2
    # number of σ deviations below the median flux of a master-flat frame beyond which a pixel is added to the bad-pixel mask
    low-sensitivity-clipping-simga: 2
    
soxs-stare:
    # number of σ deviations from the median *pixel* flux beyond which pixel is excluded from stack
    stacked-clipping-sigma: 5
    # number of σ-clipping iterations to perform before stacking
    stacked-clipping-iterations: 5
    # number of σ below the median *frame* flux beyond which pixel is added to the bad-pixel mask
    clipping-lower-simga: 10
    # number of σ above the median *frame* flux beyond which pixel is added to the bad-pixel mask
    clipping-upper-simga: 10 
    # number of sigma-clipping iterations to perform when added pixels to the bad-pixel mask
    clipping-iteration-count: 0
    clipping-lower-sigma: 10
    clipping-upper-sigma: 10 

# sky-subtraction:
#     # MEDIAN CLIPPING FIRST USED TO CLIP MOST DEVIANT PIXELS (BAD AND CRHs)
#     median_clipping_sigma: 4.0
#     median_clipping_iterations: 15
#     # ROLLING WINDOW LENGTH IN DATA POINTS
#     median_rolling_window_size: 44
#     # PECENTILE CLIPPING USED TO CLIP THE OBJECT(S) BEFORE FITTING A SKY MODEL
#     percential_clipping_sigma: 2.
#     percential_clipping_iterations: 3
#     aggressive_object_masking: True
#     percential_rolling_window_size: 15

sky-subtraction:
    # MEDIAN CLIPPING FIRST USED TO CLIP MOST DEVIANT PIXELS (BAD AND CRHs)
    median_clipping_sigma: 4.5
    median_clipping_iterations: 3
    # ROLLING WINDOW LENGTH IN DATA POINTS
    median_rolling_window_size: 31
    # PECENTILE CLIPPING USED TO CLIP THE OBJECT(S) BEFORE FITTING A SKY MODEL
    percential_clipping_sigma: 2.9
    percential_clipping_iterations: 10
    percential_rolling_window_size: 15
    aggressive_object_masking: True
    bspline_order: 3
        
soxs-straighten:
    asdasd: 1

# UTILS
background-subtraction:
    bspline-deg: 2
    median-filter-pixels: 9

test-data-root: ~/xshooter-pipeline-data/unittest_data/xsh
intermediate-data-root: ~/soxspipe-unittests/intermediate/xsh
reduced-data-root: ~/soxspipe-unittests/reduced/xsh



data-extension: 0

# INTERMEDIATE DATA PRODUCTS CAN CONSUME A LOT OF STORAGE SPACE - BE WARNED
save-intermediate-products: True

logging settings:
    formatters:
        file_style:
            format: '* %(asctime)s - %(name)s - %(levelname)s (%(pathname)s > %(funcName)s > %(lineno)d) - %(message)s  '
            datefmt: '%Y/%m/%d %H:%M:%S'
        console_style:
            format: '* %(asctime)s - %(levelname)s: %(pathname)s:%(funcName)s:%(lineno)d > %(message)s'
            datefmt: '%H:%M:%S'
        html_style:
            format: '<div id="row" class="%(levelname)s"><span class="date">%(asctime)s</span>   <span class="label">file:</span><span class="filename">%(filename)s</span>   <span class="label">method:</span><span class="funcName">%(funcName)s</span>   <span class="label">line#:</span><span class="lineno">%(lineno)d</span> <span class="pathname">%(pathname)s</span>  <div class="right"><span class="message">%(message)s</span><span class="levelname">%(levelname)s</span></div></div>'
            datefmt: '%Y-%m-%d <span class= "time">%H:%M <span class= "seconds">%Ss</span></span>'
    handlers:
        console:
            class: logging.StreamHandler
            level: DEBUG
            formatter: console_style
            stream: ext://sys.stdout
        file:
            class: logging.handlers.GroupWriteRotatingFileHandler
            level: INFO
            formatter: file_style
            filename: ~/.config/soxspipe/soxspipe.log
            mode: w+
            maxBytes: 102400
            backupCount: 1
    root:
        level: INFO
        handlers: [file,console]
