Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cirrus_wheels_macos_arm64_task:
PATH: /opt/homebrew/opt/python@3.10/bin:$PATH
CIBW_ENVIRONMENT: >
MACOSX_DEPLOYMENT_TARGET=12.0
_PYTHON_HOST_PLATFORM="macosx-12.0-arm64"
_PYTHON_HOST_PLATFORM="macosx-12.0-arm64"
SPS_HOME="${CIRRUS_WORKING_DIR}/src/fsps/libfsps"
PKG_CONFIG_PATH: /opt/arm64-builds/lib/pkgconfig
CMAKE_PREFIX_PATH: /opt/arm64-builds/
Expand Down
31 changes: 0 additions & 31 deletions .github/workflows/build_docs.sh

This file was deleted.

39 changes: 27 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
name: Release
on:
release:
types: [published]
push:
branches: [main]
pull_request:
branches:
- main
tags:
- "*"
# pull_request:
workflow_dispatch:
inputs:
prerelease:
description: "Run a pre-release, testing the build"
required: false
type: boolean
default: false

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -17,7 +25,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os:
os:
- "ubuntu-latest"
- "macos-latest"
# - "windows-latest"
Expand Down Expand Up @@ -64,20 +72,27 @@ jobs:
with:
task: cirrus_wheels_macos_arm64
commit: ${{ github.event.pull_request.head.sha || github.sha }}
timeout-minutes: 15
timeout-minutes: 15
- run: ls dist

upload_pypi:
publish:
environment:
name: pypi
url: https://pypi.org/p/fsps
permissions:
id-token: write
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
steps:
- name: Get macOS arm64 wheels from Cirrus CI
uses: getsentry/action-wait-for-cirrus@v1.0.0
with:
task: cirrus_wheels_macos_arm64
commit: ${{ github.event.pull_request.head.sha || github.sha }}
timeout-minutes: 15
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@v1.8.7
with:
user: __token__
password: ${{ secrets.pypi_password }}
# To test: repository_url: https://test.pypi.org/legacy/
25 changes: 0 additions & 25 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,28 +70,3 @@ jobs:
run: python -m nox --non-interactive --no-error-on-missing-interpreters -s ${{ matrix.nox-session }}-${{ matrix.python-version }}
env:
SPS_HOME: ${{ github.workspace }}/src/fsps/libfsps

docs:
if: github.event_name != 'pull_request'
name: "docs"
runs-on: ubuntu-latest
steps:
- name: Clone the repo
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Install dependencies
run: |
python -m pip install -U pip sphinx
python -m pip install .
- name: Build documentation
run: .github/workflows/build_docs.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SPS_HOME: ${{ github.workspace }}/src/fsps/libfsps
STABLE: ${{ github.event_name == 'release' && github.event.action == 'published' }}
6 changes: 3 additions & 3 deletions .github/workflows/update-fsps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
with:
submodules: true
fetch-depth: 0

- name: Update the submodule
run: git submodule foreach git pull origin master

- name: Create a PR
uses: peter-evans/create-pull-request@v5
with:
Expand All @@ -25,5 +25,5 @@ jobs:
title: Updating FSPS
body: |
Automatically updating the FSPS submodule

