en:praktikum:sternspektren_baches

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:praktikum:sternspektren_baches [2023/07/21 13:52] – [Basics] rhainichen:praktikum:sternspektren_baches [2024/03/20 09:29] (current) – [Plotting the spectrum] rhainich
Line 42: Line 42:
       Flatdarks/       Flatdarks/
       ...       ...
 +
 +<color #ed1c24>**Note:**</color> **This folder structure is essential for some data reduction steps. It is therefore essential that the files are sorted accordingly!**
  
 There are different tools to view the FITS files (two dimensional CCD images or data tables). //ds9// is easy to handle and can be started from the terminal via: There are different tools to view the FITS files (two dimensional CCD images or data tables). //ds9// is easy to handle and can be started from the terminal via:
Line 58: Line 60:
 ===== Data reduction ===== ===== Data reduction =====
  
-The scripts for the evaluation can be found on the [[en:praktikum: zugang| lab course computer]] in the folder ''~/scripts/n1_baches''. Copy the script ''1_masterimages.py'' into the local directory where you want to analyze the star (e.g. ''Star_1''). This script will create among other files the masterdark and the masterflat needed in the following processing steps. Furthermore, this script stacks all star images, if more than one was taken during the observations. It also offers the possibility to bin the observed images, if this was not done during the observation. It also cuts not needed parts of the captured images. This simplifies the further analysis steps. Last but not least, you should specify in this script if the exposures have to be mirrored (see previous step), so that this can be corrected as well. The configuration area of the script looks like this:+=== Install the pipeline === 
 + 
 +Some modules from the OST photometry pipeline are required for the data reduction. Python modules should always be installed in a virtual environment to reduce dependency issues. A virtual environment can be created using 
 + 
 +   mkvirtualenv ost_photometry 
 + 
 +By doing so, we have named the virtual environment ''ost_photometry''. The fact that we are in the virtual environment is indicated by the string '(ost_photometry)', which now precedes each terminal line. To leave the virtual environment, simply type 
 + 
 +   deactivate 
 + 
 +If you want to reconnect, you can do so by typing 
 + 
 +   workon ost_photometry  
 + 
 +This is also necessary if you reconnect to a12, e.g. after a break, and want to continue the data analysis.  
 + 
 +The OST photometry pipeline can then be installed in the terminal using //pip// as follows 
 + 
 +   pip install ost_photometry 
 + 
 +All necessary dependencies are also installed in this way.  
 + 
 + 
 +=== Reduce the data === 
 + 
 +The scripts for the data reduction can be found on the [[en:praktikum: zugang| lab course computer]] in the folder ''~/scripts/n1_baches''. Copy the script ''1_masterimages.py'' into the local directory where you want to analyze the star (e.g. ''Star_1''). This script will create among other files the masterdark and the masterflat needed in the following processing steps. Furthermore, this script stacks all star images, if more than one was taken during the observations. It also offers the possibility to bin the observed images, if this was not done during the observation. It also cuts not needed parts of the captured images. This simplifies the further analysis steps. Last but not least, you should specify in this script if the exposures have to be mirrored (see previous step), so that this can be corrected as well. The configuration area of the script looks like this:
  
    ############################################################################    ############################################################################
Line 77: Line 104:
        
    #   Thorium Argon exposures:    #   Thorium Argon exposures:
-   path_thars = '?'+   path_thorium_argon = '?'
        
    #   Spectra:    #   Spectra:
Line 89: Line 116:
    #   Flip images? Possibilities: True and False    #   Flip images? Possibilities: True and False
    #    #
-   flip_bool = False+   flip_images = False
        
    ###    ###
    #   Bin the images? Possibilities: True and False    #   Bin the images? Possibilities: True and False
    #    #
-   bin_bool = False+   bin_images = False
        
    #   Binning factor    #   Binning factor
-   bin_val = 2+   binning_value = 2
        
    ###    ###
Line 103: Line 130:
    #   Possibilities: True and False; Default: True    #   Possibilities: True and False; Default: True
    #    #
-   trim_bool = True+   trim_image = True
  
