How to Use The BHTOM-SPEC Documentation

This provides the spectroscopic data reduction for BHTOM. At the time of writing, it is planned for implementing the longslit spectral reduction of Gemini/GMOS, LT/SPRAT and LCO/Flloyds.

Usage

To perform a spectral extraction from SPRAT data, user only needs to type:

python sprat_extraction.py extraction_config.yaml

While for GMOS, the images have to be flattened first, before performing the spectral extraction:

python gmos_reduction.py reduction_config.yaml
python gmos_extraction.py extraction_config.yaml

Some the Configuration Files section for more information.

User Guide

Installation Guide

Dependencies

Python >= 3.6

These packages can be installed with pip

  • numpy >= 1.16
  • scipy >= 1.5
  • spectres >= 2.1.1
  • reportlab
  • svglib
  • pyyaml

These have to be installed from the respective development branches at

This is required if you wish to build the document locally

BHTOM Spec

Clone the repositry

git clone https://github.com/cylammarco/bhtomspec
git clone https://github.com/cylammarco/bhtomspec-example

To test the bhtomspec, all the examplex should run, e.g.

python3 [some_path_a]/bhtomspec/SPRAT/sprat_extraction.py [some_path_b]/bhtomspec-example/SPRAT/example/ExtractionCase1/20180810_lhs6328_case1.yaml
python3 [some_path_a]/bhtomspec/GMOS/gmos_reduction.py [some_path_b]/bhtomspec-example/GMOS/example/ReductionCase1/flattening_config.yaml
python3 [some_path_a]/bhtomspec/GMOS/gmos_extraction.py [some_path_b]/bhtomspec-example/GMOS/example/ExtractionCase1/extraction_config_1.yaml

There are 3 shell scripts that run all the examples, however, the path has to be configured before they work. For example, in [some_path_b]/bhtomspec-example/SPRAT/run_all_examples.sh

python3 sprat_extraction.py example/ExtractionCase1/20180810_lhs6328_case1.yaml
python3 sprat_extraction.py example/ExtractionCase2/20180810_lhs6328_case2.yaml
python3 sprat_extraction.py example/ExtractionCase3/20180810_lhs6328_case3.yaml
python3 sprat_extraction.py example/ExtractionCase4/20180810_lhs6328_case4.yaml
python3 sprat_extraction.py example/ExtractionCase5/20180810_lhs6328_case5.yaml

has to be modified to

python3 [some_path_a]/bhtomspec/SPRAT/ssprat_extraction.py example/ExtractionCase1/20180810_lhs6328_case1.yaml
python3 [some_path_a]/bhtomspec/SPRAT/ssprat_extraction.py example/ExtractionCase2/20180810_lhs6328_case2.yaml
python3 [some_path_a]/bhtomspec/SPRAT/ssprat_extraction.py example/ExtractionCase3/20180810_lhs6328_case3.yaml
python3 [some_path_a]/bhtomspec/SPRAT/ssprat_extraction.py example/ExtractionCase4/20180810_lhs6328_case4.yaml
python3 [some_path_a]/bhtomspec/SPRAT/ssprat_extraction.py example/ExtractionCase5/20180810_lhs6328_case5.yaml

before it can run.

Other repositories for BHTOM Spec

It is currently not a pacakge, just scripts, so it is not registered on any package index service. It may happen if this project continues onto a full integration with BHTOM.

Reduction Configuration

This only applies to GMOS reduction where a full reduction is performd. SPRAT reductions begin with flattened spectral image data.

GMOS field-flattening configuration (YAML)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
folder_path: "."
output_folder_path: "output"
light_folder: ~
flat_folder: ~
arc_folder: ~
bias_folder: ~
arc_flat_folder: ~
arc_bias_folder: ~
light_extension: ["fits", "fit", "bz2", "gz"]
flat_extension: ["fits", "fit", "bz2", "gz"]
arc_extension: ["fits", "fit", "bz2", "gz"]
bias_extension: ["fits", "fit", "bz2", "gz"]
arc_flat_extension: ["fits", "fit", "bz2", "gz"]
arc_bias_extension: ["fits", "fit", "bz2", "gz"]
bias_master_filename: bias_master
arc_bias_master_filename: arc_bias_master
flat_row_size: 10
flat_edge_size: 10
flat_strip_size: 20
force_recreate_bias: false
save_bias: true
save_bias_format: ["fits", "npy"]
overwrite_bias_image: true
save_flattened_image: true
save_flattened_image_format: ["fits", "npy"]
overwrite_flattened_image: true
create_fig: true
show_fig: false
diagnostic_pdf: true

