diff --git a/SAGA/objects/build2.py b/SAGA/objects/build2.py index 796183e..4e5e311 100644 --- a/SAGA/objects/build2.py +++ b/SAGA/objects/build2.py @@ -562,6 +562,13 @@ def remove_shreds_near_spec_obj(base, nsa=None): return base +def remove_too_close_to_host(base): + min_rhost = base['RHOST_KPC'].min() + q = Query((lambda r: ((r < 10.0) & (r > min_rhost)), 'RHOST_KPC')) + base['REMOVE'][q.mask(base)] += (1 << 30) + return base + + def add_surface_brightness(base): base['sb_r'] = base['r_mag'] + 2.5 * np.log10(np.maximum(2.0*np.pi*base['radius']**2.0, 1.0e-40)) return base @@ -586,7 +593,10 @@ def build_full_stack(host, sdss=None, des=None, decals=None, nsa=None, all_spectra = [] if sdss is not None: - all_spectra.append(extract_sdss_spectra(sdss)) + sdss_specs = extract_sdss_spectra(sdss) + if sdss_specs is not None: + all_spectra.append(sdss_specs) + del sdss_specs sdss = prepare_sdss_catalog_for_merging(sdss, sdss_remove, sdss_recover) if des is not None: @@ -622,7 +632,7 @@ def build_full_stack(host, sdss=None, des=None, decals=None, nsa=None, base = remove_shreds_near_spec_obj(base, nsa) del nsa - base['REMOVE'][Query('RHOST_KPC < 10.0').mask(base)] += (1 << 30) + base = remove_too_close_to_host(base) base = add_surface_brightness(base) base = build.find_satellites(base, version=2) base = build.add_stellar_mass(base) diff --git a/SAGA/objects/object_catalog.py b/SAGA/objects/object_catalog.py index 6b730e6..20f439c 100644 --- a/SAGA/objects/object_catalog.py +++ b/SAGA/objects/object_catalog.py @@ -1,4 +1,5 @@ import time +import traceback import numpy as np from astropy.table import vstack from easyquery import Query @@ -337,10 +338,11 @@ def get_catalog_or_none(catalog_name): base = build_module.build_full_stack(host=host, nsa=nsa, spectra=spectra, debug=debug_this, **manual_lists, **catalog_dict) except Exception as e: # pylint: disable=W0703 - print(time.strftime('[%m/%d %H:%M:%S]'), '[ERROR] Fail to build base catalog for {}\n{}'.format(host_id, e)) + print(time.strftime('[%m/%d %H:%M:%S]'), '[ERROR] Fail to build base catalog for {}'.format(host_id)) base = None if raise_exception: raise e + traceback.print_exc() continue finally: del catalog_dict @@ -351,7 +353,10 @@ def get_catalog_or_none(catalog_name): try: data_obj.write(base) except (IOError, OSError) as e: - print(time.strftime('[%m/%d %H:%M:%S]'), '[ERROR] Fail to write base catalog for {}\n{}'.format(host_id, e)) + print(time.strftime('[%m/%d %H:%M:%S]'), '[ERROR] Fail to write base catalog for {}'.format(host_id)) + if raise_exception: + raise e + traceback.print_exc() continue if return_catalogs: diff --git a/SAGA/spectra/extract_exsiting.py b/SAGA/spectra/extract_exsiting.py index 5808a60..ba071d9 100644 --- a/SAGA/spectra/extract_exsiting.py +++ b/SAGA/spectra/extract_exsiting.py @@ -7,6 +7,8 @@ def extract_sdss_spectra(sdss): specs = Query('SPEC_Z > -1.0').filter(sdss['RA', 'DEC', 'SPEC_Z', 'SPEC_Z_ERR', 'SPEC_Z_WARN', 'OBJID']) + if not len(specs): + return specs['ZQUALITY'] = np.where(specs['SPEC_Z_WARN'] == 0, 4, 1) del specs['SPEC_Z_WARN'] specs.rename_column('OBJID', 'SPECOBJID') diff --git a/SAGA/version.py b/SAGA/version.py index 4c53590..a551053 100644 --- a/SAGA/version.py +++ b/SAGA/version.py @@ -1,4 +1,4 @@ """ SAGA package version """ -__version__ = '0.8.0' +__version__ = '0.8.1'