Fussing with a GMOS CGM^2 Mask


In [12]:
# imports
import numpy as np

from linetools import utils as ltu

from pypeit import pypeit
from pypeit import pypeitsetup
from pypeit import traceimage
from pypeit.core import parse

Instantiate


In [2]:
pypeit_file = '/scratch/REDUX/Gemini/J1059+1441/gemini_gmos_north_e2v_setup_A/gemini_gmos_north_e2v_setup_A.pypeit'
pypeitSetup = pypeitsetup.PypeItSetup.from_pypeit_file(pypeit_file)


[INFO]    :: util.py 431 parse_pypeit_file() - Loading the reduction file
[INFO]    :: util.py 456 parse_pypeit_file() - Found 9 raw data frames
[INFO]    :: util.py 468 parse_pypeit_file() - Input file loaded successfully

In [3]:
pypeIt = pypeit.instantiate_me(pypeitSetup.spectrograph, verbosity=2, overwrite=True, show=True) #, logname=logname, show=args.show)

Setup


In [4]:
redux_dir = '/scratch/REDUX/Gemini/J1059+1441/gemini_gmos_north_e2v_setup_A/'

In [5]:
pypeIt.init_setup(pypeit_file, redux_dir, calibration_check=True)


[INFO]    :: util.py 431 parse_pypeit_file() - Loading the reduction file
[INFO]    :: util.py 456 parse_pypeit_file() - Found 9 raw data frames
[INFO]    :: util.py 468 parse_pypeit_file() - Input file loaded successfully
[WARNING] :: spectrograph.py 449 check_headers() - Specific header keyword checks have not been implemented for gemini_gmos_north_e2v.
[INFO]    :: metadata.py 192 _build() - Successfully loaded headers for file:
             /scratch/REDUX/Gemini/J1059+1441/Raw/N20150116S0251.fits
[WARNING] :: spectrograph.py 449 check_headers() - Specific header keyword checks have not been implemented for gemini_gmos_north_e2v.
[INFO]    :: metadata.py 192 _build() - Successfully loaded headers for file:
             /scratch/REDUX/Gemini/J1059+1441/Raw/N20150116S0252.fits
[WARNING] :: spectrograph.py 449 check_headers() - Specific header keyword checks have not been implemented for gemini_gmos_north_e2v.
[INFO]    :: metadata.py 192 _build() - Successfully loaded headers for file:
             /scratch/REDUX/Gemini/J1059+1441/Raw/N20150116S0253.fits
[WARNING] :: spectrograph.py 449 check_headers() - Specific header keyword checks have not been implemented for gemini_gmos_north_e2v.
[INFO]    :: metadata.py 192 _build() - Successfully loaded headers for file:
             /scratch/REDUX/Gemini/J1059+1441/Raw/N20150116S0095.fits
[WARNING] :: spectrograph.py 449 check_headers() - Specific header keyword checks have not been implemented for gemini_gmos_north_e2v.
[INFO]    :: metadata.py 192 _build() - Successfully loaded headers for file:
             /scratch/REDUX/Gemini/J1059+1441/Raw/N20150116S0096.fits
[WARNING] :: spectrograph.py 449 check_headers() - Specific header keyword checks have not been implemented for gemini_gmos_north_e2v.
[INFO]    :: metadata.py 192 _build() - Successfully loaded headers for file:
             /scratch/REDUX/Gemini/J1059+1441/Raw/N20150116S0099.fits
[WARNING] :: spectrograph.py 449 check_headers() - Specific header keyword checks have not been implemented for gemini_gmos_north_e2v.
[INFO]    :: metadata.py 192 _build() - Successfully loaded headers for file:
             /scratch/REDUX/Gemini/J1059+1441/Raw/N20150116S0094.fits
[WARNING] :: spectrograph.py 449 check_headers() - Specific header keyword checks have not been implemented for gemini_gmos_north_e2v.
[INFO]    :: metadata.py 192 _build() - Successfully loaded headers for file:
             /scratch/REDUX/Gemini/J1059+1441/Raw/N20150116S0097.fits
[WARNING] :: spectrograph.py 449 check_headers() - Specific header keyword checks have not been implemented for gemini_gmos_north_e2v.
[INFO]    :: metadata.py 192 _build() - Successfully loaded headers for file:
             /scratch/REDUX/Gemini/J1059+1441/Raw/N20150116S0098.fits
[INFO]    :: metadata.py 195 _build() - Headers loaded for 9 files successfully
[INFO]    :: metadata.py 426 get_frame_types() - Typing files
[INFO]    :: metadata.py 433 get_frame_types() - Using user-provided frame types.
[INFO]    :: metadata.py 583 match_to_science() - Matching calibrations to Science frames
[INFO]    :: metadata.py 604 match_to_science() - ==================================================
[INFO]    :: metadata.py 605 match_to_science() - Matching calibrations to frame: J1059+1441
[INFO]    :: metadata.py 660 match_to_science() -   Found 3 trace frame for J1059+1441 (3 required)
[INFO]    :: metadata.py 637 match_to_science() -    No standard frames are required.  Not matching...
[INFO]    :: metadata.py 660 match_to_science() -   Found 3 arc frame for J1059+1441 (1 required)
[INFO]    :: metadata.py 619 match_to_science() -   Dark frames not required.  Not matching...
[INFO]    :: metadata.py 637 match_to_science() -    No pinhole frames are required.  Not matching...
[INFO]    :: metadata.py 660 match_to_science() -   Found 3 pixelflat frame for J1059+1441 (3 required)
[INFO]    :: metadata.py 660 match_to_science() -   Found 0 bias frame for J1059+1441 (5 required)
[WARNING] :: framematch.py 398 match_warnings() -   Only 0/5 bias frames for J1059+1441
[INFO]    :: metadata.py 604 match_to_science() - ==================================================
[INFO]    :: metadata.py 605 match_to_science() - Matching calibrations to frame: J1059+1441
[INFO]    :: metadata.py 660 match_to_science() -   Found 3 trace frame for J1059+1441 (3 required)
[INFO]    :: metadata.py 637 match_to_science() -    No standard frames are required.  Not matching...
[INFO]    :: metadata.py 660 match_to_science() -   Found 3 arc frame for J1059+1441 (1 required)
[INFO]    :: metadata.py 619 match_to_science() -   Dark frames not required.  Not matching...
[INFO]    :: metadata.py 637 match_to_science() -    No pinhole frames are required.  Not matching...
[INFO]    :: metadata.py 660 match_to_science() -   Found 3 pixelflat frame for J1059+1441 (3 required)
[INFO]    :: metadata.py 660 match_to_science() -   Found 0 bias frame for J1059+1441 (5 required)
[WARNING] :: framematch.py 398 match_warnings() -   Only 0/5 bias frames for J1059+1441
[INFO]    :: metadata.py 604 match_to_science() - ==================================================
[INFO]    :: metadata.py 605 match_to_science() - Matching calibrations to frame: J1059+1441
[INFO]    :: metadata.py 660 match_to_science() -   Found 3 trace frame for J1059+1441 (3 required)
[INFO]    :: metadata.py 637 match_to_science() -    No standard frames are required.  Not matching...
[INFO]    :: metadata.py 660 match_to_science() -   Found 3 arc frame for J1059+1441 (1 required)
[INFO]    :: metadata.py 619 match_to_science() -   Dark frames not required.  Not matching...
[INFO]    :: metadata.py 637 match_to_science() -    No pinhole frames are required.  Not matching...
[INFO]    :: metadata.py 660 match_to_science() -   Found 3 pixelflat frame for J1059+1441 (3 required)
[INFO]    :: metadata.py 660 match_to_science() -   Found 0 bias frame for J1059+1441 (5 required)
[WARNING] :: framematch.py 398 match_warnings() -   Only 0/5 bias frames for J1059+1441
[INFO]    :: metadata.py 683 match_to_science() - Science frames successfully matched to calibration frames.
[INFO]    :: metadata.py 532 write() - Writing fits file metadata to /scratch/REDUX/Gemini/J1059+1441/gemini_gmos_north_e2v_setup_A/gemini_gmos_north_e2v_setup_A.lst.
[INFO]    :: pypeitsetup.py 483 run() - Inspect the .calib file: /scratch/REDUX/Gemini/J1059+1441/gemini_gmos_north_e2v_setup_A/gemini_gmos_north_e2v_setup_A.calib
[INFO]    :: pypeitsetup.py 484 run() - *********************************************************
[INFO]    :: pypeitsetup.py 485 run() - Calibration check complete and successful!
[INFO]    :: pypeitsetup.py 487 run() - *********************************************************
[INFO]    :: pypeit.py 520 init_setup() - Setting reduction path to /scratch/REDUX/Gemini/J1059+1441/gemini_gmos_north_e2v_setup_A/
[INFO]    :: paths.py 38 make_dirs() - Creating Science directory
[INFO]    :: paths.py 41 make_dirs() - The following directory already exists:
             /scratch/REDUX/Gemini/J1059+1441/gemini_gmos_north_e2v_setup_A/Science