**Maintainers should close and then re-open this PR to get the tests to run.**
17 changes: 17 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.4.0"
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
exclude_types: [json, binary]
- id: check-yaml
- repo: https://github.com/psf/black
rev: "23.1.0"
hooks:
- id: black-jupyter
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.0.277"
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ find_package(

# Find the f2py headers
execute_process(
COMMAND "${PYTHON_EXECUTABLE}"
COMMAND "${PYTHON_EXECUTABLE}"
"${CMAKE_CURRENT_SOURCE_DIR}/tools/f2py_include.py"
OUTPUT_VARIABLE F2PY_INCLUDE_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2013-2021 Python-FSPS developers.
Copyright 2013-2023 Python-FSPS developers.

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
22 changes: 10 additions & 12 deletions demos/dao69.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import (division, print_function, absolute_import,
unicode_literals)
import pyfits
import numpy as np
from __future__ import absolute_import, division, print_function, unicode_literals

import matplotlib.pyplot as pl
import numpy as np
import pyfits

import fsps

# Measurements of cluster parameters.
tage = 10. ** (8.04 - 9)
tage = 10.0 ** (8.04 - 9)
logmass = 4.09
dist_mod = 24.5

# Set up the stellar population model.
sp = fsps.StellarPopulation(imf_type=2, dust_type=1, mwr=3.1, dust2=0.3)

# The measured magnitudes from the literature.
data = {"wfc3_f160w": 16.386,
"wfc3_f275w": 17.398,
"wfc_acs_f814w": 17.155}
data = {"wfc3_f160w": 16.386, "wfc3_f275w": 17.398, "wfc_acs_f814w": 17.155}

# There are also a few filters that we have data for but aren't included in
# the standard FSPS install:
Expand All @@ -39,15 +38,14 @@

# Compute the model magnitudes.
for b, v in data.iteritems():
print(b, v, sp.get_mags(zmet=20, tage=tage, band=b) - 2.5 * logmass
+ dist_mod)
print(b, v, sp.get_mags(zmet=20, tage=tage, band=b) - 2.5 * logmass + dist_mod)

# Compute the model spectrum in ``L_sun / A``.
lam, spec = sp.get_spectrum(zmet=20, tage=tage, peraa=True)
spec *= 3.839e33 * 10. ** (logmass - dist_mod / 2.5)
spec *= 3.839e33 * 10.0 ** (logmass - dist_mod / 2.5)

f = 1.0 # obs_spec[0, obs_lambda < 5000.][-1] / spec[lam < 5000.][-1]
print(obs_spec[0, obs_lambda < 5000.][-1] / spec[lam < 5000.][-1])
print(obs_spec[0, obs_lambda < 5000.0][-1] / spec[lam < 5000.0][-1])

pl.loglog(obs_lambda, obs_spec[0], "k")
pl.loglog(lam, spec * f, "r")
Expand Down
71 changes: 35 additions & 36 deletions demos/feature_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"""

import os
import numpy as np

import matplotlib.pyplot as pl
from matplotlib.backends.backend_pdf import PdfPages

Expand All @@ -18,19 +18,19 @@ def makefig(sps, tage=13.7, oldspec=None, **plotkwargs):
w, spec = sps.get_spectrum(tage=tage)
fig, ax = pl.subplots()
if oldspec is not None:
ax.plot(w, oldspec / w * 1e19, color='gray', linewidth=2, alpha=0.5)
ax.plot(w, spec / w * 1e19, 'C2', linewidth=2)
ax.plot(w, oldspec / w * 1e19, color="gray", linewidth=2, alpha=0.5)
ax.plot(w, spec / w * 1e19, "C2", linewidth=2)
return fig, ax, spec


def prettify(fig, ax, label=None):
ax.set_xlim(0.9e3, 1e6)
ax.set_xscale('log')
ax.set_xscale("log")
ax.set_ylim(0.01, 2)
#ax.set_yscale('log')
ax.set_xlabel(r'rest-frame $\lambda$ ($\AA$)', fontsize=20)
ax.set_ylabel(r'$\lambda \, f_\lambda$', fontsize=20)
ax.tick_params(axis='both', which='major', labelsize=16)
# ax.set_yscale('log')
ax.set_xlabel(r"rest-frame $\lambda$ ($\AA$)", fontsize=20)
ax.set_ylabel(r"$\lambda \, f_\lambda$", fontsize=20)
ax.tick_params(axis="both", which="major", labelsize=16)
if label is not None:
ax.text(0.63, 0.85, label, transform=ax.transAxes, fontsize=16)

Expand All @@ -39,94 +39,93 @@ def prettify(fig, ax, label=None):


if __name__ == "__main__":

pl.rc('text', usetex=True)
pl.rc('font', family='serif')
pl.rc('axes', grid=False)
pl.rc('xtick', direction='in')
pl.rc('ytick', direction='in')
pl.rc('xtick', top=True)
pl.rc('ytick', right=True)
pl.rc("text", usetex=True)
pl.rc("font", family="serif")
pl.rc("axes", grid=False)
pl.rc("xtick", direction="in")
pl.rc("ytick", direction="in")
pl.rc("xtick", top=True)
pl.rc("ytick", right=True)

sps = fsps.StellarPopulation(zcontinuous=1)
ilib, slib, dlib = sps.libraries
print(ilib, slib)
os.makedirs("./figures", exist_ok=True)
pdf = PdfPages('./figures/features.pdf')
pdf = PdfPages("./figures/features.pdf")

# Basic spectrum
sps.params['sfh'] = 4
sps.params['tau'] = 5.0
sps.params['logzsol'] = 0.0
sps.params['dust_type'] = 4 # kriek and Conroy
sps.params['imf_type'] = 2 # kroupa
sps.params['imf3'] = 2.3
sps.params["sfh"] = 4
sps.params["tau"] = 5.0
sps.params["logzsol"] = 0.0
sps.params["dust_type"] = 4 # kriek and Conroy
sps.params["imf_type"] = 2 # kroupa
sps.params["imf3"] = 2.3
fig, ax, spec = makefig(sps)
fig, ax = prettify(fig, ax, label=r"$\tau=5$, Age$=13.7$,\\n$\log Z/Z_\odot=0.0$")
pdf.savefig(fig)
pl.close(fig)

# change IMF
sps.params['imf3'] = 2.5
sps.params["imf3"] = 2.5
fig, ax, spec = makefig(sps, oldspec=spec)
fig, ax = prettify(fig, ax, label=r"IMF slope")
pdf.savefig(fig)

# Attenuate
sps.params['add_dust_emission'] = False
sps.params['dust2'] = 0.2
sps.params["add_dust_emission"] = False
sps.params["dust2"] = 0.2
fig, ax, spec = makefig(sps, oldspec=spec)
fig, ax = prettify(fig, ax, label=r"Dust Attenuation")
pdf.savefig(fig)
pl.close(fig)

# Dust emission
sps.params['add_dust_emission'] = True
sps.params["add_dust_emission"] = True
fig, ax, spec = makefig(sps, oldspec=spec)
fig, ax = prettify(fig, ax, label=r"Dust Emission")
pdf.savefig(fig)
pl.close(fig)

# Dust temperature
sps.params['duste_umin'] = 10
sps.params["duste_umin"] = 10
fig, ax, spec = makefig(sps, oldspec=spec)
fig, ax = prettify(fig, ax, label=r"Dust SED\\n({})".format(dlib))
pdf.savefig(fig)
pl.close(fig)

# AGN emission
sps.params['fagn'] = 0.3
sps.params["fagn"] = 0.3
fig, ax, spec = makefig(sps, oldspec=spec)
fig, ax = prettify(fig, ax, label=r"AGN dust\\n(Nenkova)")
pdf.savefig(fig)
pl.close(fig)

# Nebular emission
sps.params['add_neb_emission'] = True
sps.params['gas_logu'] = -3.5
sps.params["add_neb_emission"] = True
sps.params["gas_logu"] = -3.5
fig, ax, spec = makefig(sps, oldspec=spec)
fig, ax = prettify(fig, ax, label=r"Neb. emission\\n(Byler)")
pdf.savefig(fig)
pl.close(fig)

# change logu
sps.params['gas_logu'] = -1.0
sps.params["gas_logu"] = -1.0
fig, ax, spec = makefig(sps, oldspec=spec)
fig, ax = prettify(fig, ax, label=r"Change U$_{neb}$")
pdf.savefig(fig)
pl.close(fig)

# change logz
sps.params['logzsol'] = -0.5
sps.params['gas_logz'] = -0.5
sps.params["logzsol"] = -0.5
sps.params["gas_logz"] = -0.5
fig, ax, spec = makefig(sps, oldspec=spec)
fig, ax = prettify(fig, ax, label=r"$\log Z/Z_\odot=-0.5$")
pdf.savefig(fig)
pl.close(fig)

# IGM absorption
sps.params['zred'] = 6.0
sps.params['add_igm_absorption'] = True
sps.params["zred"] = 6.0
sps.params["add_igm_absorption"] = True
fig, ax, spec = makefig(sps, oldspec=spec)
fig, ax = prettify(fig, ax, label=r"IGM attenuation\\n(Madau, $z=6$)")
pdf.savefig(fig)
Expand Down
Loading