Skip to content

Commit

Permalink
v0.14.1 (#80)
Browse files Browse the repository at this point in the history
v0.14.1
  • Loading branch information
yymao authored Nov 19, 2019
2 parents 758dd41 + bd14914 commit 1190711
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ base_paper1 = saga.object_catalog.load(hosts='paper1', return_as='list')
# count number of satellites
for base in base_paper1:
print(base['HOST_ID'][0], '# of satellites =', saga.is_sat.count(base))
print(base['HOSTID'][0], '# of satellites =', saga.is_sat.count(base))
```
You can find more examples at https://github.com/sagasurvey/examples/tree/master/notebooks
Expand Down
10 changes: 6 additions & 4 deletions SAGA/database/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,13 @@ def isfile(self):


class CsvTable(FileObject):
_read_default_kwargs = _write_default_kwargs = dict(format="ascii.csv")
_read_default_kwargs = dict(format="ascii.csv")
_write_default_kwargs = dict(format="ascii.csv", overwrite=True)


class FastCsvTable(FileObject):
_read_default_kwargs = _write_default_kwargs = dict(format="ascii.fast_csv")
_read_default_kwargs = dict(format="ascii.fast_csv")
_write_default_kwargs = dict(format="ascii.fast_csv", overwrite=True)


class GoogleSheets(FastCsvTable):
Expand All @@ -116,13 +118,13 @@ def write(self, table, **kwargs):

class FitsTableGeneric(FileObject):
_read_default_kwargs = dict(memmap=True)
_write_default_kwargs = dict(format="fits")
_write_default_kwargs = dict(format="fits", overwrite=True)


class FitsTable(FileObject):
compress_after_write = True
_read_default_kwargs = dict(cache=False, memmap=True)
_write_default_kwargs = dict(format="fits")
_write_default_kwargs = dict(format="fits", overwrite=True)

def read(self):
kwargs_this = dict(self._read_default_kwargs, **self.kwargs)
Expand Down
6 changes: 4 additions & 2 deletions SAGA/database/saga_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,8 @@ def resolve_base_version(self, version=None):
def set_default_base_version(self, version=None):
_, version_postfix = self.resolve_base_version(version)
if not version_postfix:
version_postfix = '_v2p1'
self._file_path_pattern["base"] = self._file_path_pattern["base" + version_postfix]
version_postfix = "_v2p1"
self._file_path_pattern["base"] = self._file_path_pattern[
"base" + version_postfix
]
self._add_derived_data()
14 changes: 9 additions & 5 deletions SAGA/hosts/host_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def _master_table(self):
"Cannot load master list; attempt to build from scratch..."
)
self._master_table_ = self.build_master_list()
self._master_table_['SAGA_NAME'].fill_value = ""
self._master_table_["SAGA_NAME"].fill_value = ""
self._master_table_ = self._master_table_.filled()
self._master_index_ = None
return self._master_table_
Expand All @@ -110,7 +110,7 @@ def _host_table(self):
"Cannot load host list; attempt to load master list..."
)
self._host_table_ = cuts.potential_hosts.filter(self._master_table)
self._host_table_['SAGA_NAME'].fill_value = ""
self._host_table_["SAGA_NAME"].fill_value = ""
self._host_table_ = self._host_table_.filled()
self._host_index_ = None
return self._host_table_
Expand Down Expand Up @@ -289,7 +289,7 @@ def add_object_stats(self, host_table):
for col in cols_to_keep:
if col == "HOSTID":
continue
if 'need_spec' in col:
if "need_spec" in col:
d[col].fill_value = 999999
else:
d[col].fill_value = -1
Expand Down Expand Up @@ -345,7 +345,9 @@ def load_single(self, host, add_coord=True, use_master=None, include_stats=False
d = self._annotate_table(d, add_coord=add_coord, include_stats=include_stats)
return d[0]

def load_single_near_ra_dec(self, ra, dec, sep=3600, use_master=None, add_coord=True, include_stats=False):
def load_single_near_ra_dec(
self, ra, dec, sep=3600, use_master=None, add_coord=True, include_stats=False
):
"""
ra, dec in degrees
"""
Expand All @@ -360,7 +362,9 @@ def load_single_near_ra_dec(self, ra, dec, sep=3600, use_master=None, add_coord=
ra, dec
)
)
cat = self._annotate_table(cat, add_coord=add_coord, include_stats=include_stats)
cat = self._annotate_table(
cat, add_coord=add_coord, include_stats=include_stats
)
return cat[0]

def build_master_list(self, overwrite=False, overwrite_host_list=False):
Expand Down
4 changes: 2 additions & 2 deletions SAGA/objects/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ def add_host_info(base, host, overwrite_if_different_host=False):
return base

if (
"HOST_ID" in base.colnames and base["HOST_ID"][0] != host["HOSTID"]
"HOSTID" in base.colnames and base["HOSTID"][0] != host["HOSTID"]
) and not overwrite_if_different_host:
raise ValueError("Host info exists and differs from input host info.")

base["HOST_ID"] = get_empty_str_array(len(base), 48, host["HOSTID"] or "")
base["HOSTID"] = get_empty_str_array(len(base), 48, host["HOSTID"] or "")
base["HOST_PGC"] = np.int32(host["PGC"])
base["HOST_NSAID"] = np.int32(host["NSAID"])
base["HOST_NSA1ID"] = np.int32(host["NSA1ID"])
Expand Down
26 changes: 20 additions & 6 deletions SAGA/objects/object_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,16 @@ def _annotate_catalog(
or "{}_mag".format(color[1]) not in table.colnames
):
continue
table[color] = (
table["{}_mag".format(color[0])] - table["{}_mag".format(color[1])]
)
table["{}_err".format(color)] = np.hypot(
table["{}_err".format(color[0])], table["{}_err".format(color[1])]
)
with np.errstate(invalid="ignore"):
table[color] = (
table["{}_mag".format(color[0])] - table["{}_mag".format(color[1])]
)
table["{}_err".format(color)] = np.hypot(
table["{}_err".format(color[0])], table["{}_err".format(color[1])]
)

if "HOST_ID" in table.colnames:
table.rename_column("HOST_ID", "HOSTID")

if ensure_all_objid_cols:
for s in cls._surveys:
Expand Down Expand Up @@ -409,6 +413,7 @@ def build_and_write_to_database(
manual_lists[key] = val
print(time.strftime("[%m/%d %H:%M:%S]"), "All other manual lists loaded.")

failed_count = 0
catalogs_to_return = list()
for i, host in enumerate(host_table):
host_id = host["HOSTID"]
Expand Down Expand Up @@ -513,6 +518,7 @@ def get_catalog_or_none(catalog_name):
if raise_exception:
raise e
traceback.print_exc()
failed_count += 1
continue
finally:
del catalog_dict
Expand All @@ -533,8 +539,16 @@ def get_catalog_or_none(catalog_name):
if raise_exception:
raise e
traceback.print_exc()
failed_count += 1
continue

print(
time.strftime("[%m/%d %H:%M:%S]"),
"All done building base catalogs for {}/{} hosts.".format(
nhosts - failed_count, nhosts
),
)

if return_catalogs:
return catalogs_to_return

Expand Down
9 changes: 9 additions & 0 deletions SAGA/spectra/read_observed.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"read_palomar",
]

# pylint: disable=logging-format-interpolation


def heliocentric_correction(
fits_filepath,
Expand Down Expand Up @@ -63,6 +65,13 @@ def read_generic_spectra(
for f in os.listdir(dir_path):
if not f.endswith(extension):
continue
if "conflicted copy" in f:
logging.warning(
"SKIPPING spectra file {}/{} - it's a conflicted copy; check if something went wrong!".format(
dir_path, f
)
)
continue
try:
this = Table.read(
os.path.join(dir_path, f),
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.14.0"
__version__ = "0.14.1"

0 comments on commit 1190711

Please sign in to comment.