Test instantiating PypIt parameter sets


In [1]:
# import
import os
from configobj import ConfigObj
from pypit.par import pypitpar

General usage


In [2]:
# To get the default parameters, declare the parameters set
# without arguments
p = pypitpar.ProcessImagesPar()
# Use print() to get a short-form representation
print('Print output:')
print(p)
# Use the info() method to get a long-form representation
print('.info() output:')
p.info()
# Both of these can go haywire for complex constructions of
# parameter sets (sets within sets) but are well formatted
# in the simplest cases

# Use the to_config() method to output to a *.cfg file with
# comments for each item.  You have to provide a section
# name in most cases.
p.to_config('test_process.cfg', section_name='process')
# You can also use the to_config() method to just get the
# list of strings that are then written to the file.  This
# is useful when you want to reconstruct a ConfigObj.
p_cfgobj = ConfigObj(p.to_config(cfg_file=None, section_name='process'))
print(p_cfgobj)


Print output:
Parameter     Value       Default     Type        Callable
----------------------------------------------------------
overscan      savgol      savgol      str         False   
overscan_par  5, 65       5, 65       int, list   False   
match         -1          -1          int, float  False   
combine       weightmean  weightmean  str         False   
satpix        reject      reject      str         False   
sigrej        20.0        20.0        int, float  False   
n_lohi        0, 0        0, 0        list        False   
sig_lohi      3.0, 3.0    3.0, 3.0    list        False   
replace       maxnonsat   maxnonsat   str         False   
lamaxiter     1           1           int         False   
grow          1.5         1.5         int, float  False   
rmcompact     True        True        bool        False   
sigclip       5.0         5.0         int, float  False   
sigfrac       0.3         0.3         int, float  False   
objlim        5.0         5.0         int, float  False   

.info() output:
overscan
        Value: savgol
      Default: savgol
      Options: polynomial, savgol, median
  Valid Types: str
     Callable: False
  Description: Method used to fit the overscan.  Options are: polynomial, savgol, median
 
overscan_par
        Value: [5, 65]
      Default: [5, 65]
      Options: None
  Valid Types: int, list
     Callable: False
  Description: Parameters for the overscan subtraction.  For 'polynomial', set overcan_par = order, number of pixels, number of repeats ; for 'savgol', set overscan_par = order, window size ; for 'median', set overscan_par = None or omit the keyword.
 
match
        Value: -1
      Default: -1
      Options: None
  Valid Types: int, float
     Callable: False
  Description: (Deprecate?) Match frames with pixel counts that are within N-sigma of one another, where match=N below.  If N < 0, nothing is matched.
 
combine
        Value: weightmean
      Default: weightmean
      Options: mean, median, weightmean
  Valid Types: str
     Callable: False
  Description: Method used to combine frames.  Options are: mean, median, weightmean
 
satpix
        Value: reject
      Default: reject
      Options: reject, force, nothing
  Valid Types: str
     Callable: False
  Description: Handling of saturated pixels.  Options are: reject, force, nothing
 
sigrej
        Value: 20.0
      Default: 20.0
      Options: None
  Valid Types: int, float
     Callable: False
  Description: Sigma level to reject cosmic rays (<= 0.0 means no CR removal)
 
n_lohi
        Value: [0, 0]
      Default: [0, 0]
      Options: None
  Valid Types: list
     Callable: False
  Description: Number of pixels to reject at the lowest and highest ends of the distribution; i.e., n_lohi = low, high.  Use None for no limit.
 
sig_lohi
        Value: [3.0, 3.0]
      Default: [3.0, 3.0]
      Options: None
  Valid Types: list
     Callable: False
  Description: Sigma-clipping level at the low and high ends of the distribution; i.e., sig_lohi = low, high.  Use None for no limit.
 
replace
        Value: maxnonsat
      Default: maxnonsat
      Options: min, max, mean, median, weightmean, maxnonsat
  Valid Types: str
     Callable: False
  Description: If all pixels are rejected, replace them using this method.  Options are: min, max, mean, median, weightmean, maxnonsat
 
lamaxiter
        Value: 1
      Default: 1
      Options: None
  Valid Types: int
     Callable: False
  Description: Maximum number of iterations for LA cosmics routine.
 
grow
        Value: 1.5
      Default: 1.5
      Options: None
  Valid Types: int, float
     Callable: False
  Description: Factor by which to expand regions with cosmic rays detected by the LA cosmics routine.
 
rmcompact
        Value: True
      Default: True
      Options: None
  Valid Types: bool
     Callable: False
  Description: Remove compact detections in LA cosmics routine
 
sigclip
        Value: 5.0
      Default: 5.0
      Options: None
  Valid Types: int, float
     Callable: False
  Description: Sigma level for rejection in LA cosmics routine
 
sigfrac
        Value: 0.3
      Default: 0.3
      Options: None
  Valid Types: int, float
     Callable: False
  Description: Fraction for the lower clipping threshold in LA cosmics routine.
 
objlim
        Value: 5.0
      Default: 5.0
      Options: None
  Valid Types: int, float
     Callable: False
  Description: Object detection limit in LA cosmics routine
 
{'process': {'overscan': 'savgol', 'overscan_par': ['5', '65'], 'match': '-1', 'combine': 'weightmean', 'satpix': 'reject', 'sigrej': '20.0', 'n_lohi': ['0', '0'], 'sig_lohi': ['3.0', '3.0'], 'replace': 'maxnonsat', 'lamaxiter': '1', 'grow': '1.5', 'rmcompact': 'True', 'sigclip': '5.0', 'sigfrac': '0.3', 'objlim': '5.0'}}

Demo of parameter defaults

The following just shows the results of the default parameter sets to show what parameters are defined and where.

Reduction parameter set

The reduction parameter set provides some global parameters for the data reduction.


In [3]:
pypitpar.ReducePar()


Out[3]:
Parameter     Value    Default  Type        Callable
----------------------------------------------------
spectrograph  None     None     str         False   
pipeline      None     None     str         False   
detnum        None     None     list        False   
sortroot      None     None     str         False   
calwin        0        0        int, float  False   
scidir        Science  Science  str         False   
qadir         QA       QA       str         False   

Frame groups

Parameters used for each frame type (bias, pixelflat, etc) are abstracted to a single "Frame-Group" parameter set. The default is 'bias'; valid frame types are shown using the static method valid_frame_types (see below). The parameters used to process the images in the frame group is a subset of FrameGroupPar, called ProcessImagesPar.


In [4]:
pypitpar.ProcessImagesPar()


Out[4]:
Parameter     Value       Default     Type        Callable
----------------------------------------------------------
overscan      savgol      savgol      str         False   
overscan_par  5, 65       5, 65       int, list   False   
match         -1          -1          int, float  False   
combine       weightmean  weightmean  str         False   
satpix        reject      reject      str         False   
sigrej        20.0        20.0        int, float  False   
n_lohi        0, 0        0, 0        list        False   
sig_lohi      3.0, 3.0    3.0, 3.0    list        False   
replace       maxnonsat   maxnonsat   str         False   
lamaxiter     1           1           int         False   
grow          1.5         1.5         int, float  False   
rmcompact     True        True        bool        False   
sigclip       5.0         5.0         int, float  False   
sigfrac       0.3         0.3         int, float  False   
objlim        5.0         5.0         int, float  False   

In [5]:
pypitpar.FrameGroupPar.valid_frame_types()


Out[5]:
['bias', 'pixelflat', 'arc', 'pinhole', 'trace', 'standard', 'science', 'all']

In [6]:
pypitpar.FrameGroupPar()


Out[6]:
Parameter  Value      Default    Type          Callable
-------------------------------------------------------
frametype  bias       bias       str           False   
useframe   bias       None       str           False   
number     0          0          int           False   
process    see below  see below  ParSet, dict  False   

process
Parameter     Value       Default     Type        Callable
----------------------------------------------------------
overscan      savgol      savgol      str         False   
overscan_par  5, 65       5, 65       int, list   False   
match         -1          -1          int, float  False   
combine       weightmean  weightmean  str         False   
satpix        reject      reject      str         False   
sigrej        20.0        20.0        int, float  False   
n_lohi        0, 0        0, 0        list        False   
sig_lohi      3.0, 3.0    3.0, 3.0    list        False   
replace       maxnonsat   maxnonsat   str         False   
lamaxiter     1           1           int         False   
grow          1.5         1.5         int, float  False   
rmcompact     True        True        bool        False   
sigclip       5.0         5.0         int, float  False   
sigfrac       0.3         0.3         int, float  False   
objlim        5.0         5.0         int, float  False   

Calibrations parameter set

CalibrationsPar is a super set of other parameter groups that are needed for the calibration data. It is built up of 10 other parameter sets, plus a few additional single parameters like where to save the master frames. Six of these are instances of FrameGroupPar for the bias, arc, pixelflat, pinhole, trace and standard frames (see above). The remaining four set how to peform the field flattening (FlatFieldPar), determine the wavelength solution (WavelengthSolutionPar), trace the spatial position of the slits along the dispersion axis (TraceSlitsPar), and trace the shift in the wavelength solution as a function of spatial position within a slit (WaveTiltsPar)


In [7]:
pypitpar.FlatFieldPar()


Out[7]:
Parameter    Value      Default    Type       Callable
------------------------------------------------------
frame        pixelflat  pixelflat  str        False   
slitprofile  True       True       bool       False   
method       bspline    bspline    str        False   
params       20         20         int, list  False   
twodpca      0          0          int        False   

In [8]:
pypitpar.WavelengthSolutionPar()


Out[8]:
Parameter  Value         Default       Type              Callable
-----------------------------------------------------------------
reference  arc           arc           str               False   
method     arclines      arclines      str               False   
lamps      None          None          list              False   
detection  6.0           6.0           int, float        False   
numsearch  20            20            int               False   
nfitpix    5             5             int               False   
IDpixels   None          None          int, list         False   
IDwaves    None          None          int, float, list  False   
medium     vacuum        vacuum        str               False   
frame      heliocentric  heliocentric  str               False   

In [9]:
pypitpar.TraceSlitsPar()


Out[9]:
Parameter      Value             Default           Type        Callable
-----------------------------------------------------------------------
function       legendre          legendre          str         False   
polyorder      3                 3                 int         False   
medrep         0                 0                 int         False   
number         -1                -1                int         False   
trim           3, 3              3, 3              tuple       False   
maxgap         None              None              int         False   
maxshift       0.15              0.15              int, float  False   
pad            0                 0                 int         False   
sigdetect      20.0              20.0              int, float  False   
fracignore     0.01              0.01              float       False   
diffpolyorder  2                 2                 int         False   
single         []                []                list        False   
sobel_mode     nearest           nearest           str         False   
pcatype        pixel             pixel             str         False   
pcapar         3, 2, 1, 0, 0, 0  3, 2, 1, 0, 0, 0  list        False   
pcaextrap      0, 0              0, 0              list        False   

In [10]:
pypitpar.WaveTiltsPar()


Out[10]:
Parameter    Value     Default   Type                       Callable
--------------------------------------------------------------------
idsonly      False     False     bool                       False   
tracethresh  1000.0    1000.0    int, float, list, ndarray  False   
order        2         2         int                        False   
function     legendre  legendre  str                        False   
yorder       4         4         int                        False   
func2D       legendre  legendre  str                        False   
method       spca      spca      str                        False   
params       1, 1, 0   1, 1, 0   int, list                  False   

In [11]:
# Putting it all together, the CalibrationsPar parameter set looks like this:
pypitpar.CalibrationsPar()


Out[11]:
Parameter       Value      Default    Type          Callable
------------------------------------------------------------
caldir          MF         MF         str           False   
masters         None       None       str           False   
setup           None       None       str           False   
trim            True       True       bool          False   
badpix          True       True       bool          False   
biasframe       see below  see below  ParSet, dict  False   
arcframe        see below  see below  ParSet, dict  False   
pixelflatframe  see below  see below  ParSet, dict  False   
pinholeframe    see below  see below  ParSet, dict  False   
traceframe      see below  see below  ParSet, dict  False   
standardframe   see below  see below  ParSet, dict  False   
flatfield       see below  see below  ParSet, dict  False   
wavelengths     see below  see below  ParSet, dict  False   
slits           see below  see below  ParSet, dict  False   
tilts           see below  see below  ParSet, dict  False   

biasframe
Parameter  Value      Default    Type          Callable
-------------------------------------------------------
frametype  bias       bias       str           False   
useframe   bias       None       str           False   
number     5          0          int           False   
process    see below  see below  ParSet, dict  False   

biasframe:process
Parameter     Value       Default     Type        Callable
----------------------------------------------------------
overscan      savgol      savgol      str         False   
overscan_par  5, 65       5, 65       int, list   False   
match         -1          -1          int, float  False   
combine       weightmean  weightmean  str         False   
satpix        reject      reject      str         False   
sigrej        20.0        20.0        int, float  False   
n_lohi        0, 0        0, 0        list        False   
sig_lohi      3.0, 3.0    3.0, 3.0    list        False   
replace       maxnonsat   maxnonsat   str         False   
lamaxiter     1           1           int         False   
grow          1.5         1.5         int, float  False   
rmcompact     True        True        bool        False   
sigclip       5.0         5.0         int, float  False   
sigfrac       0.3         0.3         int, float  False   
objlim        5.0         5.0         int, float  False   

arcframe
Parameter  Value      Default    Type          Callable
-------------------------------------------------------
frametype  arc        bias       str           False   
useframe   arc        None       str           False   
number     1          0          int           False   
process    see below  see below  ParSet, dict  False   

arcframe:process
Parameter     Value       Default     Type        Callable
----------------------------------------------------------
overscan      savgol      savgol      str         False   
overscan_par  5, 65       5, 65       int, list   False   
match         -1          -1          int, float  False   
combine       weightmean  weightmean  str         False   
satpix        reject      reject      str         False   
sigrej        -1          20.0        int, float  False   
n_lohi        0, 0        0, 0        list        False   
sig_lohi      3.0, 3.0    3.0, 3.0    list        False   
replace       maxnonsat   maxnonsat   str         False   
lamaxiter     1           1           int         False   
grow          1.5         1.5         int, float  False   
rmcompact     True        True        bool        False   
sigclip       5.0         5.0         int, float  False   
sigfrac       0.3         0.3         int, float  False   
objlim        5.0         5.0         int, float  False   

pixelflatframe
Parameter  Value      Default    Type          Callable
-------------------------------------------------------
frametype  pixelflat  bias       str           False   
useframe   pixelflat  None       str           False   
number     5          0          int           False   
process    see below  see below  ParSet, dict  False   

pixelflatframe:process
Parameter     Value       Default     Type        Callable
----------------------------------------------------------
overscan      savgol      savgol      str         False   
overscan_par  5, 65       5, 65       int, list   False   
match         -1          -1          int, float  False   
combine       weightmean  weightmean  str         False   
satpix        reject      reject      str         False   
sigrej        20.0        20.0        int, float  False   
n_lohi        0, 0        0, 0        list        False   
sig_lohi      3.0, 3.0    3.0, 3.0    list        False   
replace       maxnonsat   maxnonsat   str         False   
lamaxiter     1           1           int         False   
grow          1.5         1.5         int, float  False   
rmcompact     True        True        bool        False   
sigclip       5.0         5.0         int, float  False   
sigfrac       0.3         0.3         int, float  False   
objlim        5.0         5.0         int, float  False   

pinholeframe
Parameter  Value      Default    Type          Callable
-------------------------------------------------------
frametype  pinhole    bias       str           False   
useframe   pinhole    None       str           False   
number     0          0          int           False   
process    see below  see below  ParSet, dict  False   

pinholeframe:process
Parameter     Value       Default     Type        Callable
----------------------------------------------------------
overscan      savgol      savgol      str         False   
overscan_par  5, 65       5, 65       int, list   False   
match         -1          -1          int, float  False   
combine       weightmean  weightmean  str         False   
satpix        reject      reject      str         False   
sigrej        20.0        20.0        int, float  False   
n_lohi        0, 0        0, 0        list        False   
sig_lohi      3.0, 3.0    3.0, 3.0    list        False   
replace       maxnonsat   maxnonsat   str         False   
lamaxiter     1           1           int         False   
grow          1.5         1.5         int, float  False   
rmcompact     True        True        bool        False   
sigclip       5.0         5.0         int, float  False   
sigfrac       0.3         0.3         int, float  False   
objlim        5.0         5.0         int, float  False   

traceframe
Parameter  Value      Default    Type          Callable
-------------------------------------------------------
frametype  trace      bias       str           False   
useframe   trace      None       str           False   
number     3          0          int           False   
process    see below  see below  ParSet, dict  False   

traceframe:process
Parameter     Value       Default     Type        Callable
----------------------------------------------------------
overscan      savgol      savgol      str         False   
overscan_par  5, 65       5, 65       int, list   False   
match         -1          -1          int, float  False   
combine       weightmean  weightmean  str         False   
satpix        reject      reject      str         False   
sigrej        20.0        20.0        int, float  False   
n_lohi        0, 0        0, 0        list        False   
sig_lohi      3.0, 3.0    3.0, 3.0    list        False   
replace       maxnonsat   maxnonsat   str         False   
lamaxiter     1           1           int         False   
grow          1.5         1.5         int, float  False   
rmcompact     True        True        bool        False   
sigclip       5.0         5.0         int, float  False   
sigfrac       0.3         0.3         int, float  False   
objlim        5.0         5.0         int, float  False   

standardframe
Parameter  Value      Default    Type          Callable
-------------------------------------------------------
frametype  standard   bias       str           False   
useframe   standard   None       str           False   
number     1          0          int           False   
process    see below  see below  ParSet, dict  False   

standardframe:process
Parameter     Value       Default     Type        Callable
----------------------------------------------------------
overscan      savgol      savgol      str         False   
overscan_par  5, 65       5, 65       int, list   False   
match         -1          -1          int, float  False   
combine       weightmean  weightmean  str         False   
satpix        reject      reject      str         False   
sigrej        20.0        20.0        int, float  False   
n_lohi        0, 0        0, 0        list        False   
sig_lohi      3.0, 3.0    3.0, 3.0    list        False   
replace       maxnonsat   maxnonsat   str         False   
lamaxiter     1           1           int         False   
grow          1.5         1.5         int, float  False   
rmcompact     True        True        bool        False   
sigclip       5.0         5.0         int, float  False   
sigfrac       0.3         0.3         int, float  False   
objlim        5.0         5.0         int, float  False   

flatfield
Parameter    Value      Default    Type       Callable
------------------------------------------------------
frame        pixelflat  pixelflat  str        False   
slitprofile  True       True       bool       False   
method       bspline    bspline    str        False   
params       20         20         int, list  False   
twodpca      0          0          int        False   

wavelengths
Parameter  Value         Default       Type              Callable
-----------------------------------------------------------------
reference  arc           arc           str               False   
method     arclines      arclines      str               False   
lamps      None          None          list              False   
detection  6.0           6.0           int, float        False   
numsearch  20            20            int               False   
nfitpix    5             5             int               False   
IDpixels   None          None          int, list         False   
IDwaves    None          None          int, float, list  False   
medium     vacuum        vacuum        str               False   
frame      heliocentric  heliocentric  str               False   

slits
Parameter      Value             Default           Type        Callable
-----------------------------------------------------------------------
function       legendre          legendre          str         False   
polyorder      3                 3                 int         False   
medrep         0                 0                 int         False   
number         -1                -1                int         False   
trim           3, 3              3, 3              tuple       False   
maxgap         None              None              int         False   
maxshift       0.15              0.15              int, float  False   
pad            0                 0                 int         False   
sigdetect      20.0              20.0              int, float  False   
fracignore     0.01              0.01              float       False   
diffpolyorder  2                 2                 int         False   
single         []                []                list        False   
sobel_mode     nearest           nearest           str         False   
pcatype        pixel             pixel             str         False   
pcapar         3, 2, 1, 0, 0, 0  3, 2, 1, 0, 0, 0  list        False   
pcaextrap      0, 0              0, 0              list        False   

tilts
Parameter    Value     Default   Type                       Callable
--------------------------------------------------------------------
idsonly      False     False     bool                       False   
tracethresh  1000.0    1000.0    int, float, list, ndarray  False   
order        2         2         int                        False   
function     legendre  legendre  str                        False   
yorder       4         4         int                        False   
func2D       legendre  legendre  str                        False   
method       spca      spca      str                        False   
params       1, 1, 0   1, 1, 0   int, list                  False   

Object tracing

Parameters guiding the tracing of objects in the slit:


In [12]:
pypitpar.TraceObjectsPar()


Out[12]:
Parameter  Value     Default   Type        Callable
---------------------------------------------------
function   legendre  legendre  str         False   
order      2         2         int         False   
find       standard  standard  str         False   
nsmooth    3         3         int, float  False   
xedge      0.03      0.03      float       False   
method     pca       pca       str         False   
params     1, 0      1, 0      int, list   False   

Object extraction

I provide an object that defines any manual extractions (a bit overkill):


In [13]:
pypitpar.ManualExtractionPar()


Out[13]:
Parameter  Value  Default  Type  Callable
-----------------------------------------
frame      None   None     str   False   
params     None   None     list  False   

Then the manual parameter in the ExtractObjectsPar is a list of the ManualExtractionPar objects for all the manual extractions to perform. The number of manual extractions is just the length of the list or 0 if the element is None.


In [14]:
p = pypitpar.ExtractObjectsPar()
print(p)  # The printing goes a bit wrong for 'manual'
nmanual = 0 if p['manual'] is None else len(p['manual'])
print('Manual extractions to perform: {0}'.format(nmanual))


Parameter   Value     Default   Type        Callable
----------------------------------------------------
pixelmap    None      None      str         False   
pixelwidth  2.5       2.5       int, float  False   
reuse       False     False     bool        False   
profile     gaussian  gaussian  str         False   
maxnumber   None      None      int         False   
manual      None      None      list        False   

Manual extractions to perform: 0

Finally, there are parameter sets that used for the sky subtraction, flexure correction, and flux calibration.


In [15]:
#6
pypitpar.SkySubtractionPar()


Out[15]:
Parameter        Value  Default  Type        Callable
-----------------------------------------------------
bspline_spacing  0.6    0.6      int, float  False   
nodding          False  False    bool        False   

In [16]:
#3
pypitpar.FlexurePar()


Out[16]:
Parameter  Value   Default  Type        Callable
------------------------------------------------
method     boxcar  boxcar   str         False   
maxshift   20      20       int, float  False   
spectrum   None    None     str         False   

In [17]:
#5
pypitpar.FluxCalibrationPar()


Out[17]:
Parameter  Value  Default  Type  Callable
-----------------------------------------
nonlinear  False  False    bool  False   
sensfunc   None   None     str   False   

Putting it all together

All of the above are expected to be parameter subsets that are passed to individual methods. Sticking with the idea of having a single object that provides all the parameters needed for a run of pypit, the PypitPar object just collects all the above objects into a single parameter set.


In [18]:
pypitpar.PypitPar()


Out[18]:
Parameter     Value      Default    Type          Callable
----------------------------------------------------------
rdx           see below  see below  ParSet, dict  False   
calibrations  see below  see below  ParSet, dict  False   
scienceframe  see below  see below  ParSet, dict  False   
objects       see below  see below  ParSet, dict  False   
extract       see below  see below  ParSet, dict  False   
skysubtract   None       None       ParSet, dict  False   
flexure       None       None       ParSet, dict  False   
fluxcalib     None       None       ParSet, dict  False   

rdx
Parameter     Value    Default  Type        Callable
----------------------------------------------------
spectrograph  None     None     str         False   
pipeline      None     None     str         False   
detnum        None     None     list        False   
sortroot      None     None     str         False   
calwin        0        0        int, float  False   
scidir        Science  Science  str         False   
qadir         QA       QA       str         False   

calibrations
Parameter       Value      Default    Type          Callable
------------------------------------------------------------
caldir          MF         MF         str           False   
masters         None       None       str           False   
setup           None       None       str           False   
trim            True       True       bool          False   
badpix          True       True       bool          False   
biasframe       see below  see below  ParSet, dict  False   
arcframe        see below  see below  ParSet, dict  False   
pixelflatframe  see below  see below  ParSet, dict  False   
pinholeframe    see below  see below  ParSet, dict  False   
traceframe      see below  see below  ParSet, dict  False   
standardframe   see below  see below  ParSet, dict  False   
flatfield       see below  see below  ParSet, dict  False   
wavelengths     see below  see below  ParSet, dict  False   
slits           see below  see below  ParSet, dict  False   
tilts           see below  see below  ParSet, dict  False   

calibrations:biasframe
Parameter  Value      Default    Type          Callable
-------------------------------------------------------
frametype  bias       bias       str           False   
useframe   bias       None       str           False   
number     5          0          int           False   
process    see below  see below  ParSet, dict  False   

