Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dependencies = [
"loguru>=0.7.0",
"matplotlib>=3.9.0",
"numpy>=2.0.0",
"pandas>=2.2.0",
"pandas>=2.2.0,<3.0.0",
"pfs-datamodel @ git+https://github.com/Subaru-PFS/datamodel.git",
"pfs-utils @ git+https://github.com/Subaru-PFS/pfs_utils.git",
"psycopg2-binary>=2.9.8",
Expand Down
8 changes: 6 additions & 2 deletions src/pfs_design_tool/pointing_utils/dbutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def generate_fluxstds_from_targetdb(
AND teff_gspphot BETWEEN {min_teff} AND {max_teff}
"""

except:
except ValueError:
extra_where += ""

if fluxstd_versions is not None:
Expand Down Expand Up @@ -598,6 +598,10 @@ def fixcols_gaiadb_to_targetdb(
# df["priority"][tb["g_mag_ab"].value - 7 > 12] = 9999
# df["priority"][np.isnan(tb["g_mag_ab"])] = 9

df.loc[df["pmra"].isna(), "pmra"] = 0.0
df.loc[df["pmdec"].isna(), "pmdec"] = 0.0
df.loc[df["parallax"].isna(), "parallax"] = 1.0e-7

return df


Expand Down Expand Up @@ -810,7 +814,7 @@ def fixcols_filler_targetdb(
df_obs_filler_done = pd.read_csv(
os.path.join(workDir, "ppp/df_obsfiller_done.csv")
)
except:
except FileNotFoundError:
# query qaDB to get executed pfsdesign
conn = connect_qadb(conf)
cur = conn.cursor()
Expand Down
8 changes: 4 additions & 4 deletions src/pfs_design_tool/pointing_utils/designutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ def generate_pfs_design(
np.nan,
]
)
except:
except (KeyError, TypeError):
dict_of_flux_lists["psf_flux"][i_fiber] = np.array(
[
np.nan,
Expand Down Expand Up @@ -605,7 +605,7 @@ def generate_pfs_design(
np.nan,
]
)
except:
except (TypeError, AttributeError):
dict_of_flux_lists["psf_flux"][i_fiber] = np.array(
[
np.nan,
Expand Down Expand Up @@ -1041,7 +1041,7 @@ def generate_guidestars_from_gaiadb(
pa=pa_deg,
cent=np.array([ra_tel_deg, dec_tel_deg]).reshape((2, 1)),
pm=np.stack([res[coldict["pmra"]], res[coldict["pmdec"]]], axis=0),
par=res[coldict["parallax"]],
par=res[coldict["parallax"]].copy(),
time=observation_time,
epoch=gaiadb_epoch,
)
Expand Down Expand Up @@ -1272,7 +1272,7 @@ def generate_guidestars_from_csv(
pa=pa_deg,
cent=np.array([ra_tel_deg, dec_tel_deg]).reshape((2, 1)),
pm=np.stack([res[coldict["pmra"]], res[coldict["pmdec"]]], axis=0),
par=res[coldict["parallax"]],
par=res[coldict["parallax"]].copy(),
time=observation_time,
epoch=gaiadb_epoch,
)
Expand Down
6 changes: 3 additions & 3 deletions src/pfs_design_tool/pointing_utils/nfutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ def fiber_allocation(

# exit()

if (df_filler is not None) and (two_stage == False):
if (df_filler is not None) and not two_stage:
print("[single-stage] Registering stars for fillers.")
targets += register_objects(
df_filler, target_class="sci", force_exptime=force_exptime
Expand Down Expand Up @@ -610,7 +610,7 @@ def fiber_allocation(
cobraSafetyMargin=cobraSafetyMargin,
)

if two_stage == False:
if not two_stage:
return (
res[0],
target_fppos[0],
Expand All @@ -621,7 +621,7 @@ def fiber_allocation(
bench,
)

elif two_stage == True:
elif two_stage:
# get cobra ID of the 1st-stage assignment
assign_1stage = {}
for i, (vis, tp, tel) in enumerate(zip(res, target_fppos, telescopes)):
Expand Down
33 changes: 15 additions & 18 deletions src/pfs_design_tool/reconfigure_fibers_ppp.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ def reconfigure_multiprocessing(

design_ids = {}
for i, pointing in enumerate(list_pointings):
if clearOutput == True:
if clearOutput:
clear_output()
# observation_time = Time.now().iso
observation_time = str(dict_pointings[pointing.lower()]["observation_time"][0])
Expand Down Expand Up @@ -613,17 +613,18 @@ def reconfigure_multiprocessing(
)
if conf["sfa"]["reduce_sky_targets"]:
n_sky_target = conf["sfa"]["n_sky_random"] # this value can be tuned
if "CFHTLS" in ppc_code: n_sky_target=4000
if "CFHTLS" in ppc_code:
n_sky_target = 4000
if len(df_sky) > n_sky_target:
df_sky = df_sky.sample(
n_sky_target, ignore_index=True, random_state=1
)
logger.info(f"Fetched sky target DataFrame: \n{df_sky}")

# get filler targets (optional)
if conf["sfa"]["filler"] == False:
if not conf["sfa"]["filler"]:
df_filler = None
if conf["sfa"]["dup_fluxstd_remove"] == True:
if conf["sfa"]["dup_fluxstd_remove"]:
_, df_filler_nocut = dbutils.generate_fillers_from_targetdb(
dict_pointings[pointing.lower()]["ra_center"],
dict_pointings[pointing.lower()]["dec_center"],
Expand Down Expand Up @@ -662,7 +663,7 @@ def reconfigure_multiprocessing(
logger.info(
f"Duplicates in fluxstds removed: {n_fluxstd_orig} --> {n_fluxstd_red}"
)
elif conf["sfa"]["filler"] == True:
elif conf["sfa"]["filler"]:
"""
df_filler_obs = dbutils.generate_targets_from_gaiadb(
dict_pointings[pointing.lower()]["ra_center"],
Expand Down Expand Up @@ -708,7 +709,7 @@ def reconfigure_multiprocessing(
)

# remove duplicates in df_fluxstds with df_filler_usr & df_sci
if conf["sfa"]["dup_fluxstd_remove"] == True:
if conf["sfa"]["dup_fluxstd_remove"]:
n_fluxstd_orig = len(df_fluxstds)
# Build SkyCoord for df_filler_fluxstds
coords_fluxstds = SkyCoord(
Expand Down Expand Up @@ -740,25 +741,21 @@ def reconfigure_multiprocessing(

if rsl_mode == "L":
df_filler_usr = df_filler_usr[
(df_filler_usr["is_medium_resolution"] == "L/M")
| (df_filler_usr["is_medium_resolution"] == False)
df_filler_usr["is_medium_resolution"].isin(["L/M", False])
]
df_filler_obs = df_filler_obs[
(df_filler_obs["is_medium_resolution"] == "L/M")
| (df_filler_obs["is_medium_resolution"] == False)
df_filler_obs["is_medium_resolution"].isin(["L/M", False])
]
if ppc_backup:
df_filler_usr = df_filler_usr[
df_filler_usr["grade"].isin(["G", "F"])
]
elif rsl_mode == "M":
df_filler_usr = df_filler_usr[
(df_filler_usr["is_medium_resolution"] == "L/M")
| (df_filler_usr["is_medium_resolution"] == True)
df_filler_usr["is_medium_resolution"].isin(["L/M", True])
]
df_filler_obs = df_filler_obs[
(df_filler_obs["is_medium_resolution"] == "L/M")
| (df_filler_obs["is_medium_resolution"] == True)
df_filler_obs["is_medium_resolution"].isin(["L/M", True])
]
if ppc_backup:
df_filler_usr = df_filler_usr[
Expand All @@ -770,8 +767,8 @@ def reconfigure_multiprocessing(

# --- case 1: too many user fillers → downsample user fillers only ---
if len(df_filler_usr) >= n_fillers:
unobs_usr = df_filler_usr[df_filler_usr["observed"] == False]
obs_usr = df_filler_usr[df_filler_usr["observed"] == True]
unobs_usr = df_filler_usr[~df_filler_usr["observed"]]
obs_usr = df_filler_usr[df_filler_usr["observed"]]

if len(unobs_usr) >= n_fillers:
df_filler_usr = unobs_usr.sample(n_fillers, random_state=1, ignore_index=True)
Expand All @@ -789,8 +786,8 @@ def reconfigure_multiprocessing(
n_needed = n_fillers - len(df_filler_usr)

# fill df_filler_obs using the same unobs-first rule
unobs_obs = df_filler_obs[df_filler_obs["observed"] == False]
obs_obs = df_filler_obs[df_filler_obs["observed"] == True]
unobs_obs = df_filler_obs[~df_filler_obs["observed"]]
obs_obs = df_filler_obs[df_filler_obs["observed"]]

if len(unobs_obs) >= n_needed:
df_filler_obs = unobs_obs.sample(n_needed, random_state=1, ignore_index=True)
Expand Down
4 changes: 2 additions & 2 deletions src/pfs_design_tool/subaru_fiber_allocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ def main():
df_targets = df_targets[~msk].reset_index()

# degrade priority of science targets (default: no degradation)
if args.degrade_priority_proposal == None:
if args.degrade_priority_proposal is None:
df_targets.priority += args.degrade_priority
else:
df_targets.priority[
Expand Down Expand Up @@ -617,7 +617,7 @@ def main():

try:
cobra_safety_margin = conf["netflow"]["cobra_safety_margin"]
except:
except KeyError:
cobra_safety_margin = 0.0

vis, tp, tel, tgt, tgt_class_dict, is_no_target, bench = nfutils.fiber_allocation(
Expand Down