Last active
May 3, 2023 06:34
-
-
Save mileslucas/f5be374deff6f398810534bd3f7fe340 to your computer and use it in GitHub Desktop.
quickselect scripts using ds9 interfaces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Glob | |
using SAOImageDS9 | |
function quickselect(glob_str; logscale=true) | |
# parse out the directory, if any | |
directory, globstr = splitdir(glob_str) | |
filelist = collect(glob(globstr, directory)) | |
N = length(filelist) | |
@info "Selecting through $N files" | |
# connect to ds9 and set up | |
DS9.connect() | |
DS9.set("cmap magma") | |
if logscale | |
DS9.set("scale log") | |
else | |
DS9.set("scale 99.5") | |
end | |
i = 1 | |
files_to_keep = filter(filelist) do file | |
@info "$i/$N [$(round((i - 1) / N * 100, digits=1)) %]" filename=file | |
DS9.set("file $file") | |
print("Keep this file? [Y/n]: ") | |
res = readline() | |
return isempty(res) || lowercase(res) == "y" | |
end | |
return files_to_keep | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pathlib import Path | |
from argparse import ArgumentParser | |
from pyds9 import DS9 | |
parser = ArgumentParser() | |
parser.add_argument("filenames", nargs="+") | |
def main(): | |
args = parser.parse_args() | |
ds9 = DS9() | |
ds9.set("cmap magma") | |
ds9.set("scale log") | |
for file in args.filenames: | |
path = Path(file) | |
ds9.set(f"file {path.absolute():s}") | |
res = input("Keep this file [Y/n]? ") | |
if res.lower() == "n": | |
continue | |
print(path) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment