def test_image_cached(): da.reset() import ddosa reload(ddosa) fa = ddosa.ii_skyimage(assume=[ ddosa.ScWData(input_scwid="066500230010.001"), ]) fa.read_caches = [] fa.get() # now get cached fb = ddosa.ii_skyimage(assume=[ ddosa.ScWData(input_scwid="066500230010.001"), ]) fb.produce_disabled = True import time t0 = time.time() fb.get() assert time.time() - t0 < 3
def test_osa_blob(): import dataanalysis.core as da from sdsc import SDSCCache, blob_store blob_store.purge() import ddosa cache = SDSCCache() im = ddosa.ii_skyimage( assume=[ddosa.ScWData(input_scwid="066500220010.001")]) im.get() im.write_caches.append(cache.__class__) da.debug_output() cache.store(im._da_locally_complete, im) assert len(blob_store.blobs) == 1 blob = blob_store.blobs.items()[0][1] import tarfile import StringIO tar = tarfile.open(fileobj=StringIO.StringIO(blob)) print tar.getnames() assert './blob/isgri_sky_res.fits.gz' in tar.getnames()
def test_mosaic_ii_skyimage(): import ddosa import gencat cat = gencat.SourceCatalog() cat.catalog = [dict( NAME="TEST_SOURCE", RA=83, DEC=22, )] cat.promote() assert cat.virtual assert hasattr(cat, 'catalog') grcat = gencat.GRcat() grcat.serialize() sc = ddosa.da.AnalysisFactory.byname("SourceCatalog") assert cat == sc print sc.get_version() #ips=ddosa.ImageProcessingSummary().get() #print "HASH:",ips.hash ## #da.debug_output() mf = gencat.GRcat() c = mf.process(output_required=False, run_if_haveto=False)[0] print("mf:", c) mf = gencat.GRcat(assume=ddosa.ScWData(input_scwid="any")) c = mf.process(output_required=False, run_if_haveto=False)[0] print("mf:", c) assert c[1][2].startswith("SourceCatalog.v0.1.") ## mosaic = ddosa.mosaic_ii_skyimage(assume=[ ddosa.ii_skyimage(input_cat=gencat.CatForImage), ddosa.ImageGroups(input_scwlist=ddosa.IDScWList( use_scwid_list=["066500330010.001", "066500340010.001"])), ddosa.ImageBins(use_ebins=[(25, 40)], use_version="onebin_25_40"), ddosa.ImagingConfig(use_SouFit=0, use_version="soufit0") ]) mosaic.read_caches = [] mosaic.ii_NegModels = 1 mosaic.get() d = pyfits.open(mosaic.srclres.get_path())[1].data print d['NAME'] assert len(d) == 2 assert d[0]['NAME'] == cat.catalog[0]['NAME'] assert d[0]['RA_FIN'] == cat.catalog[0]['RA'] assert d[0]['DEC_FIN'] == cat.catalog[0]['DEC']
def test_catextract_grcat(): import ddosa import gencat cat = gencat.SourceCatalog() cat.catalog = [dict( NAME="TEST_SOURCE", RA=83, DEC=22, )] cat.promote() scw = ddosa.ScWData(input_scwid="066500220010.001") scw.get().promote() igrcat = gencat.ISGRIRefCat(use_read_caches=[]).get() assert os.path.exists(igrcat.cat) d = pyfits.open(igrcat.cat)[1].data assert len(d) == 1 assert d[0]['NAME'] == cat.catalog[0]['NAME'] assert d[0]['RA_OBJ'] == cat.catalog[0]['RA'] assert d[0]['DEC_OBJ'] == cat.catalog[0]['DEC'] assert d[0]['ISGRI_FLAG'] == 1 assert d[0]['ISGRI_FLAG2'] == 0 ecat = ddosa.CatExtract(use_read_caches=[]).get() assert isinstance(ecat.input_cat, gencat.ISGRIRefCat) assert os.path.exists(ecat.input_cat.cat) d = pyfits.open(ecat.input_cat.cat)[1].data assert len(d) == 1 assert d[0]['NAME'] == cat.catalog[0]['NAME'] assert d[0]['RA_OBJ'] == cat.catalog[0]['RA'] assert d[0]['DEC_OBJ'] == cat.catalog[0]['DEC'] assert d[0]['ISGRI_FLAG'] == 1 assert d[0]['ISGRI_FLAG2'] == 0 d = pyfits.open(ecat.cat.get_path())[1].data assert len(d) == 1 assert d[0]['NAME'] == cat.catalog[0]['NAME'] assert d[0]['RA_OBJ'] == cat.catalog[0]['RA'] assert d[0]['DEC_OBJ'] == cat.catalog[0]['DEC'] im = ddosa.ii_skyimage(use_read_caches=[]).get() d = pyfits.open(im.skyres.get_path())[2].data assert len(d['NAME']) >= 1 assert d[0]['NAME'] == cat.catalog[0]['NAME'] assert d[0]['RA_OBJ'] == cat.catalog[0]['RA'] assert d[0]['DEC_OBJ'] == cat.catalog[0]['DEC']
def test_image(): # da.reset() import ddosa reload(ddosa) da.debug_output() fa = ddosa.ii_skyimage(assume=[ ddosa.ScWData(input_scwid="066500230010.001"), ]) fa.read_caches = [] fa.get() print fa.skyima