Skip to content


Folders and files

Last commit message
Last commit date

Latest commit


Repository files navigation

Source code for

Anomaly detection in the Zwicky Transient Facility DR3

ascl:2106.033 GithHub actions badge

This guide allows you to use the ZTF anomaly detection tool presented by Malanchev et al., 2020.

Package installation

Install current version by

pip install git+


Before working with the code, the package should be installed in the development mode:

git clone
cd zwad
pip install -e .

Data download

Light curve feature data for ZTF DR3 fields used in the research are available on Zenodo. You can download it from the website or by:

cd data


# Run one algorithm
zwadp -c iso --oid oid_m31.dat --feature feature_m31.dat > m31_iso.csv

# zwadp uses only one core by default. Number of parallel
# jobs may be increased with the -j option.
zwadp -c iso -j 4 --oid oid_m31.dat --feature feature_m31.dat > m31_iso.csv

# Run a few more algorithms
for ALGO in iso lof gmm svm; do
  zwadp -c ${ALGO} --oid oid_m31.dat --feature feature_m31.dat > m31_${ALGO}.csv

# Combine data-sets:
zwadp -c iso --oid oid_m31.dat --oid fakes/oid_m31_fake.dat --feature feature_m31.dat --feature fakes/feature_m31_fake.dat > m31_iso_fake.csv

# See the help
zwadp -h

Active anomaly detection

Lets use the same data from Zenodo.

cd data

It is better to create temporary directory to run active anomaly detection:

mkdir ../tmp
cd ../tmp
# Run AAD algorithm with M31 dataset
zwaad --random_seed 42 --budget 4 --oid ../data/oid_m31.dat --feature ../data/feature_m31.dat --feature-names ../data/ --anomalies my_anomalies.txt aad

The script output may be as the following:

Check for details
Is 695211400088968 anomaly? [y/N]: y

It is waiting for our decision now. Let us decide that 695211400088968 is an anomaly and continue:

Check for details
Is 695211400088968 anomaly? [y/N]: y
Check for details
Is 695211400053697 anomaly? [y/N]: n
Check for details
Is 695211100037499 anomaly? [y/N]: n
Check for details
Is 695211200008024 anomaly? [y/N]: y

Now we have examined all four samples within our budget.

# Check found anomalies
cat my_anomalies.txt

Related repositories


No releases published


No packages published