-In ''path_darks'', ''path_flat_darks'', ''path_flats'', ''path_thars'' and ''path_spectra'' the corresponding subfolders are to be entered, which were created in section //Preparations//. ''out_path'' is the directory where the script places intermediate results. The reduced files (**master_dark.fit**, **master_flat.fit**, **master_thar.fit**, **master_spectrum.fit**) are stored in the local directory so that they are more easily available for the following analysis steps. +In ''path_darks'', ''path_flat_darks'', ''path_flats'', ''path_thorium_argon'' and ''path_spectra'' the corresponding subfolders are to be entered, which were created in section //Preparations//. ''out_path'' is the directory where the script places intermediate results. The reduced files (**master_dark.fit**, **master_flat.fit**, **master_thar.fit**, **master_spectrum.fit**) are stored in the local directory so that they are more easily available for the following analysis steps. 
  
-If you want to mirror the recordings you have to set ''flip_bool'' to ''True''. If the images should also be binned, set ''bin_bool'' to ''True''. The binning factor can be determined via the variable ''bin_val''.+If you want to mirror the recordings you have to set ''flip_images'' to ''True''. If the images should also be binned, set ''bin_images'' to ''True''. The binning factor can be determined via the variable ''binning_value''.
  
 +**Important:** When the data reduction is finished, disable the virtual environment with
 +
 +   deactivate
  
 ===== Data analysis ===== ===== Data analysis =====
Line 166: Line 196:
    PARAMETERS FOR THIS CALIBRATION:    PARAMETERS FOR THIS CALIBRATION:
    ===============================    ===============================
-   Flat field  = flat_20s.fit +   Flat field  = master_flat.fit 
-   Calibration lamp = ThAr_5s.fit+   Calibration lamp = master_thar.fit
    Calibration table = thar.fit    Calibration table = thar.fit
    Num. of orders  = 0026    Num. of orders  = 0026
Line 201: Line 231:
 In this case, the script should be stopped by entering a ''2''. Afterwards the script can be restarted with a reduced number of orders, e.g.: In this case, the script should be stopped by entering a ''2''. Afterwards the script can be restarted with a reduced number of orders, e.g.:
  
-   calibrate/baches flat.fit thar.fit 23 20 20+   calibrate/baches master_flat.fit master_thar.fit 23 20 20
  
-A solid method is to gradually reduce the number of orders until the script executed successfully. Afterwards, the flatfield with the identified orders will be displayed in an external window (see below). It should be checked whether the marks of the orders are horizontal and whether they coincide with the actual orders that are visible on the flatfield. The left figure shows a successful test run, whereas the middle figure depicts a failure. The right figure shows a flatfield image taken with the QHY268M, where it can happen that //MIDAS// does not finish drawing all identified orders. From the order numbers, however, it can at least be guessed that all orders were successfully identified. +A solid method is to gradually reduce the number of orders until the script executed successfully. Afterwards, the flatfield with the identified orders will be displayed in an external window (see below). It should be checked whether the marks of the orders are horizontal and whether they coincide with the actual orders that are visible on the flatfield. The left figure shows a successful test run, whereas the middle figure depicts a failure. The right figure shows a flatfield image taken with the QHY268M, where it can happen that //MIDAS// does not finish drawing all identified orders. From the order numbers, however, it can be assessed if all orders were successfully identified or not. The numbers also depend on whether the images are binned. As we usually use 2x2 binning, the above values should suffice. In case we have used 1x1 binning for the spectra however, you might have to double the second and third value.
  
 <WRAP group> <WRAP group>
Line 227: Line 257:
 **Troubleshooting:** You may get the error output **Troubleshooting:** You may get the error output
   (ERR) Problems in executing /usr/lib/eso-midas/1SSEP/stdred/exec/necdef.exe   (ERR) Problems in executing /usr/lib/eso-midas/1SSEP/stdred/exec/necdef.exe
-The source of this error could not be identified so far, try to use another file for the order identification (e.g. the flatfields), to avoid this. This error might be caused by the brightest order laying on the edge of the image, try to cut it or add additional pixel to avoid this error. Note that you have to cut/extend all other images accordingly.+The cause of this error has not yet been clearly identified. This error could be caused by the brightest order being at the edge of the image. Try cropping or adding additional pixels to the image. Note that you will also have to crop or expand all other images accordingly.
  
 === Wavelength calibration === === Wavelength calibration ===
Line 325: Line 355:
  
 ==== Pipeline ==== ==== Pipeline ====
-++++ Conversion from FITS to bdf |+++++ Conversion from FITS to bdf (optional) |
 In some cases, e.g. when changing folders, it may be necessary to convert some FITS files (e.g. the masterflat) into bdf files. For this we need //MIDAS// again, which can be opened via In some cases, e.g. when changing folders, it may be necessary to convert some FITS files (e.g. the masterflat) into bdf files. For this we need //MIDAS// again, which can be opened via
  
Line 339: Line 369:
 ++++ ++++
  
- +If //MIDAS// has been closed since the last step in this tutorial, it needs to be started again using 
- +
-To execute the pipeline you have to start //MIDAS// again using +
  
    inmidas    inmidas
  
-and the necessary scripts for the data reduction via+Subsequently, the scripts necessary for the data reduction have to be loaded
  
    set/cont baches    set/cont baches
  
-Subsequently, the pipeline can be started with+After that, the pipeline can be run with
  
    pipeline/baches master_spectrum.fit    pipeline/baches master_spectrum.fit
Line 378: Line 406:
    plot/axes xmin, xmax, ymin, ymax, x axis label, y axis label    plot/axes xmin, xmax, ymin, ymax, x axis label, y axis label
  
- 4000 - 8000 Angstrom is the usual wavelength range covered by the spectrograph. A flatfield corrected spectrum usually does not have count rates above 10. However, you may have trouble seeing the spectrum in the plot if darkframe and/or flatfield are not or wrongly used. In those cases you still can make the spectrum visible by adjusting the y-range. Set it to >10000 to account for the not corrected count rates. Also negative values are possible as a wrong result.+ 4000 - 8000 Angstrom is the usual wavelength range covered by the spectrograph. 
  
- The spectrum be be save in the postscript format with+/* 
 +A flatfield corrected spectrum usually does not have count rates above 10. However, you may have trouble seeing the spectrum in the plot if darkframe and/or flatfield are not or wrongly used. In those cases you still can make the spectrum visible by adjusting the y-range. Set it to >10000 to account for the not corrected count rates. Also negative values are possible as a wrong result. 
 +*/ 
 + 
 +The spectrum be be save in the postscript format with
  
    copy/graph postscript    copy/graph postscript
Line 416: Line 448:
 For this purpose, suitable spectral lines must be selected whose rest wavelengths are known. For this purpose, suitable spectral lines must be selected whose rest wavelengths are known.
  
