pyimcom 1.2.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyimcom/__init__.py +1 -0
- pyimcom/_version.py +24 -0
- pyimcom/analysis.py +1480 -0
- pyimcom/coadd.py +2331 -0
- pyimcom/compress/__init__.py +0 -0
- pyimcom/compress/compressutils.py +506 -0
- pyimcom/compress/compressutils_wrapper.py +116 -0
- pyimcom/compress/i24.py +514 -0
- pyimcom/config.py +1245 -0
- pyimcom/diagnostics/__init__.py +0 -0
- pyimcom/diagnostics/context_figure.py +58 -0
- pyimcom/diagnostics/dynrange.py +274 -0
- pyimcom/diagnostics/layer_diagnostics.py +208 -0
- pyimcom/diagnostics/mosaicimage.py +80 -0
- pyimcom/diagnostics/noise/stability.py +126 -0
- pyimcom/diagnostics/noise_diagnostics.py +709 -0
- pyimcom/diagnostics/outimage_utils/__init__.py +0 -0
- pyimcom/diagnostics/outimage_utils/helper.py +82 -0
- pyimcom/diagnostics/report.py +366 -0
- pyimcom/diagnostics/run.py +64 -0
- pyimcom/diagnostics/starcube_nonoise.py +264 -0
- pyimcom/diagnostics/starcube_nonoise_coldescr.txt +24 -0
- pyimcom/diagnostics/stars.py +469 -0
- pyimcom/imdestripe.py +2454 -0
- pyimcom/lakernel.py +805 -0
- pyimcom/layer.py +1439 -0
- pyimcom/layer_wrapper.py +96 -0
- pyimcom/meta/__init__.py +0 -0
- pyimcom/meta/distortimage.py +748 -0
- pyimcom/meta/ginterp.py +340 -0
- pyimcom/pictures/__init__.py +0 -0
- pyimcom/pictures/genpic.py +229 -0
- pyimcom/psfutil.py +2199 -0
- pyimcom/routine.py +588 -0
- pyimcom/splitpsf/__init__.py +0 -0
- pyimcom/splitpsf/imsubtract.py +793 -0
- pyimcom/splitpsf/imsubtract_wrapper.py +107 -0
- pyimcom/splitpsf/splitpsf.py +497 -0
- pyimcom/splitpsf/splitpsf_wrapper.py +161 -0
- pyimcom/splitpsf/update_cube.py +136 -0
- pyimcom/truthcats.py +396 -0
- pyimcom/utils/__init__.py +0 -0
- pyimcom/utils/compareutils.py +207 -0
- pyimcom/utils/piffutils.py +223 -0
- pyimcom/wcsutil.py +839 -0
- pyimcom-1.2.1.dist-info/METADATA +67 -0
- pyimcom-1.2.1.dist-info/RECORD +52 -0
- pyimcom-1.2.1.dist-info/WHEEL +5 -0
- pyimcom-1.2.1.dist-info/licenses/LICENSE +21 -0
- pyimcom-1.2.1.dist-info/scm_file_list.json +285 -0
- pyimcom-1.2.1.dist-info/scm_version.json +8 -0
- pyimcom-1.2.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import re
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
import matplotlib.pyplot as plt
|
|
6
|
+
import numpy as np
|
|
7
|
+
from astropy.io import fits
|
|
8
|
+
from mpl_toolkits.axes_grid1 import make_axes_locatable
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def load_row_profiles(directory, name_pattern):
|
|
12
|
+
"""
|
|
13
|
+
Load row median profiles from FITS files in a directory matching a name pattern.
|
|
14
|
+
Parameters
|
|
15
|
+
----------
|
|
16
|
+
directory : str
|
|
17
|
+
Path to the directory containing FITS files.
|
|
18
|
+
name_pattern : str
|
|
19
|
+
Regex pattern to match filenames.
|
|
20
|
+
|
|
21
|
+
Returns
|
|
22
|
+
-------
|
|
23
|
+
row_profiles : np.ndarray
|
|
24
|
+
2D array where each row corresponds to the row median profile of an image.
|
|
25
|
+
obsnames : list of str
|
|
26
|
+
List of observation names extracted from filenames.
|
|
27
|
+
"""
|
|
28
|
+
file_pattern = re.compile(name_pattern)
|
|
29
|
+
row_profiles = []
|
|
30
|
+
obsnames = []
|
|
31
|
+
|
|
32
|
+
for filename in sorted(os.listdir(directory)):
|
|
33
|
+
if m := file_pattern.match(filename):
|
|
34
|
+
obs = m.group(1)
|
|
35
|
+
with fits.open(os.path.join(directory, filename)) as hdul:
|
|
36
|
+
image = hdul[0].data
|
|
37
|
+
row_medians = np.median(image, axis=1)
|
|
38
|
+
row_profiles.append(row_medians)
|
|
39
|
+
obsnames.append(obs)
|
|
40
|
+
return np.array(row_profiles), obsnames
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def plot_row_stability_summary(row_profiles, SCA):
|
|
44
|
+
"""
|
|
45
|
+
Plot a summary of row stability including a heatmap of row median profiles
|
|
46
|
+
and a plot of mean ± std deviation across rows.
|
|
47
|
+
Parameters
|
|
48
|
+
----------
|
|
49
|
+
row_profiles : np.ndarray
|
|
50
|
+
2D array where each row corresponds to the row median profile of an image.
|
|
51
|
+
SCA : str
|
|
52
|
+
SCA identifier for labeling the plots.
|
|
53
|
+
Returns
|
|
54
|
+
-------
|
|
55
|
+
None
|
|
56
|
+
"""
|
|
57
|
+
n_images, n_rows = row_profiles.shape
|
|
58
|
+
|
|
59
|
+
# Compute per-row statistics
|
|
60
|
+
mean_profile = np.mean(row_profiles, axis=0)
|
|
61
|
+
std_profile = np.std(row_profiles, axis=0)
|
|
62
|
+
|
|
63
|
+
fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(10, 6), sharex=True, gridspec_kw={"height_ratios": [3, 1]})
|
|
64
|
+
|
|
65
|
+
# Top: Heatmap of row median profiles
|
|
66
|
+
im = ax1.imshow(
|
|
67
|
+
row_profiles,
|
|
68
|
+
aspect="auto",
|
|
69
|
+
cmap="viridis",
|
|
70
|
+
origin="lower",
|
|
71
|
+
vmin=np.percentile(row_profiles, 10),
|
|
72
|
+
vmax=np.percentile(row_profiles, 90),
|
|
73
|
+
)
|
|
74
|
+
ax1.set_ylabel("Observation Index")
|
|
75
|
+
ax1.set_title(f"Row Median Profiles Across Images: SCA {SCA}")
|
|
76
|
+
|
|
77
|
+
# Use make_axes_locatable to keep colorbar from shifting the axis
|
|
78
|
+
divider = make_axes_locatable(ax1)
|
|
79
|
+
cax = divider.append_axes("right", size="5%", pad=0.05)
|
|
80
|
+
plt.colorbar(im, cax=cax, label="Row Median (DN/fr)")
|
|
81
|
+
|
|
82
|
+
# Bottom: Mean ± std profile
|
|
83
|
+
x = np.arange(n_rows)
|
|
84
|
+
|
|
85
|
+
ax2.fill_between(
|
|
86
|
+
x,
|
|
87
|
+
mean_profile - std_profile,
|
|
88
|
+
mean_profile + std_profile,
|
|
89
|
+
color="yellowgreen",
|
|
90
|
+
label="±1 Sigma",
|
|
91
|
+
alpha=0.6,
|
|
92
|
+
)
|
|
93
|
+
ax2.fill_between(
|
|
94
|
+
x,
|
|
95
|
+
mean_profile - 2 * std_profile,
|
|
96
|
+
mean_profile + 2 * std_profile,
|
|
97
|
+
color="yellowgreen",
|
|
98
|
+
label="±2 Sigma",
|
|
99
|
+
alpha=0.2,
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
ax2.plot(x, mean_profile, color="black", label="Mean", linewidth=1)
|
|
103
|
+
|
|
104
|
+
ax2.set_ylim(-0.06, 0.06)
|
|
105
|
+
# ax2.set_yscale('symlog') # Optional symlog toggle
|
|
106
|
+
ax2.set_ylabel("Median Value (DN/fr)")
|
|
107
|
+
ax2.set_xlabel("Row Index")
|
|
108
|
+
ax2.set_title("Row-wise Mean ± Std")
|
|
109
|
+
|
|
110
|
+
ax2.legend()
|
|
111
|
+
plt.tight_layout()
|
|
112
|
+
plt.savefig(f"plots/row_stability_summary_{SCA}.png", bbox_inches="tight")
|
|
113
|
+
plt.close()
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
if __name__ == "__main__":
|
|
117
|
+
# --- Configuration ---
|
|
118
|
+
directory = sys.argv[1] # Set this
|
|
119
|
+
output_csv = "stripe_stability.csv"
|
|
120
|
+
|
|
121
|
+
# --- Run Analysis ---
|
|
122
|
+
for i in range(18):
|
|
123
|
+
SCA = str(i + 1)
|
|
124
|
+
name_pattern = r"slope_(\d*)_(" + SCA + ").fits"
|
|
125
|
+
row_profiles, filenames = load_row_profiles(directory, name_pattern, SCA=SCA)
|
|
126
|
+
plot_row_stability_summary(row_profiles, SCA=SCA)
|