Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Value error while using auto_script.make_filter_combintions #117

Open
Rimi98 opened this issue Nov 12, 2022 · 3 comments
Open

Value error while using auto_script.make_filter_combintions #117

Rimi98 opened this issue Nov 12, 2022 · 3 comments

Comments

@Rimi98
Copy link

Rimi98 commented Nov 12, 2022

I'm getting this error while trying to make the filter combination of cal.fits files downloaded from stsci.edu using auto_script.py routine of Grizli. It is giving the value error saying there is some non ASCII characters in fits header. But I have processed images having same fits header earlier using this same routine as mentioned in ceers_nircam notebook. Its throwing this same error while trying to make catalogue from CEERS published image in their official website https://ceers.github.io/dr05.html?s=03#nircam-imaging

the error:

auto_script.make_filter_combinations(root, weight_fnu=True, min_count=1,
filter_combinations={'lw': ['F277W','F356W','F444W']})

indef-f277w_drz_sci.fits f277w lw block_reduce=False scl=0.24861448760009672 scl_wht=3.9234162936476285

ValueError Traceback (most recent call last)
Cell In [74], line 1
----> 1 auto_script.make_filter_combinations(root, weight_fnu=True, min_count=1,
2 filter_combinations={'lw': ['F277W','F356W','F444W']})

File ~/grizli/grizli/pipeline/auto_script.py:4196, in make_filter_combinations(root, weight_fnu, filter_combinations, force_photfnu, min_count, block_filters)
4194 else:
4195 for k in im_i[0].header:
-> 4196 head[band][k] = im_i[0].header[k]
4198 for k in ref_h_i:
4199 head[band][k] = ref_h_i[k]

File ~/anaconda3/envs/grizli39/lib/python3.9/site-packages/astropy/io/fits/header.py:207, in Header.setitem(self, key, value)
203 self._modified = True
204 else:
205 # If we get an IndexError that should be raised; we don't allow
206 # assignment to non-existing indices
--> 207 self._update((key, value, comment))

File ~/anaconda3/envs/grizli39/lib/python3.9/site-packages/astropy/io/fits/header.py:1696, in Header._update(self, card)
1694 self._modified = True
1695 elif keyword in Card._commentary_keywords:
-> 1696 cards = self._splitcommentary(keyword, value)
1697 if keyword in self._keyword_indices:
1698 # Append after the last keyword of the same type
1699 idx = self.index(keyword, start=len(self) - 1, stop=-1)

File ~/anaconda3/envs/grizli39/lib/python3.9/site-packages/astropy/io/fits/header.py:1938, in Header._splitcommentary(self, keyword, value)
1936 cards = []
1937 while idx < len(valuestr):
-> 1938 cards.append(Card(keyword, valuestr[idx:idx + maxlen]))
1939 idx += maxlen
1940 return cards

File ~/anaconda3/envs/grizli39/lib/python3.9/site-packages/astropy/io/fits/card.py:194, in Card.init(self, keyword, value, comment, **kwargs)
192 self.keyword = keyword
193 if value is not None:
--> 194 self.value = value
196 if comment is not None:
197 self.comment = comment

File ~/anaconda3/envs/grizli39/lib/python3.9/site-packages/astropy/io/fits/card.py:334, in Card.value(self, value)
332 m = self.ascii_text_re.match(value)
333 if not m:
--> 334 raise ValueError(
335 'FITS header values must contain standard printable ASCII '
336 'characters; {!r} contains characters not representable in '
337 'ASCII or non-printable characters.'.format(value))
338 elif isinstance(value, np.bool
):
339 value = bool(value)

ValueError: FITS header values must contain standard printable ASCII characters; '\nAssociation information\n\n\nProgram information\n\n\nObservation identifiers' contains characters not representable in ASCII or non-printable characters.

@lboogaard
Copy link

lboogaard commented Nov 17, 2022

Running into the same issue when reprocessing the GLASS data. The loop-and-copy (introduced in e06b452) appears to trigger the validation issue, which is not triggered by a .copy().

@gbrammer
Copy link
Owner

gbrammer commented Dec 2, 2022

Do you know which keyword has the offending \n characters? COMMENT, HISTORY?

@lboogaard
Copy link

I believe the problems are actually the blocks like Program information, Observation identifiers, etc:

COMPRESS=                    F / On-board data compression was used (T/F)

        Program information

TITLE   = 'Through the looking GLASS: a JWST exploration of galaxy formation &'
CONTINUE  'and evolution from cosmic dawn to present day&'
CONTINUE  '' / Proposal title
PI_NAME = 'Treu, Tommaso L.'   / Principal investigator name
CATEGORY= 'ERS     '           / Program category
SCICAT  = 'Galaxies and the IGM' / Science category assigned during TAC process

        Observation identifiers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants