Commit 2579ee10 authored by GROUAZEL's avatar GROUAZEL

change the generation spectra png script

parent ac5ca3c4
import plot_spec_V2
import Spectrum
from SpectrumReader import SpectrumReaderSat
from SpectrumReader import SpectrumReader
# from SpectrumReader import SpectrumReaderSat
# from SpectrumReader import SpectrumReader
# from SpectrumReaderSentinel import SpectrumReaderSat
from SpectrumReader_V2 import SpectrumReader
import matplotlib
import spectrumUtil
import logging
......@@ -11,7 +13,18 @@ from datetime import datetime
import collections
import time
if __name__ == "__main__":
print "start generating Xspec png files"
print("start generating Xspec png files")
import argparse
parser = argparse.ArgumentParser(description='generate png spectra')
parser.add_argument('--verbose', action='store_true',default=False)
parser.add_argument('--overwrite', action='store_true',default=False,help='overwrite existing png')
args = parser.parse_args()
if args.verbose:
logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(levelname)-5s %(message)s',
datefmt='%d/%m/%Y %H:%M:%S')
logging.basicConfig(level=logging.INFO,format='%(asctime)s %(levelname)-5s %(message)s',
datefmt='%d/%m/%Y %H:%M:%S')
year = str(
month = str(
day = str(
......@@ -24,7 +37,7 @@ if __name__ == "__main__":
nbsuccess = 0
nberror = 0
# logging.basicConfig(level=logging.INFO)
logging.debug('start plot')
cpt = collections.defaultdict(int)
t0 = time.time()
......@@ -45,11 +58,14 @@ if __name__ == "__main__":
output_file, extension = os.path.splitext(output_file)
if not os.path.exists(output_dir):
os.makedirs(output_dir, 0775)
if os.path.exists(output_file+'.png') and args.overwrite:
currentSpectrum = SpectrumReader.read_spectrum(input_file, mode).write(output_file+'.png')#add .png at the end agrouaze august 2018 fix missing .png at the end of the filenames
nbsuccess += 1
except Exception as e:
print 'exception occured:'
print e
print('exception occured:')
filewriter = open(filesinerror, 'a')
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment