Skip to content

Commit

Permalink
more path stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
mcoughlin committed Apr 28, 2024
1 parent fc086a1 commit 0b16d7e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions gwemopt/catalogs/glade.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ def download_catalog(self):
df.rename(columns=key_map, inplace=True)
df["PGC"] = df["PGC"].astype(str)
cat = Table.from_pandas(df)
write_table_hdf5(cat, save_path, path="df")
write_table_hdf5(cat, str(save_path), path="df")

def load_catalog(self) -> pd.DataFrame:
cat = read_table_hdf5(self.get_catalog_path(), path="df")
cat = read_table_hdf5(str(self.get_catalog_path()), path="df")
df = cat.to_pandas()
return df
10 changes: 6 additions & 4 deletions gwemopt/catalogs/nedlvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import numpy as np
import pandas as pd
from astropy.io import fits
from astropy.io.misc.hdf5 import read_table_hdf5, write_table_hdf5
from astropy.table import Table

from gwemopt.catalogs.base_catalog import BaseCatalog

Expand Down Expand Up @@ -41,14 +43,14 @@ def download_catalog(self):
inplace=True,
)
df = df[df["redshift"] > 0]

df.to_hdf(self.get_catalog_path(), key="df")
cat = Table.from_pandas(df)
write_table_hdf5(cat, str(self.get_catalog_path()), path="df")
temp_path.unlink()

def get_temp_path(self):
return self.get_catalog_path(filetype="fits").with_stem(f"temp_{self.name}")

def load_catalog(self) -> pd.DataFrame:
df = pd.read_hdf(self.get_catalog_path(), key="df")

cat = read_table_hdf5(str(self.get_catalog_path()), path="df")
df = cat.to_pandas()
return df
4 changes: 2 additions & 2 deletions gwemopt/catalogs/twomrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ def download_catalog(self):
mask = mk < mk_max
df = df[mask]
cat = Table.from_pandas(df)
write_table_hdf5(cat, save_path, path="df")
write_table_hdf5(cat, str(save_path), path="df")

def load_catalog(self) -> pd.DataFrame:
cat = read_table_hdf5(self.get_catalog_path(), path="df")
cat = read_table_hdf5(str(self.get_catalog_path()), path="df")
df = cat.to_pandas()
return df

0 comments on commit 0b16d7e

Please sign in to comment.