aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2019-01-29 15:00:16 +0800
committerAaron LI <aly@aaronly.me>2019-01-29 15:00:16 +0800
commit67b720f6d36891b17dad02ea6aca187c0813a412 (patch)
tree0e7a2c7ceaa6a137b3b96ef3ac4312cee75d50c4
parente2e1606538d3f412ee210171ff5f4d64c4da903b (diff)
downloadfg21sim-67b720f6d36891b17dad02ea6aca187c0813a412.tar.bz2
Use UTC time instead of local time
-rw-r--r--fg21sim/sky.py8
-rw-r--r--fg21sim/utils/healpix.py17
-rw-r--r--fg21sim/utils/io.py14
3 files changed, 17 insertions, 22 deletions
diff --git a/fg21sim/sky.py b/fg21sim/sky.py
index 2b94c7c..a016cb6 100644
--- a/fg21sim/sky.py
+++ b/fg21sim/sky.py
@@ -1,5 +1,5 @@
-# Copyright (c) 2017 Weitian LI <weitian@aaronly.me>
-# MIT license
+# Copyright (c) 2017,2019 Weitian LI <wt@liwt.net>
+# MIT License
"""
Generic simulation sky supporting both sky patch and HEALPix all-sky
@@ -13,7 +13,7 @@ References
import logging
import copy
-from datetime import datetime, timezone
+from datetime import datetime
import numpy as np
from scipy import ndimage
@@ -253,7 +253,7 @@ class SkyBase:
hdr["PixSize"] = (self.pixelsize, "Pixel size [arcsec]")
hdr["CREATOR"] = (self.creator, "Sky Creator")
hdr["FREQ"] = (self.frequency, "Sky frequency [MHz]")
- hdr["DATE"] = (datetime.now(timezone.utc).astimezone().isoformat(),
+ hdr["DATE"] = (datetime.utcnow().isoformat()+"Z",
"File creation date")
return hdr
diff --git a/fg21sim/utils/healpix.py b/fg21sim/utils/healpix.py
index 9ec210b..2c5d9ba 100644
--- a/fg21sim/utils/healpix.py
+++ b/fg21sim/utils/healpix.py
@@ -1,5 +1,5 @@
-# Copyright (c) 2016 Weitian LI <liweitianux@live.com>
-# MIT license
+# Copyright (c) 2016,2019 Weitian LI <wt@liwt.net>
+# MIT License
#
# References:
# [1] K. M. Gorski, et al. 2005, ApJ, 622, 759
@@ -25,7 +25,7 @@ hpx2healpix:
"""
-from datetime import datetime, timezone
+from datetime import datetime
import logging
import numpy as np
@@ -301,9 +301,8 @@ def _make_hpx_header(header, append_history=None, append_comment=None):
header["PV2_1"] = (4, "HPX H parameter (longitude)")
header["PV2_2"] = (3, "HPX K parameter (latitude)")
logger.info("Made HPX FITS header")
- #
- header["DATE"] = (datetime.now(timezone.utc).astimezone().isoformat(),
- "File creation date")
+
+ header["DATE"] = (datetime.utcnow().isoformat()+"Z", "File creation date")
comments = [
'The HPX coordinate system is an reorganization of the HEALPix',
'data without regridding or interpolation, which is described in',
@@ -339,10 +338,8 @@ def _make_healpix_header(header, nside,
header["FIRSTPIX"] = (0, "First pixel # (0 based)")
header["LASTPIX"] = (npix-1, "Last pixel # (0 based)")
logger.info("Made HEALPix FITS header")
- #
- header["DATE"] = (datetime.now(timezone.utc).astimezone().isoformat(),
- "File creation date")
- #
+
+ header["DATE"] = (datetime.utcnow().isoformat()+"Z", "File creation date")
if append_history is not None:
logger.info("HEALPix FITS header: append history")
for history in append_history:
diff --git a/fg21sim/utils/io.py b/fg21sim/utils/io.py
index b3666b6..b6719ec 100644
--- a/fg21sim/utils/io.py
+++ b/fg21sim/utils/io.py
@@ -1,5 +1,5 @@
-# Copyright (c) 2017 Weitian LI <weitian@aaronly.me>
-# MIT license
+# Copyright (c) 2017,2019 Weitian LI <wt@liwt.net>
+# MIT License
"""
Input/output utilities
@@ -29,7 +29,7 @@ Input/output utilities
import os
import logging
import pickle
-from datetime import datetime, timezone
+from datetime import datetime
import numpy as np
import pandas as pd
@@ -119,7 +119,7 @@ def dataframe_to_csv(df, outfile, comment=None, clobber=False):
if comment is None:
comment = [
"by %s" % __name__,
- "at %s" % datetime.now(timezone.utc).astimezone().isoformat(),
+ "at %sZ" % datetime.utcnow().isoformat(),
]
with open(outfile, "w") as fh:
@@ -240,8 +240,7 @@ def write_fits_image(outfile, image, header=None, float32=False,
hdr = fits.Header()
hdr["CREATOR"] = (__name__, "File creator")
- hdr["DATE"] = (datetime.now(timezone.utc).astimezone().isoformat(),
- "File creation date")
+ hdr["DATE"] = (datetime.utcnow().isoformat()+"Z", "File creation date")
if header is not None:
hdr.extend(header, update=True)
@@ -368,8 +367,7 @@ def write_fits_healpix(outfile, hpmap, header=None, float32=False,
#
hdr["EXTNAME"] = ("HEALPIX", "Name of the binary table extension")
hdr["CREATOR"] = (__name__, "File creator")
- hdr["DATE"] = (datetime.now(timezone.utc).astimezone().isoformat(),
- "File creation date")
+ hdr["DATE"] = (datetime.utcnow().isoformat()+"Z", "File creation date")
# Merge user-provided header
# NOTE: use the `.extend()` method instead of `.update()` method
if header is not None: