new_contents: #!/usr/bin/env python3
  # -*- coding: utf-8 -*-
  
  # Copyright (c) 2016 Jérémie DECOCK (http://www.jdhp.org)
  
  # This script is provided under the terms and conditions of the MIT license:
  # Permission is hereby granted, free of charge, to any person obtaining a copy
  # of this software and associated documentation files (the "Software"), to deal
  # in the Software without restriction, including without limitation the rights
  # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  # copies of the Software, and to permit persons to whom the Software is
  # furnished to do so, subject to the following conditions:
  # The above copyright notice and this permission notice shall be included in
  # all copies or substantial portions of the Software.
  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  # THE SOFTWARE.
  
  import os
  import numpy as np
  from datapipe.io import images
  import shutil
  
  def main(input_file_or_dir_path_list,
           output_file_path):
  
      image_counter = 0
  
      for input_file_or_dir_path in input_file_or_dir_path_list:
  
          if os.path.isdir(input_file_or_dir_path):
              input_file_path_list = []
              for dir_item in os.listdir(input_file_or_dir_path):
                  dir_item_path = os.path.join(input_file_or_dir_path, dir_item)
                  if dir_item_path.lower().endswith('.fits') and os.path.isfile(dir_item_path):
                      input_file_path_list.append(dir_item_path)
          else:
              input_file_path_list = [input_file_or_dir_path]
  
          for input_file_path in input_file_path_list:
  
              if image_counter > 1000:
                  break
  
              fits_images_dict, fits_metadata_dict = images.load_benchmark_images(input_file_path)
  
              if 50 <= fits_metadata_dict["npe"] <= 400:
                  print(image_counter, input_file_path)
                  shutil.copy(input_file_path, output_file_path)
                  image_counter += 1
  
  
  if __name__ == "__main__":
      main(["/Users/jdecock/astri_data/fits_flashcam/gamma/"], "/Volumes/ramdisk/flashcam/fits/gamma/")
  
  
subject: Add a tool script.