-Hint: If difficulties arise during the line selection, it can be helpful to look at a hydrogen line for a first estimation. However, since these lines are often very broad, the radial velocity determined in this way will usually not be very accurate. Another pair of lines suitable in many cases would also be seen by pointing the spectrograph at street lamps, although these types of lamps are becoming increasingly rare. Alternatively, you can jump to the [[en:praktikum:sternspektren_baches#Plotting the spectrum | Plotting the spectrum]] section and look at the spectrum divided into smaller sections. This way you may already get a better impression of the potential spectral type and potentially suitable spectral lines.+**Please note:** If difficulties arise during the line selection, it can be helpful to look at a hydrogen lines for a first estimation. However, since these lines are often very broad, the radial velocity determined in this way will usually not be very accurate. Another pair of lines suitable in many cases would also be seen by pointing the spectrograph at street lamps, although these types of lamps are becoming increasingly rare. Alternatively, you can jump to the [[en:praktikum:sternspektren_baches#Plotting the spectrum | Plotting the spectrum]] section and look at the spectrum divided into smaller sections. This way you may already get a better impression of the potential spectral type and potentially suitable spectral lines.
  
 The central wavelength must now be determined for the selected lines. To achieve this, the line can be fitted with a Gaussian function:  The central wavelength must now be determined for the selected lines. To achieve this, the line can be fitted with a Gaussian function: 
    center/gauss gcursor,2 ? absorption    center/gauss gcursor,2 ? absorption
-To do the fit of the function click left and right of the absorption line with the left mouse button, to quit press the right mouse button. In the terminal you will find the fit parameters like "CENTER" (central wavelength of the line core) or "FWHM" (Full Width at Half Maximum), which gives you the width of the Gaussian function. Re-do the measurement several times to be sure to set good limits for the Gaussian fit and to get a feeling of the error in the measurement. This should be done for at least five single absorption lines. Do you see a difference in the accuracy of the measurent of the central wavelength of different lines? Discuss the reason in the report. With the help of the Doppler formula you can then calculate the relative velocity of the star from the shift of the central wavelength of the absorption lines in respective to their rest wavelength. The rest wavelength can be determined via the [[https://physics.nist.gov/PhysRefData/ASD/lines_form.html | NIST database ]]. Of course, we also have a [[en:praktikum:nist|tutorial]] for this. +To do the fit of the function click left and right of the absorption line with the left mouse button, to quit press the right mouse button. In the terminal you will find the fit parameters like "CENTER" (central wavelength of the line core) or "FWHM" (Full Width at Half Maximum), which gives you the width of the Gaussian function. Re-do the measurement several times to be sure to set good limits for the Gaussian fit and to get a feeling of the error in the measurement. This should be done for at least five single absorption lines. Do you see a difference in the accuracy of the measurent of the central wavelength of different lines? Discuss the reason in the report. With the help of the Doppler formula you can then calculate the relative velocity of the star from the shift of the central wavelength of the absorption lines in respective to their rest wavelength. The rest wavelength can be determined via the [[https://physics.nist.gov/PhysRefData/ASD/lines_form.html | NIST database]]. Of course, we also have a [[en:praktikum:nist|tutorial]] for this. 
  
 === Barycentric correction === === Barycentric correction ===
Line 454: Line 486:
  
 {{section>deng:praktikum:a12:python#English&noheader}} {{section>deng:praktikum:a12:python#English&noheader}}
 +
 +**Important:** Make sure that the virtual environment we used for data reduction is disabled before proceeding:
 +
 +   deactivate
  
 The spectrum should be plotted by means of the python script ''3_printmasterplot.py'', which can be found in the following directory ''~/scripts/n1_baches/''. This script can extract both the total spectrum created by //MIDAS// and the individual spectra of the various orders from the FITS files and then display them.  The spectrum should be plotted by means of the python script ''3_printmasterplot.py'', which can be found in the following directory ''~/scripts/n1_baches/''. This script can extract both the total spectrum created by //MIDAS// and the individual spectra of the various orders from the FITS files and then display them. 
Line 461: Line 497:
 |< 100% - >| |< 100% - >|
 ^ Variable ^ Description  ^ ^ Variable ^ Description  ^
-| ''File_orders'' | Name of the FITS file created with //MIDAS// which contains the individual orders (usually master_spectrum_wr.fit). | +| ''file_with_orders'' | Name of the FITS file created with //MIDAS// which contains the individual orders (usually master_spectrum_wr.fit). | 
-| ''File_merged'' | Name of the FITS file created with //MIDAS// which contains the merged spectrum (usually master_spectrum_wrm.fit). | +| ''file_with_merged_spectrum'' | Name of the FITS file created with //MIDAS// which contains the merged spectrum (usually master_spectrum_wrm.fit). | 
-| ''objectname'' | Name of the object |+| ''object_name'' | Name of the object |
 | ''radial_velocity'' | Measured radial velocity in km/s (without barycentric correction) | | ''radial_velocity'' | Measured radial velocity in km/s (without barycentric correction) |
 | ''ions'' | Ions to be considered for line identification | | ''ions'' | Ions to be considered for line identification |
 | ''manual_lines'' | By means of this variable further line identifications can be added manually. An identification string such as "HeI", the wavelength and the alignment parameter ("center", "left" or "right") must be set for each line. | | ''manual_lines'' | By means of this variable further line identifications can be added manually. An identification string such as "HeI", the wavelength and the alignment parameter ("center", "left" or "right") must be set for each line. |
-| ''line_lower_continuum'' | This variable determines how deep lines must be in comparison to the continuum so that line identifications are displayed for the corresponding lines. The higher this value, the fewer line identifications are displayed, since only the stronger lines then fulfill this criterion. **Note:** If the radial velocity is wrong and a value greater than zero is set here, then the line identification often does not work. Therefore this variable should be set to zero if the radial velocity is unknown. |+| ''percentage_line_flux_must_be_below_continuum'' | This variable determines how deep lines must be in comparison to the continuum so that line identifications are displayed for the corresponding lines. The higher this value, the fewer line identifications are displayed, since only the stronger lines then fulfill this criterion. **Note:** If the radial velocity is wrong and a value greater than zero is set here, then the line identification often does not work. Therefore this variable should be set to zero if the radial velocity is unknown. |
  
  
Line 475: Line 511:
        
    #   Name of file with individual orders    #   Name of file with individual orders
-   File_orders = "master_spectrum_wr.fit"+   file_with_orders = "master_spectrum_wr.fit"
        
    #   Name of file with merged spectrum    #   Name of file with merged spectrum
-   File_merged = "master_spectrum_wrm.fit"+   file_with_merged_spectrum = "master_spectrum_wrm.fit"
        
    #   Name of the object    #   Name of the object
-   objectname = "?"+   object_name = "?"
        
              
Line 504: Line 540:
        
    #   Percent the line flux must be lower than the continuum    #   Percent the line flux must be lower than the continuum
-   line_lower_continuum = 3.+   percentage_line_flux_must_be_below_continuum = 3.
  
 By default, the script creates two PDF files: ''spectrum_panels_MIDAS-merged_<objectname>.pdf'' and ''spectrum_total_MIDAS-merged_<objectname>.pdf''. The file with ''total'' in its name displays the spectrum in a single plot. Due to the large spectral range in this plot, details are often hard to see. Therefore, the second file (with ''panels'' in the name) shows the respective spectrum distributed over several "panels", which in turn makes the identification of individual lines much easier.  By default, the script creates two PDF files: ''spectrum_panels_MIDAS-merged_<objectname>.pdf'' and ''spectrum_total_MIDAS-merged_<objectname>.pdf''. The file with ''total'' in its name displays the spectrum in a single plot. Due to the large spectral range in this plot, details are often hard to see. Therefore, the second file (with ''panels'' in the name) shows the respective spectrum distributed over several "panels", which in turn makes the identification of individual lines much easier. 
Line 513: Line 549:
 === Identification of the spectral lines === === Identification of the spectral lines ===
  
-The **ions** that are to be identified via the line identifications **must be specified in the variable** ''ions''. **If this is not done, no line identifications will be displayed!** The script reads the line information from the file ''atomic_lines.tsv''. **But since this file contains only a selection of spectral lines**, which are found in the many different stars, **it is necessary to search for additional spectral lines** and their transitions, e.g., in the [[http://physics.nist.gov/PhysRefData/ASD/index.html|NIST data base]] as already mentioned, we also have a [[en:praktikum:nist|tutorial]] for this database. The extracted line information must then be entered into the variable ''manual_lines''+The **ions** that are to be identified via the line identifications **must be specified in the variable** ''ions''. **If this is not done, no line identifications will be displayed!** The script reads the line information from the file ''atomic_lines.tsv''. **But since this file contains only a selection of spectral lines**, which are found in the many different stars, **it is necessary to search for additional spectral lines** and their transitions, e.g., in the [[http://physics.nist.gov/PhysRefData/ASD/index.html|NIST data base]] as already mentioned, we also have a [[en:praktikum:nist|tutorial]] for this database. The extracted line information need to be entered into the variable ''manual_lines''
  
 === Determination of the spectral type === === Determination of the spectral type ===
  • en/praktikum/sternspektren_baches.1689947572.txt.gz
  • Last modified: 2023/07/21 13:52
  • by rhainich