def test_check_source_filename(self): verifier = ProductVerifier('20100505121116-ESACCI-L2P_GHRSST-SSTskin-AVHRRMTA_G-EXP1.2-v02.0-fv1.0.nc') product_type = verifier._check_source_filename() self.assertIsInstance(product_type, L2P) report = verifier.get_report() self.assertEquals(0, report['source_filename_check'])
def accumulate(self): try: for root, dirnames, filenames in os.walk(self.report_dir_pathname): for filename in filenames: if re.match(self.report_filename_pattern, filename): report_pathname = os.path.join(root, filename) print ProductVerifier.get_current_time(), "accumulating report", report_pathname report = ProductVerifier.load_report(report_pathname) for k, v in report.iteritems(): self.accumulate_entry(k, v) self.accumulate_entry("summary_report.count", 1) finally: ProductVerifier.dump_report(self.summary_report, self.summary_report_pathname)
def run(self): source_pathnames = self.glob_source_pathnames() print ProductVerifier.get_current_time(), \ "found " + str(len(source_pathnames)) + " source files in '" + self.source_dirpath + "'" for source_pathname in source_pathnames: print ProductVerifier.get_current_time( ), "source pathname:", source_pathname report_filename = path.basename(source_pathname) + ".json" report_pathname = path.join(self.report_dirpath, report_filename) print ProductVerifier.get_current_time( ), "report pathname:", report_pathname verifier = ProductVerifier(source_pathname, report_pathname) verifier.verify()
def accumulate(self): try: for root, dirnames, filenames in os.walk(self.report_dir_pathname): for filename in filenames: if re.match(self.report_filename_pattern, filename): report_pathname = os.path.join(root, filename) print ProductVerifier.get_current_time( ), 'accumulating report', report_pathname report = ProductVerifier.load_report(report_pathname) for k, v in report.iteritems(): self.accumulate_entry(k, v) self.accumulate_entry('summary_report.count', 1) finally: ProductVerifier.dump_report(self.summary_report, self.summary_report_pathname)
def test_check_source_pathname(self): verifier = ProductVerifier('20100505121116-ESACCI-L2P_GHRSST-SSTskin-AVHRRMTA_G-EXP1.2-v02.0-fv1.0.nc') try: verifier._check_source_pathname() self.fail() except VerificationError: report = verifier.get_report() self.assertEquals(1, report['source_pathname_check']) ProductVerifierTests.create_new_file(verifier.get_source_pathname()) try: verifier._check_source_pathname() report = verifier.get_report() self.assertEquals(0, report['source_pathname_check']) finally: os.remove(verifier.get_source_pathname())
def run(self): source_pathnames = self.glob_source_pathnames() print ProductVerifier.get_current_time(), \ "found " + str(len(source_pathnames)) + " source files in '" + self.source_dirpath + "'" for source_pathname in source_pathnames: print ProductVerifier.get_current_time(), "source pathname:", source_pathname report_filename = path.basename(source_pathname) + ".json" report_pathname = path.join(self.report_dirpath, report_filename) print ProductVerifier.get_current_time(), "report pathname:", report_pathname verifier = ProductVerifier(source_pathname, report_pathname) verifier.verify()
def test_plot_report_AVHRR(self): plotter = ReportPlotter('l2p', 'AVHRR16_G', ProductVerifier.load_report('testdata/l2p-AVHRR16_G-summary.json')) plotter.plot()
def test_plot_report_AATSR(self): plotter = ReportPlotter('l2p', 'AATSR', ProductVerifier.load_report('testdata/l2p-AATSR-summary.json')) plotter.plot()
starts[i] = starts[i - 1] + values[i - 1] if len(values) > 1: plt.barh(pos, values, left=starts, color=colors[1:], align='center', height=0.5) else: plt.barh(pos, values, left=starts, color=colors[:1], align='center', height=0.5) if __name__ == "__main__": # Call with up to two arguments: # # 1 = usecase # 2 = sensor # 3 = summary report pathname # 4 = figure directory path import sys argument_count = len(sys.argv) if argument_count == 5: plotter = ReportPlotter(sys.argv[1], sys.argv[2], ProductVerifier.load_report(sys.argv[3]), sys.argv[4]) else: print 'usage:', sys.argv[0], '<usecase> <sensor> <summary report pathname> <figure dirpath>' sys.exit(1) # noinspection PyBroadException try: plotter.plot() except: sys.exit(1) sys.exit()
def test_plot_report_AVHRR(self): plotter = ReportPlotter( 'l2p', 'AVHRR16_G', ProductVerifier.load_report('testdata/l2p-AVHRR16_G-summary.json')) plotter.plot()
def test_plot_report_AATSR(self): plotter = ReportPlotter( 'l2p', 'AATSR', ProductVerifier.load_report('testdata/l2p-AATSR-summary.json')) plotter.plot()
height=0.5) if __name__ == "__main__": # Call with up to two arguments: # # 1 = usecase # 2 = sensor # 3 = summary report pathname # 4 = figure directory path import sys argument_count = len(sys.argv) if argument_count == 5: plotter = ReportPlotter(sys.argv[1], sys.argv[2], ProductVerifier.load_report(sys.argv[3]), sys.argv[4]) else: print 'usage:', sys.argv[ 0], '<usecase> <sensor> <summary report pathname> <figure dirpath>' sys.exit(1) # noinspection PyBroadException try: plotter.plot() except Exception as e: print "Error {0}".format(e.message) sys.exit(1) sys.exit()
def test_verify(self): verifier = ProductVerifier('testdata/20100505121116-ESACCI-L2P_GHRSST-SSTskin-AVHRRMTA_G-EXP1.2-v02.0-fv1.0.nc') verifier.verify() expected_report = ProductVerifier.load_report('testdata/report.json') self.assertEquals(expected_report, verifier.get_report())