#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 18 13:54:07 2017

@author: xliq
"""

'''
The MetroPy Raw-2D File:
    Generates the 2D heatmaps of the raw Metrology data.
'''
#### Initialization
from sys import argv
FITS_file = argv[1]
rmsLength = int(argv[2])
resolution = int(argv[3])
img = argv[4]

#### Importing
#### Importing
# import necessary things from the init file
from MetroPy_Init import plotstyle, volts
from MetroPy_Helper import heatmap2d, plotnumber, plotlabel

# import necessary packages
import os
import matplotlib.pyplot as plt
# plotstyle for Metrology data
plt.style.use(plotstyle)
# numpy ofcourse
import numpy as np
#import progressbar as pb

# format
plt.rcParams['font.size'] = 10
plt.rcParams['image.cmap'] = 'Blues'

size = [20, 28]

# start processing the image
counter=0
# activate progressbar
#bar = pb.ProgressBar()
for n in np.arange(0, 80, 2):
    
    fig = plt.gcf()
    plt.subplot(8, 5, plotnumber('raw2d', n, counter))
    plt.axvline(0, 0, 1, color='grey', lw=0.5)
    plt.axhline(0, 0, 1, color='grey', lw=0.5)
    plt.xlabel('Voltage [V]')
    plt.ylabel('Voltage [V]')
    plt.title('%s' %plotlabel('raw2d', n))
    heatmap2d(fig, volts, n, max(abs(volts[:,n])),
              max(abs(volts[:,n+1])), resolution, size)
           
    counter += 1

plt.savefig('%s.Raw2D.%s' %(FITS_file, img), bbox_inches='tight')

print('Raw 2D Plots: Done!')


