#!/bin/bash

# Copyright (c) 2012-2014 by the GalSim developers team on GitHub
# https://github.com/GalSim-developers
#
# This file is part of GalSim: The modular galaxy image simulation toolkit.
# https://github.com/GalSim-developers/GalSim
#
# GalSim is free software: redistribution and use in source and binary forms,
# with or without modification, are permitted provided that the following
# conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
#    list of conditions, and the disclaimer given in the accompanying LICENSE
#    file.
# 2. Redistributions in binary form must reproduce the above copyright notice,
#    this list of conditions, and the disclaimer given in the documentation
#    and/or other materials provided with the distribution.
#

cd des

python=../../bin/installed_python  # For python scripts
bin=../../bin  # For galsim executable

if [ ! -d "output" ]; then
    mkdir output
fi
if [ ! -d "output_yaml" ]; then
    mkdir output_yaml
fi

/bin/rm -rf output/DECam*
/bin/rm -rf output_yaml/DECam*

time $python draw_psf.py || exit
time $bin/galsim -m des -v1 draw_psf.yaml || exit

echo 'Checking diffs:'

cd output
for f in $(ls DECam*.fits)
do
    echo diff -q $f ../output_yaml/$f
    diff -q $f ../output_yaml/$f
done
