Skip to content

Commit 30bf899

Browse files
committed
Improvements while extracting MRES spectra
1 parent 210415c commit 30bf899

6 files changed

Lines changed: 10968 additions & 207 deletions
21 KB
Binary file not shown.

EXOhSPEC_Data_Reduction_UserManual.tex

Lines changed: 94 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
}
3232

3333
\title{User Manual for Data Reduction of the EXOhSPEC Instrument \\ Working version: V0.3.1}
34-
\date{September, 2018}
34+
\date{December, 2018}
3535
\author{Ronny Errmann, Neil Cook\\ Physics, Astronomy and Maths, University of Hertfordshire}
3636

3737
\begin{document}
@@ -70,7 +70,7 @@ \section{Installation and dependencies}
7070

7171
\subsection{With Anaconda and python 2.7}
7272

73-
\noindent Anaconda can be downloaded from \url{https://www.continuum.io/downloads}. Please select the version for python 2.7. After download it can be installed by running
73+
\noindent Anaconda can be downloaded from \url{https://www.anaconda.com/download/}. Please select the version for python 2.7. After download it can be installed by running
7474
\begin{lstlisting}[style=base]
7575
sh Downloads/Anaconda2-5.0.1-Linux-x86_64.sh
7676
\end{lstlisting}
@@ -91,7 +91,7 @@ \subsubsection{Additional modules}
9191

9292
\noindent Once Anaconda is installed tow other modules are needed (tqdm, gatspy). If Anaconda is installed correctly then pip can be used to install this module
9393
\begin{lstlisting}[style=base]
94-
pip install tqdm gatspy
94+
pip install tqdm gatspy pyfits
9595
\end{lstlisting}
9696
%gatspy for lomb scargle
9797

@@ -148,39 +148,6 @@ \subsubsection{Finding further information}
148148

149149

150150

151-
\newpage
152-
\section{Short introduction to reduction of CCD images}
153-
154-
The data stored in CCD images is affected by the physical parameters of the individual pixels and way the readout electronics work. Therefore each scientific frame needs to be corrected (pixel by pixel) with the formula:
155-
\begin{equation}
156-
\mathrm{reduced\ Science} = \frac{\mathrm{raw\ Science} - \mathrm{master\ Bias} - \mathrm{master\ Dark}}{\mathrm{master\ Flat}}\,.
157-
\end{equation}
158-
The master Dark should have the same exposure time as the Science frame and the master Flat should be normalised in order to keep the flux levels. To create the master Dark and master Flat, the following steps are necessary:
159-
\begin{equation}
160-
\mathrm{master\ Dark} = \mathrm{raw\ Dark} - \mathrm{master\ Bias}
161-
\end{equation}
162-
\begin{equation}
163-
\mathrm{master\ Flat} = \mathrm{raw\ Flat} - \mathrm{master\ Bias} - \mathrm{master\ Dark}\,.
164-
\end{equation}
165-
The master Dark used for the creation of the master Flat should have the same exposure time as the Flat and needs to be corrected with the Bias. The master Bias in each of the formulas can be different.
166-
167-
In order to decrease the noise levels, each of the master file should be created by median combining several (corrected) images together. If the brightness of the individual flats vary, then the flats should be weighted by their median flux before combining them. Combining all steps leads to the formula
168-
\begin{equation}
169-
\label{eq:reduction_full}
170-
\mathrm{reduced\ Science} = \frac{\mathrm{raw\ Science} - B_S - (D_S - B_{D_S})}{F - B_F - (D_F - B_{D_F})}\,,
171-
\end{equation}
172-
where $B_S$ is the master Bias, created by combining biases taken at a similar time as the science frame, $D_S$ is the master Dark, created of darks with the same exposure time as the science frame. In case the bias level and noise don't change during the night, then Equation~\ref{eq:reduction_full} changes to
173-
\begin{equation}
174-
\mathrm{reduced\ Science} = \frac{\mathrm{raw\ Science} - D_S}{F - D_F}\,.
175-
\end{equation}
176-
177-
In case the dark level is negligible and the Bias level is constant, then Equation~\ref{eq:reduction_full} changes to
178-
\begin{equation}
179-
\mathrm{reduced\ Science} = \frac{\mathrm{raw\ Science} - B}{F - B}\,.
180-
\end{equation}
181-
182-
183-
In the pipeline always the individual frames are corrected before frames are combined.
184151
% -------------------------------------------------------------------------------------------
185152

186153

@@ -235,6 +202,7 @@ \subsection{Necessary CCD images}
235202
\item Arc (5x, calibration lamp through the calibration fiber, alternating a short (e.g. 5\,s) and a long (e.g. 120\,s) exposure time). The filename should start with \textbf{arc}, \textbf{ThAr}, or \textbf{UNe} and the science fiber should be dark for this data.
236203
% \item FlatArc (11x, white light source and calibration lamp), the filename should be \textbf{flatarc}, \textbf{sflatThAr}, \textbf{whli-UNe}, or similar.
237204
\item Bias (11x) and/or Darks (11x, for the exposure time of the true Flat and Flat)% and FlatArc)
205+
\item Filenames science images: the optimimum is to use ``\_'' for object name (as in reference file \verb|object_file|, see Chapter~\ref{Section:create_object_list_file}). Use ``-'' to seperate exposure time, number of series and other information.
238206
\end{itemize}
239207

240208
\subsection{Steps to run the code on a new set of data}
@@ -274,7 +242,7 @@ \subsection{Possible parameters for the CCD processing}
274242
\item[localbackground] : Applies background correction by fitting a 2d polynomalial against the current reduced image, excluding the area of the science and calibration traces. The fitted 2d-image is then subtracted from the (reduced) image.
275243
\end{description}
276244

277-
\noindent The following parameters change the way, several CCD images are combined:
245+
\noindent The following parameters change the way, several CCD images are combined. In the pipeline always the individual frames are corrected before frames are combined.
278246
\begin{description}
279247
\item[normalise] : Before combining the files the images are normalised by their median flux.
280248
\item[combine\_sum] : Normally files are combined using a pixel by pixel median. With this keyword the files will summed up. This parameter will be overwritten by \verb|combine_mean| (This might collide with \verb|max_good_value|.)
@@ -334,7 +302,7 @@ \subsection{Assigning the observed data and calibration data to the pipeline}
334302
\item Type of light for the calibration fiber
335303
\item Exposure time in seconds
336304
\item Observation time
337-
\item Flag 'e', if the spectrum should be extracted. This can be modified in order to allow different processing of the images before extraction. The following options are possible:
305+
\item Flag 'w', if the Arc spectrum should be extracted (important for single fiber spectrographs). Flag 'e', if the spectrum should be extracted. This can be modified in order to allow different processing of the images before extraction. The following options are possible:
338306
\begin{description}
339307
\item[e alone:] The processing as given in parameter \verb|extract_calibs_create_g| will be assigned.
340308
\item[e \textless obj \textgreater :] The processing as given in parameter \\ \verb|extract<obj>_calibs_create_g| will be assigned. If this parameter doesn't exist, then parameter \verb|extract_calibs_create_g| will be used.
@@ -343,19 +311,52 @@ \subsection{Assigning the observed data and calibration data to the pipeline}
343311
\end{description}
344312
\end{itemize}
345313

314+
\subsection{Necessary information to calculate the barycentric correction}
315+
In order to calculate the barycentric correction the time of the observation (or Julian Date), the pointing on the sky, and the position of the observatory on earth need to be known. These information can be given in different ways.
316+
317+
\begin{itemize}
318+
\item The mid-exposure date and time is derived from the image header using the keys given in the parameter \verb|raw_data_dateobs_keyword| and \verb|raw_data_exptim_keyword| (half of the exposure time). The pipeline can handle different standard formats (YYYY-MM-DDThh:mm:ss). If necessary, further formats can be added in the procedure \textit{get\_obsdate}.
319+
\item The position of the observatory will be extracted from the following sources (using the first available source in the following list:
320+
\begin{enumerate}\setlength\itemsep{0em}
321+
\item Reading latitude, longitude, and elevation from the header, using the the header keys defined in the beginning of procedure \textit{get\_barycent\_cor}: site\_keys, altitude\_keys, latitude\_keys, longitude\_keys (the first available entry of each list will be used, if necessary these lists can be extended).
322+
\item Using the site coordinates as given in the configuration file.
323+
\end{enumerate}
324+
\item The pointing of the telescope (RA and DEC) will be derived from the following sources (using the first available source in the following list:
325+
\begin{enumerate}\setlength\itemsep{0em}
326+
\item reading the object coordinates from a list of objects (see Chaper~\ref{Section:create_object_list_file}).
327+
\item Reading the object coordinates and epoch from the image header, using the header keys defined in the beginning of procedure \textit{get\_barycent\_cor}: ra\_keys, dec\_keys, epoch\_keys (the first available entry of each list will be used, if necessary these lists can be extended).
328+
\item If the object name contains sun or moon, then the coordinates of the sun/moon are calculated for the mid of the observing time.
329+
\end{enumerate}
330+
\end{itemize}
331+
332+
333+
\subsubsection{Creating a list of objects}
334+
\label{Section:create_object_list_file}
335+
If the coordinates of the object are not stored in the fits header, then they can be given using a the file specified in parameter \verb|object_file|. The file must contain one line per object. For each object the following tab-separated values need to be given:
336+
\begin{enumerate}\setlength\itemsep{0em}
337+
\item Object name (the filename should start with the object name in order to be used)
338+
\item RA (hh:mm:ss.ss)
339+
\item DEC ($\pm$dd:mm:ss.ss)
340+
\item PM RA (arcsec/year)
341+
\item PM DEC (arcsec/year)
342+
\item Epoch of the coordinates (only the number)
343+
\item Enable/Disable flag (1 for enabled)
344+
\end{enumerate}
345+
346+
346347
\subsection{Format of the extracted files}
347348
Different types of extracted files are created. They are described in the following subsections.
348349

349-
\subsubsection{raw-data filename}
350+
\subsubsection*{raw-data filename}
350351
\label{section:extraction_data_format}
351352
The final fits file contains the original header and some additional information, for example the calibration steps which were applied and some information about the flux collected in the different apertures. The data in the file is stored in a 3D array in the form: data type, aperture, and pixel. The data types are similar to the ones created by the CERES pipeline and are the following:
352353
\begin{enumerate}
353354
\setcounter{enumi}{-1}
354355
\item 2D array with the wavelength for each aperture and pixel.
355356
\item Extracted spectrum without any modification.
356-
\item (Measurement of the error the extracted spectrum)
357-
\item Flat corrected spectrum, calculated by dividing the extracted spectrum and the normalised flat spectrum.
358-
\item (Error the flat corrected spectrum)
357+
\item Measurement of the error the extracted spectrum (using the scatter of the residuals after fitting a 2d polynomalial to the background areas (noise in the dark/bias))
358+
\item Blaze corrected spectrum, calculated by dividing the extracted spectrum and the normalised flat spectrum.
359+
\item Error of the flat corrected spectrum (residuals of a polynomial fitted to the blaze corrected spectrum).
359360
\item Continuum normalised spectrum. The continuum is derived by fitting a polynomial to the flat corrected spectrum, using only areas of the spectrum where no lines are located.
360361
\item Signal to noise ratio in the continuum, calculated from the residuals between continuum fit and measured continuum and the flux in the continuum.
361362
\item Mask with good areas of the spectrum. The following values are used:
@@ -368,16 +369,25 @@ \subsubsection{raw-data filename}
368369
\item Spectrum of the calibration fiber, e.g. of the emission line lamp.
369370
\end{enumerate}
370371

371-
\subsubsection{raw-data filename + \_harps\_e2ds}
372+
\subsubsection*{raw-data filename + \_harps\_e2ds}
372373
This file contains the extracted spectrum without any modification in the same form as the \textit{e2ds} files created by the HARPS pipeline. The wavelength solution is stored in the header.
373374

374-
\subsubsection{raw-data filename + \_lin}
375+
\subsubsection*{raw-data filename + \_lin}
375376
\label{Section:linearised_spectrum}
376377
The extracted spectrum is linearised using a wavelength step as given in parameter \verb|wavelength_scale_resolution|. The wavelength spectrum is interpolated by using the weighted mean of the neighbouring data points with the wavelength difference as weights.
377378

378-
\subsubsection{raw-data filename + \_lin\_cont}
379+
\subsubsection*{raw-data filename + \_lin\_cont}
379380
This file contains data in the same form as described in Section~\ref{Section:linearised_spectrum}, only that the continuum corrected data was linearised.
380381

382+
\subsubsection*{inside single folder}
383+
\begin{itemize}
384+
\item[raw-data filename + \_spec] Continuum normalised spectrum.
385+
\item[raw-data filename + \_wave] 2D array with the wavelength for each aperture and pixel.
386+
\item[raw-data filename + \_weight] Mask with good areas of the spectrum.
387+
\end{itemize}
388+
389+
\subsubsection*{Object1/data/YYYY-MM-DDHHMMSS}
390+
381391
\subsection{Results from the pipeline}
382392
\label{section:results_pipeline}
383393

@@ -409,7 +419,7 @@ \subsection{Results from the pipeline}
409419
\includegraphics[width=\textwidth]{./figures/arcorders_in_master_arc}
410420
\end{center}
411421
\caption{Reduced CCD image of a ThAr exposure (log10 gray scale) with the marked traces of the identified calibration orders/apertures (red). The extraction width is given in dashed lines. The extraction width (determined from the Gaussian width of the order multiplied with the value in parameter \textbf{arcextraction\_width\_multiplier}) is given in dashed lines.
412-
\label{figure_arapertures_in_master_arc}}
422+
\label{figure_arcapertures_in_master_arc}}
413423
\end{figure}
414424

415425

@@ -788,6 +798,44 @@ \section{Module dependencies if not using Anaconda}
788798

789799
% Other versions may work but these are the ones tested.
790800

801+
802+
\newpage
803+
\appendix
804+
\section{Short introduction to reduction of CCD images}
805+
806+
The data stored in CCD images is affected by the physical parameters of the individual pixels and way the readout electronics work. Therefore each scientific frame needs to be corrected (pixel by pixel) with the formula:
807+
\begin{equation}
808+
\mathrm{reduced\ Science} = \frac{\mathrm{raw\ Science} - \mathrm{master\ Bias} - \mathrm{master\ Dark}}{\mathrm{master\ Flat}}\,.
809+
\end{equation}
810+
The master Dark should have the same exposure time as the Science frame and the master Flat should be normalised in order to keep the flux levels. To create the master Dark and master Flat, the following steps are necessary:
811+
\begin{equation}
812+
\mathrm{master\ Dark} = \mathrm{raw\ Dark} - \mathrm{master\ Bias}
813+
\end{equation}
814+
\begin{equation}
815+
\mathrm{master\ Flat} = \mathrm{raw\ Flat} - \mathrm{master\ Bias} - \mathrm{master\ Dark}\,.
816+
\end{equation}
817+
The master Dark used for the creation of the master Flat should have the same exposure time as the Flat and needs to be corrected with the Bias. The master Bias in each of the formulas can be different.
818+
819+
In order to decrease the noise levels, each of the master file should be created by median combining several (corrected) images together. If the brightness of the individual flats vary, then the flats should be weighted by their median flux before combining them. Combining all steps leads to the formula
820+
\begin{equation}
821+
\label{eq:reduction_full}
822+
\mathrm{reduced\ Science} = \frac{\mathrm{raw\ Science} - B_S - (D_S - B_{D_S})}{F - B_F - (D_F - B_{D_F})}\,,
823+
\end{equation}
824+
where $B_S$ is the master Bias, created by combining biases taken at a similar time as the science frame, $D_S$ is the master Dark, created of darks with the same exposure time as the science frame. In case the bias level and noise don't change during the night, then Equation~\ref{eq:reduction_full} changes to
825+
\begin{equation}
826+
\mathrm{reduced\ Science} = \frac{\mathrm{raw\ Science} - D_S}{F - D_F}\,.
827+
\end{equation}
828+
829+
In case the dark level is negligible and the Bias level is constant, then Equation~\ref{eq:reduction_full} changes to
830+
\begin{equation}
831+
\mathrm{reduced\ Science} = \frac{\mathrm{raw\ Science} - B}{F - B}\,.
832+
\end{equation}
833+
834+
835+
In the pipeline always the individual frames are corrected before frames are combined.
836+
837+
838+
791839
\end{document}
792840

793841

conf.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,25 @@ standard_calibs_create = []
188188
# when reading already processed images from the result path, this defines what calibrations should be done. If one file type should be handled different, then <filetype>_calibs_read can be used
189189
calibs_read = [subframe]
190190

191+
## Getting oject site and object coordinates to perform barycentric correction. If the values are stored in the header, then the header values are used
192+
-------------------------------------------------------------------------------
193+
# Define the observatory site:
194+
site = UH
195+
altitude = 30
196+
latitude = 51.7534
197+
longitude = -0.2401
198+
199+
site = TNT
200+
altitude = 2457
201+
latitude = 18.59055
202+
longitude = -98.48655
203+
204+
# Define the object coordinates using a file with a list of objects.
205+
# The file needs to contain the comma separated values: Object name, RA (hh:mm:ss.ss), DEC (+-dd:mm:ss.ss), PM RA ("/year), PM DEC ("year), Epoch of the coordinates (only the number), Enable/Disable flag (1 for enabled)
206+
object_file = object_list.txt
207+
208+
209+
191210

192211
## Result storage information:
193212
#-----------------------------

find_rv.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ def rv_analysis(params, spec, im_head, fitsfile, obname, bcvel_baryc, reffile, m
124124
for order in range(spec.shape[1]):
125125
L = np.where( (spec[1,order,:] != 0) & (~np.isnan(spec[1,order,:])) ) # good values
126126
#ratio = np.polyval(ccoefs[order],spec[0,order,:][L])*Rnorms[order]
127+
np.warnings.filterwarnings('ignore')
127128
ratio = spec[1,order,:][L]/ spec[5,order,:][L] # ratio between extracted spectrum and continuum normalised spectrum -> blaze function, cancels absorption lines
129+
np.warnings.resetwarnings()
128130
spec[7,order,:][L] = ratio
129131
#spec[8,order,:][L] = spec[6,order,:][L] # error continuum (first guess), but not good. #sn_order=8
130132
spec[8,order,:][L] = spec[2,order,:][L] # error of the extracted data, depending on what is used, the RV changes by few 100 km/s -> > several \AA
@@ -133,7 +135,9 @@ def rv_analysis(params, spec, im_head, fitsfile, obname, bcvel_baryc, reffile, m
133135
#dlambda_dx = scipy.interpolate.splev(np.arange(WavSol.shape[0]), spl, der=1)
134136
#NN = np.average(dlambda_dx)
135137
#dlambda_dx /= NN
138+
np.warnings.filterwarnings('ignore')
136139
LL = np.where(spec[5,order,:] > 1 + 10. / scipy.signal.medfilt(spec[8,order,:],21))[0] # remove emission lines and cosmics
140+
np.warnings.resetwarnings()
137141
spec[5,order,LL] = 1.
138142
spec[9,order,:][L] = spec[5,order,:][L]# * (dlambda_dx[L] ** 1) # used for the analysis in XCor (spec_order=9, iv_order=10)
139143
spec[10,order,:][L] = spec[2,order,:][L]# / (dlambda_dx[L] ** 2) # used for the analysis in XCor (spec_order=9, iv_order=10)
@@ -236,14 +240,14 @@ def rv_analysis(params, spec, im_head, fitsfile, obname, bcvel_baryc, reffile, m
236240
xc_av = GLOBALutils.Average_CCF(xc_full, sn, sn_min=3.0, Simple=True, W=W_ccf)
237241
pred = scipy.interpolate.splev(vels,tck1)
238242
xc_av /= pred
239-
print 'min(vels),max(vels),len(vels), min(xc_av),max(xc_av),len(xc_av), refvel, moon_sig', min(vels),max(vels),len(vels), min(xc_av),max(xc_av),len(xc_av), refvel, moon_sig
243+
#print 'min(vels),max(vels),len(vels), min(xc_av),max(xc_av),len(xc_av), refvel, moon_sig', min(vels),max(vels),len(vels), min(xc_av),max(xc_av),len(xc_av), refvel, moon_sig
240244
if max(np.abs(xc_av)) > 10:
241245
logger('Warn: stopped RV fit because of too big absolute value in xc_av: min(xc_av) = {0} , max(xc_av) = {1} , len(xc_av) = {2}'.format(min(xc_av),max(xc_av),len(xc_av)))
242246
return -999.0, 999.0, -999.0, 999.0, bcvel_baryc
243247
p1,XCmodel,p1gau,XCmodelgau,Ls2 = \
244248
GLOBALutils.XC_Final_Fit( vels, xc_av, sigma_res = 4,\
245249
horder=8, moonv=refvel, moons=moon_sig, moon=False)
246-
print 'plgau 345', p1gau
250+
#print 'plgau 345', p1gau
247251

248252
moonmatters = False
249253
if (know_moon and here_moon):

0 commit comments

Comments
 (0)