[INFO]    :: paths.py 63 make_dirs() - Creating Object directories
[INFO]    :: paths.py 66 make_dirs() - Creating Master Calibrations directory
[INFO]    :: paths.py 86 make_dirs() - Creating QA directory
[WARNING] :: paths.py 89 make_dirs() - Pre-existing QA plots will be overwritten

Reduce


In [6]:
pypeIt.caliBrate.par['slits']['min_slit_width'] = 4.0
pypeIt.caliBrate.par['slits']


Out[6]:
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.02        0.01        float       False   
min_slit_width  4.0         6.0         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  3, 2, 1, 0  list        False   
pcaextrap       0, 0        0, 0        list        False   

In [7]:
pypeIt.reduce_all()


[INFO]    :: pypeit.py 325 reduce_exposure() - Reducing file N20150116S0094.fits, target J1059+1441
[INFO]    :: pypeit.py 339 reduce_exposure() - Working on detector 1
[INFO]    :: calibrations.py 194 get_arc() - Preparing a master arc frame
[INFO]    :: gemini_gmos.py 485 read_gmos() - Reading GMOS file: /scratch/REDUX/Gemini/J1059+1441/Raw/N20150116S0251.fits
[INFO]    :: gemini_gmos.py 485 read_gmos() - Reading GMOS file: /scratch/REDUX/Gemini/J1059+1441/Raw/N20150116S0251.fits
[INFO]    :: gemini_gmos.py 485 read_gmos() - Reading GMOS file: /scratch/REDUX/Gemini/J1059+1441/Raw/N20150116S0251.fits
[INFO]    :: gemini_gmos.py 485 read_gmos() - Reading GMOS file: /scratch/REDUX/Gemini/J1059+1441/Raw/N20150116S0251.fits
[INFO]    :: gemini_gmos.py 485 read_gmos() - Reading GMOS file: /scratch/REDUX/Gemini/J1059+1441/Raw/N20150116S0251.fits
[INFO]    :: processimages.py 275 bias_subtract() - Bias subtracting your image(s)
[INFO]    :: processimages.py 288 bias_subtract() - Using overscan to subtact
[INFO]    :: masters.py 368 save_master() - Saving master arc frame as:
             /scratch/REDUX/Gemini/J1059+1441/gemini_gmos_north_e2v_setup_A/MF_gemini_gmos_north_e2v/MasterArc_A_01_aa.fits
[INFO]    :: masters.py 386 save_master() - Writing header information
[WARNING] :: masters.py 397 save_master() - Overwriting file:
             /scratch/REDUX/Gemini/J1059+1441/gemini_gmos_north_e2v_setup_A/MF_gemini_gmos_north_e2v/MasterArc_A_01_aa.fits
[INFO]    :: masters.py 401 save_master() - Master arc frame saved successfully:
             /scratch/REDUX/Gemini/J1059+1441/gemini_gmos_north_e2v_setup_A/MF_gemini_gmos_north_e2v/MasterArc_A_01_aa.fits
