Skip to content

Commit

Permalink
Merge pull request #59 from sagasurvey/better-specs-merge
Browse files Browse the repository at this point in the history
more minor fixes
  • Loading branch information
yymao authored Jul 10, 2018
2 parents 05b092f + 2a2c46e commit 5211bdc
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
14 changes: 12 additions & 2 deletions SAGA/objects/build2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 7 additions & 2 deletions SAGA/objects/object_catalog.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import time
import traceback
import numpy as np
from astropy.table import vstack
from easyquery import Query
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions SAGA/spectra/extract_exsiting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion SAGA/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
SAGA package version
"""
__version__ = '0.8.0'
__version__ = '0.8.1'

0 comments on commit 5211bdc

Please sign in to comment.