Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let svdmodel-benchmark take comma-separated filters #315

Merged
Merged
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
30 changes: 18 additions & 12 deletions nmma/em/svdmodel_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,8 @@ def get_parser():
)
parser.add_argument(
"--filters",
nargs="+",
type=str,
help="A space-seperated list of filters to use (e.g. g r i). If none is provided, will use all the filters available",
help="A space-seperated list of filters to use (e.g. ztfg,ztfr,ztfi). If none is provided, will use all the filters available",
)
parser.add_argument(
"--ncpus",
Expand Down Expand Up @@ -163,6 +162,22 @@ def create_benchmark(
model_function = MODEL_FUNCTIONS[model]
grid_training_data, parameters = model_function(grid_data)

# get the filts
if not filters:
first_entry_name = list(grid_training_data.keys())[0]
first_entry = grid_training_data[first_entry_name]
filts = first_entry.keys() - set(["t"] + parameters)
filts = list(filts)
elif isinstance(filters, str):
filts = filters.replace(" ", "") # remove all whitespace
filts = filts.split(",")
else:
# list input from analysis test code
filts = filters

if len(filts) == 0:
raise ValueError("Need at least one valid filter.")

# create the SVDlight curve model
sample_times = np.arange(tmin, tmax + dt, dt)
light_curve_model = SVDLightCurveModel(
Expand All @@ -171,19 +186,10 @@ def create_benchmark(
svd_path=svd_path,
mag_ncoeff=svd_ncoeff,
interpolation_type=interpolation_type,
filters=filters,
filters=filts,
local_only=local_only,
)

# get the filts
if not filters:
first_entry_name = list(grid_training_data.keys())[0]
first_entry = grid_training_data[first_entry_name]
filts = first_entry.keys() - set(["t"] + parameters)
filts = list(filts)
else:
filts = filters

print(f"Benchmarking model {model} on filter {filts} with {ncpus} cpus")

def chi2_func(grid_entry_name, data_time_unit="days"):
Expand Down
Loading