[INFO]    :: gemini_gmos.py 485 read_gmos() - Reading GMOS file: /scratch/REDUX/Gemini/J1059+1441/Raw/N20150116S0094.fits
[INFO]    :: gemini_gmos.py 485 read_gmos() - Reading GMOS file: /scratch/REDUX/Gemini/J1059+1441/Raw/N20150116S0094.fits
[INFO]    :: gemini_gmos.py 485 read_gmos() - Reading GMOS file: /scratch/REDUX/Gemini/J1059+1441/Raw/N20150116S0094.fits
[INFO]    :: pixels.py 37 gen_pixloc() - Deriving physical pixel locations on the detector
[INFO]    :: pixels.py 40 gen_pixloc() - Pixel gap in the dispersion direction = 0.000
[INFO]    :: pixels.py 41 gen_pixloc() - Pixel size in the dispersion direction = 1.000
[INFO]    :: pixels.py 44 gen_pixloc() - Pixel gap in the spatial direction = 0.000
[INFO]    :: pixels.py 45 gen_pixloc() - Pixel size in the spatial direction = 1.000
[INFO]    :: pixels.py 50 gen_pixloc() - Saving pixel locations
[INFO]    :: gemini_gmos.py 485 read_gmos() - Reading GMOS file: /scratch/REDUX/Gemini/J1059+1441/Raw/N20150116S0095.fits
[INFO]    :: gemini_gmos.py 485 read_gmos() - Reading GMOS file: /scratch/REDUX/Gemini/J1059+1441/Raw/N20150116S0096.fits
[INFO]    :: gemini_gmos.py 485 read_gmos() - Reading GMOS file: /scratch/REDUX/Gemini/J1059+1441/Raw/N20150116S0099.fits
[INFO]    :: gemini_gmos.py 485 read_gmos() - Reading GMOS file: /scratch/REDUX/Gemini/J1059+1441/Raw/N20150116S0095.fits
[INFO]    :: gemini_gmos.py 485 read_gmos() - Reading GMOS file: /scratch/REDUX/Gemini/J1059+1441/Raw/N20150116S0095.fits
[INFO]    :: gemini_gmos.py 485 read_gmos() - Reading GMOS file: /scratch/REDUX/Gemini/J1059+1441/Raw/N20150116S0095.fits
[INFO]    :: gemini_gmos.py 485 read_gmos() - Reading GMOS file: /scratch/REDUX/Gemini/J1059+1441/Raw/N20150116S0095.fits
[INFO]    :: processimages.py 275 bias_subtract() - Bias subtracting your image(s)
[INFO]    :: processimages.py 288 bias_subtract() - Using overscan to subtact
[INFO]    :: processimages.py 288 bias_subtract() - Using overscan to subtact
[INFO]    :: processimages.py 288 bias_subtract() - Using overscan to subtact
[INFO]    :: combine.py 62 comb_frames() - Combining 3 trace_image frames
[WORK IN ]::
[PROGRESS]:: combine.py 66 comb_frames() - lscomb feature has not been included here yet...
[INFO]    :: combine.py 95 comb_frames() - Finding saturated and non-linear pixels
[INFO]    :: combine.py 119 comb_frames() - Rejecting cosmic rays
[INFO]    :: combine.py 163 comb_frames() - Not rejecting any low/high pixels
[INFO]    :: combine.py 171 comb_frames() - Rejecting deviant pixels
[INFO]    :: combine.py 188 comb_frames() - Combining frames with a weightmean operation
[INFO]    :: combine.py 201 comb_frames() - Replacing completely masked pixels with the maxnonsat value of the input frames
[INFO]    :: combine.py 215 comb_frames() - 3 trace_image frames combined successfully!
[INFO]    :: gemini_gmos.py 485 read_gmos() - Reading GMOS file: /scratch/REDUX/Gemini/J1059+1441/Raw/N20150116S0095.fits
[INFO]    :: gemini_gmos.py 485 read_gmos() - Reading GMOS file: /scratch/REDUX/Gemini/J1059+1441/Raw/N20150116S0095.fits
[WARNING] :: procimg.py 456 gain_frame() - Should probably be measuring the gain across the amplifier boundary
[INFO]    :: trace_slits.py 813 edgearr_from_binarr() - Detecting slit edges in the mstrace image
[INFO]    :: trace_slits.py 874 edgearr_from_binarr() - Applying bad pixel mask
[INFO]    :: trace_slits.py 933 edgearr_add_left_right() - 49 left edges and 48 right edges were found in the trace
[INFO]    :: trace_slits.py 960 edgearr_add_left_right() - Assigning slit edge traces
[INFO]    :: traceslits.py 361 _assign_edges() - Assigning left slit edges
             trace_slits.py 160 assign_slits() - Outer left edge loop, Iteration 1
             trace_slits.py 298 assign_slits() -   Inner loop, Iteration 1, 49 left edges assigned (49 total)
             trace_slits.py 160 assign_slits() - Outer left edge loop, Iteration 2
             trace_slits.py 298 assign_slits() -   Inner loop, Iteration 1, 49 left edges assigned (49 total)
[INFO]    :: traceslits.py 369 _assign_edges() - Assigning right slit edges
             trace_slits.py 160 assign_slits() - Outer right edge loop, Iteration 1
             trace_slits.py 298 assign_slits() -   Inner loop, Iteration 1, 47 right edges assigned (47 total)
             trace_slits.py 298 assign_slits() -   Inner loop, Iteration 2, 1 right edges assigned (48 total)
             trace_slits.py 160 assign_slits() - Outer right edge loop, Iteration 2
             trace_slits.py 298 assign_slits() -   Inner loop, Iteration 1, 47 right edges assigned (47 total)
             trace_slits.py 298 assign_slits() -   Inner loop, Iteration 2, 1 right edges assigned (48 total)
[INFO]    :: trace_slits.py 1157 edgearr_final_left_right() - 49 left edges and 48 right edges were found in the trace
[INFO]    :: trace_slits.py 560 edgearr_tcrude() - Crude tracing the edges
[WARNING] :: trace_slits.py 472 edgearr_mslit_sync() - Missing a right edge for slit with left edge at 1442
[WARNING] :: trace_slits.py 473 edgearr_mslit_sync() - Adding in a corresponding right edge!
[INFO]    :: trace_slits.py 1309 fit_edges() - Fitting left slit traces
[INFO]    :: trace_slits.py 1311 fit_edges() - Fitting right slit traces
[INFO]    :: traceslits.py 797 _synchronize() - Synchronizing left and right slit traces
[INFO]    :: trace_slits.py 2437 synchronize_edges() - Relabelling slit edges
[WORK IN ]::
[PROGRESS]:: trace_slits.py 2080 pca_pixel_slit_edges() - May need to do a check here to make sure ofit is reasonable
[INFO]    :: trace_slits.py 2086 pca_pixel_slit_edges() - Performing a PCA on the slit traces
             pca.py 98 basis() -   Reduced chi-squared = 2.109613E-07
[INFO]    :: traceslits.py 845 _trim_slits() - Slit 13 has width = 2.1837675380609904 < less than min_slit_width = 4.0 arcseconds - ignoring this slit
[INFO]    :: traceslits.py 845 _trim_slits() - Slit 39 has width = 2.1278821357908866 < less than min_slit_width = 4.0 arcseconds - ignoring this slit
[INFO]    :: traceslits.py 845 _trim_slits() - Slit 42 has width = 1.871624592335081 < less than min_slit_width = 4.0 arcseconds - ignoring this slit
[INFO]    :: traceslits.py 845 _trim_slits() - Slit 49 has width = 2.162858407606137 < less than min_slit_width = 4.0 arcseconds - ignoring this slit
[INFO]    :: traceslits.py 535 _make_pixel_arrays() - Converting physical trace locations to nearest pixel
[INFO]    :: traceslits.py 542 _make_pixel_arrays() - Identifying the pixels belonging to each slit
[INFO]    :: traceslits.py 933 save_master() - Wrote TraceSlit arrays to /scratch/REDUX/Gemini/J1059+1441/gemini_gmos_north_e2v_setup_A/MF_gemini_gmos_north_e2v/MasterTrace_A_01_aa.fits
[INFO]    :: traceslits.py 935 save_master() - gzip compressing /scratch/REDUX/Gemini/J1059+1441/gemini_gmos_north_e2v_setup_A/MF_gemini_gmos_north_e2v/MasterTrace_A_01_aa.fits
[INFO]    :: traceslits.py 949 save_master() - Writing TraceSlit dict to /scratch/REDUX/Gemini/J1059+1441/gemini_gmos_north_e2v_setup_A/MF_gemini_gmos_north_e2v/MasterTrace_A_01_aa.json
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 1
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 2
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 3
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 4
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 5
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 6
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 7
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 8
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 9
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 10
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 11
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 12
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 13
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 14
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 15
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 16
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 17
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 18
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 19
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 20
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 21
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 22
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 23
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 24
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 25
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 26
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 27
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 28
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 29
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 30
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 31
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 32
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 33
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 34
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 35
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 36
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 37
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 38
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 39
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 40
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 41
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 42
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 43
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 44
[INFO]    :: arc.py 148 get_censpec() - Extracting an approximate arc spectrum at the centre of slit 45
[INFO]    :: arc.py 71 setup_param() - Loading line list using CuAr lamps
> /data/Projects/Python/PypeIt/pypeit/core/wavecal/waveio.py(148)load_line_lists()
-> raise IOError("Input line {:s} is not included in arclines".format(line))
(Pdb) line
'CuAr'
(Pdb) w
  /home/xavier/.pyenv/versions/anaconda3-4.4.0/lib/python3.6/runpy.py(193)_run_module_as_main()
-> "__main__", mod_spec)
  /home/xavier/.pyenv/versions/anaconda3-4.4.0/lib/python3.6/runpy.py(85)_run_code()
-> exec(code, run_globals)
  /home/xavier/.pyenv/versions/anaconda3-4.4.0/lib/python3.6/site-packages/ipykernel_launcher.py(16)<module>()
-> app.launch_new_instance()
  /home/xavier/.pyenv/versions/anaconda3-4.4.0/lib/python3.6/site-packages/traitlets/config/application.py(658)launch_instance()
-> app.start()
  /home/xavier/.pyenv/versions/anaconda3-4.4.0/lib/python3.6/site-packages/ipykernel/kernelapp.py(477)start()
-> ioloop.IOLoop.instance().start()
  /home/xavier/.pyenv/versions/anaconda3-4.4.0/lib/python3.6/site-packages/zmq/eventloop/ioloop.py(177)start()
-> super(ZMQIOLoop, self).start()
  /home/xavier/.pyenv/versions/anaconda3-4.4.0/lib/python3.6/site-packages/tornado/ioloop.py(888)start()
-> handler_func(fd_obj, events)
  /home/xavier/.pyenv/versions/anaconda3-4.4.0/lib/python3.6/site-packages/tornado/stack_context.py(277)null_wrapper()