calibrations:biasframe:process
Parameter     Value       Default     Type        Callable
----------------------------------------------------------
overscan      savgol      savgol      str         False   
overscan_par  5, 65       5, 65       int, list   False   
match         -1          -1          int, float  False   
combine       weightmean  weightmean  str         False   
satpix        reject      reject      str         False   
sigrej        20.0        20.0        int, float  False   
n_lohi        0, 0        0, 0        list        False   
sig_lohi      3.0, 3.0    3.0, 3.0    list        False   
replace       maxnonsat   maxnonsat   str         False   
lamaxiter     1           1           int         False   
grow          1.5         1.5         int, float  False   
rmcompact     True        True        bool        False   
sigclip       5.0         5.0         int, float  False   
sigfrac       0.3         0.3         int, float  False   
objlim        5.0         5.0         int, float  False   

calibrations:arcframe
Parameter  Value      Default    Type          Callable
-------------------------------------------------------
frametype  arc        bias       str           False   
useframe   arc        None       str           False   
number     1          0          int           False   
process    see below  see below  ParSet, dict  False   

calibrations:arcframe:process
Parameter     Value       Default     Type        Callable
----------------------------------------------------------
overscan      savgol      savgol      str         False   
overscan_par  5, 65       5, 65       int, list   False   
match         -1          -1          int, float  False   
combine       weightmean  weightmean  str         False   
satpix        reject      reject      str         False   
sigrej        -1          20.0        int, float  False   
n_lohi        0, 0        0, 0        list        False   
sig_lohi      3.0, 3.0    3.0, 3.0    list        False   
replace       maxnonsat   maxnonsat   str         False   
lamaxiter     1           1           int         False   
grow          1.5         1.5         int, float  False   
rmcompact     True        True        bool        False   
sigclip       5.0         5.0         int, float  False   
sigfrac       0.3         0.3         int, float  False   
objlim        5.0         5.0         int, float  False   

calibrations:pixelflatframe
Parameter  Value      Default    Type          Callable
-------------------------------------------------------
frametype  pixelflat  bias       str           False   
useframe   pixelflat  None       str           False   
number     5          0          int           False   
process    see below  see below  ParSet, dict  False   

calibrations:pixelflatframe:process
Parameter     Value       Default     Type        Callable
----------------------------------------------------------
overscan      savgol      savgol      str         False   
overscan_par  5, 65       5, 65       int, list   False   
match         -1          -1          int, float  False   
combine       weightmean  weightmean  str         False   
satpix        reject      reject      str         False   
sigrej        20.0        20.0        int, float  False   
n_lohi        0, 0        0, 0        list        False   
sig_lohi      3.0, 3.0    3.0, 3.0    list        False   
replace       maxnonsat   maxnonsat   str         False   
lamaxiter     1           1           int         False   
grow          1.5         1.5         int, float  False   
rmcompact     True        True        bool        False   
sigclip       5.0         5.0         int, float  False   
sigfrac       0.3         0.3         int, float  False   
objlim        5.0         5.0         int, float  False   

calibrations:pinholeframe
Parameter  Value      Default    Type          Callable
-------------------------------------------------------
frametype  pinhole    bias       str           False   
useframe   pinhole    None       str           False   
number     0          0          int           False   
process    see below  see below  ParSet, dict  False   

calibrations:pinholeframe:process
Parameter     Value       Default     Type        Callable
----------------------------------------------------------
overscan      savgol      savgol      str         False   
overscan_par  5, 65       5, 65       int, list   False   
match         -1          -1          int, float  False   
combine       weightmean  weightmean  str         False   
satpix        reject      reject      str         False   
sigrej        20.0        20.0        int, float  False   
n_lohi        0, 0        0, 0        list        False   
sig_lohi      3.0, 3.0    3.0, 3.0    list        False   
replace       maxnonsat   maxnonsat   str         False   
lamaxiter     1           1           int         False   
grow          1.5         1.5         int, float  False   
rmcompact     True        True        bool        False   
sigclip       5.0         5.0         int, float  False   
sigfrac       0.3         0.3         int, float  False   
objlim        5.0         5.0         int, float  False   

calibrations:traceframe
Parameter  Value      Default    Type          Callable
-------------------------------------------------------
frametype  trace      bias       str           False   
useframe   trace      None       str           False   
number     3          0          int           False   
process    see below  see below  ParSet, dict  False   

calibrations:traceframe:process
Parameter     Value       Default     Type        Callable
----------------------------------------------------------
overscan      savgol      savgol      str         False   
overscan_par  5, 65       5, 65       int, list   False   
match         -1          -1          int, float  False   
combine       weightmean  weightmean  str         False   
satpix        reject      reject      str         False   
sigrej        20.0        20.0        int, float  False   
n_lohi        0, 0        0, 0        list        False   
sig_lohi      3.0, 3.0    3.0, 3.0    list        False   
replace       maxnonsat   maxnonsat   str         False   
lamaxiter     1           1           int         False   
grow          1.5         1.5         int, float  False   
rmcompact     True        True        bool        False   
sigclip       5.0         5.0         int, float  False   
sigfrac       0.3         0.3         int, float  False   
objlim        5.0         5.0         int, float  False   

calibrations:standardframe
Parameter  Value      Default    Type          Callable
-------------------------------------------------------
frametype  standard   bias       str           False   
useframe   standard   None       str           False   
number     1          0          int           False   
process    see below  see below  ParSet, dict  False   

calibrations:standardframe:process
Parameter     Value       Default     Type        Callable
----------------------------------------------------------
overscan      savgol      savgol      str         False   
overscan_par  5, 65       5, 65       int, list   False   
match         -1          -1          int, float  False   
combine       weightmean  weightmean  str         False   
satpix        reject      reject      str         False   
sigrej        20.0        20.0        int, float  False   
n_lohi        0, 0        0, 0        list        False   
sig_lohi      3.0, 3.0    3.0, 3.0    list        False   
replace       maxnonsat   maxnonsat   str         False   
lamaxiter     1           1           int         False   
grow          1.5         1.5         int, float  False   
rmcompact     True        True        bool        False   
sigclip       5.0         5.0         int, float  False   
sigfrac       0.3         0.3         int, float  False   
objlim        5.0         5.0         int, float  False   

calibrations:flatfield
Parameter    Value      Default    Type       Callable
------------------------------------------------------
frame        pixelflat  pixelflat  str        False   
slitprofile  True       True       bool       False   
method       bspline    bspline    str        False   
params       20         20         int, list  False   
twodpca      0          0          int        False   

calibrations:wavelengths
Parameter  Value         Default       Type              Callable
-----------------------------------------------------------------
reference  arc           arc           str               False   
method     arclines      arclines      str               False   
lamps      None          None          list              False   
detection  6.0           6.0           int, float        False   
numsearch  20            20            int               False   
nfitpix    5             5             int               False   
IDpixels   None          None          int, list         False   
IDwaves    None          None          int, float, list  False   
medium     vacuum        vacuum        str               False   
frame      heliocentric  heliocentric  str               False   

calibrations:slits
Parameter      Value             Default           Type        Callable
-----------------------------------------------------------------------
function       legendre          legendre          str         False   
polyorder      3                 3                 int         False   
medrep         0                 0                 int         False   
number         -1                -1                int         False   
trim           3, 3              3, 3              tuple       False   
maxgap         None              None              int         False   
maxshift       0.15              0.15              int, float  False   
pad            0                 0                 int         False   
sigdetect      20.0              20.0              int, float  False   
fracignore     0.01              0.01              float       False   
diffpolyorder  2                 2                 int         False   
single         []                []                list        False   
sobel_mode     nearest           nearest           str         False   
pcatype        pixel             pixel             str         False   
pcapar         3, 2, 1, 0, 0, 0  3, 2, 1, 0, 0, 0  list        False   
pcaextrap      0, 0              0, 0              list        False   

calibrations:tilts
Parameter    Value     Default   Type                       Callable
--------------------------------------------------------------------
idsonly      False     False     bool                       False   
tracethresh  1000.0    1000.0    int, float, list, ndarray  False   
order        2         2         int                        False   
function     legendre  legendre  str                        False   
yorder       4         4         int                        False   
func2D       legendre  legendre  str                        False   
method       spca      spca      str                        False   
params       1, 1, 0   1, 1, 0   int, list                  False   

scienceframe
Parameter  Value      Default    Type          Callable
-------------------------------------------------------
frametype  science    bias       str           False   
useframe   science    None       str           False   
number     0          0          int           False   
process    see below  see below  ParSet, dict  False   

scienceframe:process
Parameter     Value       Default     Type        Callable
----------------------------------------------------------
overscan      savgol      savgol      str         False   
overscan_par  5, 65       5, 65       int, list   False   
match         -1          -1          int, float  False   
combine       weightmean  weightmean  str         False   
satpix        reject      reject      str         False   
sigrej        20.0        20.0        int, float  False   
n_lohi        0, 0        0, 0        list        False   
sig_lohi      3.0, 3.0    3.0, 3.0    list        False   
replace       maxnonsat   maxnonsat   str         False   
lamaxiter     1           1           int         False   
grow          1.5         1.5         int, float  False   
rmcompact     True        True        bool        False   
sigclip       5.0         5.0         int, float  False   
sigfrac       0.3         0.3         int, float  False   
objlim        5.0         5.0         int, float  False   

objects
Parameter  Value     Default   Type        Callable
---------------------------------------------------
function   legendre  legendre  str         False   
order      2         2         int         False   
find       standard  standard  str         False   
nsmooth    3         3         int, float  False   
xedge      0.03      0.03      float       False   
method     pca       pca       str         False   
params     1, 0      1, 0      int, list   False   

extract
Parameter   Value     Default   Type        Callable
----------------------------------------------------
pixelmap    None      None      str         False   
pixelwidth  2.5       2.5       int, float  False   
reuse       False     False     bool        False   
profile     gaussian  gaussian  str         False   
maxnumber   None      None      int         False   
manual      None      None      list        False   

Like all the other pypit parameter sets, PypitPar has a from_dict method, but it also has a from_cfg_file that allows you to read and write the full parameter sets to a *.cfg config file. However, for runs of pypit, we're most often going to be reading the configuration from a group of lines in the *.pypit file. Here's a short demo of how to read and write the pypit parameters to a *.cfg; writing may be useful to see the full set of parameters along with the description of each parameter.


In [19]:
help(pypitpar.PypitPar.from_cfg_file)


Help on method from_cfg_file in module pypit.par.pypitpar:

from_cfg_file(cfg_file=None, merge_with=None, evaluate=True) method of builtins.type instance
    Construct the parameter set using a configuration file.
    
    Note that::
    
        default = PypitPar()
        nofile = PypitPar.from_cfg_file()
        assert default.data == nofile.data, 'This should always pass.'
    
    Args:
        cfg_file (:obj:`str`, optional):
            The name of the configuration file that defines the
            default parameters.  This can be used to load a pypit
            config file from a previous run that was constructed and
            output by pypit.  This has to contain the full set of
            parameters, not just the subset you want to change.  For
            the latter, use :arg:`merge_with` to provide one or more
            config files to merge with the defaults to construct the
            full parameter set.
        merge_with (:obj:`str`, :obj:`list`, optional):
            One or more config files with the modifications to
            either default parameters (:arg:`cfg_file` is None) or
            the parameters provided by :arg:`cfg_file`.  The
            modifications are performed in series so the list order
            of the config files is important.
        evaluate (:obj:`bool`, optional):
            Evaluate the values in the config object before
            assigning them in the subsequent parameter sets.  The
            parameters in the config file are *always* read as
            strings, so this should almost always be true; however,
            see the warning below.
            
    .. warning::
    
        When :arg:`evaluate` is true, the function runs `eval()` on
        all the entries in the `ConfigObj` dictionary, done using
        :func:`_recursive_dict_evaluate`.  This has the potential to
        go haywire if the name of a parameter unintentionally
        happens to be identical to an imported or system-level
        function.  Of course, this can be useful by allowing one to
        define the function to use as a parameter, but it also means
        one has to be careful with the values that the parameters
        should be allowed to have.  The current way around this is
        to provide a list of strings that should be ignored during
        the evaluation, done using :func:`_eval_ignore`.
    
    .. todo::
        Allow the user to add to the ignored strings.
    
    Returns:
        :class:`pypit.par.core.PypitPar`: The instance of the
        parameter set.

You can get the default parameters and print the result like this.


In [20]:
# Write the defaults
p = pypitpar.PypitPar.from_cfg_file()
p.to_config('default.cfg')

You can then read it back in. The expand_spectrograph option allows you to set all the spectrograph setting using the spectrograph keyword in the input config file (this is KECK_LRISb by default). If you just want to use what's in the config file without finding the spectrograph configuration file (because those keywords are already in the configuration file in this example), you would set expand_spectrograph=False.


In [21]:
# Read them in
p = pypitpar.PypitPar.from_cfg_file('default.cfg')
p['rdx']['spectrograph'] is None


Out[21]:
True

User-level example

I import PypitPar as part of the __init__.py setup of the pypit.par module, meaning you can import it directly. I expect this is how we'll use it in the rest of the code.


In [22]:
from pypit.par import PypitPar

Below are a few examples of how to setup a PypitPar instance. In all these cases, you only have to specify the parameters that are different from the defaults.

Using PypitSetup

The most common usage for setting up a PypitPar instance will be to use PypitSetup. For example:


In [23]:
from pypit import pypitsetup
pypit_file = '../../pypit/tests/files/example_pypit_file.pypit'
setup = pypitsetup.PypitSetup.from_pypit_file(pypit_file)
par, spectrograph, fitstbl, setup_dict = setup.run()


[INFO]    :: Loading the reduction file
[INFO]    :: Found 2 raw data frames
[INFO]    :: Input file loaded successfully
[WARNING] :: UTC is not listed as a header keyword in file:
             /Users/westfall/Work/packages/PYPIT/pypit/tests/files/b1.fits.gz
[WARNING] :: BINNING keyword not in header. Setting to None
[INFO]    :: Successfully loaded headers for file:
             /Users/westfall/Work/packages/PYPIT/pypit/tests/files/b1.fits.gz
[WARNING] :: UTC is not listed as a header keyword in file:
             /Users/westfall/Work/packages/PYPIT/pypit/tests/files/b27.fits.gz
[WARNING] :: BINNING keyword not in header. Setting to None
[INFO]    :: Successfully loaded headers for file:
             /Users/westfall/Work/packages/PYPIT/pypit/tests/files/b27.fits.gz
[INFO]    :: Checking spectrograph settings for required header information
[INFO]    :: Headers loaded for 2 files successfully
[INFO]    :: Typing files
[INFO]    :: Adding file type information to the fitstbl
[INFO]    :: Matching calibrations to Science frames
[INFO]    :: =================================================
[INFO]    :: Matching calibrations to J1217p3905: b27.fits.gz
[INFO]    ::   Found 1 arc frame for J1217p3905 (1 required)
[INFO]    ::    No bias frames are required.  Not matching..
[INFO]    ::   Dark frames not required.  Not matching..
[INFO]    ::    No pinhole frames are required.  Not matching..
[INFO]    ::    No pixelflat frames are required.  Not matching..
[INFO]    ::    No standard frames are required.  Not matching..
[INFO]    ::    No trace frames are required.  Not matching..
[INFO]    :: Science frames successfully matched to calibration frames

In [24]:
# The compiled parameter set is in par
print(par)


Parameter     Value      Default    Type          Callable
----------------------------------------------------------
rdx           see below  see below  ParSet, dict  False   
calibrations  see below  see below  ParSet, dict  False   
scienceframe  see below  see below  ParSet, dict  False   
objects       see below  see below  ParSet, dict  False   
extract       see below  see below  ParSet, dict  False   
skysubtract   see below  see below  ParSet, dict  False   
flexure       see below  see below  ParSet, dict  False   
fluxcalib     see below  see below  ParSet, dict  False   

rdx
Parameter     Value                    Default  Type        Callable
--------------------------------------------------------------------
spectrograph  shane_kast_blue          None     str         False   
pipeline      ARMS                     None     str         False   
detnum        None                     None     list        False   
sortroot      shane_kast_blue_setup_A  None     str         False   
calwin        0                        0        int, float  False   
scidir        Science                  Science  str         False   
qadir         QA                       QA       str         False   

