Astronomical source extraction and photometry library
Project description
SEP-PJW
Python and C library for Source Extraction and Photometry, forked from kbarbary/sep to provide additional features and bug fixes.
"... [it's] an SEP: Somebody Else's Problem." "Oh, good. I can relax then."
SEP-PJW vs. SEP
The original release of sep
by Kyle Barbary,
kbarbary/sep, no longer appears to be
maintained. Whilst the package is incredibly useful, there are a few
outstanding bugs, and support for the latest versions of Python
(python>=3.11
) will be limited. The aim of sep-pjw
is to offer a
version of sep
that resolves these issues, whilst maintaining
compatibility as much as is feasibly possible. Any fixes or updates to
the original library are documented in CHANGES.md. For
existing workflows, the only necessary update will be to change the import
to
import sep_pjw as sep
About
Source Extractor (Bertin & Arnouts 1996) is a widely used command-line program for segmentation and analysis of astronomical images. It reads in FITS format files, performs a configurable series of tasks, including background estimation, source detection, deblending and a wide array of source measurements, and finally outputs a FITS format catalog file.
While Source Extractor is highly useful, the fact that it can only be used as an executable can limit its applicability or lead to awkward workflows. There is often a desire to have programmatic access to perform one or more of the above tasks on in-memory images as part of a larger custom analysis.
SEP makes the core algorithms of Source Extractor available as a library of stand-alone functions and classes. These operate directly on in-memory arrays (no FITS files or configuration files). The code is derived from the Source Extractor code base (written in C) and aims to produce results compatible with Source Extractor whenever possible. SEP consists of a C library with no dependencies outside the standard library, and a Python module that wraps the C library in a Pythonic API. The Python wrapper operates on NumPy arrays with NumPy as its only dependency. See below for language-specfic build and usage instructions.
Python
Documentation: http://sep-pjw.readthedocs.io
Requirements:
- Python 3.9+
- numpy 1.23+
Install release version:
SEP-PJW can be installed with pip:
python -m pip install sep-pjw
If you get an error about permissions, you are probably using your system Python. In this case, we recommend using pip's "user install" option to install sep-pjw into your user directory:
python -m pip install --user sep-pjw
Do not install sep or other third-party Python packages using
sudo
unless you are fully aware of the risks.
Install development version:
Building the development version (from github) requires Cython. Build and install in the usual place:
python -m pip install --editable .
Run tests: Tests require the pytest Python
package. To run the tests, execute ./test.py
in the top-level
directory. Some tests require a FITS reader (either fitsio or astropy)
and will be skipped if neither is present.
C Library
Note: The build process only works on Linux and OS X.
CMake: To build using CMake, enter these commands:
cd sep
mkdir -p build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr ../
and follow next steps from the build folder
Build: To build the C library from source:
make
Run tests:
make test
Install The static library and header can be installed with
make install
make PREFIX=/path/to/prefix install
This will install the shared and static library in /path/to/prefix/lib
and header file in /path/to/prefix/include
. The default prefix is
/usr/local
.
API: The C library API is documented in the header file sep.h.
Rust bindings: Low-level Rust wrapper for the C library can be found at https://crates.io/crates/sep-sys
Contributing
- Report a bug or documentation issue: http://github.com/PJ-Watson/sep-pjw/issues
- Ask (or answer) a question: https://github.com/PJ-Watson/sep-pjw/discussions/categories/q-a
Development of SEP-PJW takes place on GitHub at PJ-Watson/sep-pjw. Contributions of bug fixes, documentation improvements and minor feature additions are welcome via GitHub pull requests. For major features, it is best to discuss the change first via GitHub Discussions.
Citation
If you use SEP in a publication, please cite the following article in the Journal of Open Source Software:
Please also cite the original Source Extractor paper (Bertin & Arnouts 1996).
The DOI for the sep v1.0.0 code release is:
License
The license for all parts of the code derived from Source Extractor is
LGPLv3. The license for code derived from photutils (src/overlap.h
)
is BSD 3-clause. Finally, the license for the Python wrapper
(sep.pyx
) is MIT. The license for the library as a whole is
therefore LGPLv3. The license for each file is explicitly stated at
the top of the file and the full text of each license can be found in
licenses
.
FAQ
Why isn't the C library part of Source Extractor?
Source Extractor is not designed as a library with an executable built on top of the library. In Source Extractor, background estimation, object detection and photometry are deeply integrated into the Source Extractor executable. Many changes to the code were necessary in order to put the functionality in stand-alone C functions. It's too much to ask of the Source Extractor developer to rewrite large parts of the core of the Source Extractor program with little gain for the executable.
What sort of changes?
-
Source Extractor reads in only a small portion of each image at a time. This allows it to keep its memory footprint extremely low and to operate on images that are much larger than the system's physical memory. It also means that a FITS reader is deeply integrated into the code. SEP operates on images in memory, so all the FITS I/O machinery in Source Extractor is not used here.
-
Error handling: When it encounters a problem, Source Extractor immediately exits with an error message. This is fine for an executable, but a library function doesn't have that luxury. Instead it must ensure that allocated memory is freed and return an error code.
-
Options: Source Extractor has many options that affect its behavior. These are stored in a global structure used throughout the executable. In SEP, options for a particular function are passed as function parameters.
-
Array types: Source Extractor can operate on FITS images containing various types of data (float, double, int, etc). Internally, it does this by converting all data to
float
immediately when reading from disk. SEP does something similar, but in memory: SEP functions typically convert input arrays to float on the fly within each function, then perform all operations as floating point.
Is SEP as fast as Source Extractor?
It's fast. It should be similar to Source Extractor as a lot of the code is identical. Source Extractor has the advantage of doing all the operations (detection and analysis) simultaneously on each image section, which may confer CPU cache advantages, but this hasn't been tested at all. On the other hand, depending on your usage SEP might let you avoid writing files to disk, which is likely to be a bigger win.
What happens when Source Extractor is updated in the future?
SEP can be considered a fork of the Source Extractor code base: it's development will not track that of Source Extractor in any automated way. However, the algorithms implemented so far in SEP are stable in Source Extractor: the SEP code was forked from v2.18.11, yet it is tested against the results of v2.8.6. This indicates that the algorithms have not changed in Source Extractor over the last few years.
In the Python interface, why do I have to byte swap data when using astropy.io.fits?
This occurs because FITS files have big-endian byte order, whereas most widely used CPUs have little-endian byte order. In order for the CPU to operate on the data, it must be byte swapped at some point. Some FITS readers such as fitsio do the byte swap immediately when reading the data from disk to memory, returning numpy arrays in native (little-endian) byte order. However, astropy.io.fits does not (for reasons having to do with memory mapping). Most of the time you never notice this because when you do any numpy operations on such arrays, numpy uses an intermediate buffer to byte swap the array behind the scenes and returns the result as a native byte order array. Internally, SEP is not using numpy operations; it's just getting a pointer to the data in the array and passing it to C code. As the C code does not include functionality to do buffered byte swapping, the input array must already be in native byte order.
It would be possible to add buffered byte swapping capability to the
SEP code, but it would increase the code complexity. A simpler
alternative would be to make a byte swapped copy of the entire input
array, whenever necessary. However, this would significantly increase
memory use, and would have to be done repeatedly in multiple SEP
functions: Background
, extract
, sum_circle
, etc. Each would make
a copy of the entire data array. Given these considerations, it seemed
best to just explicitly tell the user to do the byte swap operation
themselves so they could just do it once, immediately after reading in
the data.
I have more questions!
Open a discussion on the GitHub Discussions page!
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
Built Distributions
Hashes for sep_pjw-1.3.6-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0bfa02982e062f71e547ee91c0349b3f939ba1f926bad8c0b9d37897396fe14 |
|
MD5 | b86e1335af648d6c5cdaa9daeba7db3d |
|
BLAKE2b-256 | 938599bc66f4b6c88bfd9f8b382a6c958628bcea25ed3b676c24e8a7ac15b30a |
Hashes for sep_pjw-1.3.6-cp312-cp312-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53fec74e6093fe164a1e481e17a0b08b4371cfd9dff94a72cebb3ad22767ad77 |
|
MD5 | 97af622c1833d102a8fb944fbf995407 |
|
BLAKE2b-256 | ed96c1c5ab802816fef578157d4882830c5477a3544cf0c51665a931744957f5 |
Hashes for sep_pjw-1.3.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d95f933654c0a805d1bd31556016be4fff75dfcfe79e1d0c1dc3a7837dbea46 |
|
MD5 | a362ce1b8e800993b258353061bf80b8 |
|
BLAKE2b-256 | a8f8b91574b8a63065b5fa73b47a7333c3da5f4cb1f6bfe22a617b347343dbf2 |
Hashes for sep_pjw-1.3.6-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b84ba1de8594179a65d426faf6ae56e7d59fc6c587653f40d115248a4508ba9d |
|
MD5 | 81e443737ff0b44fa5646622425fdc95 |
|
BLAKE2b-256 | a77d23638e0494dcc7769e8c60c66cf6377f761f99f5db62cd91603cf0f36a4f |
Hashes for sep_pjw-1.3.6-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 80257cbbe1fd37c75260b71ee8ebdc55be8744b4393af1a70788b4e43195ca18 |
|
MD5 | 2cf54179af4564d396c6b5509a920260 |
|
BLAKE2b-256 | edde9af2dc10ffe469b7a598f7bf7b289f0bc1666099a70fe178ad16081850bb |
Hashes for sep_pjw-1.3.6-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ce0fd6be45628772620b014784077dbbd3cf3cc775e25b2313404f0c63da084 |
|
MD5 | e1ec44c0d9632c75f08f1c8f418a793d |
|
BLAKE2b-256 | 483b61dd5d8f95c8d48249e68ca118fc10178168e2d2c7b8048e06ec8079edaa |
Hashes for sep_pjw-1.3.6-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 086fefb005e5b25a96e600d103629a08d5685b47a29eca69c0386ad2a808f20e |
|
MD5 | 6818bb3da4ef1132c92832bc3aa4f0c0 |
|
BLAKE2b-256 | 787ec4a62c215741c5ac6f8feb4177a10cadd0713ef87165286d5a0d25301e75 |
Hashes for sep_pjw-1.3.6-cp312-cp312-macosx_10_13_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f11a197e11105d5ce76c6cd08b3c3fe7051f6436d40ee2f6f4e49a9e62d8806 |
|
MD5 | 813b255b75dc345826e0a1d945b9bb4e |
|
BLAKE2b-256 | 85a0fa420528761df3e4a0ad2f618a3412d02d45e33c0bb8ca7845e35324833e |
Hashes for sep_pjw-1.3.6-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | adf293539943c67abf5dd38309736082d45381b20c75324cfb1b8070fb0ecc03 |
|
MD5 | b3e4c5982571f16e50bca9e137065990 |
|
BLAKE2b-256 | fc5804ea236dcee923fbd362cac88e28d005bece4ea78e4cb26effdb68151468 |
Hashes for sep_pjw-1.3.6-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cdf6f48adbdec8c92b3efb25d21ccba132c1cae90435643b9bd6b82324c05347 |
|
MD5 | a61b507db2cf4490f850daeb7b6e1763 |
|
BLAKE2b-256 | d99f0784a7664034a60ab3bae5fccea80167606c5aa1f92a765f92bf8912aaec |
Hashes for sep_pjw-1.3.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a4e7a0e5c824883ae2503243a4a08c17ca2acf2b1aacda644bdbe0ea1173715 |
|
MD5 | ab672b8bfd017b0df047f05d1d3e8ed1 |
|
BLAKE2b-256 | ae555f83ae6823461de0ee780924a39bdf413cc096f6a2575c86691cdb7a7ebd |
Hashes for sep_pjw-1.3.6-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d84adcf73c172e0ec71777b2f2192fa4010675a7eb1d39b43d0c0a89e6023df9 |
|
MD5 | 556341f5ad7e16b59c7aa57d1963b4ec |
|
BLAKE2b-256 | df95adb13df1bb6dbc64783e86601bb4d5522f4a5d51f86ccfda62345ac038fa |
Hashes for sep_pjw-1.3.6-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b67f2b960cb98779491c820f35c6838400dd5d73472a154d9012df3f41f77298 |
|
MD5 | 997e652295438bde8f1b20e362ba0191 |
|
BLAKE2b-256 | bf18fff587bfd47089b6abe0deae7dfc7b6b046a8b2cadcba83eed1f1c923cee |
Hashes for sep_pjw-1.3.6-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2326ac617a3fe322474fa2a311eb562ab277f77c47a0876857bb8c65aa6a1a2b |
|
MD5 | 102301d7683d04449ab9daff3fd3162d |
|
BLAKE2b-256 | d697cd8839d159547656ab72cfd2f689a43895eca44bd75fb8eb7f907078511e |
Hashes for sep_pjw-1.3.6-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 458e4af5683631ca04824694d7e3a5e4bfe1118519a891d151f0bfeae4764d9e |
|
MD5 | 04b02b13035fbff3ac7447b425169819 |
|
BLAKE2b-256 | 6b7ef8b7f138706409c8b74982141cf698c2933ffe851378cc872e529a533d69 |
Hashes for sep_pjw-1.3.6-cp311-cp311-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10733544e90e445dba4ffe223152bdac71c3b2bca649ea26a643b2f11e5ab065 |
|
MD5 | 83826a06f96eb4add1d7068fc7c3c528 |
|
BLAKE2b-256 | ad2d7868250fc8a0f7c05ecbd4b664ed017ae97c8707a225ba4f00cf887dd437 |
Hashes for sep_pjw-1.3.6-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68fb5651eda1ca145df31eb77c0854f1b4b0277f925ce6459dccb0989fd3199e |
|
MD5 | 8041cacd70df1007d0720dbe1e6bf727 |
|
BLAKE2b-256 | c6136a0df07dd0c55cb9dd59a0c9d5b871a4552e68827296ed0f161ba86a3d3f |
Hashes for sep_pjw-1.3.6-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a99c20900eebc94ab59d9648617edbceb9ad430a52b5d9ce0c96349b822d2192 |
|
MD5 | e3fe05169471f852034a9d8f6dcaf18d |
|
BLAKE2b-256 | f7b511e9b8115c3bb62290d461467da853209bc18d1e3d3bb4e21fced1a064c6 |
Hashes for sep_pjw-1.3.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f004f622fb71552495ee960643659347b0268e1af63149ea9bc073d60de56798 |
|
MD5 | b4f8e2122e72647fe80d0d44cda21db4 |
|
BLAKE2b-256 | 9621a010ddad742859647ecc617ddc623378cd7b4a01aa8a33350b38e60a75a0 |
Hashes for sep_pjw-1.3.6-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31cc0fdc8f0ce3e7ea4bc3e2bb1db7052322037b7e74c09e4832dd74dc230a6f |
|
MD5 | c4655bac13ee4564a355dbd57c59b857 |
|
BLAKE2b-256 | 16f025938ff545616a457f8ff2b65bec0a7533584eb7a14fa4097407c4dcf650 |
Hashes for sep_pjw-1.3.6-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2cb593c7668e12981d474bb2572905bb4f7ae016bfc06bfe8d258722d5ed5c5 |
|
MD5 | bb1519078f51c0555fa2103f384f49ec |
|
BLAKE2b-256 | 28bb303718bb617e2007a235ff3d3c9bc5872d954f4f8f498ffcc403862065b1 |
Hashes for sep_pjw-1.3.6-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0af124482946abc5ed01199a6b7bb41140d94113afdf8ca99a612652b44726b |
|
MD5 | 3947c113b198125d11bdbc93eebb4d27 |
|
BLAKE2b-256 | f72a83d40795e195101c49b37778427988a7b75437e916c1260448ce51df17e2 |
Hashes for sep_pjw-1.3.6-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | baabb7dc2763b3b3678a20c91ebb512ba9b1197909c3af4deb469520e1996c49 |
|
MD5 | 216801896c6705edc45f03bd6873d450 |
|
BLAKE2b-256 | fba6d3db4935a0f9be52bff68183b20b12ef07743675d6dd55a285e5cd2ad1a8 |
Hashes for sep_pjw-1.3.6-cp310-cp310-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a7ded33ebeac244810120dc64a6df8c1386408fc8213e659ab53fc56d13585b |
|
MD5 | 6dc7afe97ae330746d727f2166703f15 |
|
BLAKE2b-256 | a91e56943698b3f49b19e900f3b7ded5ef5ef32aa5f1b9282d54f90bde230d37 |
Hashes for sep_pjw-1.3.6-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e7156417466ecfcdc7773a4f9a5679e64bb758967b0b1cd65cc0133746581e0 |
|
MD5 | 416d73648e641c9cd29a2e122426ca13 |
|
BLAKE2b-256 | f2036855eba23618888d657af940cd772d9e44c98df1674b0d6e3c217bb66396 |
Hashes for sep_pjw-1.3.6-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e343085e60651c624b248313cb66ab7fac41f2c570c5616d8c52c0eb80c4ee4f |
|
MD5 | a6e88a28e1b9b89d20f4a6efd6ea2dde |
|
BLAKE2b-256 | 6f119c1956217246e51416d377ecc4d5de9f636fa4b432e8f86e455da225b85f |
Hashes for sep_pjw-1.3.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13ee14c05790f3b80945c4ea5dd645ac22cd64e67bcb5bccbe95c7d4b92e46a0 |
|
MD5 | 2520b900f3fa51bbc9f5c4a9d2a90c54 |
|
BLAKE2b-256 | 10695b9102e176e8b70cbd7ab9aaf37f7c03ef4fb616b6447dd04bbf836ff694 |
Hashes for sep_pjw-1.3.6-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f85611af811ff0df58455bdc10a0897201c0a00e79bacb69d21d03117146908 |
|
MD5 | aed021b63b62fc0944eaa0b0cd34639f |
|
BLAKE2b-256 | 77a15dd88fa89c82f77aa6917a4f6502d0d5945a504856b37b4c38865a029e23 |
Hashes for sep_pjw-1.3.6-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec57770f787dc984247217ece9d947c7a81ea3fb7f7ea56ceb06be465f9da353 |
|
MD5 | 3e3507662fc7488efa0f93fa8897b1a3 |
|
BLAKE2b-256 | 1891b5a058ad975c4cfe3fae305620a793871582af99bf34593ad03068e91f0b |
Hashes for sep_pjw-1.3.6-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9040c92e74fd38f2ba97c8a77173432dec706c53581197afb0a9bc2ce4c59d4c |
|
MD5 | 20ef1b91b81003e2989488e993a7751c |
|
BLAKE2b-256 | 6c265447d4e0a36417ae8853d5548f1c8f63cbfc8519c3f0c9c31e986a01b8ba |
Hashes for sep_pjw-1.3.6-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 134639e65a9b0f6d92076c9742fc2cd786f59baa74ddb3ac673f2aa3af979423 |
|
MD5 | 48fa8d181f35cb61c363410d2f740aba |
|
BLAKE2b-256 | 14d8646141ed9e13e63c2f85a484ae1d482bc5f9bb5c87957903dbf110b57f2c |
Hashes for sep_pjw-1.3.6-cp39-cp39-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2064079eb810b99fb335712ed1f6e764984a7c0ce6414dc33a158359923588df |
|
MD5 | 63eed88675f4405ee2a7eb8c69b3ee67 |
|
BLAKE2b-256 | 8729c4a1a53da76510ed66b183aeac9929f75d16c16ecb46853cafe53710f317 |