-> return fn(*args, **kwargs)
  /home/xavier/.pyenv/versions/anaconda3-4.4.0/lib/python3.6/site-packages/zmq/eventloop/zmqstream.py(440)_handle_events()
-> self._handle_recv()
  /home/xavier/.pyenv/versions/anaconda3-4.4.0/lib/python3.6/site-packages/zmq/eventloop/zmqstream.py(472)_handle_recv()
-> self._run_callback(callback, msg)
  /home/xavier/.pyenv/versions/anaconda3-4.4.0/lib/python3.6/site-packages/zmq/eventloop/zmqstream.py(414)_run_callback()
-> callback(*args, **kwargs)
  /home/xavier/.pyenv/versions/anaconda3-4.4.0/lib/python3.6/site-packages/tornado/stack_context.py(277)null_wrapper()
-> return fn(*args, **kwargs)
  /home/xavier/.pyenv/versions/anaconda3-4.4.0/lib/python3.6/site-packages/ipykernel/kernelbase.py(283)dispatcher()
-> return self.dispatch_shell(stream, msg)
  /home/xavier/.pyenv/versions/anaconda3-4.4.0/lib/python3.6/site-packages/ipykernel/kernelbase.py(235)dispatch_shell()
-> handler(stream, idents, msg)
  /home/xavier/.pyenv/versions/anaconda3-4.4.0/lib/python3.6/site-packages/ipykernel/kernelbase.py(399)execute_request()
-> user_expressions, allow_stdin)
  /home/xavier/.pyenv/versions/anaconda3-4.4.0/lib/python3.6/site-packages/ipykernel/ipkernel.py(196)do_execute()
-> res = shell.run_cell(code, store_history=store_history, silent=silent)
  /home/xavier/.pyenv/versions/anaconda3-4.4.0/lib/python3.6/site-packages/ipykernel/zmqshell.py(533)run_cell()
-> return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
  /home/xavier/.pyenv/versions/anaconda3-4.4.0/lib/python3.6/site-packages/IPython/core/interactiveshell.py(2717)run_cell()
-> interactivity=interactivity, compiler=compiler, result=result)
  /home/xavier/.pyenv/versions/anaconda3-4.4.0/lib/python3.6/site-packages/IPython/core/interactiveshell.py(2827)run_ast_nodes()
-> if self.run_code(code, result):
  /home/xavier/.pyenv/versions/anaconda3-4.4.0/lib/python3.6/site-packages/IPython/core/interactiveshell.py(2881)run_code()
-> exec(code_obj, self.user_global_ns, self.user_ns)
  <ipython-input-7-84c6e515cd69>(1)<module>()
-> pypeIt.reduce_all()
  /data/Projects/Python/PypeIt/pypeit/pypeit.py(229)reduce_all()
-> sci_dict = self.reduce_exposure(sci_ID, reuse_masters=reuse_masters)
  /data/Projects/Python/PypeIt/pypeit/pypeit.py(343)reduce_exposure()
-> self.calibrate_one(sci_ID, det)
  /data/Projects/Python/PypeIt/pypeit/pypeit.py(697)calibrate_one()
-> self.caliBrate.run_the_steps()
  /data/Projects/Python/PypeIt/pypeit/calibrations.py(694)run_the_steps()
-> getattr(self, 'get_{:s}'.format(step))()
  /data/Projects/Python/PypeIt/pypeit/calibrations.py(591)get_wv_calib()
-> nonlinear=nonlinear, skip_QA=(not self.write_qa))
  /data/Projects/Python/PypeIt/pypeit/wavecalib.py(327)run()
-> self.wv_calib = self._build_wv_calib(self.par['method'], skip_QA=skip_QA)
  /data/Projects/Python/PypeIt/pypeit/wavecalib.py(134)_build_wv_calib()
-> self.wv_calib = arc.calib_with_arclines(self.arcparam, self.arccen, ok_mask=ok_mask)
  /data/Projects/Python/PypeIt/pypeit/core/arc.py(882)calib_with_arclines()
-> arcfitter = autoid.General(spec, aparm['lamps'], ok_mask=ok_mask, fit_parm=aparm, min_ampl=aparm['min_ampl'], nonlinear_counts = aparm['nonlinear_counts'])
  /data/Projects/Python/PypeIt/pypeit/core/wavecal/autoid.py(393)__init__()
-> self.load_linelist()
  /data/Projects/Python/PypeIt/pypeit/core/wavecal/autoid.py(424)load_linelist()
-> self._line_lists = waveio.load_line_lists(self._lines)
> /data/Projects/Python/PypeIt/pypeit/core/wavecal/waveio.py(148)load_line_lists()
-> raise IOError("Input line {:s} is not included in arclines".format(line))
(Pdb) exit
---------------------------------------------------------------------------
BdbQuit                                   Traceback (most recent call last)
<ipython-input-7-84c6e515cd69> in <module>()
----> 1 pypeIt.reduce_all()

/data/Projects/Python/PypeIt/pypeit/pypeit.py in reduce_all(self, reuse_masters)
    227 
    228         for kk,sci_ID in enumerate(all_sci_ID):
--> 229             sci_dict = self.reduce_exposure(sci_ID, reuse_masters=reuse_masters)
    230             # Save
    231             scidx = self.fitstbl.find_frames('science', sci_ID=sci_ID, index=True)[0]

/data/Projects/Python/PypeIt/pypeit/pypeit.py in reduce_exposure(self, sci_ID, reuse_masters)
    341 
    342             # Calibrate
--> 343             self.calibrate_one(sci_ID, det)
    344 
    345             # Init ScienceImage class

/data/Projects/Python/PypeIt/pypeit/pypeit.py in calibrate_one(self, sci_ID, det)
    695         self.caliBrate.reset(self.setup, det, sci_ID, self.par['calibrations'])
    696         # Run em
--> 697         self.caliBrate.run_the_steps()
    698 
    699         msgs.info("Successful Calibration!")

