|
1 | | -__all__ = [ 'gz_and_ext', 'sky_subtract', 'stampmaker' ] |
| 1 | +__all__ = [ 'sky_subtract', 'stampmaker' ] |
2 | 2 |
|
3 | 3 | # IMPORTS Standard: |
4 | | -import io |
5 | 4 | import numpy as np |
6 | | -import gzip |
7 | | -import multiprocessing |
8 | | -import shutil |
9 | 5 | import pathlib |
10 | 6 | import random |
11 | 7 |
|
12 | | -# IMPORTS Astro: |
13 | | -from astropy.io import fits |
14 | | - |
15 | 8 | # IMPORTS SFFT: |
16 | 9 | from sfft.utils.SExSkySubtract import SEx_SkySubtract |
17 | 10 | from sfft.utils.StampGenerator import Stamp_Generator |
|
22 | 15 | from snpit_utils.config import Config |
23 | 16 |
|
24 | 17 |
|
25 | | -def gz_and_ext(in_path, out_path): |
26 | | - """Utility function that unzips the original file and turns |
27 | | - it into a single-extension FITS file. |
28 | | -
|
29 | | - Parameters |
30 | | - ---------- |
31 | | - in_path: Path |
32 | | - The input path of the file to unzip and flatten. |
33 | | -
|
34 | | - out_path: Path |
35 | | - The desired output path of the file that is unzipped and flattened, once it is saved. |
36 | | -
|
37 | | - Returns |
38 | | - ------- |
39 | | - out_path: Path |
40 | | - The output path of the file that has been unzipped and flattened. |
41 | | -
|
42 | | - """ |
43 | | - |
44 | | - raise RuntimeError( "No longer needed." ) |
45 | | - |
46 | | - bio = io.BytesIO() |
47 | | - with gzip.open(in_path, 'rb') as f_in: |
48 | | - shutil.copyfileobj(f_in, bio) |
49 | | - bio.seek(0) |
50 | | - |
51 | | - with fits.open(bio) as hdu: |
52 | | - newhdu = fits.HDUList([fits.PrimaryHDU(data=hdu[1].data, header=hdu[0].header)]) |
53 | | - SNLogger.debug( f"Process {multiprocessing.current_process().pid} Writing extracted HDU 1 to {out_path}..." ) |
54 | | - newhdu.writeto(out_path, overwrite=True) |
55 | | - SNLogger.debug( f"...process {multiprocessing.current_process().pid} done writing " |
56 | | - f"extracted HDU 1 to {out_path}." ) |
57 | | - |
58 | | - return out_path |
59 | | - |
60 | | - |
61 | 18 | def sky_subtract( img, temp_dir=None ): |
62 | 19 | """Subtracts background, found with Source Extractor. |
63 | 20 |
|
|
0 commit comments