def test_imstack(mock_run_command): filelist = 'files.txt' confidence_map = 'confidence.fits' casutools.imstack(filelist, confidence_map) assert len(mock_run_command.args) == 1 command = mock_run_command.args[0] assert filelist in command[0] and confidence_map in command[0]
def main(argv): if argv["--verbose"] == True: print "Creating source catalogue from first {} images...".format(argv["--nfiles"]) # Pick the first N files if argument given nfiles = int(argv["--nfiles"]) if argv["--nfiles"] else None with NamedTemporaryFile() as tmp: name = tmp.name with open(argv["--filelist"]) as infile: for i, line in enumerate(infile): if nfiles and i >= nfiles: break tmp.write(line) tmp.seek(0) if not argv["--no-wcs"]: m_solve_images( name, name, thresh=argv["--s_thresh"], nproc=int(argv["--nproc"]) if argv["--nproc"] else None, verbose=argv["--verbose"], ) with open(argv["--stacklist"], "w") as stacklist: for line in tmp: image = line.strip() status_check = ["ok", "ok"] if all([status == "ok" for status in status_check]): stacklist.write(image + "\n") outstack_name = "outstack.fits" outstackconf_name = "outstackconf.fits" casutools.imstack( argv["--stacklist"], argv["--confmap"], verbose=argv["--verbose"], outstack=outstack_name, outconf=outstackconf_name, ) casutools.imcore( outstack_name, argv["--outname"], threshold=argv["--c_thresh"], confidence_map=outstackconf_name, verbose=argv["--verbose"], ) if argv["--verbose"] == True: print "Catalogue complete"
def main(argv): if argv['--verbose'] == True: print 'Creating source catalogue from first {} images...'.format( argv['--nfiles']) # Pick the first N files if argument given nfiles = int(argv['--nfiles']) if argv['--nfiles'] else None with NamedTemporaryFile() as tmp: name = tmp.name with open(argv['--filelist']) as infile: for i, line in enumerate(infile): if nfiles and i >= nfiles: break tmp.write(line) tmp.seek(0) if not argv['--no-wcs']: m_solve_images( name, name, thresh=argv['--s_thresh'], nproc=int(argv['--nproc']) if argv['--nproc'] else None, verbose=argv['--verbose']) with open(argv['--stacklist'], 'w') as stacklist: for line in tmp: image = line.strip() status_check = ['ok', 'ok'] if all([status == 'ok' for status in status_check]): stacklist.write(image + '\n') outstack_name = 'outstack.fits' outstackconf_name = 'outstackconf.fits' casutools.imstack(argv['--stacklist'], argv['--confmap'], verbose=argv['--verbose'], outstack=outstack_name, outconf=outstackconf_name) casutools.imcore(outstack_name, argv['--outname'], threshold=argv['--c_thresh'], confidence_map=outstackconf_name, verbose=argv['--verbose']) if argv['--verbose'] == True: print 'Catalogue complete'