calibrations
Parameter       Value      Default    Type          Callable
------------------------------------------------------------
caldir          MF         MF         str           False   
masters         None       None       str           False   
setup           None       None       str           False   
trim            True       True       bool          False   
badpix          True       True       bool          False   
biasframe       see below  see below  ParSet, dict  False   
arcframe        see below  see below  ParSet, dict  False   
pixelflatframe  see below  see below  ParSet, dict  False   
pinholeframe    see below  see below  ParSet, dict  False   
traceframe      see below  see below  ParSet, dict  False   
standardframe   see below  see below  ParSet, dict  False   
flatfield       see below  see below  ParSet, dict  False   
wavelengths     see below  see below  ParSet, dict  False   
slits           see below  see below  ParSet, dict  False   
tilts           see below  see below  ParSet, dict  False   

calibrations:biasframe
Parameter  Value      Default    Type          Callable
-------------------------------------------------------
frametype  bias       bias       str           False   
useframe   bias       None       str           False   
number     0          0          int           False   
process    see below  see below  ParSet, dict  False   

calibrations:biasframe:process
Parameter     Value      Default     Type        Callable
---------------------------------------------------------
overscan      savgol     savgol      str         False   
overscan_par  5, 65      5, 65       int, list   False   
match         -1         -1          int, float  False   
combine       mean       weightmean  str         False   
satpix        reject     reject      str         False   
sigrej        30         20.0        int, float  False   
n_lohi        0, 0       0, 0        list        False   
sig_lohi      10, 10     3.0, 3.0    list        False   
replace       maxnonsat  maxnonsat   str         False   
lamaxiter     1          1           int         False   
grow          1.5        1.5         int, float  False   
rmcompact     True       True        bool        False   
sigclip       5.0        5.0         int, float  False   
sigfrac       0.3        0.3         int, float  False   
objlim        5.0        5.0         int, float  False   

calibrations:arcframe
Parameter  Value      Default    Type          Callable
-------------------------------------------------------
frametype  arc        bias       str           False   
useframe   arc        None       str           False   
number     1          0          int           False   
process    see below  see below  ParSet, dict  False   

calibrations:arcframe:process
Parameter     Value      Default     Type        Callable
---------------------------------------------------------
overscan      savgol     savgol      str         False   
overscan_par  5, 65      5, 65       int, list   False   
match         -1         -1          int, float  False   
combine       mean       weightmean  str         False   
satpix        reject     reject      str         False   
sigrej        -1         20.0        int, float  False   
n_lohi        0, 0       0, 0        list        False   
sig_lohi      3.0, 3.0   3.0, 3.0    list        False   
replace       maxnonsat  maxnonsat   str         False   
lamaxiter     1          1           int         False   
grow          1.5        1.5         int, float  False   
rmcompact     True       True        bool        False   
sigclip       5.0        5.0         int, float  False   
sigfrac       0.3        0.3         int, float  False   
objlim        5.0        5.0         int, float  False   

calibrations:pixelflatframe
Parameter  Value      Default    Type          Callable
-------------------------------------------------------
frametype  pixelflat  bias       str           False   
useframe   pixelflat  None       str           False   
number     0          0          int           False   
process    see below  see below  ParSet, dict  False   

calibrations:pixelflatframe:process
Parameter     Value      Default     Type        Callable
---------------------------------------------------------
overscan      savgol     savgol      str         False   
overscan_par  5, 65      5, 65       int, list   False   
match         -1         -1          int, float  False   
combine       mean       weightmean  str         False   
satpix        reject     reject      str         False   
sigrej        30         20.0        int, float  False   
n_lohi        0, 0       0, 0        list        False   
sig_lohi      3.0, 3.0   3.0, 3.0    list        False   
replace       maxnonsat  maxnonsat   str         False   
lamaxiter     1          1           int         False   
grow          1.5        1.5         int, float  False   
rmcompact     True       True        bool        False   
sigclip       5.0        5.0         int, float  False   
sigfrac       0.3        0.3         int, float  False   
objlim        5.0        5.0         int, float  False   

calibrations:pinholeframe
Parameter  Value      Default    Type          Callable
-------------------------------------------------------
frametype  pinhole    bias       str           False   
useframe   pinhole    None       str           False   
number     0          0          int           False   
process    see below  see below  ParSet, dict  False   

calibrations:pinholeframe:process
Parameter     Value      Default     Type        Callable
---------------------------------------------------------
overscan      savgol     savgol      str         False   
overscan_par  5, 65      5, 65       int, list   False   
match         -1         -1          int, float  False   
combine       mean       weightmean  str         False   
satpix        reject     reject      str         False   
sigrej        30         20.0        int, float  False   
n_lohi        0, 0       0, 0        list        False   
sig_lohi      3.0, 3.0   3.0, 3.0    list        False   
replace       maxnonsat  maxnonsat   str         False   
lamaxiter     1          1           int         False   
grow          1.5        1.5         int, float  False   
rmcompact     True       True        bool        False   
sigclip       5.0        5.0         int, float  False   
sigfrac       0.3        0.3         int, float  False   
objlim        5.0        5.0         int, float  False   

calibrations:traceframe
Parameter  Value      Default    Type          Callable
-------------------------------------------------------
frametype  trace      bias       str           False   
useframe   trace      None       str           False   
number     0          0          int           False   
process    see below  see below  ParSet, dict  False   

calibrations:traceframe:process
Parameter     Value      Default     Type        Callable
---------------------------------------------------------
overscan      savgol     savgol      str         False   
overscan_par  5, 65      5, 65       int, list   False   
match         -1         -1          int, float  False   
combine       mean       weightmean  str         False   
satpix        reject     reject      str         False   
sigrej        30         20.0        int, float  False   
n_lohi        0, 0       0, 0        list        False   
sig_lohi      3.0, 3.0   3.0, 3.0    list        False   
replace       maxnonsat  maxnonsat   str         False   
lamaxiter     1          1           int         False   
grow          1.5        1.5         int, float  False   
rmcompact     True       True        bool        False   
sigclip       5.0        5.0         int, float  False   
sigfrac       0.3        0.3         int, float  False   
objlim        5.0        5.0         int, float  False   

calibrations:standardframe
Parameter  Value      Default    Type          Callable
-------------------------------------------------------
frametype  standard   bias       str           False   
useframe   standard   None       str           False   
number     0          0          int           False   
process    see below  see below  ParSet, dict  False   

calibrations:standardframe:process
Parameter     Value      Default     Type        Callable
---------------------------------------------------------
overscan      savgol     savgol      str         False   
overscan_par  5, 65      5, 65       int, list   False   
match         -1         -1          int, float  False   
combine       mean       weightmean  str         False   
satpix        reject     reject      str         False   
sigrej        30         20.0        int, float  False   
n_lohi        0, 0       0, 0        list        False   
sig_lohi      3.0, 3.0   3.0, 3.0    list        False   
replace       maxnonsat  maxnonsat   str         False   
lamaxiter     1          1           int         False   
grow          1.5        1.5         int, float  False   
rmcompact     True       True        bool        False   
sigclip       5.0        5.0         int, float  False   
sigfrac       0.3        0.3         int, float  False   
objlim        5.0        5.0         int, float  False   

calibrations:flatfield
Parameter    Value      Default    Type       Callable
------------------------------------------------------
frame        pixelflat  pixelflat  str        False   
slitprofile  True       True       bool       False   
method       bspline    bspline    str        False   
params       20         20         int, list  False   
twodpca      0          0          int        False   

calibrations:wavelengths
Parameter  Value         Default       Type              Callable
-----------------------------------------------------------------
reference  arc           arc           str               False   
method     arclines      arclines      str               False   
lamps      None          None          list              False   
detection  6.0           6.0           int, float        False   
numsearch  20            20            int               False   
nfitpix    5             5             int               False   
IDpixels   None          None          int, list         False   
IDwaves    None          None          int, float, list  False   
medium     vacuum        vacuum        str               False   
frame      heliocentric  heliocentric  str               False   

calibrations:slits
Parameter      Value             Default           Type        Callable
-----------------------------------------------------------------------
function       legendre          legendre          str         False   
polyorder      3                 3                 int         False   
medrep         0                 0                 int         False   
number         -1                -1                int         False   
trim           3, 3              3, 3              tuple       False   
maxgap         None              None              int         False   
maxshift       0.15              0.15              int, float  False   
pad            0                 0                 int         False   
sigdetect      20.0              20.0              int, float  False   
fracignore     0.01              0.01              float       False   
diffpolyorder  2                 2                 int         False   
single         []                []                list        False   
sobel_mode     nearest           nearest           str         False   
pcatype        pixel             pixel             str         False   
pcapar         3, 2, 1, 0, 0, 0  3, 2, 1, 0, 0, 0  list        False   
pcaextrap      0, 0              0, 0              list        False   

calibrations:tilts
Parameter    Value     Default   Type                       Callable
--------------------------------------------------------------------
idsonly      False     False     bool                       False   
tracethresh  1000.0    1000.0    int, float, list, ndarray  False   
order        2         2         int                        False   
function     legendre  legendre  str                        False   
yorder       4         4         int                        False   
func2D       legendre  legendre  str                        False   
method       spca      spca      str                        False   
params       1, 1, 0   1, 1, 0   int, list                  False   

scienceframe
Parameter  Value      Default    Type          Callable
-------------------------------------------------------
frametype  science    bias       str           False   
useframe   science    None       str           False   
number     0          0          int           False   
process    see below  see below  ParSet, dict  False   

scienceframe:process
Parameter     Value      Default     Type        Callable
---------------------------------------------------------
overscan      savgol     savgol      str         False   
overscan_par  5, 65      5, 65       int, list   False   
match         -1         -1          int, float  False   
combine       mean       weightmean  str         False   
satpix        reject     reject      str         False   
sigrej        30         20.0        int, float  False   
n_lohi        8, 8       0, 0        list        False   
sig_lohi      3.0, 3.0   3.0, 3.0    list        False   
replace       maxnonsat  maxnonsat   str         False   
lamaxiter     1          1           int         False   
grow          1.5        1.5         int, float  False   
rmcompact     True       True        bool        False   
sigclip       5.0        5.0         int, float  False   
sigfrac       0.3        0.3         int, float  False   
objlim        5.0        5.0         int, float  False   

objects
Parameter  Value     Default   Type        Callable
---------------------------------------------------
function   legendre  legendre  str         False   
order      2         2         int         False   
find       standard  standard  str         False   
nsmooth    3         3         int, float  False   
xedge      0.03      0.03      float       False   
method     pca       pca       str         False   
params     1, 0      1, 0      int, list   False   

extract
Parameter   Value     Default   Type        Callable
----------------------------------------------------
pixelmap    None      None      str         False   
pixelwidth  2.5       2.5       int, float  False   
reuse       False     False     bool        False   
profile     gaussian  gaussian  str         False   
maxnumber   None      None      int         False   
manual      None      None      list        False   

skysubtract
Parameter        Value  Default  Type        Callable
-----------------------------------------------------
bspline_spacing  0.6    0.6      int, float  False   
nodding          False  False    bool        False   

flexure
Parameter  Value   Default  Type        Callable
------------------------------------------------
method     boxcar  boxcar   str         False   
maxshift   20      20       int, float  False   
spectrum   None    None     str         False   

fluxcalib
Parameter  Value  Default  Type  Callable
-----------------------------------------
nonlinear  False  False    bool  False   
sensfunc   None   None     str   False   

Directly from a pypit file

Alternatively, you can get the parameter set directly from a pypit file like this:


In [25]:
from pypit.par.util import parse_pypit_file
from pypit.spectrographs.util import load_spectrograph

# Read the PypeIt file
cfg, data, frametype, setups = parse_pypit_file(pypit_file) #,file_check=False)
# Long-winded way of getting the spectrograph name
name = pypitpar.PypitPar.from_cfg_lines(merge_with=cfg)['rdx']['spectrograph']
# Instantiate the spectrograph
spectrograph = load_spectrograph(name)
# Get the spectrograph specific configuration
spec_cfg = spectrograph.default_pypit_par().to_config()
# Initialize the PypeIt parameters merge in the user config
par = pypitpar.PypitPar.from_cfg_lines(cfg_lines=spec_cfg, merge_with=cfg)
print(par)


Parameter     Value      Default    Type          Callable
----------------------------------------------------------
rdx           see below  see below  ParSet, dict  False   
calibrations  see below  see below  ParSet, dict  False   
scienceframe  see below  see below  ParSet, dict  False   
objects       see below  see below  ParSet, dict  False   
extract       see below  see below  ParSet, dict  False   
skysubtract   see below  see below  ParSet, dict  False   
flexure       see below  see below  ParSet, dict  False   
fluxcalib     see below  see below  ParSet, dict  False   

rdx
Parameter     Value                    Default  Type        Callable
--------------------------------------------------------------------
spectrograph  shane_kast_blue          None     str         False   
pipeline      ARMS                     None     str         False   
detnum        None                     None     list        False   
sortroot      shane_kast_blue_setup_A  None     str         False   
calwin        0                        0        int, float  False   
scidir        Science                  Science  str         False   
qadir         QA                       QA       str         False   

calibrations
Parameter       Value      Default    Type          Callable
------------------------------------------------------------
caldir          MF         MF         str           False   
masters         None       None       str           False   
setup           None       None       str           False   
trim            True       True       bool          False   
badpix          True       True       bool          False   
biasframe       see below  see below  ParSet, dict  False   
arcframe        see below  see below  ParSet, dict  False   
pixelflatframe  see below  see below  ParSet, dict  False   
pinholeframe    see below  see below  ParSet, dict  False   
traceframe      see below  see below  ParSet, dict  False   
standardframe   see below  see below  ParSet, dict  False   
flatfield       see below  see below  ParSet, dict  False   
wavelengths     see below  see below  ParSet, dict  False   
slits           see below  see below  ParSet, dict  False   
tilts           see below  see below  ParSet, dict  False   

calibrations:biasframe
Parameter  Value      Default    Type          Callable
-------------------------------------------------------
frametype  bias       bias       str           False   
useframe   bias       None       str           False   
number     0          0          int           False   
process    see below  see below  ParSet, dict  False   

calibrations:biasframe:process
Parameter     Value      Default     Type        Callable
---------------------------------------------------------
overscan      savgol     savgol      str         False   
overscan_par  5, 65      5, 65       int, list   False   
match         -1         -1          int, float  False   
combine       mean       weightmean  str         False   
satpix        reject     reject      str         False   
sigrej        30         20.0        int, float  False   
n_lohi        0, 0       0, 0        list        False   
sig_lohi      10, 10     3.0, 3.0    list        False   
replace       maxnonsat  maxnonsat   str         False   
lamaxiter     1          1           int         False   
grow          1.5        1.5         int, float  False   
rmcompact     True       True        bool        False   
sigclip       5.0        5.0         int, float  False   
sigfrac       0.3        0.3         int, float  False   
objlim        5.0        5.0         int, float  False   

calibrations:arcframe
Parameter  Value      Default    Type          Callable
-------------------------------------------------------
frametype  arc        bias       str           False   
useframe   arc        None       str           False   
number     1          0          int           False   
process    see below  see below  ParSet, dict  False   

calibrations:arcframe:process
Parameter     Value      Default     Type        Callable
---------------------------------------------------------
overscan      savgol     savgol      str         False   
overscan_par  5, 65      5, 65       int, list   False   
match         -1         -1          int, float  False   
combine       mean       weightmean  str         False   
satpix        reject     reject      str         False   
sigrej        -1         20.0        int, float  False   
n_lohi        0, 0       0, 0        list        False   
sig_lohi      3.0, 3.0   3.0, 3.0    list        False   
replace       maxnonsat  maxnonsat   str         False   
lamaxiter     1          1           int         False   
grow          1.5        1.5         int, float  False   
rmcompact     True       True        bool        False   
sigclip       5.0        5.0         int, float  False   
sigfrac       0.3        0.3         int, float  False   
objlim        5.0        5.0         int, float  False   

calibrations:pixelflatframe
Parameter  Value      Default    Type          Callable
-------------------------------------------------------
frametype  pixelflat  bias       str           False   
useframe   pixelflat  None       str           False   
number     0          0          int           False   
process    see below  see below  ParSet, dict  False   

calibrations:pixelflatframe:process
Parameter     Value      Default     Type        Callable
---------------------------------------------------------
overscan      savgol     savgol      str         False   
overscan_par  5, 65      5, 65       int, list   False   
match         -1         -1          int, float  False   
combine       mean       weightmean  str         False   
satpix        reject     reject      str         False   
sigrej        30         20.0        int, float  False   
n_lohi        0, 0       0, 0        list        False   
sig_lohi      3.0, 3.0   3.0, 3.0    list        False   
replace       maxnonsat  maxnonsat   str         False   
lamaxiter     1          1           int         False   
grow          1.5        1.5         int, float  False   
rmcompact     True       True        bool        False   
sigclip       5.0        5.0         int, float  False   
sigfrac       0.3        0.3         int, float  False   
objlim        5.0        5.0         int, float  False   

