Skip to content

Commit

Permalink
Merge pull request #389 from Allonck/updateDCR
Browse files Browse the repository at this point in the history
Update dcr
  • Loading branch information
simontorres authored Mar 15, 2024
2 parents b3a57ce + cf2f4b3 commit 1ede463
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 14 deletions.
48 changes: 48 additions & 0 deletions docs/_common_issues.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
.. _common_issues:

Common issues
*************

No comparison lamps were found
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The latest version may introduce changes to wavelength solutions. To
view the current list of available modes and lamps, please refer to the
`GitHub repository <https://github.com/soar-telescope/goodman_pipeline/tree/main/goodman_pipeline/data/ref_comp>`_.

If your lamp, filter, or mode is not included in the repository mentioned
above, ``redspec`` will not work as expected. This is particularly common
with custom modes of the |pipeline full name|. You may encounter the following
error after running ``redspec``:

.. code-block:: console
$ redspec
[15:02:49][W]: No comparison lamps were provided for file ecfzst_0001_science.fits
This error occurs because the |pipeline full name| relies on specific keywords to
extract spectra, such as:

.. _`table lamp key`:

.. table:: Keywords that are used to produce a wavelength solution.

========== =============================================================
Keyword Purpose
========== =============================================================
LAMP_HGA Indicates if HgAr lamp is used.
LAMP_NE Indicates if Ne lamp is used.
LAMP_AR Indicates if Ar lamp is used.
LAMP_FE Indicates if Fe lamp is used.
LAMP_CU Indicates if Cu lamp is used.
WAVMODE Slit and mode configuration.
========== =============================================================

Multiple spectra output
^^^^^^^^^^^^^^^^^^^^^^^^

When taking multiple ``ARC`` images during your observation run, they will be linked
with your science data. This means that if you capture several lamp files,
they will be processed alongside the science images, potentially resulting
in multiple outputs of the same spectrum.
4 changes: 4 additions & 0 deletions docs/_running_prepare_data_for_reduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ need to change the following keywords.
``SYZY_400`` becomes ``400_SYZY``.
- ``WAVMODE``: Replace whitespace with underscore and all letters are capitalized.
For instance. ``400 m1`` becomes ``400_M1``.
- ``INSTRUME``: Instead of using the classical keywords 'Goodman Spectro' and
'Goodman Imaging', the AEON standard keywords ``ghts_red`` and ``ghts_blue``
will be used for spectroscopy, and ``ghts_red_imager`` and ``ghts_blue_imager``
for imaging. This is an exception of the upper case rule.

.. note::

Expand Down
9 changes: 5 additions & 4 deletions docs/_running_redspec.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ behavior for every user or science case, we have implemented a set of
is *current working directory*.
- ``--proc-path <path>`` Folder were processed data will be stored. Default
is *current working directory*.
- ``--search-pattern <pattern>`` Prefix for picking up files. Default
``cfzst``. See :ref:`file-prefixes`.
- ``--output-prefix <prefix>`` Prefix to be added to calibrated spectrum.
- ``--search-pattern <pattern>`` Prefix for picking up files. Default is
``cfzst-``. See :ref:`file-prefixes`.
- ``--output-prefix <prefix>`` Prefix to be added to calibrated spectrum. Default is
``w-``. See :ref:`file-prefixes`.
- ``--extraction <method>`` Select the :ref:`extraction-methods`. The only one
implemented at the moment is ``fractional`` .
- ``--fit-targets-with {moffat, gaussian}`` Model to fit peaks on spatial profile
while searching for spectroscopic targets.
while searching for spectroscopic targets. Default ``moffat``.
- ``--target-min-width <target min width>`` Minimum profile width for fitting the spatial axis of spectroscopic targets.
If fitting a Moffat it will be reflected as the FWHM attribute of the fitted model and if fitting a Gaussian it will
be reflected as the STDDEV attribute of the Gaussian model.
Expand Down
3 changes: 2 additions & 1 deletion docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ Getting Help.

.. include:: _extraction_methods.rst


.. include:: _file_prefixes.rst

.. include:: _file_suffixes.rst

.. include:: _shortcuts.rst

.. include:: _common_issues.rst
19 changes: 11 additions & 8 deletions goodman_pipeline/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,8 @@ def call_cosmic_rejection(ccd,

_create(instrument=_instrument, binning=_binning, path=red_path)

#out_prefix = prefix + out_prefix #Move line here

full_path = os.path.join(red_path, f"{out_prefix}_{image_name}")

ccd.header.set('GSP_COSM',
Expand Down Expand Up @@ -919,24 +921,26 @@ def dcr_cosmicray_rejection(data_path, in_file, prefix,
# define the name for the cosmic rays file
cosmic_file = 'cosmic_' + '_'.join(in_file.split('_')[1:])

# get current working directory and goes to reduction folder
cwd = os.getcwd()
full_path_data = os.path.join(cwd, data_path)

# define full path for all the files involved
full_path_in = os.path.join(data_path, in_file)
full_path_out = os.path.join(data_path, out_file)
full_path_cosmic = os.path.join(data_path, cosmic_file)
full_path_in = os.path.join(full_path_data, in_file)
full_path_out = os.path.join(full_path_data, out_file)
full_path_cosmic = os.path.join(full_path_data, cosmic_file)

# this is the command for running dcr, all arguments are required
command = 'dcr {:s} {:s} {:s}'.format(full_path_in,
full_path_out,
full_path_cosmic)

log.debug('DCR command:')
log.debug(command)
# get the current working directory to go back to it later in case the
# the pipeline has not been called from the same data directory.
cwd = os.getcwd()

# move to the directory were the data is, dcr is expecting a file dcr.par
os.chdir(data_path)
os.chdir(full_path_data)

# call dcr
try:
Expand Down Expand Up @@ -969,7 +973,7 @@ def kill_process(process): # pragma: no cover
# wait for dcr to terminate
# dcr.wait()

# go back to the original directory. Could be the same.
#go back to the original directory. Could be the same.
os.chdir(cwd)

# If no error stderr is an empty string
Expand Down Expand Up @@ -1012,7 +1016,6 @@ def kill_process(process): # pragma: no cover
os.unlink(full_path_out)
return ccd


def define_trim_section(sample_image, technique):
"""Get the initial trim section
Expand Down
2 changes: 1 addition & 1 deletion goodman_pipeline/spectroscopy/redspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def get_args(arguments=None):
type=str,
metavar='<Search Pattern>',
dest='pattern',
help="Pattern for matching the goodman's reduced data.")
help="Pattern for matching the goodman's reduced data. Default is cfzst*.")

parser.add_argument('--output-prefix',
action='store',
Expand Down

0 comments on commit 1ede463

Please sign in to comment.