Skip to content

Commit

Permalink
copy data in initialize
Browse files Browse the repository at this point in the history
  • Loading branch information
ConnorStoneAstro committed Jan 13, 2025
1 parent 407a00d commit c23f339
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions astrophot/models/_shared_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def parametric_segment_initialize(
return
# Get the sub-image area corresponding to the model image
target_area = target[model.window]
target_dat = target_area.data.detach().cpu().numpy()
target_dat = target_area.data.detach().cpu().numpy().copy()
if target_area.has_mask:
mask = target_area.mask.detach().cpu().numpy()
target_dat[mask] = np.median(target_dat[np.logical_not(mask)])
Expand Down Expand Up @@ -477,7 +477,7 @@ def spline_segment_initialize(

profR = parameters["I(R)"].prof.detach().cpu().numpy()
target_area = target[self.window]
target_dat = target_area.data.detach().cpu().numpy()
target_dat = target_area.data.detach().cpu().numpy().copy()
if target_area.has_mask:
mask = target_area.mask.detach().cpu().numpy()
target_dat[mask] = np.median(target_dat[np.logical_not(mask)])
Expand Down Expand Up @@ -578,7 +578,7 @@ def relspline_initialize(self, target=None, parameters=None, **kwargs):
super(self.__class__, self).initialize(target=target, parameters=parameters)

target_area = target[self.window]
target_dat = target_area.data.detach().cpu().numpy()
target_dat = target_area.data.detach().cpu().numpy().copy()
if target_area.has_mask:
mask = target_area.mask.detach().cpu().numpy()
target_dat[mask] = np.median(target_dat[np.logical_not(mask)])
Expand Down
2 changes: 1 addition & 1 deletion astrophot/models/galaxy_model_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def initialize(self, target=None, parameters: Optional[Parameter_Node] = None, *
if not (parameters["PA"].value is None or parameters["q"].value is None):
return
target_area = target[self.window]
target_dat = target_area.data.detach().cpu().numpy()
target_dat = target_area.data.detach().cpu().numpy().copy()
if target_area.has_mask:
mask = target_area.mask.detach().cpu().numpy()
target_dat[mask] = np.median(target_dat[np.logical_not(mask)])
Expand Down
2 changes: 1 addition & 1 deletion astrophot/models/multi_gaussian_expansion_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def initialize(self, target=None, parameters=None, **kwargs):
super().initialize(target=target, parameters=parameters)

target_area = target[self.window]
target_dat = target_area.data.detach().cpu().numpy()
target_dat = target_area.data.detach().cpu().numpy().copy()
if target_area.has_mask:
mask = target_area.mask.detach().cpu().numpy()
target_dat[mask] = np.median(target_dat[np.logical_not(mask)])
Expand Down
2 changes: 1 addition & 1 deletion astrophot/models/point_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def initialize(self, target=None, parameters=None, **kwargs):
if parameters["flux"].value is not None:
return
target_area = target[self.window]
target_dat = target_area.data.detach().cpu().numpy()
target_dat = target_area.data.detach().cpu().numpy().copy()
with Param_Unlock(parameters["flux"]), Param_SoftLimits(parameters["flux"]):
icenter = target_area.plane_to_pixel(parameters["center"].value)
edge = np.concatenate(
Expand Down

0 comments on commit c23f339

Please sign in to comment.