The light_folder, flat_folder, arc_folder, bias_folder, arc_flat_folder and arc_bias_folder are relative to the folder_path. If they are empty, the folders are assumed to be called light, flat, arc, bias, arc_flat, arc_bias folders located at folder_path.

All the files with the extension listed in the respective extension arguments (light_extension…) will be processed.

flat_row_size is the number of rows on either size from the central row of the spectral image that are to be summed to compute the sensitivity function. flat_edge_size is the number of edge pixels that are removed in the computation. flat_strip_size is the number of pixels from the flat_edge_size-th pixel to be fitted a straight line over.

Extraction Configuration

This applies to both GMOS and SPRAT.

Extraction configuration (YAML)

Once the flattening is performed, the longslit spectral extraction is like any extractions from a generic spectrograph. The format of the parameter files for GMOS and SPRAT are the same. Most of the parameters can be kept constant, respective to the instrument. The file paths, which are the first few lines of the file, have to be updated for each extraction. The output data can be exported as FITS/CSV, static png/jpg/pdf image, an interactive plotly iframe, or just the JSON file for the plotly graph. The following shows the example YAML of the GMOS extraction.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
folder_path: "."
output_folder_path: "20181115_gaia18cnz/output"

# Input
science_file:
  # - they have to be in a list
  - "20181115_gaia18cnz/output/N20181115S0097_flattened.fits"
  - "20181115_gaia18cnz/output/N20181115S0098_flattened.fits"
  - "20181115_gaia18cnz/output/N20181115S0101_flattened.fits"
  - "20181115_gaia18cnz/output/N20181115S0102_flattened.fits"
science_arc_file: "20181115_gaia18cnz/output/N20181115S0215_flattened.fits"

standard_file: "20180811_g191b2b/output/N20180811S0148_flattened.fits"
standard_arc_file: "20180811_g191b2b/output/N20180813S0115_flattened.fits"

# If sensitivity curve is provided, standard star extraction will be skipped
sensitivity_file:  "20180811_g191b2b/output/sensitivity_itp.npy"

# Output - they have to be lists
science_output_file:
  # - they have to be in a list
  - "20181115_gaia18cnz/output/N20181115S0097"
  - "20181115_gaia18cnz/output/N20181115S0098"
  - "20181115_gaia18cnz/output/N20181115S0101"
  - "20181115_gaia18cnz/output/N20181115S0102"
standard_output_file: "20180811_g191b2b/output/N20180811S0148"

science_output_type:
  - "fits"
  - "csv"
  - "png"
  - "iframe"
standard_output_type:
  - "fits"
  - "csv"
  - "png"
  - "iframe"

# Output
savefits: True
fits_output: 'flux_resampled+wavecal+flux+adu+adu_resampled'
fits_filename: 'reduced'
fits_stype: 'science'
fits_individual: False
fits_overwrite: False
savecsv: True
csv_output: 'flux_resampled+wavecal+flux+adu+adu_resampled'
csv_filename: 'reduced'
csv_stype: 'science'
csv_individual: False
csv_overwrite: False

# Only needed if images/iframe are being exported
width: 1920
height: 1080

It is then followed by all the extraction parameters. At the time of writing, the readnoise, gain, seeing and exptime are not read automatically from the header. In order to have a correct absolute flux calibration, the exposure time has to be filled in manually. The gain is constant for the instrument over time, so it does not need adusting unless the observatory has changed the instrument setting. While the seeing varies with time, it does not affect the extraction quality, it can slightly slow down the speed in aperture tracing, which is hardly a bottleneck process of the data extraction to begin with, so it can be left as it is. The same applies to the paramteers for the standard.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# Science traget

# TwoDSpec parameters
science_saxis: 1
science_spatial_mask: ''
science_spec_mask: ''
science_flip: True
science_cosmicray: True
science_cosmicray_sigma: 5.
science_readnoise: 0.
science_gain: 1.64
science_seeing: 1.2
science_exptime: 300
science_silence: False

Below is the rest of the configuration file.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
# Aperture Tracing
science_aptrace_nspec: 1
science_aptrace_nwindow: 25
science_aptrace_spec_sep: 5
science_aptrace_resample_factor: 10
science_aptrace_rescale: False
science_aptrace_scaling_min: 0.995
science_aptrace_scaling_max: 1.005
science_aptrace_scaling_step: 0.001
science_aptrace_percentile: 5
science_aptrace_tol: 3
science_aptrace_polydeg: 3
science_aptrace_ap_faint: 10
science_aptrace_display: False
science_aptrace_renderer: "default"
science_aptrace_jsonstring: False
science_aptrace_iframe: False
science_aptrace_open_iframe: False
# Aperture Extraction
science_apextract_apwidth: 10
science_apextract_skysep: 5
science_apextract_skywidth: 5
science_apextract_skydeg: 1
science_apextract_optimal: True
science_apextract_display: False
science_apextract_renderer: "default"
science_apextract_jsonstring: False
science_apextract_iframe: False
science_apextract_open_iframe: False
# WavelengthCalibration
science_silence: False
science_pixel_list: ~
# Provide polyfit coefficients
science_polyfit: False
science_polyfit_coeff: [0., 0., 0., 0., 0.]
science_polyfit_type: ['poly']
# Extract Arc spectrum
science_arc_spec_display: False
science_arc_spec_jsonstring: False
science_arc_spec_renderer: 'default'
science_arc_spec_iframe: False
science_arc_spec_open_iframe: False
# Find arc lines
science_findarc_background: 1000.
science_findarc_percentile: ~
science_findarc_prominence: 0.
science_findarc_distance: 5.
science_findarc_refine: True
science_findarc_refine_window_width: 5
science_findarc_display: False
science_findarc_jsonstring: False
science_findarc_renderer: 'default'
science_findarc_iframe: False
science_findarc_open_iframe: False
# Calibrator parameters
science_wavecal_min_wavelength: 5000
science_wavecal_max_wavelength: 9500
science_wavecal_plotting_library: 'plotly'
science_wavecal_log_level: 'info'
# Calibrator Fit constraints
science_constraints_num_slopes: 10000
science_constraints_range_tolerance: 500
science_constraints_fit_tolerance: 10.
science_constraints_polydeg: 4
science_constraints_candidate_thresh: 15.
science_constraints_linearity_thresh: 1.5
science_constraints_ransac_thresh: 3
science_constraints_num_candidates: 25
science_constraints_xbins: 200
science_constraints_ybins: 200
science_constraints_brute_force: False
science_constraints_polyfit_type: 'poly'
science_constraints_spec_id: ~
# Atlas
science_atlas_elements: ['Cu', 'Ar']
science_atlas_min_atlas_wavelength: 0
science_atlas_max_atlas_wavelength: 15000
science_atlas_min_intensity: 0
science_atlas_min_distance: 0
science_atlas_vacuum: False
science_atlas_pressure: ~
science_atlas_temperature: ~
science_atlas_relative_humidity: ~
science_atlas_constrain_poly: False
science_atlas_spec_id: ~
# User-supplied Atlas, the following OVERRIDES the Atlas config set above
science_atlas_user_supplied: True
science_atlas_user_wavelengths: [
                4703.632, 4728.19041, 4766.19677, 4807.36348, 4849.16386, 4881.22627, 4890.40721, 4906.12088, 4934.58593, 4966.46490,
                5018.56194, 5063.44827, 5163.723, 5189.191, 5497.401,
                5560.246, 5608.290, 5913.723,
                6754.698, 6873.185, 6967.352,
                7032.190, 7069.167, 7149.012, 7274.940, 7386.014,
                7505.935, 7516.721, 7637.208, 7725.887, 7893.246, 7950.362,
                8105.921, 8117.542, 8266.794, 8410.521, 8426.963,
                8523.783, 8670.325,
                9125.471, 9197.161, 9227.03, 9356.787,
                9660.435, 9787.186
            ]
science_atlas_user_elements: ['CuAr']
science_atlas_user_vacuum: True
science_atlas_user_pressure: ~
science_atlas_user_temperature: ~
science_atlas_user_relative_humidity: ~
science_atlas_user_constrain_poly: False
science_atlas_user_spec_id: ~

# Fit
science_fit_sample_size: 5
science_fit_top_n: 10
science_fit_max_tries: 20000
science_fit_progress: True
science_fit_coeff: ~
science_fit_linear: True
science_fit_weighted: True
science_fit_filter_close: False
science_fit_display: False
science_fit_savefig: False
science_fit_filename: ~
science_fit_spec_id: ~
# Refine Fit 1st pass
science_refinefit1: False
science_refinefit1_polyfit_coeff: ~
science_refinefit1_n_delta: 2
science_refinefit1_refine: True
science_refinefit1_tolerance: 10.
science_refinefit1_method: 'Nelder-Mead'
science_refinefit1_convergence: 1.0e-6
science_refinefit1_robust_refit: True
science_refinefit1_polydeg: ~
science_refinefit1_display: False
science_refinefit1_savefig: False
science_refinefit1_filename: ~
science_refinefit1_spec_id: ~
# Refine Fit 2nd pass
science_refinefit2: False
science_refinefit2_polyfit_coeff: ~
science_refinefit2_n_delta: ~
science_refinefit2_refine: True
science_refinefit2_tolerance: 5.
science_refinefit2_method: 'Nelder-Mead'
science_refinefit2_convergence: 1.0e-6
science_refinefit2_robust_refit: True
science_refinefit2_polydeg: ~
science_refinefit2_display: False
science_refinefit2_savefig: False
science_refinefit2_filename: ~
science_refinefit2_spec_id: ~

# Standard traget

# TwoDSpec parameters
standard_saxis: 1
standard_spatial_mask: ''
standard_spec_mask: ''
standard_flip: True
standard_cosmicray: True
standard_cosmicray_sigma: 5.
standard_readnoise: ~
standard_gain: ~
standard_seeing: ~
standard_exptime: ~
standard_silence: False
# TwoDSpec header keywords (NOT used if the values are provided above)
standard_readnoise_keyword: ~
standard_gain_keyword: ~
standard_seeing_keyword: ~
standard_exptime_keyword: ~
# Aperture Tracing
standard_aptrace_nspec: 1
standard_aptrace_nwindow: 25
standard_aptrace_spec_sep: 5
standard_aptrace_resample_factor: 10
standard_aptrace_rescale: False
standard_aptrace_scaling_min: 0.995
standard_aptrace_scaling_max: 1.005
standard_aptrace_scaling_step: 0.001
standard_aptrace_percentile: 5
standard_aptrace_tol: 3
standard_aptrace_polydeg: 3
standard_aptrace_ap_faint: 10
standard_aptrace_display: False
standard_aptrace_renderer: "default"
standard_aptrace_jsonstring: False
standard_aptrace_iframe: False
standard_aptrace_open_iframe: False
# Aperture Extraction
standard_apextract_apwidth: 15
standard_apextract_skysep: 5
standard_apextract_skywidth: 5
standard_apextract_skydeg: 1
standard_apextract_optimal: True
standard_apextract_display: False
standard_apextract_renderer: "default"
standard_apextract_jsonstring: False
standard_apextract_iframe: False
standard_apextract_open_iframe: False
# WavelengthCalibration
standard_silence: False
standard_pixel_list: ~
# Provide polyfit coefficients
standard_polyfit: False
standard_polyfit_coeff: [0., 0., 0., 0., 0.]
standard_polyfit_type: ['poly']
# Extract Arc spectrum
standard_arc_spec_display: False
standard_arc_spec_jsonstring: False
standard_arc_spec_renderer: 'default'
standard_arc_spec_iframe: False
standard_arc_spec_open_iframe: False
# Find arc lines
standard_findarc_background: 1000.
standard_findarc_percentile: ~
standard_findarc_prominence: 0.
standard_findarc_distance: 5.
standard_findarc_refine: True
standard_findarc_refine_window_width: 5
standard_findarc_display: False
standard_findarc_jsonstring: False
standard_findarc_renderer: 'default'
standard_findarc_iframe: False
standard_findarc_open_iframe: False
# Calibrator parameters
standard_wavecal_min_wavelength: 5000
standard_wavecal_max_wavelength: 9500
standard_wavecal_plotting_library: 'plotly'
standard_wavecal_log_level: 'info'
# Calibrator Fit constraints
standard_constraints_num_slopes: 10000
standard_constraints_range_tolerance: 500
standard_constraints_fit_tolerance: 10.
standard_constraints_polydeg: 4
standard_constraints_candidate_thresh: 15.
standard_constraints_linearity_thresh: 1.5
standard_constraints_ransac_thresh: 3
standard_constraints_num_candidates: 25
standard_constraints_xbins: 200
standard_constraints_ybins: 200
standard_constraints_brute_force: False
standard_constraints_polyfit_type: 'poly'
standard_constraints_spec_id: ~
# Atlas
standard_atlas_elements: ['Cu', 'Ar']
standard_atlas_min_atlas_wavelength: 0
standard_atlas_max_atlas_wavelength: 15000
standard_atlas_min_intensity: 0
standard_atlas_min_distance: 0
standard_atlas_vacuum: False
standard_atlas_pressure: ~
standard_atlas_temperature: ~
standard_atlas_relative_humidity: ~
standard_atlas_constrain_poly: False
standard_atlas_spec_id: ~
# User-supplied Atlas, the following OVERRIDES the Atlas config set above
standard_atlas_user_supplied: True
standard_atlas_user_wavelengths: [
                4703.632, 4728.19041, 4766.19677, 4807.36348, 4849.16386, 4881.22627, 4890.40721, 4906.12088, 4934.58593, 4966.46490,
                5018.56194, 5063.44827, 5163.723, 5189.191, 5497.401,
                5560.246, 5608.290, 5913.723,
                6754.698, 6873.185, 6967.352,
                7032.190, 7069.167, 7149.012, 7274.940, 7386.014,
                7505.935, 7516.721, 7637.208, 7725.887, 7893.246, 7950.362,
                8105.921, 8117.542, 8266.794, 8410.521, 8426.963,
                8523.783, 8670.325,
                9125.471, 9197.161, 9227.03, 9356.787,
                9660.435, 9787.186
            ]
