Skip to content

Commit

Permalink
genralize docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
Jammy2211 committed Sep 26, 2022
1 parent dd260d8 commit 4214316
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 25 deletions.
17 changes: 12 additions & 5 deletions autocti/charge_injection/imaging/imaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,9 @@ def set_noise_scaling_map_list(
def from_fits(
cls,
layout,
image_path,
pixel_scales,
image_path=None,
image=None,
image_hdu=0,
noise_map_path=None,
noise_map_hdu=0,
Expand All @@ -168,9 +169,15 @@ def from_fits(
cosmic_ray_map_hdu=0,
):

ci_image = aa.Array2D.from_fits(
file_path=image_path, hdu=image_hdu, pixel_scales=pixel_scales
)
if image_path is not None and image is None:

ci_image = aa.Array2D.from_fits(
file_path=image_path, hdu=image_hdu, pixel_scales=pixel_scales
)

elif image is not None:

ci_image = image

if noise_map_path is not None:
ci_noise_map = aa.util.array_2d.numpy_array_2d_via_fits_from(
Expand All @@ -187,7 +194,7 @@ def from_fits(
hdu=pre_cti_data_hdu,
pixel_scales=pixel_scales,
)
else:
elif pre_cti_data is None:
raise exc.ImagingCIException(
"Cannot load pre_cti_data from .fits and pass explicit pre_cti_data."
)
Expand Down
2 changes: 0 additions & 2 deletions autocti/charge_injection/model/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ def log_likelihood_function(self, instance: ModelInstance) -> float:

logl = fit.log_likelihood

print(logl)

return logl

def hyper_noise_scalar_list_from(
Expand Down
8 changes: 4 additions & 4 deletions autocti/extract/two_d/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def array_2d_list_from(
self, array: aa.Array2D, pixels: Tuple[int, int]
) -> List[aa.Array2D]:
"""
Extract a specific region from every charge injection region on the charge injection image and return as a list
Extract a specific region from every signal region (e.g. the charge injection region of charge injection data) on the CTI calibration data and return as a list
of 2D arrays.
For example, this might extract the parallel EPERs of every charge injection region.
Expand All @@ -89,7 +89,7 @@ def array_2d_list_from(
Parameters
----------
array
The array from which the regions are extracted and put into the returned list of rrays.
The array from which the regions are extracted and put into the returned list of arrays.
pixels
The integer range of pixels between which the extraction is performed.
"""
Expand All @@ -111,7 +111,7 @@ def stacked_array_2d_from(
self, array: aa.Array2D, pixels: Tuple[int, int]
) -> np.ndarray:
"""
Extract a region (e.g. the parallel FPR) of every charge injection region on the charge injection image and
Extract a region (e.g. the parallel FPR) of every signal region (e.g. the charge injection region of charge injection data) on the CTI calibration data and
stack them by taking their mean.
This returns the 2D average of the extracted regions (e.g. the parallel FPRs) of all of the charge injection
Expand Down Expand Up @@ -181,7 +181,7 @@ def binned_array_1d_from(
self, array: aa.Array2D, pixels: Tuple[int, int]
) -> aa.Array1D:
"""
Extract a region (e.g. the parallel FPR) of every charge injection region on the charge injection image, stack
Extract a region (e.g. the parallel FPR) of every signal region (e.g. the charge injection region of charge injection data) on the CTI calibration data, stack
them by taking their mean and then bin them up to a 1D region (e.g. the 1D parallel FPR) by taking the mean
across the direction opposite to clocking (e.g. bin over the serial direction for a parallel FPR).
Expand Down
4 changes: 2 additions & 2 deletions autocti/extract/two_d/parallel_eper.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def binning_axis(self) -> int:

def region_list_from(self, pixels: Tuple[int, int]):
"""
Extract the parallel EPERs of every charge injection region on the charge injection image and return as a list
of 2D arrays.
Extract the parallel EPERs of every signal region (e.g. the charge injection region of charge injection data)
on the CTI calibration data and return as a list of 2D arrays.
The diagram below illustrates the extraction for `pixels=(0, 1)`:
Expand Down
4 changes: 2 additions & 2 deletions autocti/extract/two_d/serial_eper.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def binning_axis(self) -> int:

def region_list_from(self, pixels: Tuple[int, int]):
"""
Extract the serial EPERs of every charge injection region on the charge injection image and return as a list
of 2D arrays.
Extract the serial EPERs of every signal region (e.g. the charge injection region of charge injection data)
on the CTI calibration data and return as a list of 2D arrays.
Negative pixel values are supported to the `pixels` tuple, whereby columns in front of the serial EPERs
(e.g. the FPRs) are also extracted.
Expand Down
4 changes: 2 additions & 2 deletions autocti/extract/two_d/serial_fpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def binning_axis(self) -> int:

def region_list_from(self, pixels: Tuple[int, int]):
"""
Extract the serial FPR of every charge injection region on the charge injection image and return as a list
of 2D arrays.
Extract the serial FPR of every signal region (e.g. the charge injection region of charge injection data) on
the CTI calibration data and return as a list of 2D arrays.
Negative pixel values are supported to the `pixels` tuple, whereby columns in front of the serial FPRs (e.g.
the serial prescan) are also extracted.
Expand Down
2 changes: 1 addition & 1 deletion autocti/layout/two_d.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def layout_extracted_from(
) -> "Layout2D":
"""
The charge injection layout after an extraction is performed on its associated charge injection image, where
the extraction is defined by a region of pixel coordinates
the extraction is defined by a region of pixel coordinates:
(top-row, bottom-row, left-column, right-column) = (y0, y1, x0, x1)
Expand Down
18 changes: 11 additions & 7 deletions test_autocti/extract/two_d/test_parallel_calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,31 +86,35 @@ def test__extracted_layout_from():

def test__imaging_ci_from(imaging_ci_7x7):

print(imaging_ci_7x7.layout.shape_2d)

# The ci layout starts at column 1, so the left most column is removed below

extract = ac.Extract2DParallelCalibration(
shape_2d=imaging_ci_7x7.shape_native,
region_list=imaging_ci_7x7.layout.region_list,
)

parallel_calibration_imaging = extract.imaging_ci_from(
imaging_ci=imaging_ci_7x7, columns=(0, 6)
imaging_ci_parallel_calibration = extract.imaging_ci_from(
imaging_ci=imaging_ci_7x7, columns=(1, 3)
)

print(imaging_ci_parallel_calibration.layout.shape_2d)

assert (
parallel_calibration_imaging.image.native == imaging_ci_7x7.image.native[:, 1:7]
imaging_ci_parallel_calibration.image.native == imaging_ci_7x7.image.native[:, 1:7]
).all()
assert (
parallel_calibration_imaging.noise_map.native
imaging_ci_parallel_calibration.noise_map.native
== imaging_ci_7x7.noise_map.native[:, 1:7]
).all()
assert (
parallel_calibration_imaging.pre_cti_data.native
imaging_ci_parallel_calibration.pre_cti_data.native
== imaging_ci_7x7.pre_cti_data.native[:, 1:7]
).all()
assert (
parallel_calibration_imaging.cosmic_ray_map.native
imaging_ci_parallel_calibration.cosmic_ray_map.native
== imaging_ci_7x7.cosmic_ray_map.native[:, 1:7]
).all()

assert parallel_calibration_imaging.layout.region_list == [(1, 5, 0, 4)]
assert imaging_ci_parallel_calibration.layout.region_list == [(1, 5, 0, 4)]
12 changes: 12 additions & 0 deletions to_do_list
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@ __Workspace__

- Copy from Bayesian description stuff from HowToFit.


__Bugs__

- ImagingCI should not _need_ pre_cti_data (or have bool to turn off the need) because of pre_cti image estimate.


__Paper__

- readthedocs.
- introduction notebook.


__Visualization__

- Always use square axis liimits even if extracted data is rectangular.


__TimeEvolution Mock Data Product__

- Refresh brain on how this works with DataModel.
Expand Down

0 comments on commit 4214316

Please sign in to comment.