def testLoadJsonJob(self):
        """Can we load a Job from a JSON file?"""

        # without throwing an error
        job = load_json_output(self.jsonFile)
        # Spot-check a few attributes
        self.assertEqual(len(job.measurements), 30)
    def testPlotMetricsFromJsonJob(self):
        """Does plotting the metrics run and produce the correct filenames?

        This could be loosely seen as a test of the outputPrefix handling
        and thus DM-11410, it's a rather incomplete one because the chain
        of wrapping functions is different.
        """
        job = load_json_output(self.jsonFile)
        filterName = get_filter_name_from_job(job)

        noOutputPrefixFiles = [
            'check_astrometry.png', 'check_photometry.png', 'PA1.png',
            'validate_drp.AM1_D_5_arcmin_17.0_21.5_mag.png',
            'validate_drp.TE1_D_1_arcmin.png',
            'validate_drp.TE2_D_5_arcmin.png'
        ]
        # test with no output prefix.
        plot_metrics(job, filterName)
        for filename in noOutputPrefixFiles:
            assert os.path.exists(filename), "File not created: %s" % filename
            os.remove(filename)

        # test that outputPrefix is prepended correctly.
        outputPrefix = 'foobarbaz'
        outputPrefixFiles = [
            '%s_%s' % (outputPrefix, f) for f in noOutputPrefixFiles
        ]
        plot_metrics(job, filterName, outputPrefix=outputPrefix)
        for filename in outputPrefixFiles:
            assert os.path.exists(filename), "File not created: %s" % filename
            os.remove(filename)
Example #3
0
    def testLoadJsonJob(self):
        """Can we load a Job from a JSON file?"""

        # without throwing an error
        job = load_json_output(self.jsonFile)
        # Spot-check a few attributes
        self.assertEqual(len(job._measurements), 28)
        self.assertEqual(set(job.spec_levels), set(['design', 'minimum', 'stretch']))
    def testPrintMetricsFromJsonJob(self):
        """Does printing the metrics run without error using itself?

        This is in essence half the big test.
        If we load a file do we get printed metrics?
        Next TODO is to actually check for the values printed.
        """
        job = load_json_output(self.jsonFile)
        filterName = get_filter_name_from_job(job)
        print_metrics(job, filterName)
Example #5
0
    def testPlotMetricsFromJsonJob(self):
        """Does plotting the metrics run and produce the correct filenames?

        This could be loosely seen as a test of the outputPrefix handling
        and thus DM-11410, it's a rather incomplete one because the chain
        of wrapping functions is different.
        """
        job = load_json_output(self.jsonFile)
        filterName = get_filter_name_from_job(job)

        plot_metrics(job, filterName)
        assert os.path.exists('check_astrometry.png')

        outputPrefix = repoNameToPrefix(self.jsonFile)
        plot_metrics(job, filterName, outputPrefix=outputPrefix)
        expectedCheckAstrometryFile = '%s_%s' % (outputPrefix,
                                                 'check_astrometry.png')
        assert os.path.exists(expectedCheckAstrometryFile)
def ingest_data(filenames):
    """Load JSON files into a list of lsst.validate.base measurement Jobs.

    Parameters
    ----------
    filenames : list of str
        Filenames of JSON files to load.

    Returns
    -------
    list of lsst.validate.base.Job
        Each element is the Job representation of the JSON file.
    """
    jobs = {}
    # Read in JSON output from metrics run
    for file in filenames:
        job = load_json_output(file)
        filter_name = get_filter_name_from_job(job)
        jobs[filter_name] = job

    return jobs
 def testParseJobFilterName(self):
     """Do we correctly read the filterName from a Job object?"""
     job = load_json_output(self.jsonFile)
     filterName = get_filter_name_from_job(job)
     self.assertEqual(filterName, self.jsonFile_filter)