Skip to content

Commit

Permalink
Merge remote-tracking branch 'legolason/master' into host_prior
Browse files Browse the repository at this point in the history
  • Loading branch information
WenkeRen committed Jul 10, 2024
2 parents 43303a8 + 2dcb3f6 commit 1219ce1
Show file tree
Hide file tree
Showing 144 changed files with 5,390 additions and 380 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python package

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
if [ -f test-requirements.txt ]; then pip install -r requirements.txt -r test-requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
python -m pip install .
pytest tests/test_dr7sample.py
43 changes: 43 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["master"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# Upload entire repository
path: './docs/_build'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
37 changes: 17 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,33 @@
## PyQSOFit: A code to fit the spectrum of quasar

### Getting Started

__See the [example](https://nbviewer.org/github/legolason/PyQSOFit/blob/master/example/example.ipynb) demo notebook for a quick start tutorial__

We provide a brief guide of the Python QSO fitting code (PyQSOFit) to measure spectral properties of SDSS quasars. The code was originally translated from Yue Shen's IDL code to Python. The package includes the main routine, Fe II templates, an input line-fitting parameter list, host galaxy templates, and dust reddening map to extract spectral measurements from the raw fits. Monte Carlo estimation of the measurement uncertainties of the fitting results can be conducted with the same fitting code.
We provide a brief guide of the Python QSO fitting code (PyQSOFit) to measure spectral properties of SDSS quasars. The code was originally translated from Yue Shen's IDL code to Python. The package includes the main routine, Fe II templates, an input line-fitting parameter list, host galaxy templates, and dust reddening map to extract spectral measurements from the raw fits. Monte Carlo or MCMC estimation of the measurement uncertainties of the fitting results can be conducted with the same fitting code.

The code takes an input spectrum (observed-frame wavelength, flux density and error arrays) and the redshift as input parameters, performs the fitting in the restframe, and outputs the best-fit parameters and quality-checking plots to the paths specified by the user.

The code uses an input line-fitting parameter list to specify the fitting range and parameter constraints of the individual emission line components. An example of such a file is provided in the ``example.ipynb``. Within the code, the user can switch on/off components to fit to the pseudo-continuum. For example, for some objects the UV/optical Fe II emission cannot be well constrained and the user may want to exclude this component in the continuum fit. The code is highly flexible and can be modified to meet the specific needs of the user.

Use this code at your own risk, as we are not responsible for any errors. But if you report bugs, it will be greatly appreciated.

## Install
### Install

Bleeding edge:

``git clone https://github.com/legolason/PyQSOFit``<br>
``cd PyQSOFit``<br>
``python -m pip install .``<br>

Pip install (stable version):

v1.1 (stable): https://github.com/legolason/PyQSOFit/releases/tag/v1.1
``pip install pyqsofit`` (coming soon)

## Known problem
### Cite

1. During the line fitting procedure, some emission lines need less Gaussian models than provided to be well fitted. In these circumstances, the code will give two (or more) exactly the same Gaussian models to fit the data instead of one. This problem will not affect the physical measurements but only wierd in the QA image. One can use BIC to judge the proper number of Gaussian models for each line referencing to our `example.ipynb`.
2. Since the host decomposition hiring BC03 template is non-negative linear fitting, the host component will not stay at zero even if no hosts are detected or the decomposition is failed. We suggest user to determine the reliability of the host decomposition through QA image and the host fraction parameters f_host. (i.e., f_host>0.05 from (Shen et al. 2019)[https://doi.org/10.1088/0004-637X/805/2/96])
Preferred code citation: [Guo, H., Shen, Y., Wang, S. 2018, ascl:1809.008](https://ui.adsabs.harvard.edu/abs/2018ascl).

## Cite this code
Please also cite: [Shen, Y. et al. 2019, ApJS, 241, 34S](https://ui.adsabs.harvard.edu/abs/2019ApJS..241...34S/abstract)

> The preferred citation for this code is Guo, Shen & Wang (2018), ascl:1809:008\
> @misc{2018ascl.soft09008G,\
> author = {{Guo}, H. and {Shen}, Y. and {Wang}, S.},\
> title = "{PyQSOFit: Python code to fit the spectrum of quasars}",\
> keywords = {Software },\
> howpublished = {Astrophysics Source Code Library},\
> year = 2018,\
> month = sep,\
> archivePrefix = "ascl",\
> eprint = {1809.008},\
> adsurl = {[http://adsabs.harvard.edu/abs/2018ascl.soft09008G}](http://adsabs.harvard.edu/abs/2018ascl.soft09008G%7D),\
> adsnote = {Provided by the SAO/NASA Astrophysics Data System}\
> }
If using new host decompistion tools (`host_prior=True`), please cite: [Ren, W. et al. 2024](https://ui.adsabs.harvard.edu/abs/2024arXiv240617598R/abstract)
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
20 changes: 20 additions & 0 deletions docs/_build/_sources/index.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.. pyqsofit documentation master file, created by
sphinx-quickstart on Fri Jun 28 18:21:35 2024.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to pyqsofit's documentation!
====================================

.. toctree::
:maxdepth: 2
:caption: Contents:



Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
7 changes: 7 additions & 0 deletions docs/_build/_sources/modules.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pyqsofit
========

.. toctree::
:maxdepth: 4

pyqsofit
45 changes: 45 additions & 0 deletions docs/_build/_sources/pyqsofit.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
pyqsofit package
================

Submodules
----------

pyqsofit.HostDecomp module
--------------------------

.. automodule:: pyqsofit.HostDecomp
:members:
:undoc-members:
:show-inheritance:

pyqsofit.MESFit module
----------------------

.. automodule:: pyqsofit.MESFit
:members:
:undoc-members:
:show-inheritance:

pyqsofit.PyQSOFit module
------------------------

.. automodule:: pyqsofit.PyQSOFit
:members:
:undoc-members:
:show-inheritance:

pyqsofit.version module
-----------------------

.. automodule:: pyqsofit.version
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

.. automodule:: pyqsofit
:members:
:undoc-members:
:show-inheritance:
Loading

0 comments on commit 1219ce1

Please sign in to comment.