@@ -1465,13 +1465,13 @@ def fill_masked(self, fill_value, uncertainty_fill_value=None, unmask=False, fil
14651465
14661466 def to_nddata (self ,
14671467 * ,
1468- data = True ,
1469- wcs = True ,
1470- uncertainty = True ,
1471- mask = True ,
1472- unit = True ,
1473- meta = True ,
1474- psf = True ,
1468+ data = "copy" ,
1469+ wcs = "copy" ,
1470+ uncertainty = "copy" ,
1471+ mask = "copy" ,
1472+ unit = "copy" ,
1473+ meta = "copy" ,
1474+ psf = "copy" ,
14751475 nddata_type = NDData ,
14761476 ** kwargs ,
14771477 ):
@@ -1482,7 +1482,7 @@ def to_nddata(self,
14821482 this object, values can be altered on the output object by
14831483 setting a kwarg with the new value, e.g. ``data=new_data``.
14841484 Custom attributes on this class can be passed by setting that
1485- keyword to `True `, for example ``mycube.to_nddata(spam=True )``
1485+ keyword to `"copy" `, for example ``mycube.to_nddata(spam="copy" )``
14861486 is the equivalent of setting
14871487 ``mycube.to_nddata(spam=mycube.spam)``.
14881488 Any attributes not supported by the new class
@@ -1510,9 +1510,10 @@ def to_nddata(self,
15101510 kwargs:
15111511 Additional inputs to the ``nddata_type`` constructor. For example, to
15121512 set different data values on the returned object, set a kwarg ``data=new_data``,
1513- where ``new_data`` is an array of compatible shape and dtype. Note that kwargs
1514- given by the user and attributes on this instance that are not supported by the
1515- ``nddata_type`` constructor are ignored.
1513+ where ``new_data`` is an array of compatible shape and dtype.
1514+ Other keyword arguments can be specified to copy custom
1515+ attributes with the value ``"copy"``, for example
1516+ ``global_coords="copy"``.
15161517
15171518 Returns
15181519 -------
@@ -1543,8 +1544,10 @@ def to_nddata(self,
15431544 "meta" : meta ,
15441545 "psf" : psf ,
15451546 ** kwargs }
1546- # If any are True then copy by reference
1547- user_kwargs = {key : getattr (self , key ) if value is True else value for key , value in user_kwargs .items ()}
1547+ # If any are "copy" then copy by reference
1548+ user_kwargs = {key : getattr (self , key )
1549+ if isinstance (value , str ) and value == "copy" else value
1550+ for key , value in user_kwargs .items ()}
15481551 # Construct and return new instance.
15491552 return nddata_type (** user_kwargs )
15501553
0 commit comments