Skip to main content

Forced PSF photometry on ZTF science images

Project description

ztforce logo

ztforce

Forced PSF photometry on ZTF science images — measures flux at a fixed sky position in every available epoch, even below the detection threshold, producing a calibrated AB-magnitude lightcurve.

Template

PyPI GitHub Workflow Status Codecov Read The Docs

Installation

pip install ztforce

Python 3.10–3.13 is supported.

Credentials

ztforce downloads ZTF science images from IRSA and requires an IRSA account (free at irsa.ipac.caltech.edu). Set your credentials in one of three ways:

Environment variables (recommended for scripts/CI):

export ZTFORCE_IRSA_USER=your_username
export ZTFORCE_IRSA_PASS=your_password

Config file at ~/.ztforce/config.toml:

[credentials]
irsa_user = "your_username"
irsa_pass = "your_password"

Direct argument:

from ztforce import build_config
config = build_config(irsa_user="your_username", irsa_pass="your_password")

Quick start

from ztforce import run_forced_photometry

# Measure flux at a fixed position across all ZTF g- and r-band epochs.
# A tqdm progress bar tracks downloads and PSF fitting; results are cached
# on disk so repeated calls return instantly.
lcs = run_forced_photometry(ra=210.08, dec=-6.88, bands=["g", "r"])

lcs["g"].df              # pandas DataFrame of all epochs
lcs["g"].stack()         # inverse-variance weighted stack of detections
lcs["g"].save("my_source_g.ecsv")   # save to ECSV

Batch processing

from astropy.coordinates import SkyCoord
from ztforce import run_forced_photometry_batch

targets = SkyCoord(ra=[210.08, 130.13], dec=[-6.88, 19.70], unit="deg")

# Processes targets in parallel; downloads are shared across all workers.
results = run_forced_photometry_batch(targets, bands=["g", "r"], n_workers=4)

results[0]["g"].stack()  # stacked photometry for first target, g-band

Related services

Several official ZTF services offer complementary photometry — ztforce fills a gap none of them cover:

Service What it does Why you'd use ztforce instead
ZTF Forced Photometry Service (ZFPS) (Masci et al. 2023) Forced PSF photometry on ZTF difference images at user positions Science-image photometry avoids subtraction artifacts; no account/queue required; runs locally
ZTF DR lightcurves (IRSA) Catalog lightcurves for sources detected in ZTF data releases Forced photometry works for transients and sub-threshold sources not in any catalog and at any arbitrary position
ZuberCal Ubercalibrated PSF photometry catalog for PS1-matched ZTF sources Only covers sources detected in PS1; ztforce works at any arbitrary position

ztforce is designed for cases where the source may not appear in any existing catalog — supernovae, kilonova, flares, or any transient — and you need calibrated flux measurements at a fixed sky position across every available epoch, including non-detections.

Dev Guide - Getting Started

Before installing any dependencies or writing code, it's a great idea to create a virtual environment. LINCC-Frameworks engineers primarily use conda to manage virtual environments. If you have conda installed locally, you can run the following to create and activate a new environment.

>> conda create -n <env_name> python=3.11
>> conda activate <env_name>

Once you have created a new environment, you can install this project for local development using the following commands:

>> ./.setup_dev.sh
>> conda install pandoc

Notes:

  1. ./.setup_dev.sh will initialize pre-commit for this local repository, so that a set of tests will be run prior to completing a local commit. For more information, see the Python Project Template documentation on pre-commit
  2. Install pandoc allows you to verify that automatic rendering of Jupyter notebooks into documentation for ReadTheDocs works as expected. For more information, see the Python Project Template documentation on Sphinx and Python Notebooks

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ztforce-0.1.1.tar.gz (86.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ztforce-0.1.1-py3-none-any.whl (23.3 kB view details)

Uploaded Python 3

File details

Details for the file ztforce-0.1.1.tar.gz.

File metadata

  • Download URL: ztforce-0.1.1.tar.gz
  • Upload date:
  • Size: 86.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ztforce-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7d336557615dabd14620dc423921a56f263d6a95791111b12acc72047934776f
MD5 26230ddbdf63f664477db3c4f102917d
BLAKE2b-256 18950ebd0a5cf21fd9a232c54b514e335f50171608c937d8917cdcfd6a4b33c9

See more details on using hashes here.

Provenance

The following attestation bundles were made for ztforce-0.1.1.tar.gz:

Publisher: publish-to-pypi.yml on Adam-Boesky/ztforce

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ztforce-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: ztforce-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 23.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ztforce-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 63c334bc80bcd6db1b8c95cd462f22db76756675ba586e7026af8d532cf1181a
MD5 9527934717763c403995036ff20def4f
BLAKE2b-256 e01cfb948b688a00844c1af332609d9bf19456addb766e6093f2554a630f845a

See more details on using hashes here.

Provenance

The following attestation bundles were made for ztforce-0.1.1-py3-none-any.whl:

Publisher: publish-to-pypi.yml on Adam-Boesky/ztforce

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page