standard_atlas_user_elements: ['CuAr']
standard_atlas_user_vacuum: True
standard_atlas_user_pressure: ~
standard_atlas_user_temperature: ~
standard_atlas_user_relative_humidity: ~
standard_atlas_user_constrain_poly: False
standard_atlas_user_spec_id: ~
# Fit
standard_fit_sample_size: 5
standard_fit_top_n: 20
standard_fit_max_tries: 20000
standard_fit_progress: True
standard_fit_coeff: ~
standard_fit_linear: True
standard_fit_weighted: True
standard_fit_filter_close: False
standard_fit_display: False
standard_fit_savefig: False
standard_fit_filename: ~
standard_fit_spec_id: ~
# Refine Fit 1st pass
standard_refinefit1: True
standard_refinefit1_polyfit_coeff: ~
standard_refinefit1_n_delta: 2
standard_refinefit1_refine: True
standard_refinefit1_tolerance: 10.
standard_refinefit1_method: 'Nelder-Mead'
standard_refinefit1_convergence: 1.0e-6
standard_refinefit1_robust_refit: True
standard_refinefit1_polydeg: ~
standard_refinefit1_display: False
standard_refinefit1_savefig: False
standard_refinefit1_filename: ~
standard_refinefit1_spec_id: ~
# Refine Fit 2nd pass
standard_refinefit2: True
standard_refinefit2_polyfit_coeff: ~
standard_refinefit2_n_delta: ~
standard_refinefit2_refine: True
standard_refinefit2_tolerance: 5.
standard_refinefit2_method: 'Nelder-Mead'
standard_refinefit2_convergence: 1.0e-6
standard_refinefit2_robust_refit: True
standard_refinefit2_polydeg: ~
standard_refinefit2_display: False
standard_refinefit2_savefig: False
standard_refinefit2_filename: ~
standard_refinefit2_spec_id: ~

# Choose Flux Calibration
fluxcal_target: 'LTT7987'
fluxcal_library: 'esoxshooter'
fluxcal_ftype: 'flux'
fluxcal_cutoff: 0.4
fluxcal_display: True
fluxcal_renderer: 'default'
fluxcal_jsonstring: False
fluxcal_iframe: True
fluxcal_open_iframe: True
# Compute sensitivity curve
sensecurve_kind: 3
sensecurve_smooth: False
sensecurve_slength: 5
sensecurve_sorder: 3
sensecurve_mask_range:
  - [6860, 6960]
  - [7150, 7410]
  - [7580, 7720]
sensecurve_display: False
sensecurve_renderer: 'default'
sensecurve_jsonstring: False
sensecurve_iframe: False
sensecurve_open_iframe: False

LT SPRAT

The Liverpool Telescope distributes the SPRAT Level 2 (L2) data in multi-extension FITS files containing a primary image array for the Level 1 (L1) reduced CCD frame and up to five FITS extensions of derived products. The executive summary of the data product is listed in the following table, full description can be referred to the same link above.

Multi-extention FITS data format
Index EXTNAME Description
0 L1_IMAGE Fieldflattened long-slit image.
1 LSS_NONSS Wavelength calibrated and trimmed long-slit image.
2 SPEC_NONSS Tophat extracted 1D spectrum.
3 SPEC_SS Tophat extracted and sky subtracted 1D spectrum. Always exists if SPEC_NONSS exists, but it may not be picking the right regions for sky subtraction (e.g. nebulosity from the resolved host galaxy).
4 NORMFLUX Detector response corrected SPEC_SS spectrum. Flux is normalised to unity over the region 5000-6000 A. Always exists if SPEC_SS exists.
5 FLUX Absolute flux calibrated spectrum in unit of erg / s / cm^2 / A.

The provided reduced data only guarantee to contain index 0 and 1. The native pipeline may fail to produce SPEC_NONSS in crowded field; the flux may not be calibrated if the photometry from the acquisition image is not reliable (see more here).

With only the Science FITS file

If the data comes with 6 HDUs, the spectrum can be re-extracted directly from the LSS_NONSS image, and then re-appply the absolute flux calibration by extracting the sensitivity function by dividing [SPEC_SS] by [FLUX]. The sensitivity function the native pipeline applied is (ADU / s) /(erg / s / cm^2 / A). This can improve the signal-to-noise ratio (SNR) by up to ~30% coming purely from the difference between optimal extraction and tophat etraction.

If the data comes with 5 HDUs, the same procedure applies except the absolute calibration will be done by using a pre-saved sensitivity function adjusted to the unit of (erg / s / cm^2 / A) / s. This will only give the estimate of the absolute flux. The spectral shape will be the same as the NORMFLUX data from their native pipeline.

If the data comes with less than 5 HDUs, the sensitivity function will be taken from the pre-saved data, which can be out of date but should give a good general shape of the spectrum.

With only the Science and Standard FITS file

It is not common for the LT programmes to include standard frames. However, if one is provided, it can be used to compute a more representatibe response function. The procedures are the same as above in terms of spectral extraction. The sensitivity will be computed by providing the name of the standard star in the configuration file.

With arc files

The arc file is taken every time after an observing group/block. It is extremely rare that the automated LT pipeline fail to the perform wavelength calibration. Using a different way to compute the wavelength solution with more lines with RASCAL, a recalibration may give a marginal improvment in the calibration (less than the resolution in any case). We recommend providing an arc file if you wish to use the native pixel scale such that the resampling done from L1_IMAGE to LSS_NONSS will not lead to any loss of information, regardless of how small they can be.

Data Processing

The above processes will be assignd as one of the following five scenarios when handled by this pipeline:

  1. science frame only (Science L1 Image)
    1. Improving the S/N ratio by using optimal extraction (Science)
  2. science + science arc frames only (Science LSS_NONSS)
    1. Improving the S/N ratio by using optimal extraction (Science)
    2. Recomputing the wavelength solution (Science)
  3. science + standard frames only (Science L1 Image + Standard L1 Image)
    1. Improving the S/N ratio by using optimal extraction (Science + Standard)
    2. Recompute the sensitivity response function
  4. scince + science arc + standard frames (Science L1 Image + Standard LSS_NONSS)
    1. Improving the S/N ratio by using optimal extraction (Science + Standard)
    2. Recomputing the wavelength solution (Science)
    3. Recompute the sensitivity response function
  5. scince + science arc + standard + standard arc frames (Science L1 Image + Standard L1 Image)
    1. Improving the S/N ratio by using optimal extraction (Science + Standard)
    2. Recomputing the wavelength solution (Science + Standard)
    3. Recompute the sensitivity response function
  • science + standard + standard arc will be treated as (3)
  • science + standard arc will be treated as (1)
  • If sensitivity file is provided, they will be used and the reprocessing will ignore the standard and standard arc files, i.e. (3) will reduced to (1), (4) & (5) will reduced to (2).