calibrations:pinholeframe
Parameter  Value      Default    Type          Callable
-------------------------------------------------------
frametype  pinhole    bias       str           False   
useframe   pinhole    None       str           False   
number     0          0          int           False   
process    see below  see below  ParSet, dict  False   

calibrations:pinholeframe:process
Parameter     Value      Default     Type        Callable
---------------------------------------------------------
overscan      savgol     savgol      str         False   
overscan_par  5, 65      5, 65       int, list   False   
match         -1         -1          int, float  False   
combine       mean       weightmean  str         False   
satpix        reject     reject      str         False   
sigrej        30         20.0        int, float  False   
n_lohi        0, 0       0, 0        list        False   
sig_lohi      3.0, 3.0   3.0, 3.0    list        False   
replace       maxnonsat  maxnonsat   str         False   
lamaxiter     1          1           int         False   
grow          1.5        1.5         int, float  False   
rmcompact     True       True        bool        False   
sigclip       5.0        5.0         int, float  False   
sigfrac       0.3        0.3         int, float  False   
objlim        5.0        5.0         int, float  False   

calibrations:traceframe
Parameter  Value      Default    Type          Callable
-------------------------------------------------------
frametype  trace      bias       str           False   
useframe   trace      None       str           False   
number     0          0          int           False   
process    see below  see below  ParSet, dict  False   

calibrations:traceframe:process
Parameter     Value      Default     Type        Callable
---------------------------------------------------------
overscan      savgol     savgol      str         False   
overscan_par  5, 65      5, 65       int, list   False   
match         -1         -1          int, float  False   
combine       mean       weightmean  str         False   
satpix        reject     reject      str         False   
sigrej        30         20.0        int, float  False   
n_lohi        0, 0       0, 0        list        False   
sig_lohi      3.0, 3.0   3.0, 3.0    list        False   
replace       maxnonsat  maxnonsat   str         False   
lamaxiter     1          1           int         False   
grow          1.5        1.5         int, float  False   
rmcompact     True       True        bool        False   
sigclip       5.0        5.0         int, float  False   
sigfrac       0.3        0.3         int, float  False   
objlim        5.0        5.0         int, float  False   

calibrations:standardframe
Parameter  Value      Default    Type          Callable
-------------------------------------------------------
frametype  standard   bias       str           False   
useframe   standard   None       str           False   
number     0          0          int           False   
process    see below  see below  ParSet, dict  False   

calibrations:standardframe:process
Parameter     Value      Default     Type        Callable
---------------------------------------------------------
overscan      savgol     savgol      str         False   
overscan_par  5, 65      5, 65       int, list   False   
match         -1         -1          int, float  False   
combine       mean       weightmean  str         False   
satpix        reject     reject      str         False   
sigrej        30         20.0        int, float  False   
n_lohi        0, 0       0, 0        list        False   
sig_lohi      3.0, 3.0   3.0, 3.0    list        False   
replace       maxnonsat  maxnonsat   str         False   
lamaxiter     1          1           int         False   
grow          1.5        1.5         int, float  False   
rmcompact     True       True        bool        False   
sigclip       5.0        5.0         int, float  False   
sigfrac       0.3        0.3         int, float  False   
objlim        5.0        5.0         int, float  False   

calibrations:flatfield
Parameter    Value      Default    Type       Callable
------------------------------------------------------
frame        pixelflat  pixelflat  str        False   
slitprofile  True       True       bool       False   
method       bspline    bspline    str        False   
params       20         20         int, list  False   
twodpca      0          0          int        False   

calibrations:wavelengths
Parameter  Value         Default       Type              Callable
-----------------------------------------------------------------
reference  arc           arc           str               False   
method     arclines      arclines      str               False   
lamps      None          None          list              False   
detection  6.0           6.0           int, float        False   
numsearch  20            20            int               False   
nfitpix    5             5             int               False   
IDpixels   None          None          int, list         False   
IDwaves    None          None          int, float, list  False   
medium     vacuum        vacuum        str               False   
frame      heliocentric  heliocentric  str               False   

calibrations:slits
Parameter      Value             Default           Type        Callable
-----------------------------------------------------------------------
function       legendre          legendre          str         False   
polyorder      3                 3                 int         False   
medrep         0                 0                 int         False   
number         -1                -1                int         False   
trim           3, 3              3, 3              tuple       False   
maxgap         None              None              int         False   
maxshift       0.15              0.15              int, float  False   
pad            0                 0                 int         False   
sigdetect      20.0              20.0              int, float  False   
fracignore     0.01              0.01              float       False   
diffpolyorder  2                 2                 int         False   
single         []                []                list        False   
sobel_mode     nearest           nearest           str         False   
pcatype        pixel             pixel             str         False   
pcapar         3, 2, 1, 0, 0, 0  3, 2, 1, 0, 0, 0  list        False   
pcaextrap      0, 0              0, 0              list        False   

calibrations:tilts
Parameter    Value     Default   Type                       Callable
--------------------------------------------------------------------
idsonly      False     False     bool                       False   
tracethresh  1000.0    1000.0    int, float, list, ndarray  False   
order        2         2         int                        False   
function     legendre  legendre  str                        False   
yorder       4         4         int                        False   
func2D       legendre  legendre  str                        False   
method       spca      spca      str                        False   
params       1, 1, 0   1, 1, 0   int, list                  False   

scienceframe
Parameter  Value      Default    Type          Callable
-------------------------------------------------------
frametype  science    bias       str           False   
useframe   science    None       str           False   
number     0          0          int           False   
process    see below  see below  ParSet, dict  False   

scienceframe:process
Parameter     Value      Default     Type        Callable
---------------------------------------------------------
overscan      savgol     savgol      str         False   
overscan_par  5, 65      5, 65       int, list   False   
match         -1         -1          int, float  False   
combine       mean       weightmean  str         False   
satpix        reject     reject      str         False   
sigrej        30         20.0        int, float  False   
n_lohi        8, 8       0, 0        list        False   
sig_lohi      3.0, 3.0   3.0, 3.0    list        False   
replace       maxnonsat  maxnonsat   str         False   
lamaxiter     1          1           int         False   
grow          1.5        1.5         int, float  False   
rmcompact     True       True        bool        False   
sigclip       5.0        5.0         int, float  False   
sigfrac       0.3        0.3         int, float  False   
objlim        5.0        5.0         int, float  False   

objects
Parameter  Value     Default   Type        Callable
---------------------------------------------------
function   legendre  legendre  str         False   
order      2         2         int         False   
find       standard  standard  str         False   
nsmooth    3         3         int, float  False   
xedge      0.03      0.03      float       False   
method     pca       pca       str         False   
params     1, 0      1, 0      int, list   False   

extract
Parameter   Value     Default   Type        Callable
----------------------------------------------------
pixelmap    None      None      str         False   
pixelwidth  2.5       2.5       int, float  False   
reuse       False     False     bool        False   
profile     gaussian  gaussian  str         False   
maxnumber   None      None      int         False   
manual      None      None      list        False   

skysubtract
Parameter        Value  Default  Type        Callable
-----------------------------------------------------
bspline_spacing  0.6    0.6      int, float  False   
nodding          False  False    bool        False   

flexure
Parameter  Value   Default  Type        Callable
------------------------------------------------
method     boxcar  boxcar   str         False   
maxshift   20      20       int, float  False   
spectrum   None    None     str         False   

fluxcalib
Parameter  Value  Default  Type  Callable
-----------------------------------------
nonlinear  False  False    bool  False   
sensfunc   None   None     str   False   

[INFO]    :: Loading the reduction file
[INFO]    :: Found 2 raw data frames
[INFO]    :: Input file loaded successfully

Directly from a config file

Lastly, you can setup a PypitPar object directly using a config file.


In [26]:
p = PypitPar.from_cfg_file(merge_with='keck_lris_blue_long_400_3400_d560.cfg')

I actually had to comment out the definition of the flexure spectrum because I can't find it on my disk, and the declaration above faults when it can't find the file.

With the declaration above, all the default parameters are set, the spectrograph key (KECK_LRISb) is used to find the appropriate spectrograph definition file (../../pypit/config/spectrographs/KECK_LRISb_spectrograph.cfg), and both are merged with the alterations in the local keck_lris_blue_long_400_3400_d560.cfg file.

You can print the compiled parameters using the to_config method.


In [27]:
p.to_config('compiled_example.cfg')

In [ ]: