def test_generate_report(modelfitting_run, sim12_r_01_reference, sim12_r_simulation, datafiles, module_output_area): """ Not quite a test. Generate a PDF report to allow for better insights. """ modelfitting_catalog = modelfitting_run.catalog module_output_area = module_output_area / modelfitting_catalog.meta['engine'] image = plot.Image(datafiles / 'sim12' / 'img' / 'sim12_r_01.fits.gz') with plot.Report(module_output_area / 'report.pdf') as report: loc_map = plot.Location(image, sim12_r_simulation) loc_map.add('SExtractor2', sim12_r_01_reference, 'XMODEL_IMAGE', 'YMODEL_IMAGE', marker='1') loc_map.add('SourceXtractor++', modelfitting_catalog, 'model_x', 'model_y', marker='2') report.add(loc_map) dist = plot.Distances(image, sim12_r_simulation) dist.add('SExtractor2', sim12_r_01_reference, 'XMODEL_IMAGE', 'YMODEL_IMAGE', marker='o') dist.add('SourceXtractor++', modelfitting_catalog, 'model_x', 'model_y', marker='.') report.add(dist) mag_r = plot.Magnitude('R', sim12_r_simulation) mag_r.add( 'SExtractor2', sim12_r_01_reference, 'ALPHA_SKY', 'DELTA_SKY', 'MAG_MODEL', 'MAGERR_MODEL', marker='o' ) mag_r.add( 'SourceXtractor++', modelfitting_catalog, 'world_centroid_alpha', 'world_centroid_delta', 'model_mag_r', 'model_mag_r_err', marker='.' ) report.add(mag_r) hist = plot.Histogram(image, sim12_r_simulation) hist.add( 'SExtractor2 MAG_MODEL', sim12_r_01_reference, 'ALPHA_SKY', 'DELTA_SKY', 'MAG_MODEL' ) hist.add( 'SourceXtractor++ model_mag_r', modelfitting_catalog, 'world_centroid_alpha', 'world_centroid_delta', 'model_mag_r' ) report.add(hist) report.add(plot.RunResult(modelfitting_run.run))
logging.info( f'Loading detection image {args.detection_image} with weight {args.weight_image}' ) image = plot.Image(args.detection_image, args.weight_image) log.info(f'Creating report {args.output}') with plot.Report(args.output) as report: # Profile if args.mprof: for (catalog_name, _), mprof_path in zip(catalogs, args.mprof): mprof_data = mprof.read_mprofile_file(mprof_path) report.add(plot_mprof(catalog_name, mprof_data)) # Location markers = itertools.cycle('1234') loc_map = plot.Location(image, reference) for catalog_name, catalog in catalogs: loc_map.add(catalog_name, catalog, args.pixel_x, args.pixel_y, marker=next(markers)) report.add(loc_map) # Distance plot markers = itertools.cycle('1234') distance = plot.Distances(image, reference) for catalog_name, catalog in catalogs: distance.add(catalog_name, catalog, args.pixel_x,
def test_generate_report(multi_compressed_run, sim12_r_reference, sim12_r_simulation, datafiles, module_output_area): """ Not quite a test. Generate a PDF report to allow for better insights. """ multi_compressed_catalog = multi_compressed_run.catalog image = plot.Image(datafiles / 'sim12' / 'img' / 'sim12_r.fits.gz', weight_image=datafiles / 'sim12' / 'img' / 'sim12_r.weight.fits.gz') with plot.Report(module_output_area / 'report.pdf') as report: loc_map = plot.Location(image, sim12_r_simulation) loc_map.add('SExtractor2 (R)', sim12_r_reference, 'X_IMAGE', 'Y_IMAGE', 'ISOAREA_IMAGE', marker='1') loc_map.add('SourceXtractor++', multi_compressed_catalog, 'pixel_centroid_x', 'pixel_centroid_y', 'area', marker='2') report.add(loc_map) dist = plot.Distances(image, sim12_r_simulation) dist.add('SExtractor2 (R)', sim12_r_reference, 'X_IMAGE', 'Y_IMAGE', marker='o') dist.add('SourceXtractor++', multi_compressed_catalog, 'pixel_centroid_x', 'pixel_centroid_y', marker='.') report.add(dist) mag_r = plot.Magnitude(f'iso_mag', sim12_r_simulation) mag_r.add('SExtractor2', sim12_r_reference, 'ALPHA_SKY', 'DELTA_SKY', 'MAG_ISO', 'MAGERR_ISO', marker='o') mag_r.add('SourceXtractor++', multi_compressed_catalog, 'world_centroid_alpha', 'world_centroid_delta', 'isophotal_mag', 'isophotal_mag_err', marker='.') report.add(mag_r) for i in range(3): mag_r = plot.Magnitude(f'auto_mag:{i}', sim12_r_simulation) mag_r.add('SExtractor2', sim12_r_reference, 'ALPHA_SKY', 'DELTA_SKY', 'MAG_AUTO', 'MAGERR_AUTO', marker='o') mag_r.add('SourceXtractor++', multi_compressed_catalog, 'world_centroid_alpha', 'world_centroid_delta', f'auto_mag:{i}', f'auto_mag_err:{i}', marker='.') report.add(mag_r) for i in range(3): flag_r = plot.Flags(image) flag_r.set_sextractor2('SExtractor2', sim12_r_reference, 'X_IMAGE', 'Y_IMAGE', 'FLAGS') flag_r.set_sourcextractor(f'SourceXtractor++ auto_flags:{i}', multi_compressed_catalog, 'pixel_centroid_x', 'pixel_centroid_y', f'auto_flags:{i}') report.add(flag_r) report.add(plot.RunResult(multi_compressed_run.run))
def test_generate_report(modelfitting_run, sim12_r_simulation, sim12_g_simulation, sim12_r_reference, sim12_g_reference, datafiles, module_output_area): """ Not quite a test. Generate a PDF report to allow for better insights. """ modelfitting_catalog = modelfitting_run.catalog module_output_area = module_output_area / modelfitting_catalog.meta[ 'engine'] # Filter not fitted sources not_flagged = modelfitting_catalog['fmf_flags'] == 0 image = plot.Image(datafiles / 'sim12' / 'img' / 'sim12.fits.gz', weight_image=datafiles / 'sim12' / 'img' / 'sim12.weight.fits.gz') image_r = plot.Image( datafiles / 'sim12' / 'img' / 'sim12_r.fits.gz', datafiles / 'sim12' / 'img' / 'sim12_r.weight.fits.gz') image_g = plot.Image(datafiles / 'sim12' / 'img' / 'sim12_g.fits.gz', weight_image=datafiles / 'sim12' / 'img' / 'sim12_g.weight.fits.gz') with plot.Report(module_output_area / 'report.pdf') as report: loc_map = plot.Location(image, sim12_r_simulation) loc_map.add('SourceXtractor++', modelfitting_catalog[not_flagged], 'model_x', 'model_y', marker='3') report.add(loc_map) dist_r = plot.Distances(image_r, sim12_r_simulation) dist_r.add('SExtractor2 (R)', sim12_r_reference, 'XMODEL_IMAGE', 'YMODEL_IMAGE', marker='o') report.add(dist_r) dist_g = plot.Distances(image_g, sim12_g_simulation) dist_g.add('SExtractor2 (G)', sim12_g_reference, 'XMODEL_IMAGE', 'YMODEL_IMAGE', marker='h') report.add(dist_g) dist = plot.Distances(image, sim12_g_simulation) dist.add('SourceXtractor++', modelfitting_catalog[not_flagged], 'model_x', 'model_y', marker='.') report.add(dist) mag_r = plot.Magnitude('R', sim12_r_simulation) mag_r.add('SExtractor2', sim12_r_reference, 'ALPHA_SKY', 'DELTA_SKY', 'MAG_MODEL', 'MAGERR_MODEL', marker='o') mag_r.add('SourceXtractor++', modelfitting_catalog[not_flagged], 'world_centroid_alpha', 'world_centroid_delta', 'model_mag_r', 'model_mag_r_err', marker='.') report.add(mag_r) mag_g = plot.Magnitude('G', sim12_g_simulation) mag_g.add('SExtractor2', sim12_r_reference, 'ALPHA_SKY', 'DELTA_SKY', 'MAG_MODEL', 'MAGERR_MODEL', marker='o') mag_g.add('SourceXtractor++', modelfitting_catalog[not_flagged], 'world_centroid_alpha', 'world_centroid_delta', 'model_mag_r', 'model_mag_r_err', marker='.') report.add(mag_g) flags = plot.Flags(image) flags.set_sourcextractor('SourceXtractor++ fmf_flags', modelfitting_catalog, 'pixel_centroid_x', 'pixel_centroid_y', f'fmf_flags') report.add(flags) report.add(plot.RunResult(modelfitting_run.run))