@@ -108,6 +108,11 @@ def _set_default_data_label(self, *args):
108108 # only show the prefix and append the extension later during import
109109 self .data_label_default = prefix
110110 self .data_label_is_prefix = True
111+ elif isinstance (self .input , NDData ):
112+ # will append with [DATA]/[UNCERTAINTY]/[MASK] later
113+ # TODO: allow user to select extensions and include in same logic as HDUList
114+ self .data_label_default = prefix
115+ self .data_label_is_prefix = True
111116 else :
112117 self .data_label_default = prefix
113118 self .data_label_is_prefix = False
@@ -136,10 +141,22 @@ def __call__(self, show_in_viewer=True):
136141 # self.output is always a list of Data objects
137142 outputs = self .output
138143
139- exts = self .extension .selected_name if self .input_hdulist else [None ] * len (outputs )
140- hdus = self .extension .selected_hdu if self .input_hdulist else [None ] * len (outputs )
144+ if self .input_hdulist :
145+ exts = self .extension .selected_name
146+ hdus = self .extension .selected_hdu
147+ elif isinstance (self .input , NDData ):
148+ exts = ['DATA' , 'MASK' , 'UNCERTAINTY' ] # must match order in _nddata_to_glue_data
149+ hdus = [None ] * len (outputs )
150+ else :
151+ exts = [None ] * len (outputs )
152+ hdus = [None ] * len (outputs )
141153
142154 for output , ext , hdu in zip (outputs , exts , hdus ):
155+ if output is None :
156+ # needed for NDData where one of the "extensions" might
157+ # not be present. Remove this once users can select
158+ # which to import.
159+ continue
143160 if self .data_label_is_prefix :
144161 # If data_label is a prefix, we need to append the extension
145162 # to the data label.
@@ -226,6 +243,7 @@ def _nddata_to_glue_data(ndd):
226243 for attrib in ('data' , 'mask' , 'uncertainty' ):
227244 arr = getattr (ndd , attrib )
228245 if arr is None :
246+ returned_data .append (None )
229247 continue
230248 comp_label = attrib .upper ()
231249 cur_data = Data ()
0 commit comments