From m.shemuni at gmail.com Sat Dec 16 18:59:58 2023 From: m.shemuni at gmail.com (Mohammad Shameoni Niaei) Date: Sun, 17 Dec 2023 02:59:58 +0300 Subject: [AstroPy] Seeking Assistance: Issues Updating WCS Headers Message-ID: Dear Astropy I hope this message finds you well. I?m reaching out for some help regarding an issue I?ve encountered while updating WCS headers. Here's a rundown of what I'm facing: I?ve created a new header using fit_wcs_from_points, and when I use to_header on the result and save the header, everything seems to function properly. However, I?m eager to preserve other crucial values from the previous header, like airmass, among others. To retain these values, I attempted to update the old header with the header from the newly generated WCS object. However, despite these efforts, both DS9 and world_to_pixel continue displaying the old pixel-to-sky relation. Here's a snippet of the code I've been working with: w = WCS(header) highest = min(self.data().shape) xs = np.random.randint(0, highest, 20) ys = np.random.randint(0, highest, 20) skys = w.pixel_to_world(xs.tolist(), ys.tolist()) new_w = fit_wcs_from_points([xs + x, ys + y], skys) temp_header = header.copy() temp_header.update(new_w.to_header()) # saving it.... I'm a bit perplexed as to where I might be going wrong in this process. Could anyone with experience in handling WCS headers or a similar issue lend some guidance or suggestions on how I might rectify this? Thank you so much for your time and any help you can provide. Ps: The data I work with: https://www.astropy.org/astropy-data/tutorials/FITS-images/HorseHead.fits Best regards, -- Mohammad Shameoni Niaei Astronomer -------------- next part -------------- An HTML attachment was scrubbed... URL: