Skip to content
This repository has been archived by the owner on Oct 26, 2022. It is now read-only.

Commit

Permalink
Discard images not taken in any of the given --filters
Browse files Browse the repository at this point in the history
  • Loading branch information
Víctor Terrón committed Sep 3, 2014
1 parent 8a4bdb2 commit 2ea430f
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions photometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,34 +746,36 @@ def get_date(img):

# The --filter option allows the user to specify on which FITS files, among
# all those received as input, photometry must be done: only those files in
# the options.filter photometric filter. The Passband class, which supports
# comparison operations, makes it possible to compare filters for what they
# really are, not how they were written: "Johnson V" and "johnson_v", for
# example, are the same filter after all, but if we just compared the two
# strings we would consider them to be different.
if options.filter:

msg = "%sIgnoring images not taken in the '%s' photometric filter..."
print msg % (style.prefix, options.filter) ,
# any of the photometric filters contained in options.filter. The Passband
# class, which supports comparison operations, makes it possible to compare
# filters for what they really are, not how they were written: "Johnson V"
# and "johnson_v", for example, are the same filter after all, but if we
# just compared the two strings we would consider them to be different.

if options.filters:

msg = "%sIgnoring images not taken in any of the following filters:"
print msg % style.prefix
for index, pfilter in enumerate(sorted(options.filters)):
print "%s (%d) %s" % (style.prefix, index + 1, pfilter)
sys.stdout.flush()

discarded = 0
for pfilter, images in files.items():
if pfilter != options.filter:
if pfilter not in options.filters:
discarded += len(images)
del files[pfilter]

if not files:
print
msg = "%sError. No image was taken in the '%s' filter."
print msg % (style.prefix, options.filter)
msg = "%sError. No image was taken in any of the above filters."
print msg % style.prefix
print style.error_exit_message
return 1

else:
print 'done.'
msg = "%s%d images taken in the '%s' filter, %d were discarded."
print msg % (style.prefix, len(files), options.filter, discarded)
msg = "%s%d images taken in the above filters, %d were discarded."
print msg % (style.prefix, len(files), discarded)

# If a JSON file is specified with --annuli, it must list the photometric
# parameters for all the filters on which photometry is to be done.
Expand Down

0 comments on commit 2ea430f

Please sign in to comment.