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

Add check-quads-for-sources script from generate_features_slurm #575

Merged
Merged
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
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ scope-manage-annotation = "tools.scope_manage_annotation:main"
post-taxonomy = "tools.taxonomy:main"
generate-features = "tools.generate_features:main"
generate-features-slurm = "tools.generate_features_slurm:main"
check-quads-for-sources = "tools.generate_features_slurm:check_quads_for_sources"
generate-features-job-submission = "tools.generate_features_job_submission:main"
train-algorithm-slurm = "tools.train_algorithm_slurm:main"
train-algorithm-job-submission = "tools.train_algorithm_job_submission:main"
Expand Down
51 changes: 51 additions & 0 deletions tools/generate_features_slurm.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ def check_quads_for_sources(
:return missing_ccd_quad: boolean stating whether each field in fields has no sources in at least one ccd/quad
"""

parser = get_check_quads_parser()
args, _ = parser.parse_known_args()

fields = args.fields
catalog = args.catalog
count_sources = args.count_sources
minobs = args.minobs
save = args.save
filename = args.filename

running_total_sources = 0
has_sources = np.zeros(len(fields), dtype=bool)
missing_ccd_quad = np.zeros(len(fields), dtype=bool)
Expand Down Expand Up @@ -176,6 +186,47 @@ def check_quads_for_sources(
return field_dct, has_sources, missing_ccd_quad


def get_check_quads_parser():
parser = argparse.ArgumentParser()
parser.add_argument(
"--fields",
type=int,
nargs="+",
default=np.arange(0, 2000),
help="list of integer field numbers to query",
)
parser.add_argument(
"--catalog",
type=str,
default=source_catalog,
help="name of source catalog to query",
)
parser.add_argument(
"--count-sources",
action="store_true",
help="if set, count number of sources per quad and return",
)
parser.add_argument(
"--minobs",
type=int,
default=0,
help="minimum number of observations needed to count a source",
)
parser.add_argument(
"--save",
action="store_true",
help="if set, save results dictionary in json format",
)
parser.add_argument(
"--filename",
type=str,
default="catalog_completeness",
help="filename of saved results",
)

return parser


def get_slurm_parser():

fg_parser = get_parser(add_help=False)
Expand Down
Loading