37 """Retrieve the value of the current card along with the keyword name.
42 The name of the current card.
44 The value in the correct Python type.
47 typeLut = {CardType.INT: self.getFitsI,
48 CardType.FLOAT: self.getFitsF,
49 CardType.STRING: self.getFitsS,
50 CardType.COMPLEXF: self.getFitsCF,
51 CardType.LOGICAL: self.getFitsL
55 ctype = self.getCardType()
58 name = self.getCardName()
65 if ctype == CardType.UNDEF:
67 elif ctype
in typeLut:
68 found = typeLut[ctype](
"")
72 raise RuntimeError(f
"Unexpectedly failed to find card '{name}'")
73 elif ctype == CardType.COMMENT:
74 value = self.getCardComm()
76 raise RuntimeError(f
"Type, {ctype} of FITS card '{name}' not supported")
229 name : `str` or `int`
230 If the name is an integer index this corresponds to a position within
231 the FitsChan. Index values are 0-based. A negative index counts
232 from the end of the FitsChan. If the index matches the number of
233 cards (e.g. the return value of `len()`) the new value will be
234 appended to the end of the FitsChan.
235 If the name is an empty string or `None`, the value will be inserted
236 at the current card position as a comment card.
237 If the name is a string corresponding to a header card that is already
238 present in the FitsChan, the new value will overwrite the existing
239 value leaving the header name and any comment unchanged.
240 Any other cards matching that name later in the header will
241 be removed. If there is no header with that name, a new card will
242 be inserted at the end of the FitsChan.
243 value : `str`, `int`, `float`, `bool`, `None`
244 The new value to be inserted. If an integer index is given it must be
245 a complete FITS header card. The string will be padded to 80
251 Raised if the supplied integer index is out of range.
253 Raised if the supplied name is neither a string or an integer.
255 Raised if an integer index is given but the supplied value is not
259 if isinstance(name, int):
268 self.putFits(value,
True)
274 self.setFitsCM(value,
False)
277 if not isinstance(name, str):
278 raise KeyError(f
"Supplied key, '{name}' of unsupported type")
281 currentCard = self.getCard()
288 self.findFits(name,
False)
293 self.setFitsU(name, overwrite=
True)
294 elif isinstance(value, int):
295 self.setFitsI(name, value, overwrite=
True)
296 elif isinstance(value, float):
297 self.setFitsF(name, value, overwrite=
True)
298 elif isinstance(value, bool):
299 self.setFitsL(name, value, overwrite=
True)
302 self.setFitsS(name, str(value), overwrite=
True)
306 found = self.findFits(name,
False)
312 self.setCard(currentCard)