diff options
Diffstat (limited to 'fg21sim/utils')
-rw-r--r-- | fg21sim/utils/healpix.py | 17 | ||||
-rw-r--r-- | fg21sim/utils/io.py | 14 |
2 files changed, 13 insertions, 18 deletions
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: |