Skip to content

Commit

Permalink
Small changes in the GSAOI tutorial and added script to display the t…
Browse files Browse the repository at this point in the history
…utorial images
  • Loading branch information
b1quint committed May 15, 2019
1 parent 182c007 commit 43770b9
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 9 deletions.
11 changes: 5 additions & 6 deletions geminidr/doc/tutorials/GSAOIImg-DRTutorial/01_introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ machine. You can test that by typing the following commands:
Where ``geminiconda`` is the name of the conda environment where DRAGONS should
be installed. If you have an error message, make sure:

- Conda is properly installed;
- AnaConda or MiniConda is properly installed;

- A Conda Virtual Environment is properly created and is active;

Expand All @@ -51,9 +51,8 @@ be installed. If you have an error message, make sure:
Download Sample Files
=====================

For this tutorial we selected a very sparse field. This makes the sky
subtraction less prone to errors. The selected data set was observed for the
GS-2017A-Q-29 program on the night starting on May 04, 2017.
For this tutorial we selected data observed for for the GS-2017A-Q-29 program on
the night starting on May 04, 2017.

You can search and download the files on the
`Gemini Archive <https://archive.gemini.edu/searchform>`_ using the
Expand All @@ -78,14 +77,14 @@ can be downloaded using `this link
<https://archive.gemini.edu/download/exposure_time=150/notengineering/GSAOI/Pass/DARK/present/canonical>`_.
or copying and pasting the following address to search form into your browser: ::

.. https://archive.gemini.edu/searchform/exposure_time=150/cols=CTOWEQ/notengineering/GSAOI/Pass/DARK
https://archive.gemini.edu/searchform/exposure_time=150/cols=CTOWEQ/notengineering/GSAOI/Pass/DARK


The FLAT files to build the BPM can be downloaded directly by `clicking here
<https://archive.gemini.edu/download/20171201-20171231/object=Domeflat/filter=H/notengineering/GSAOI/Pass/present/canonical>`_
or using the following address: ::

.. https://archive.gemini.edu/searchform/object=Domeflat/cols=CTOWEQ/filter=H/notengineering/GSAOI/20171201-20171231/Pass
https://archive.gemini.edu/searchform/object=Domeflat/cols=CTOWEQ/filter=H/notengineering/GSAOI/20171201-20171231/Pass


Copy all the files to the same place in your computer. Then use ``tar`` and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ For this tutorial, we will be also using other `Supplemental tools
<https://dragons-recipe-system-users-manual.readthedocs.io/en/latest/supptools.html>`_,
like dataselect_, showd_, typewalk_, and caldb_.

.. warning:: Some primitives use a lot of RAM memory and they can make `reduce`
.. warning:: Some primitives use a lot of RAM memory and they can make reduce_
crash. Our team is aware of this problem and we are working on that. For
now, if that happens to you, you might need to run the pipeline on a
smaller data set.
Expand Down Expand Up @@ -83,8 +83,8 @@ reduction pipeline does not organize the data.

That means that we first need to identify these files and create lists that will
be used in the data-reduction process. For that, we will use the dataselect_
command line. Please, refer to the `dataselect page <dataselect>`_ for details
regarding its usage. Let us start with the DARK files: ::
command line. Please, refer to the dataselect_ page for details regarding its
usage. Let us start with the DARK files: ::

$ dataselect --tags DARK raw/*.fits > list_of_darks.txt

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#!/usr/bin/env python
"""
Displays a Flat Corrected and Sky Subtracted GSAOI data reduced with DRAGONS
to be used in the GSAOIIMG-Tutorial.
"""

import astrodata
import gemini_instruments
import numpy as np

from astropy import visualization
from copy import copy
from matplotlib import pyplot as plt
from matplotlib import colors


def main():

# filename = 'S20170505S0102_flatCorrected.fits'
filename = get_filename()

ad = astrodata.open(filename)
print(ad.info())

fig = plt.figure(num=filename, figsize=(8, 8))
fig.suptitle('{}'.format(filename))

palette = copy(plt.cm.viridis)
palette.set_bad('w', 1.0)

norm = visualization.ImageNormalize(
np.dstack([ad[i].data for i in range(4)]),
stretch=visualization.LinearStretch(),
interval=visualization.ZScaleInterval()
)

ax1 = fig.add_subplot(224)
ax1.imshow(
np.ma.masked_where(ad[0].mask > 0, ad[0].data),
norm=colors.Normalize(vmin=norm.vmin, vmax=norm.vmax),
origin='lower',
cmap=palette
)

ax1.annotate('d1', (20, 20), color='white')
ax1.set_xlabel('x [pixels]')
ax1.set_ylabel('y [pixels]')

ax2 = fig.add_subplot(223)
ax2.imshow(
np.ma.masked_where(ad[1].mask > 0, ad[1].data),
norm=colors.Normalize(vmin=norm.vmin, vmax=norm.vmax),
origin='lower',
cmap=palette
)

ax2.annotate('d2', (20, 20), color='white')
ax2.set_xlabel('x [pixels]')
ax2.set_ylabel('y [pixels]')

ax3 = fig.add_subplot(221)
ax3.imshow(
np.ma.masked_where(ad[2].mask > 0, ad[2].data),
norm=colors.Normalize(vmin=norm.vmin, vmax=norm.vmax),
origin='lower',
cmap=palette
)

ax3.annotate('d3', (20, 20), color='white')
ax3.set_xlabel('x [pixels]')
ax3.set_ylabel('y [pixels]')

ax4 = fig.add_subplot(222)
ax4.imshow(
np.ma.masked_where(ad[3].mask > 0, ad[3].data),
norm=colors.Normalize(vmin=norm.vmin, vmax=norm.vmax),
origin='lower',
cmap=palette
)

ax4.annotate('d4', (20, 20), color='white')
ax4.set_xlabel('x [pixels]')
ax4.set_ylabel('y [pixels]')

fig.tight_layout(rect=[0, 0.03, 1, 0.95])

plt.savefig(filename.replace('.fits', '.png'))
plt.show()


def get_filename():

import argparse

parser = argparse.ArgumentParser()

parser.add_argument('filename', type=str,
help='Path to the fits file')

args = parser.parse_args()

return args.filename


if __name__ == main():
main()

0 comments on commit 43770b9

Please sign in to comment.