Generation of a defined wavelength section from a fits-1d spectrum

Sometimes one would like to process only a defined wavelength range from a „long“ 1d spectrum (e.g. Echelle spectrum), for example for cross correlations or comparisons in a time series. Then a program is desired which can generate such a crop and save the shortened spectrum as .fit and/or as .dat with an additional name.

The Python3 code Crop_fits.py (download here) performs these tasks. It generates two new files xxx_6000_6700.fit and xxx_6000_6700.dat from one spectrum  xxx.fit, and graphically displays the spectrum shortened to the wavelength range 6000 to 6700 Angstroms. The wavelength range is of course freely selectable. In the fit file the header entries CVAL1 (start of wavelength) and NAXIS1 (number of pixels) are adapted accordingly. In the dat file there are two tab-separated columns, overwritten with ‚WAVE‘ and ‚FLUX‘.

The program also plots the original spectrum and the shortened one into 2 graphics, which can also be saved as PDF and/or PNG if desired (commenting out lines 75 -77 and/or 105 -107).

180426_norm_screenshot
Screenshot of Spyder

 

180426_norm_complete
Original spectrum
180426_norm_crop
Cropped spectrum