Class: AstroSubframeOrganizer::FitsOrganizer
- Inherits:
-
Object
- Object
- AstroSubframeOrganizer::FitsOrganizer
- Includes:
- Logging
- Defined in:
- lib/astro_subframe_organizer/fits_organizer.rb
Overview
Main class responsible for interactively organizing FITS files based on their headers and user input.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(path = Dir.pwd, dry_run: nil) ⇒ FitsOrganizer
constructor
A new instance of FitsOrganizer.
-
#is_dry_run? ⇒ Boolean
rubocop:disable Naming/PredicatePrefix.
-
#organize ⇒ Object
Prompts the user to choose which organizing task to run.
- #organize_biases ⇒ Object
-
#organize_darks ⇒ Object
Organizes dark files by ISO, BIN, CCD-TEMP, EXPOSURE, and MONTH to facilitate the creation of master darks that may have varying temperatures.
-
#organize_flats ⇒ Object
Organizes flat files by FLATSET, ISO, BIN, EXP (EXPOSURE), TELESCOPE, and FILTER.
-
#organize_lights ⇒ Object
Organizes light files by FLATSET, ISO, BIN, EXP (EXPOSURE), TELESCOPE, and FILTER.
-
#remove_empty_directories ⇒ Object
Checks for empty directories.
-
#remove_jpg_thumbnails ⇒ Object
Removes all the jpg thumbnails under this directory.
-
#rename_from_exif ⇒ Object
Renames CR2 Raw files to match the same name pattern as ASIAir does based on EXIF data.
- #rename_to_img ⇒ Object
Methods included from Logging
Constructor Details
#initialize(path = Dir.pwd, dry_run: nil) ⇒ FitsOrganizer
Returns a new instance of FitsOrganizer.
10 11 12 13 14 |
# File 'lib/astro_subframe_organizer/fits_organizer.rb', line 10 def initialize(path = Dir.pwd, dry_run: nil) self.prompt = AstroSubframeOrganizer.prompt self.path = path self.dry_run = dry_run end |
Class Method Details
.run ⇒ Object
144 145 146 147 |
# File 'lib/astro_subframe_organizer/fits_organizer.rb', line 144 def self.run organizer = FitsOrganizer.new organizer.organize end |
Instance Method Details
#is_dry_run? ⇒ Boolean
rubocop:disable Naming/PredicatePrefix
104 105 106 |
# File 'lib/astro_subframe_organizer/fits_organizer.rb', line 104 def is_dry_run? # rubocop:disable Naming/PredicatePrefix dry_run.nil? ? prompt.yes?('Is this a dry run?', default: 'y') : dry_run end |
#organize ⇒ Object
Prompts the user to choose which organizing task to run. This is the main entry point of this script.
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/astro_subframe_organizer/fits_organizer.rb', line 115 def organize loop do = 'What are we organizing?' += ' (Dry Run)' if dry_run choice = prompt.enum_select , per_page: 8 do || .choice 'Darks', :darks .choice 'Flats', :flats .choice 'Lights', :lights .choice 'Biases', :biases .choice 'Remove empty directories', :empty_dirs .choice 'Remove jpg thumbnails', :thumbnails .choice 'Rename files from EXIF data', :rename .choice 'Quit', :quit end case choice when :darks then organize_darks when :flats then organize_flats when :lights then organize_lights when :biases then organize_biases when :empty_dirs then remove_empty_directories when :thumbnails then remove_jpg_thumbnails when :rename then rename_from_exif when :quit then break end end end |
#organize_biases ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/astro_subframe_organizer/fits_organizer.rb', line 37 def organize_biases Organizer.new( path: path, type: Astrophoto::BIAS, prompt: prompt, ).organize(dry_run: is_dry_run?) end |
#organize_darks ⇒ Object
Organizes dark files by ISO, BIN, CCD-TEMP, EXPOSURE, and MONTH to facilitate the creation of master darks that may have varying temperatures. This organization can be changed by updating Astrophoto#target_dir for the DARK type.
If the file has an exposure of less than 10 seconds, you will be asked if it is a flat dark. If so, it will be organized into a folder that will match your corresponding flat files so that you can run WBPP with just your biases, flat darks, and flats using the grouping keywords FLATSET, BIN, EXP, and ISO. CCD-TEMP will be ignored for the purposes of these files, as it is assumed they will be taken under roughly the same conditions as the flats are taken.
If the files are normal dark files, they will be organized by ISO, EXPOSURE, BIN, CCD-TEMP, and MONTH. With this, you can run WBPP with just bias and darks using the grouping keywords CCD-TEMP, ISO, EXP, and MONTH (optional).
29 30 31 32 33 34 35 |
# File 'lib/astro_subframe_organizer/fits_organizer.rb', line 29 def organize_darks Organizer.new( path: path, type: Astrophoto::DARK, prompt: prompt, ).organize(dry_run: is_dry_run?) end |
#organize_flats ⇒ Object
Organizes flat files by FLATSET, ISO, BIN, EXP (EXPOSURE), TELESCOPE, and FILTER. To change these properties, update Astrophoto#target_dir for the FLAT type. The TELESCOPE and FILTER keywords are for matching LIGHTS which will have the same keywords set when organized using this script.
You can run WBPP with just your biases, flat darks, and flats using the grouping keywords FLATSET, BIN, EXP, and ISO. CCD-TEMP will be ignored for the purposes of these files, as it is assumed they will be taken under roughly the same conditions as the flat darks are taken.
After running WBPP, you should delete the ‘EXP` keyword from the master flat file name (if present) before using that master flat in a WBPP integration run, since exposure time should not be considered when grouping flats to lights.
56 57 58 59 60 61 62 |
# File 'lib/astro_subframe_organizer/fits_organizer.rb', line 56 def organize_flats Organizer.new( path: path, type: Astrophoto::FLAT, prompt: prompt, ).organize(dry_run: is_dry_run?) end |
#organize_lights ⇒ Object
Organizes light files by FLATSET, ISO, BIN, EXP (EXPOSURE), TELESCOPE, and FILTER. To change these properties, update Astrophoto#target_dir for the LIGHT type. The TELESCOPE and FILTER keywords are for matching LIGHTS which will have the same keywords set when organized using this script.
CCD-TEMP is included in the group naming using a rounded value to facilitate consistent keyword matching in PixInsight WBPP, ensuring frames captured within a temperature range are grouped together.
You can run WBPP with just your master biases, master darks, and master flats using the grouping keywords FLATSET, BIN, EXP, CCD-TEMP, and ISO.
If you are running WBPP on multiple targets using this data, e.g. for a mosaic, you should make sure to use LIGHT as a post-processing keyword and register files using ‘auto by LIGHT`.
76 77 78 79 80 81 82 |
# File 'lib/astro_subframe_organizer/fits_organizer.rb', line 76 def organize_lights Organizer.new( path: path, type: Astrophoto::LIGHT, prompt: prompt, ).organize(dry_run: is_dry_run?) end |
#remove_empty_directories ⇒ Object
Checks for empty directories. Run this option after performing a move of previously organized data.
86 87 88 |
# File 'lib/astro_subframe_organizer/fits_organizer.rb', line 86 def remove_empty_directories Utils::EmptyDirectoryCleaner.new(path).cleanup(dry_run: is_dry_run?) end |
#remove_jpg_thumbnails ⇒ Object
Removes all the jpg thumbnails under this directory.
91 92 93 |
# File 'lib/astro_subframe_organizer/fits_organizer.rb', line 91 def remove_jpg_thumbnails Utils::ThumbnailCleaner.new(path).cleanup(dry_run: is_dry_run?) end |
#rename_from_exif ⇒ Object
Renames CR2 Raw files to match the same name pattern as ASIAir does based on EXIF data.
96 97 98 99 100 101 102 |
# File 'lib/astro_subframe_organizer/fits_organizer.rb', line 96 def rename_from_exif renamer = Utils::ExifRenamer.new(path) type = prompt.enum_select('What is the file type?', Astrophoto::TYPES) target = prompt.ask('What is the target name?') if type == Astrophoto::LIGHT renamer.rename(type: type, target: target, dry_run: is_dry_run?) end |
#rename_to_img ⇒ Object
108 109 110 111 |
# File 'lib/astro_subframe_organizer/fits_organizer.rb', line 108 def rename_to_img renamer = Utils::ExifRenamer.new(path) renamer.revert(dry_run: is_dry_run?) end |