Skip to content

Commit

Permalink
Merge pull request #36 from simontorres/change_field_separator
Browse files Browse the repository at this point in the history
Change field separator closes #31 #34 #35
  • Loading branch information
Simon Torres committed Jan 26, 2021
2 parents c452359 + 968351b commit ef7cf8c
Show file tree
Hide file tree
Showing 14 changed files with 159 additions and 98 deletions.
2 changes: 1 addition & 1 deletion .readthedocs.yml
Expand Up @@ -6,7 +6,7 @@ sphinx:
formats: all

python:
version: 3.5
version: 3.7
install:
- method: pip
path: .
Expand Down
26 changes: 0 additions & 26 deletions .travis.yml

This file was deleted.

10 changes: 10 additions & 0 deletions CHANGES.rst
@@ -1,3 +1,13 @@
.. _v1.0.0:

1.0.0
=====

- Removed Travis CI [#31]
- Replaced separator to double underscore [#34, #35]
- Updated documentation.


.. _v0.3.6:

0.3.6
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -3,7 +3,7 @@

# Goodman Focus Finder

[![Build Status](https://travis-ci.org/soar-telescope/goodman_focus.svg?branch=master)](https://travis-ci.org/soar-telescope/goodman_focus)
![Goodman Focus](https://github.com/soar-telescope/goodman_focus/workflows/Goodman%20Focus/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/soar-telescope/goodman_focus/badge.svg?branch=master)](https://coveralls.io/github/soar-telescope/goodman_focus?branch=master)
[![Documentation Status](https://readthedocs.org/projects/goodman-focus/badge/?version=latest)](https://goodman-focus.readthedocs.io/en/latest/?badge=latest)
[![pypi](https://img.shields.io/pypi/v/goodman_focus.svg?style=flat)](https://pypi.org/project/goodman-focus/)
Expand Down
3 changes: 1 addition & 2 deletions docs/conf.py
Expand Up @@ -44,7 +44,6 @@
'sphinx.ext.autodoc',
'sphinx.ext.intersphinx',
'sphinxcontrib.napoleon',
'm2r',
'matplotlib.sphinxext.plot_directive',
]

Expand All @@ -54,7 +53,7 @@
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
source_suffix = ['.rst', '.md']
source_suffix = ['.rst']
# source_suffix = '.rst'

# The master toctree document.
Expand Down
6 changes: 2 additions & 4 deletions docs/index.rst
Expand Up @@ -6,8 +6,8 @@
Welcome to Goodman Focus' documentation!
========================================

.. image:: https://travis-ci.org/soar-telescope/goodman_focus.svg?branch=master
:target: https://travis-ci.org/soar-telescope/goodman_focus
.. image:: https://github.com/soar-telescope/goodman_focus/workflows/Goodman%20Focus/badge.svg
:alt: Goodman Focus
.. image:: https://coveralls.io/repos/github/soar-telescope/goodman_focus/badge.svg?branch=master
:target: https://coveralls.io/github/soar-telescope/goodman_focus?branch=master
.. image:: https://readthedocs.org/projects/goodman-focus/badge/?version=latest
Expand All @@ -25,8 +25,6 @@ different focus values. It works for imaging and for spectroscopy.

This tool requires python `3.6` at least to work. It will not install with `3.5`.

We recommend using `astroconda <https://astroconda.readthedocs.io/en/latest/>`_ since it is easier.


.. toctree::
:maxdepth: 2
Expand Down
33 changes: 19 additions & 14 deletions docs/usingit.rst
Expand Up @@ -90,7 +90,7 @@ Interpreting Results

The terminal version will print a message like this

``[17:16:06][INFO]: Best Focus for mode SP_Red_400m2_GG455 is -1032.6413206603302``
``[17:16:06][INFO]: Best Focus for mode SP__Red__400m2__GG455 is -1032.6413206603302``


Using it as a library will return a dictionary with the following values.
Expand All @@ -100,16 +100,16 @@ explained in :ref:`decoding-mode-name`

.. code-block:: python
{'IM_Red_g-SDSS': -571.4837418709354,
'IM_Red_i-SDSS': -802.567783891946,
'IM_Red_r-SDSS': -573.8694347173587,
'IM_Red_z-SDSS': -1161.5072536268135,
'SP_Red_400m1_NOFILTER': -492.0760380190095,
'SP_Red_400m2_GG455': -1032.6413206603302}
{'IM__Red__g-SDSS': -571.4837418709354,
'IM__Red__i-SDSS': -802.567783891946,
'IM__Red__r-SDSS': -573.8694347173587,
'IM__Red__z-SDSS': -1161.5072536268135,
'SP__Red__400m1__NOFILTER': -492.0760380190095,
'SP__Red__400m2__GG455': -1032.6413206603302}
It is also possible to obtain a plot, from terminal, use ``--plot-results``.
Below is a repreduction of results obtained with test data.
Below is a reproduction of results obtained with test data.

.. plot::

Expand All @@ -118,7 +118,7 @@ Below is a repreduction of results obtained with test data.
import matplotlib.pyplot as plt

best_focus = -571.483741871
mode_name = 'IM_Red_g-SDSS'
mode_name = 'IM__Red__g-SDSS'

data = {'file': ['0186_focus_gp.fits',
'0187_focus_gp.fits',
Expand Down Expand Up @@ -187,21 +187,26 @@ The mode name is different for Imaging and Spectroscopy, since for imaging
the important settings are the instrument and the filter and for spectroscopy
the important values come from the instrument, the grating and observing mode and
filter from second filter wheel. Below, the word inside the parenthesis represents
a kewyword from the header.
a keyword from the header.

.. warning::
Be aware that the separator string is a ``double underscore``. This change
was necessary to avoid confusion with single underscores used in certain
keyword values.

For imaging:

``IM_(INSTCONF)_(FILTER)``
``IM__(INSTCONF)__(FILTER)``

for example:

``IM_Red_g-SDSS``
``IM__Red__g-SDSS``

For spectroscopy:

``SP_(INSTCONF)_(WAVMODE)_(FILTER2)``
``SP__(INSTCONF)__(WAVMODE)__(FILTER2)``


for example:

``SP_Red_400m2_GG455``
``SP__Red__400m2__GG455``
2 changes: 1 addition & 1 deletion environment.yml
Expand Up @@ -10,6 +10,6 @@ dependencies:
- pip:
- ccdproc
- coveralls
- m2r
- sphinx_rtd_theme
- sphinx
- sphinxcontrib.napoleon
55 changes: 10 additions & 45 deletions goodman_focus/goodman_focus.py
Expand Up @@ -168,11 +168,10 @@ def get_fwhm(peaks, values, x_axis, profile, model, sigma=3, maxiter=3):
peaks (numpy.ndarray): An array of peaks present in the profile.
values (numpy.ndarray): An array of values at peak location.
x_axis (numpy.ndarray): X-axis for the profile, usually is equivalent to
`range(len(profile))`.
profile (numpy.ndarray): 1-dimensional profile of the image being
analyzed.
`range(len(profile))`.
profile (numpy.ndarray): 1-dimensional profile of the image being analyzed.
model (Model): A model to fit to each peak location. `Gaussian1D` and
`Moffat1D` are supported.
`Moffat1D` are supported.
sigma (int): Number sigmas to use on sigma-clipping
maxiter (int): Maximum number of sigma-clipping iterations
Expand Down Expand Up @@ -496,14 +495,14 @@ def _get_mode_name(group):
subset=['INSTCONF', 'FILTER', 'FILTER2', 'WAVMODE'], keep='first')

if unique_values['WAVMODE'].values == ['IMAGING']:
mode_name = 'IM_{}_{}'.format(
unique_values['INSTCONF'].values[0],
unique_values['FILTER'].values[0])
mode_name = '__'.join(['IM',
str(unique_values['INSTCONF'].values[0]),
str(unique_values['FILTER'].values[0])])
else:
mode_name = 'SP_{}_{}_{}'.format(
unique_values['INSTCONF'].values[0],
unique_values['WAVMODE'].values[0],
unique_values['FILTER2'].values[0])
mode_name = '__'.join(['SP',
str(unique_values['INSTCONF'].values[0]),
str(unique_values['WAVMODE'].values[0]),
str(unique_values['FILTER2'].values[0])])
mode_name = re.sub('[<> ]', '', mode_name)
# mode_name = re.sub('[- ]', '_', mode_name)
return mode_name
Expand Down Expand Up @@ -592,39 +591,5 @@ def run_goodman_focus(args=None): # pragma: no cover
log.info("Mode: {} Best Focus: {}".format(key, result[key]))


# def run_goodman_focus_list(args=None): # pragma: no cover
# """Entrypoint
#
# Args:
# args (list): (optional) a list of arguments and respective values.
#
# """
# args = get_args(arguments=args)
# goodman_focus = GoodmanFocus(data_path=args.data_path,
# file_pattern=args.file_pattern,
# obstype=args.obstype,
# features_model=args.features_model,
# plot_results=args.plot_results,
# debug=args.debug)
#
# file_list = ['0016_foc_400m2.fits',
# '0018_foc_400m2.fits',
# '0020_foc_400m2.fits',
# '0022_foc_400m2.fits',
# '0024_foc_400m2.fits',
# '0026_foc_400m2.fits',
# '0028_foc_400m2.fits',
# '0017_foc_400m2.fits',
# '0019_foc_400m2.fits',
# '0021_foc_400m2.fits',
# '0023_foc_400m2.fits',
# '0025_foc_400m2.fits',
# '0027_foc_400m2.fits']
#
# result = goodman_focus(files=file_list)
# print(result)


if __name__ == '__main__': # pragma: no cover
# full_path = '/user/simon/data/soar/work/focus2'
run_goodman_focus()
4 changes: 2 additions & 2 deletions goodman_focus/tests/test_goodman_focus.py
Expand Up @@ -221,15 +221,15 @@ def setUp(self):

def test_imaging_mode(self):
df = pandas.DataFrame(self.data)
expected_name = 'IM_Blue_FILTER-X'
expected_name = 'IM__Blue__FILTER-X'
mode_name = GoodmanFocus._get_mode_name(group=df)
self.assertEqual(mode_name, expected_name)

def test_spectroscopy_mode(self):
self.data['WAVMODE'] = ['400 z1'] * 5
df = pandas.DataFrame(self.data)

expected_name = 'SP_Blue_400z1_NOFILTER'
expected_name = 'SP__Blue__400z1__NOFILTER'

mode_name = GoodmanFocus._get_mode_name(group=df)

Expand Down
2 changes: 1 addition & 1 deletion goodman_focus/version.py
@@ -1,2 +1,2 @@
# This is an automatic generated file please do not edit
__version__ = '0.3.5'
__version__ = '0.3.7'
7 changes: 7 additions & 0 deletions pyproject.toml
@@ -0,0 +1,7 @@
[build-system]

requires = ["setuptools",
"setuptools_scm",
"wheel"]

build-backend = 'setuptools.build_meta'
2 changes: 1 addition & 1 deletion setup.cfg
Expand Up @@ -32,4 +32,4 @@ install_requires =
sphinx

# version should be PEP440 compatible (http://www.python.org/dev/peps/pep-0440)
version = 0.3.6
version = 1.0.0

0 comments on commit ef7cf8c

Please sign in to comment.