GMOS Longslit

The GMOS Longslit spectrograph is available with both Gemini North and Gemini South. The characteristics of the instruments are very similar, with only some minute differences, at the detector plane. This comment is at least true for the purpose of this quicklook pipeline. The non-negligible differences are taken care of, for example, different sizes of the chip gaps. See the detailed description of the instuments here.

This quicklook pipeline divides the reduction in two parts - (1) fieldflattening and (2) spectral extraction. The first part takes care of the different binnings, Region Of Interest (ROI), chip gap sizes (North/South are different), bias subtraction, overscan subtraction and response function within chip & across the focal plane. The second part is the spectral extraction.

1. Fieldflattening

The procedure follows that described on the US National Gemini Office GMOS cookbook page . The gmos_spectral_extraction.py keeps the fucntions for performing image reconstruction, generating master bias and global sensitivity function. The only procedure that is not directly obvious from the page is the construction of the response function across the detector array, the steps are as follow:

  1. Generate the master flat by dividing the stacked flat by the mean (with sigma clipping and NAN handled).
  2. Sum the ADU counts over the few pixels covered by the 2D spectrum in the spatial direction to generate the relative response across the spectral direction.
  3. Fit straight lines through the back-to-back end pixels (ignore the last few pixels) of the relative response between the adjacent chips in order to normalise the inter-chip response. See the linear_fit() function.
  4. Apply the global response function to absolutely normalise the 3-chip image.

In order to reduce the images, the gmos_reduction.py should be executed, which makes use of the gmos_extraction.py and the parameter YAML file.

The different combinations of available frames will be assignd as one of the following eight scenarios, we require at least one light and one flat frame:

  1. Light + Flat
  2. Light + Flat + Bias
  3. Light + Flat + Arc
  4. Light + Flat + Arc + Arc Flat
  5. Light + Flat + Arc + Arc Bias
  6. Light + Flat + Bias + Arc + Arc Flat
  7. Light + Flat + Bias + Arc + Arc Bias
  8. Light + Flat + Bias + Arc + Arc Flat + Arc Bias

An example diagnostic pdf:

2. Spectral Extraction

After the images are flattened and reconstructed, the ‘gmos_spetral_extraction.py’ can be executed with another YAML parameter file for the spectral extraction configuration. For the purposes of quicklook, most of the parameters can be kept untouched. The paths have to be changed accordingly in order to extract the spectra properly. Mismatched binnings could be handled by automatically up/downsampling the flat/bias frames. However, even when mismatched instruments (North/South) and mismatched gratings can allow the output of a reduced spectrum, the pipeline is not checking all the cases whether the input combination makes sense.

With only Science FITS file

Extraction will be performed and only the ADU as a function of pixel can be produced.

With only Science and Arc FITS files

Extraction will be performed and only the ADU as a function of wavelength can be produced.

With only Science, Standard and one of Science or Standard Arc FITS files

Extraction will be performed on both the science and standard spectra. The arc will be used for wavelength calibration for both frames. Wavelength and flux will be calibrated.

With Science, Science Arc, Standard and Standard Arc FITS file

Extraction will be performed on both the science and standard spectra. The respective arc will be used for wavelength calibration for the respective frames. Wavelength and flux will be calibrated.

The different combinations of available frames from the fieldflatting will give different sets of final products, they will be one of the following five scenarios:

Data Product
Case Input Output
1 Science ADU(pix)
2 Science + Arc ADU(wavelength)
3 Science + Arc + Sensitivity Curve Flux(wavelength) from pre-saved sensitivity curve, though it may not provide a good SED, it should be good enough for quick inspection. Need to be careful to select the right combination of grating and central wavelength.
4 Science + Arc + Standard Flux(wavelength) with the potential in getting better absolute flux calibration, if a bad standard is used, the quality will be lower than (3)
5 Science + Arc + Standard + Standard Arc Flux(wavelength) with the potential in getting better absolute flux calibration, if a bad standard is used, the quality will be lower than (3)
  • If sensitivity file is provided, (4) & (5) will reduced to (3).
  • Without Arc, sensitivity file cannot be used, it will remain as case (1).

An example output html of the extracted spectrum (click for the interactive display in a new tab):

_images/N20181115S0097_spectrum_0.png

Indices and tables