#!/usr/bin/env python
import sys, os
#import re
#import time
#import Image, ImageChops, ImageOps, ImageDraw, ImageFont

sys.path.append('..')
from ImgDk2Game import *

srcdir = '../sample_data'
datestr = '2010122502'
ch = 1

files = untarjmbsc(srcdir, datestr, ch)
g = ImgDk2Game(files[0])

box = (70, 70, 210, -70)
size = (700, 700)
image = g.geotransraw(box, size)
g.writegame(image, box, size)

#fo = file(g.satname + datestr + g.ch + 'CAL.dat', 'w')
#fo.write(g.getcal())
#fo.write('\n')
#fo.close()

offset = (-470, 500)
size = (640, 480)
lambda_0 = 140.0
mag = 9.0/6400*6356.5838 # change in earth radius definition
image = g.poltransraw(offset, size, lambda_0, mag)
image.save('%s.jpg' % g.nomjst)

