Open bkornpob opened 4 years ago
Another solution?: When supplying list of files during the astrodrizzle, shorten the file paths by using relative paths. This would be similar to the cookbook example.
New problem: Here is the full error report
KeyError Traceback (most recent call last)
in 3 os.chdir(cwd) 4 os.chdir("DIRECT") ----> 5 axetasks.iolprep(drizzle_image='DIRECT_drz.fits',input_cat='../SEX/cookbook.cat',dimension_in=dimension_info) 6 7 get_ipython().system('ls *.cat') ~/anaconda3/envs/pyaxe/lib/python3.7/site-packages/pyaxe/axesrc/axetasks.py in iolprep(drizzle_image, input_cat, dimension_in) 68 iol_maker = iolmaking.IOLMaker(drizzle_image, 69 input_cat, ---> 70 dimension_in) 71 iol_maker.run() 72 ~/anaconda3/envs/pyaxe/lib/python3.7/site-packages/pyaxe/axesrc/iolmaking.py in __init__(self, drizzle_image, input_cat, dim_term) 307 308 # create the list of Input Object Instances --> 309 self._fill_iollist() 310 311 def _set_dimension_info(self, dimension_term): ~/anaconda3/envs/pyaxe/lib/python3.7/site-packages/pyaxe/axesrc/iolmaking.py in _fill_iollist(self) 362 # create a new IOl instance at the end of the list 363 self.iol_list.append(ProjectionList(drizzle_head[keyname], --> 364 self.dim_info)) 365 366 def _get_niol(self): ~/anaconda3/envs/pyaxe/lib/python3.7/site-packages/pyaxe/axesrc/iolmaking.py in __init__(self, filename, dim_info) 53 54 # the the dimension of the input image ---> 55 self._set_indims() 56 57 # compute the dimension information ~/anaconda3/envs/pyaxe/lib/python3.7/site-packages/pyaxe/axesrc/iolmaking.py in _set_indims(self) 99 100 in_img = fits.open(self.iol_info['fits'], 'readonly') --> 101 in_head = in_img[self.iol_info['ext_nam'], self.iol_info['ext_ver']].header 102 103 # extract the keywords for the image size from ~/anaconda3/envs/pyaxe/lib/python3.7/site-packages/astropy/io/fits/hdu/hdulist.py in __getitem__(self, key) 305 try: 306 return self._try_while_unread_hdus(super().__getitem__, --> 307 self._positive_index_of(key)) 308 except IndexError as e: 309 # Raise a more helpful IndexError if the file was not fully read. ~/anaconda3/envs/pyaxe/lib/python3.7/site-packages/astropy/io/fits/hdu/hdulist.py in _positive_index_of(self, key) 759 """ 760 --> 761 index = self.index_of(key) 762 763 if index >= 0: ~/anaconda3/envs/pyaxe/lib/python3.7/site-packages/astropy/io/fits/hdu/hdulist.py in index_of(self, key) 740 741 if (found is None): --> 742 raise KeyError(f'Extension {key!r} not found.') 743 else: 744 return found KeyError: "Extension ('ts[sci', 1) not found."
Solved:
Here is the full error report:
I checked the error line (i.e., iolmaking.py at Line 64: exte_str = self.filename.split('.fits')[1]), and here is the result:
self.filename >>> idco02ptq_flt.f
I noticed that the filename is incorrect. So, I tracked when the self.filename was assigned. It was from Line 47 in iolmaking.py.
Before Line 47, it was Line 362-363 in iolmaking.py calling
The input drizzle_head[keyname] is the header of the drz file of direct images that loops over the keyname as (Line 359)
This simply reads the input images that were supplied in the astrodrizzle to make the drz file. And, I think this is where the name problem (i.e., recall self.filename >>> idco02ptq_flt.f) happened.
drizzle_head[keyname] supposes to return the full path to the file, however astrodrizzle limits the string length. That is why the name was cut to only idco02ptq_flt.f instead of .fits.
I tested this by running astrodrizzle from files with very very very long paths. And, the result was that drizzle_head[keyname] >>> /Users/kbhirombhakdi/_work/___GD153_pyaxe/DIRECT/abcdefghijklmno.
Solution?: since astrodrizzle seems to record drizzle_head[keyname] in the same sequence as the supplied input list, supplying the same input list as another input argument when calling axetasks.iolprep might be work. Instead of constructing self.filename from drizzle_head[keyname], use the input list (e.g., F140W.lis from the cookbook example).