Skip to content

Commit

Permalink
fix input dict file
Browse files Browse the repository at this point in the history
  • Loading branch information
Elisa-Visentin committed Sep 10, 2024
1 parent d7a7a65 commit 8814070
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 268 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["22.76", "34.76", "48.22", "61.66", "66.76", "9.31", "-18.02", "-29.24", "-4.13"]

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -42,37 +42,21 @@ def main():
help="End date to update database (YYYYMMDD)",
)
parser.add_argument(
"--dict-ra",
"-r",
dest="ra",
"--dict-source",
"-s",
dest="source",
type=str,
default="./ra_dict.txt",
help="File with dictionary of RA coordinates for sources",
)
parser.add_argument(
"--dict-dec",
"-d",
dest="dec",
type=str,
default="./dec_dict.txt",
help="File with dictionary of Dec coordinates for sources",
default="./source_dict.json",
help="File with dictionary of info (RA/Dec/point-source) for sources",
)
parser.add_argument(
"--mc-dec",
"-m",
dest="dec_mc",
type=str,
default="./dec_mc.txt",
default="./dec_mc.json",
help="File with list of MC declinations",
)
parser.add_argument(
"--point-source",
"-p",
dest="point",
type=str,
default="./point_dict.txt",
help="File with dictionary of point sources",
)

args = parser.parse_args()
config_file = resource_file("database_config.yaml")
Expand Down Expand Up @@ -104,18 +88,13 @@ def main():
df_LST = df_LST[df_LST["DATE"].astype(int) <= args.end]

sources = np.unique(df_LST["source"])
with open(args.ra) as f:
dict_ra = f.read()
with open(args.dec) as f:
dict_dec = f.read()
with open(args.source) as f:
dict_source = f.read()
with open(args.dec_mc) as f:
mc_dec = f.read()
with open(args.point) as f:
dict_point = f.read()
ra_dict = json.loads(dict_ra)
dec_dict = json.loads(dict_dec)
dec_mc = np.asarray(mc_dec.replace(",", "").split("\n")).astype(np.float64)
point_dict = json.loads(dict_point)
source_dict = json.loads(dict_source)
dec_mc = np.asarray(json.loads(mc_dec)).astype(np.float64)
print("MC declinations: \t", dec_mc)
print("\n\nChecking RA/Dec...\n\n")
i = 0
for src in sources:
Expand All @@ -133,17 +112,17 @@ def main():
)
except NameResolveError:
print(f"{i}: {src} not found in astropy. Looking to the dictionaries...")
if src in ra_dict.keys():
src_ra = float(ra_dict.get(src))
if (src in source_dict.keys()) and (source_dict.get(src)[0] != "NaN"):
src_ra = float(source_dict.get(src)[0])
df_LST["ra"] = np.where(df_LST["source"] == src, src_ra, df_LST["ra"])

else:
print(
f"\t {i}: {src} RA not in the dictionaries. Please add it to the dictionaries"
)

if src in dec_dict.keys():
src_dec = float(dec_dict.get(src))
if (src in source_dict.keys()) and (source_dict.get(src)[1] != "NaN"):
src_dec = float(source_dict.get(src)[1])
df_LST["dec"] = np.where(
df_LST["source"] == src, src_dec, df_LST["dec"]
)
Expand All @@ -161,8 +140,8 @@ def main():
print("\n\nChecking if point source...\n\n")
i = 0
for src in sources:
if src in point_dict.keys():
src_point = str(point_dict.get(src))
if (src in source_dict.keys()) and (source_dict.get(src)[2] != "NaN"):
src_point = str(source_dict.get(src)[2])
df_LST["point_source"] = np.where(
df_LST["source"] == src, src_point, df_LST["point_source"]
)
Expand Down
Loading

0 comments on commit 8814070

Please sign in to comment.