Skip to content

Commit

Permalink
Dione RC-2
Browse files Browse the repository at this point in the history
  • Loading branch information
Steffenhir committed Dec 29, 2022
2 parents edb8ca5 + 324c69e commit 3872490
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions src/astroimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def crop(self, startx, endx, starty, endy):
return

def update_fits_header(self, original_header, background_mean, app, app_state):
if(self.fits_header is None):
if(original_header is None):
self.fits_header = fits.Header()
else:
self.fits_header = original_header
Expand Down Expand Up @@ -229,28 +229,49 @@ def update_saturation(self):
return

def update_xisf_imagedata(self):
for key in self.fits_header.keys():
unique_keys = list(dict.fromkeys(self.fits_header.keys()))

for key in unique_keys:
if key == "BG-PTS":
bg_pts = json.loads(self.fits_header["BG-PTS"])

for i in range(len(bg_pts)):
self.image_metadata["FITSKeywords"]["BG-PTS" + str(i)] = [{"value": bg_pts[i],"comment": ""}]
else:

value = str(self.fits_header[key])
comment = str(self.fits_header.comments[key])
self.image_metadata["FITSKeywords"][key] = [{"value": value, "comment":comment}]
value = str(self.fits_header[key]).splitlines()
comment = str(self.fits_header.comments[key]).splitlines()

entry = []

for i in range(max(len(comment), len(value))):
value_i = ""
comment_i = ""

if i < len(comment):
comment_i = comment[i]
if i < len(value):
value_i = value[i]

entry.append({"value": value_i, "comment": comment_i})

if len(entry) == 0:
entry = [{"value": "", "comment": ""}]

self.image_metadata["FITSKeywords"][key] = entry


def xisf_imagedata_2_fitsheader(self):
bg_pts = []
for key in self.image_metadata["FITSKeywords"].keys():
if key.startswith("BG-PTS"):
bg_pts.append(json.loads(self.image_metadata["FITSKeywords"][key][0]["value"]))

value = self.image_metadata["FITSKeywords"][key][0]["value"]
comment = self.image_metadata["FITSKeywords"][key][0]["comment"]
for i in range(len(self.image_metadata["FITSKeywords"][key])):
value = self.image_metadata["FITSKeywords"][key][i]["value"]
comment = self.image_metadata["FITSKeywords"][key][i]["comment"]

self.fits_header[key] = (value, comment)
self.fits_header[key] = (value, comment)

if len(bg_pts) > 0:
self.fits_header["BG-PTS"] = str(bg_pts)

0 comments on commit 3872490

Please sign in to comment.