#!/bin/bash

basedir=$1
patch_x=$2
patch_y=$3
patch="$patch_x,$patch_y"
#echo $basedir $patch

g=$basedir/HSC-G/0/$patch/calexp-HSC-G-0-$patch.fits
r=$basedir/HSC-R/0/$patch/calexp-HSC-R-0-$patch.fits
i=$basedir/HSC-I/0/$patch/calexp-HSC-I-0-$patch.fits
z=$basedir/HSC-Z/0/$patch/calexp-HSC-Z-0-$patch.fits
#echo $g

out="patch"$patch_x$patch_y"_grz.png"

ds9 -xpa no \
    -rgb \
    -rgb red $z \
    -scale limits '-0.05' 35 -scale log \
    -rgb green $r \
    -scale limits '-0.05' 25 -scale log \
    -rgb blue $g \
    -scale limits '-0.1' 25 -scale log \
    -export png $out \
    -quit


