#! /bin/csh -f
#
if ( $#argv == 6) then
  set inpcoo1 = $argv[1]
  set inpcoo2 = $argv[2]
  set regsiz = $argv[3]
  set outnam = $argv[4]
  set sl = $argv[5]
  set su = $argv[6]
else
  echo -n "Enter J2000 RA in format HHhMMmSSs or decimal degrees:"
  set inpcoo1 = $<
  echo -n "Enter J2000 Dec in format DDdMMmSSs or decimal degrees:"
  set inpcoo2 = $<
  echo -n "Enter region size (in degrees) for FITS images:"
  set regsiz = $<
  echo -n "Enter base name for output 2MASS FITS images:"
  set outnam = $<
  echo -n "Lower sigma limit for RGB stretch (recommended -1): "
  set sl = $<
  echo -n "Upper sigma limit for RGB stretch (recommended 5): "
  set su = $<
endif
#
# Create header
mHdr -d '"'"$inpcoo1 $inpcoo2 Equ J2000"'"' $regsiz $outnam\.hdr
echo mHdr '"'"$inpcoo1 $inpcoo2 Equ J2000"'"' $regsiz $outnam\.hdr
cat $outnam\.hdr
#
# Create J
echo "Processing...J"
mExec -d 1 -c -f $outnam\.hdr -o$outnam\-2MASS-J 2MASS J $outnam\-2MASS-J
#
# Create H
echo "Processing...H"
mExec -d 1 -c -f $outnam\.hdr -o$outnam\-2MASS-H 2MASS H $outnam\-2MASS-H
#
# Create K
echo "Processing...K"
mExec -d 1 -c -f $outnam\.hdr -o$outnam\-2MASS-K 2MASS K $outnam\-2MASS-K
echo "Making RGB image from JHK..."
#
# Create RGB jpg
mJPEG -d -red $outnam\-2MASS-K/mosaic.fits $sl\s $su\s -green $outnam\-2MASS-H/mosaic.fits $sl\s $su\s -blue $outnam\-2MASS-J/mosaic.fits $sl\s $su\s -out 2MASS-JHK.jpg
#
echo "Done!"

