From 3d7404e701820ba048883fdf4da91b89df102c31 Mon Sep 17 00:00:00 2001 From: fangyuedong Date: Sun, 31 Mar 2024 10:14:18 +0800 Subject: [PATCH] bug fix: datetime conversion in ImageHeader.py --- ObservationSim/Config/Header/ImageHeader.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ObservationSim/Config/Header/ImageHeader.py b/ObservationSim/Config/Header/ImageHeader.py index 6b71d5c..cd022b5 100644 --- a/ObservationSim/Config/Header/ImageHeader.py +++ b/ObservationSim/Config/Header/ImageHeader.py @@ -352,7 +352,7 @@ def generatePrimaryHeader(xlen = 9216, ylen = 9232, pointNum = '1', ra = 60, dec # ccdnum = str(k) datetime_obs = datetime.utcfromtimestamp(time_pt) - datetime_obs = datetime_obs.replace(microsecond=round(datetime_obs.microsecond, -5)) + datetime_obs = datetime.utcfromtimestamp(np.round(datetime_obs.timestamp(), 1)) # date_obs = datetime_obs.strftime("%y%m%d") # time_obs = datetime_obs.strftime("%H%M%S%f")[:-5] @@ -558,9 +558,11 @@ def generateExtensionHeader(chip, xlen = 9216, ylen = 9232,ra = 60, dec = -40, p # t_s2 = str(tend_read.datetime).split() # h_ext['ROTIME1'] = t_s2[0] + 'T' + t_s2[1] - tstart1=tstart.datetime.replace(microsecond=round(tstart.datetime.microsecond, -5)) + # tstart1=tstart.datetime.replace(microsecond=round(tstart.datetime.microsecond, -5)) + tstart1 = datetime.utcfromtimestamp(np.round(datetime.utcfromtimestamp(tstart.unix).timestamp(), 1)) h_ext['ROTIME0'] = tstart1.strftime("%Y-%m-%dT%H:%M:%S.%f")[:-5] - tend_read1 = tend_read.datetime.replace(microsecond=round(tend_read.datetime.microsecond, -5)) + # tend_read1 = tend_read.datetime.replace(microsecond=round(tend_read.datetime.microsecond, -5)) + tend_read1 = datetime.utcfromtimestamp(np.round(datetime.utcfromtimestamp(tend_read.unix).timestamp(), 1)) h_ext['ROTIME1'] = tend_read1.strftime("%Y-%m-%dT%H:%M:%S.%f")[:-5] # h_ext['POS_ANG'] = pa header_wcs = WCS_def(xlen=xlen, ylen=ylen, gapy=898.0, gapx1=534, gapx2=1309, ra_ref=ra, dec_ref=dec, pa=pa, pixel_scale=pixel_scale, pixel_size=pixel_size, -- GitLab