|
1 | | -TEST |
| 1 | +# README for reduction_phangs_hst |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +The reduction_phangs_hst repository provides tools and pipelines for reducing and analyzing Hubble Space Telescope (HST) observations as part of the PHANGS-HST project. It includes workflows for continuum subtraction, extinction correction, and emission line analysis of HST narrowband observations, with optional integration of MUSE data for calibration. |
| 6 | + |
| 7 | +See Chandar et al. 2024 paper for more details. |
| 8 | + |
| 9 | +Features |
| 10 | +* Continuum Subtraction |
| 11 | + * Advanced subtraction of stellar continuum from narrowband HST images (e.g., F658N for H-alpha). |
| 12 | + * Optional integration with MUSE data for background and [NII] contamination correction. |
| 13 | + * Simplified continuum subtraction without MUSE data. |
| 14 | +* Extinction Correction: |
| 15 | + * Applies forground corrections based on input extinction values. |
| 16 | +* Modular Pipeline: |
| 17 | + * Customizable for vario us scientific goals, including emission line analysis and star formation studies. |
| 18 | + |
| 19 | +## Directory Structure and Requirements |
| 20 | + |
| 21 | +The pipeline expects a specific directory structure for input and output files. Ensure your data is organized accordingly before running the pipeline. |
| 22 | + |
| 23 | +### Expected Input Directory Structure |
| 24 | + |
| 25 | +For example, the current setup is the following: |
| 26 | + |
| 27 | +```rootdir = '/Users/abarnes/Dropbox/work/Smallprojects/galaxies/data_hstha/'``` |
| 28 | + |
| 29 | +### Example galaxy: ic5332 |
| 30 | + |
| 31 | +``` |
| 32 | +# HST data |
| 33 | +rootdir/ic5332/hst/ |
| 34 | + - ic5332_uvis_f658n_exp_drc_sci.fits # Narrowband science image |
| 35 | + - ic5332_uvis_f555w_exp_drc_sci.fits # Broadband filter image (F555W) |
| 36 | + - ic5332_uvis_f814w_exp_drc_sci.fits # Broadband filter image (F814W) |
| 37 | + - ic5332_uvis_f658n_err_drc_wht.fits # Narrowband error image |
| 38 | + - ic5332_uvis_f555w_err_drc_wht.fits # Broadband error image (F555W) |
| 39 | + - ic5332_uvis_f814w_err_drc_wht.fits # Broadband error image (F814W) |
| 40 | +
|
| 41 | +# MUSE data |
| 42 | +# Note that these MUSE images are only needed if running for with MUSE |
| 43 | +# See below for different run cases... |
| 44 | +rootdir/ic5332/muse/ |
| 45 | + - IC5332-0.87asec_UVIS_F658N.fits # Synthetic F658N image from MUSE |
| 46 | + - IC5332-0.87asec_UVIS_F555W.fits # Synthetic F555W image from MUSE |
| 47 | + - IC5332-0.87asec_UVIS_F814W.fits # Synthetic F814W image from MUSE |
| 48 | + - IC5332_starmask.fits # Star mask |
| 49 | + - IC5332_nebmask.fits # Nebula mask |
| 50 | + - IC5332-0.87asec_MAPS.fits # MUSE MAPS file |
| 51 | +
|
| 52 | +# HST Filter transmission curves |
| 53 | +rootdir/../data_misc/hst_filters/ |
| 54 | + - HST_ACS_WFC.F550M.dat |
| 55 | + - HST_ACS_WFC.F555W.dat |
| 56 | + - HST_ACS_WFC.F658N.dat |
| 57 | + - HST_ACS_WFC.F814W.dat |
| 58 | + - HST_WFC3_UVIS1.F555W.dat |
| 59 | + - HST_WFC3_UVIS1.F657N.dat |
| 60 | + - HST_WFC3_UVIS1.F658N.dat |
| 61 | + - HST_WFC3_UVIS1.F814W.dat |
| 62 | + - (and other relevant HST filter throughput files) |
| 63 | +``` |
| 64 | + |
| 65 | +### Output Files |
| 66 | + |
| 67 | +Processed outputs (e.g., continuum-subtracted images, calibrated H-alpha maps) will be saved in directories within the same rootdir under (`rootdir/ic5332/hst_contsub/`). The pipeline will create subdirectories for specific results if they do not already exist. |
| 68 | + |
| 69 | +## Installation and Dependencies |
| 70 | + |
| 71 | +### Dependencies |
| 72 | + |
| 73 | +This project requires Python 3.x and several scientific libraries for data handling, analysis, and visualization. Below is the complete list of required Python packages: |
| 74 | + |
| 75 | +Core Dependencies: |
| 76 | +* Astropy: FITS file handling, WCS manipulation, modeling, and statistical tools |
| 77 | + * astropy.io.fits |
| 78 | + * astropy.wcs |
| 79 | + * astropy.units |
| 80 | + * astropy.stats |
| 81 | + * astropy.convolution |
| 82 | + * astropy.modeling |
| 83 | + * astropy.table |
| 84 | +* Numpy: Numerical computations (numpy) |
| 85 | +* Scipy: Advanced data processing and optimization (scipy.ndimage, scipy.optimize) |
| 86 | +* Matplotlib: Visualization (matplotlib.pyplot, matplotlib.ticker) |
| 87 | +* Photutils: Background subtraction and source extraction (photutils.background) |
| 88 | +* Reproject: Reprojecting astronomical images (reproject) |
| 89 | +* Radio_beam: Beam manipulation for radio astronomy data (radio_beam.Beam) |
| 90 | +* Synphot: Synthetic photometry tools (synphot.SpectralElement, synphot.units) |
| 91 | +* Extinction: Extinction curve calculation (extinction) |
| 92 | +* Aplpy: Astronomical data visualization (aplpy) |
| 93 | +* DeepCR: Cosmic ray cleaning for astronomical data (deepCR) |
| 94 | + |
| 95 | +Other Utilities |
| 96 | +* Colorcet: Colormap utilities (colorcet) |
| 97 | +* Glob: File search with patterns (glob) |
| 98 | +* Warnings: Suppressing warnings (warnings) |
| 99 | +* Datetime: Handling date and time (datetime) |
| 100 | +* OS: Operating system utilities (os) |
| 101 | + |
| 102 | +Additional Features |
| 103 | + |
| 104 | +These packages are used for advanced functionalities, such as Gaussian convolution, background matching, and handling of data at different resolutions: |
| 105 | +* Astropy.convolution: Convolution and replacing NaNs |
| 106 | +* Astropy.stats.mad_std: Median absolute deviation for robust statistics |
| 107 | +* Scipy.ndimage: Binary dilation and closing |
| 108 | +* Extinction: Calculating dust extinction |
| 109 | + |
| 110 | +For specific modules (e.g., deepCR), additional installation steps may be required. Refer to the module documentation for detailed instructions. |
| 111 | + |
| 112 | +Let me know if you need further assistance! |
| 113 | + |
| 114 | +## Usage |
| 115 | + |
| 116 | +### Running the Continuum Subtraction Pipeline with MUSE |
| 117 | + |
| 118 | +1. Open the Jupyter Notebook: |
| 119 | + |
| 120 | + ```jupyter notebook hstha_pipeline/run_pipeline/run_pipeline_contsub_withmuse.ipynb``` |
| 121 | + |
| 122 | + |
| 123 | +2. Follow the notebook’s step-by-step instructions to: |
| 124 | + * Load the HST narrowband and broadband images. |
| 125 | + * Apply continuum subtraction using MUSE synthetic photometry. |
| 126 | + * Perform background and [NII] corrections. |
| 127 | + * Generate corrected H-alpha maps. |
| 128 | + |
| 129 | +### Running the Continuum Subtraction Pipeline without MUSE |
| 130 | + |
| 131 | +For cases where MUSE data is unavailable, a simplified continuum subtraction pipeline is available: |
| 132 | + |
| 133 | +1. Open the notebook: |
| 134 | + |
| 135 | +```jupyter notebook hstha_pipeline/run_pipeline/run_pipeline_contsub_withoutmuse.ipynb``` |
| 136 | + |
| 137 | + |
| 138 | +2. Follow the instructions to: |
| 139 | + * Load HST narrowband and broadband images. |
| 140 | + * Perform continuum subtraction without applying MUSE-based corrections. |
| 141 | + |
| 142 | +### Custom usage |
| 143 | + |
| 144 | +For custom use cases, you could edit or create versions of the following pipeline commands: |
| 145 | + |
| 146 | +#### With MUSE |
| 147 | +``` |
| 148 | + def initial_pipeline(self): |
| 149 | +
|
| 150 | + self.load_data_hst() |
| 151 | + self.load_data_muse() |
| 152 | + self.load_data_muse_stars() |
| 153 | + self.load_data_muse_neb() |
| 154 | + self.load_data_muse_halpha() |
| 155 | + self.load_data_hst_inv() |
| 156 | + self.get_resolution() |
| 157 | + self.get_bandpass_info() |
| 158 | + self.get_sampletable_info() |
| 159 | + self.get_extinction() |
| 160 | +``` |
| 161 | +``` |
| 162 | + def continuum_subtraction_pipeline_withMUSE(self): |
| 163 | + |
| 164 | + time_start = time.time() |
| 165 | +
|
| 166 | + self.get_clean_paths() |
| 167 | + self.load_and_preprocess_errors() |
| 168 | + self.preprocess_hst_data() |
| 169 | +
|
| 170 | + self.apply_covmask() |
| 171 | + self.convert_units() |
| 172 | + self.smooth_and_regrid() |
| 173 | + self.background_correction_from_muse() |
| 174 | + self.correct_extinction() |
| 175 | + self.subtract_continuum_all() |
| 176 | +
|
| 177 | + self.convert_to_physical_units() |
| 178 | + self.NII_correction_from_muse() |
| 179 | + self.generate_map_plots() |
| 180 | + self.clean_headers() |
| 181 | + self.convert_units_to_arcsec2() |
| 182 | + # self.convert_to_cdelt() |
| 183 | + self.save_fit_tables() |
| 184 | +
|
| 185 | + time_end = time.time() |
| 186 | + time_elapsed = time_end - time_start |
| 187 | + print(f"Run time: {time_elapsed/60} mins") |
| 188 | +``` |
| 189 | + |
| 190 | +#### Without MUSE |
| 191 | +``` |
| 192 | + def initial_pipeline_noMUSE(self): |
| 193 | +
|
| 194 | + self.load_data_hst() |
| 195 | + self.load_data_hst_inv() |
| 196 | + self.get_bandpass_info() |
| 197 | + self.get_sampletable_info() |
| 198 | + self.get_extinction() |
| 199 | +``` |
| 200 | +``` |
| 201 | + def continuum_subtraction_pipeline_noMUSE(self): |
| 202 | +
|
| 203 | + time_start = time.time() |
| 204 | +
|
| 205 | + self.get_clean_paths() |
| 206 | + self.load_and_preprocess_errors() |
| 207 | + self.preprocess_hst_data() |
| 208 | + self.apply_covmask() |
| 209 | + self.convert_units() |
| 210 | + self.correct_extinction() |
| 211 | + self.subtract_continuum_witherr_hst() |
| 212 | + self.convert_to_physical_units() |
| 213 | + self.generate_map_plots() |
| 214 | + self.clean_headers() |
| 215 | + self.convert_units_to_arcsec2() |
| 216 | + # self.convert_to_cdelt() |
| 217 | +
|
| 218 | + time_end = time.time() |
| 219 | + time_elapsed = time_end - time_start |
| 220 | + print(f"Run time: {time_elapsed/60} mins") |
| 221 | +``` |
| 222 | + |
| 223 | + |
| 224 | + |
| 225 | +## Contributing |
| 226 | + |
| 227 | +Contributions are welcome! If you find a bug, have a question, or want to propose new features: |
| 228 | +1. Open an issue on GitHub. |
| 229 | +2. Fork the repository and create a pull request with your changes. |
| 230 | + |
| 231 | +## License |
| 232 | + |
| 233 | +This project is licensed under the MIT License. |
| 234 | + |
| 235 | +## Contact |
| 236 | + |
| 237 | +For any inquiries, please reach out via GitHub or email at ashley.barnes@eso.org. |
0 commit comments