Skip to content

Commit

Permalink
Merge pull request #79 from desihub/update-api
Browse files Browse the repository at this point in the history
Update api.rst
  • Loading branch information
weaverba137 committed Nov 22, 2022
2 parents ca10e23 + 732003f commit bfa2e3f
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 42 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest]
python-version: [3.6, 3.7, 3.8]
python-version: ['3.8', '3.9']

steps:
- name: Checkout code
Expand All @@ -30,9 +30,9 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip wheel
python -m pip install --upgrade pip setuptools wheel
python -m pip install pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f requirements.txt ]; then python -m pip install -r requirements.txt; fi
- name: Run the test
run: pytest

Expand All @@ -43,7 +43,7 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest]
python-version: [3.8]
python-version: ['3.9']

steps:
- name: Checkout code
Expand All @@ -56,9 +56,9 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip wheel
python -m pip install --upgrade pip setuptools wheel
python -m pip install pytest pytest-cov coveralls
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f requirements.txt ]; then python -m pip install -r requirements.txt; fi
- name: Run the test with coverage
run: pytest --cov
- name: Coveralls
Expand All @@ -74,7 +74,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: [3.8]
python-version: ['3.9']

steps:
- name: Checkout code
Expand All @@ -86,7 +86,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
run: python -m pip install --upgrade pip wheel Sphinx
run: python -m pip install --upgrade pip setuptools wheel Sphinx
- name: Test the documentation
run: sphinx-build -W --keep-going -b html doc doc/_build/html

Expand All @@ -97,7 +97,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: [3.8]
python-version: ['3.9']

steps:
- name: Checkout code
Expand All @@ -109,7 +109,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
run: python -m pip install --upgrade pip wheel pycodestyle
run: python -m pip install --upgrade pip setuptools wheel pycodestyle
- name: Test the style; failures are allowed
# This is equivalent to an allowed falure.
continue-on-error: true
Expand Down
2 changes: 1 addition & 1 deletion doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXOPTS = -W --keep-going
# For macports, use the second line...
SPHINXBUILD = sphinx-build
# SPHINXBUILD = sphinx-build-2.7
Expand Down
11 changes: 7 additions & 4 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ prospect API
.. automodule:: prospect
:members:

.. automodule:: prospect.grid_thumbs
.. automodule:: prospect.coaddcam
:members:

.. automodule:: prospect.coaddcam
.. automodule:: prospect.grid_thumbs
:members:

.. automodule:: prospect.scripts
Expand All @@ -17,6 +17,9 @@ prospect API
.. automodule:: prospect.scripts.prospect_pages
:members:

.. automodule:: prospect.scripts.prospect_std_templates
:members:

.. automodule:: prospect.specutils
:members:

Expand All @@ -35,8 +38,8 @@ prospect API
.. automodule:: prospect.viewer.plots
:members:

.. automodule:: prospect.viewer.widgets
.. automodule:: prospect.viewer.vi_widgets
:members:

.. automodule:: prospect.viewer.vi_widgets
.. automodule:: prospect.viewer.widgets
:members:
4 changes: 3 additions & 1 deletion doc/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ prospect's Change Log
1.2.4 (unreleased)
------------------

* No changes yet.
* Update API documentation and test infrastructure (PR `#79`_).

.. _`#79`: https://github.com/desihub/prospect/pull/79

1.2.3 (2022-09-15)
------------------
Expand Down
63 changes: 38 additions & 25 deletions py/prospect/scripts/prospect_std_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"""

import os
import sys
import numpy as np
from astropy.table import Table
from astropy.io import fits
Expand All @@ -20,31 +21,43 @@
# Log of previous versions:
# std_templates_v0.fits : old Redrock templates only

std_template_file = os.path.join(os.environ['HOME'], 'prospect/py/prospect/data/std_templates.fits')
if os.path.isfile(std_template_file):
print('Error std template file already exists')

#- Templates produced from 1st component of old (pre-Aug 2022) Redrock templates:
template_dir = os.path.join(os.environ['DESICONDA'], '../code/redrock-templates/0.7.2')
#std_templates = {'QSO': ('QSO',''), 'GALAXY': ('GALAXY',''), 'STAR': ('STAR','F') }
std_templates = {'GALAXY': ('GALAXY',''), 'STAR': ('STAR','F') }
delta_lambd_templates = 3

rr_templts = load_redrock_templates(template_dir=template_dir)
for key,rr_key in std_templates.items() :
wave_array = np.arange(rr_templts[rr_key].wave[0], rr_templts[rr_key].wave[-1], delta_lambd_templates)
flux_array = resample_flux(wave_array, rr_templts[rr_key].wave, rr_templts[rr_key].flux[0,:])
table_templates = Table(data=[wave_array, flux_array], names=['wave_'+key, 'flux_'+key], meta={'name':key})
def main():
"""Entry-point for command-line scripts.
Returns
-------
:class:`int`
An integer suitable for passing to :func:`sys.exit`.
"""
std_template_file = os.path.join(os.environ['HOME'], 'prospect/py/prospect/data/std_templates.fits')
if os.path.isfile(std_template_file):
print('Error std template file already exists')

#- Templates produced from 1st component of old (pre-Aug 2022) Redrock templates:
template_dir = os.path.join(os.environ['DESICONDA'], '../code/redrock-templates/0.7.2')
#std_templates = {'QSO': ('QSO',''), 'GALAXY': ('GALAXY',''), 'STAR': ('STAR','F') }
std_templates = {'GALAXY': ('GALAXY',''), 'STAR': ('STAR','F') }
delta_lambd_templates = 3

rr_templts = load_redrock_templates(template_dir=template_dir)
for key,rr_key in std_templates.items() :
wave_array = np.arange(rr_templts[rr_key].wave[0], rr_templts[rr_key].wave[-1], delta_lambd_templates)
flux_array = resample_flux(wave_array, rr_templts[rr_key].wave, rr_templts[rr_key].flux[0,:])
table_templates = Table(data=[wave_array, flux_array], names=['wave_'+key, 'flux_'+key], meta={'name':key})
table_templates.write(std_template_file, append=True)

#- Case of QSO (Summer 2022): use new template provided by A. Brodzeller
qsotemplate_file = os.environ['HOME'] + '/stdtemplate-qso.fits'
hdul = fits.open(qsotemplate_file)
qsowave = 10**(hdul[0].header['CRVAL1']+np.arange(hdul[0].header['NAXIS1'])*hdul[0].header['CDELT1'])
qsoflux = hdul[0].data
# Resample as previously:
wave_array = np.arange(qsowave[0], qsowave[-1], delta_lambd_templates)
flux_array = resample_flux(wave_array, qsowave, qsoflux)
table_templates = Table(data=[wave_array, flux_array], names=['wave_QSO', 'flux_QSO'], meta={'name':'QSO'})
table_templates.write(std_template_file, append=True)
return 0

#- Case of QSO (Summer 2022): use new template provided by A. Brodzeller
qsotemplate_file = os.environ['HOME'] + '/stdtemplate-qso.fits'
hdul = fits.open(qsotemplate_file)
qsowave = 10**(hdul[0].header['CRVAL1']+np.arange(hdul[0].header['NAXIS1'])*hdul[0].header['CDELT1'])
qsoflux = hdul[0].data
# Resample as previously:
wave_array = np.arange(qsowave[0], qsowave[-1], delta_lambd_templates)
flux_array = resample_flux(wave_array, qsowave, qsoflux)
table_templates = Table(data=[wave_array, flux_array], names=['wave_QSO', 'flux_QSO'], meta={'name':'QSO'})
table_templates.write(std_template_file, append=True)

if __name__ == '__main__':
sys.exit(main())
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
specutils
bokeh
jinja2
git+https://github.com/desihub/desiutil.git@3.0.3#egg=desiutil
git+https://github.com/desihub/desiutil.git@3.2.5#egg=desiutil

0 comments on commit bfa2e3f

Please sign in to comment.