/data/Projects/Python/PypeIt/pypeit/calibrations.py in run_the_steps(self)
    692         """
    693         for step in self.steps:
--> 694             getattr(self, 'get_{:s}'.format(step))()
    695 
    696     # This is general to any attribute

/data/Projects/Python/PypeIt/pypeit/calibrations.py in get_wv_calib(self)
    589                                                   self.tslits_dict['rcen'],
    590                                                   self.tslits_dict['slitpix'],
--> 591                                                   nonlinear=nonlinear, skip_QA=(not self.write_qa))
    592             # Save to Masters
    593             if self.save_masters:

/data/Projects/Python/PypeIt/pypeit/wavecalib.py in run(self, lordloc, rordloc, slitpix, nonlinear, skip_QA)
    325 
    326         # Fill up the calibrations and generate QA
--> 327         self.wv_calib = self._build_wv_calib(self.par['method'], skip_QA=skip_QA)
    328         self.wv_calib['steps'] = self.steps
    329         sv_aparam = self.arcparam.copy()

/data/Projects/Python/PypeIt/pypeit/wavecalib.py in _build_wv_calib(self, method, skip_QA)
    132                                                     IDwaves=self.par['IDwaves'])
    133         elif method == 'arclines':
--> 134             self.wv_calib = arc.calib_with_arclines(self.arcparam, self.arccen, ok_mask=ok_mask)
    135 
    136         # QA

/data/Projects/Python/PypeIt/pypeit/core/arc.py in calib_with_arclines(aparm, spec, ok_mask, use_method)
    880     else:
    881         # Now preferred
--> 882         arcfitter = autoid.General(spec, aparm['lamps'], ok_mask=ok_mask, fit_parm=aparm, min_ampl=aparm['min_ampl'], nonlinear_counts = aparm['nonlinear_counts'])
    883         patt_dict, final_fit = arcfitter.get_results()
    884     return final_fit

/data/Projects/Python/PypeIt/pypeit/core/wavecal/autoid.py in __init__(self, spec, lines, ok_mask, min_ampl, nonlinear_counts, islinelist, outroot, debug, verbose, fit_parm, lowest_ampl, rms_threshold, binw, bind, nstore, use_unknowns)
    391 
    392         # Load the linelist to be used for pattern matching
--> 393         self.load_linelist()
    394 
    395         # Find the wavelength solution!

/data/Projects/Python/PypeIt/pypeit/core/wavecal/autoid.py in load_linelist(self)
    422                 self._unknwns = line_lists_all[np.where(line_lists_all['ion'] == 'UNKNWN')]
    423             else:
--> 424                 self._line_lists = waveio.load_line_lists(self._lines)
    425                 self._unknwns = waveio.load_unknown_list(self._lines)
    426 

/data/Projects/Python/PypeIt/pypeit/core/wavecal/waveio.py in load_line_lists(lines, unknown, skip, all, NIST)
    146             if not skip:
    147                 import pdb; pdb.set_trace()
--> 148                 raise IOError("Input line {:s} is not included in arclines".format(line))
    149         else:
    150             lists.append(load_line_list(line_file, NIST=NIST))

/data/Projects/Python/PypeIt/pypeit/core/wavecal/waveio.py in load_line_lists(lines, unknown, skip, all, NIST)
    146             if not skip:
    147                 import pdb; pdb.set_trace()
--> 148                 raise IOError("Input line {:s} is not included in arclines".format(line))
    149         else:
    150             lists.append(load_line_list(line_file, NIST=NIST))

/home/xavier/.pyenv/versions/anaconda3-4.4.0/lib/python3.6/bdb.py in trace_dispatch(self, frame, event, arg)
     49             return # None
     50         if event == 'line':
---> 51             return self.dispatch_line(frame)
     52         if event == 'call':
     53             return self.dispatch_call(frame, arg)

/home/xavier/.pyenv/versions/anaconda3-4.4.0/lib/python3.6/bdb.py in dispatch_line(self, frame)
     68         if self.stop_here(frame) or self.break_here(frame):
     69             self.user_line(frame)
---> 70             if self.quitting: raise BdbQuit
     71         return self.trace_dispatch
     72 

BdbQuit: 

In [ ]:
pypeIt.caliBrate.traceSlits.tslits_dict

Slits

Generate trace image


In [ ]:
pypeIt.caliBrate.trace_image_files

In [ ]:
# Instantiate
traceImage = traceimage.TraceImage(pypeitSetup.spectrograph,
                               file_list=pypeIt.caliBrate.trace_image_files, det=1,
                               par=pypeIt.caliBrate.par['traceframe'])

In [ ]:
# Process
mstrace = traceImage.process(bias_subtract='overscan', trim=pypeIt.caliBrate.par['trim'], apply_gain=True)

In [ ]:
traceImage.show()

binarr


In [ ]:
_= pypeIt.caliBrate.traceSlits.make_binarr()

In [ ]:
32*0.0728*2

Plate scale


In [ ]:
# Compute the plate scale in arcsec which is needed to trim short slits
scidx = np.where(pypeIt.caliBrate.fitstbl.find_frames('science', sci_ID=pypeIt.caliBrate.sci_ID))[0][0]
binspatial, binspectral = parse.parse_binning(pypeIt.caliBrate.fitstbl['binning'][scidx])
## Old code: binspatial, binspectral = parse.parse_binning(self.fitstbl['binning'][scidx])
plate_scale = binspatial*pypeitSetup.spectrograph.detector[0]['platescale']
plate_scale

Edgearr


In [ ]:
_= pypeIt.caliBrate.traceSlits._edgearr_from_binarr()

In [ ]:
pypeIt.caliBrate.traceSlits.show('edgearr')

Match edges


In [ ]:
pypeIt.caliBrate.traceSlits._match_edges()

Assign edges


In [ ]:
pypeIt.caliBrate.traceSlits._assign_edges()

Final left/right


In [ ]:
pypeIt.caliBrate.traceSlits._final_left_right()

Mslit magic


In [ ]:
pypeIt.caliBrate.traceSlits._mslit_tcrude()

In [ ]:
pypeIt.caliBrate.traceSlits._mslit_sync()

Fit Edges


In [ ]:
pypeIt.caliBrate.traceSlits._set_lrminx()
pypeIt.caliBrate.traceSlits._fit_edges('left')
pypeIt.caliBrate.traceSlits._fit_edges('right')

Synchronize


In [ ]:
pypeIt.caliBrate.traceSlits._synchronize()

PCA


In [ ]:
pypeIt.caliBrate.traceSlits._pca()

In [ ]:
pypeIt.caliBrate.traceSlits.show('edges')

In [ ]:
pypeIt.caliBrate.traceImage.show()

In [ ]:
pypeIt.caliBrate.traceSlits.show('siglev')

In [ ]:
pypeIt.caliBrate.traceSlits.show('edgearr')

In [ ]:
pypeIt.caliBrate.par

Wavelengths


In [8]:
pypeIt.caliBrate.waveCalib.arccen.shape


Out[8]:
(1024, 45)

In [9]:
from pypeit import debugger

In [11]:
debugger.plot1d(pypeIt.caliBrate.waveCalib.arccen[:,1])


Save to disk


In [13]:
tdict = {}
tdict['arccen'] = pypeIt.caliBrate.waveCalib.arccen
#
jdict = ltu.jsonify(tdict)

In [17]:
ltu.savejson('GMOS_R400_blue.json', jdict)


In [19]:
IDpixels = np.array([802.14, 487.28, 322.49, 31.8])
IDwave =   np.array([5189.191, 4766.197, 4546.3258, 4159.762])

In [20]:
dwv = (IDwave-np.roll(IDwave,1))/(IDpixels-np.roll(IDpixels,1))

In [22]:
dwv/2


Out[22]:
array([0.66816536, 0.67171759, 0.66712543, 0.66490729])

In [ ]: