Skip to content

Commit

Permalink
write time as days
Browse files Browse the repository at this point in the history
  • Loading branch information
AugustinMortier committed Sep 20, 2024
1 parent 51c742b commit cfc15ad
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
12 changes: 6 additions & 6 deletions aprofiles/io/write_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ def write(profiles, base_dir, verbose):
- verbose (bool): Verbose mode. Defaults to False.
"""

def _convert_time_after_epoch(ds, resolution='ms'):
time_attrs = ds["time"].attrs
ds = ds.assign_coords(time=ds.time.data.astype(f"datetime64[{resolution}]").astype(int))
ds["time"] = ds["time"].assign_attrs(time_attrs)
ds["time"].attrs['units'] = 'milliseconds since 1970-01-01T00:00:00'
def _convert_time_after_epoch(ds):
ds = ds.assign_coords(time=ds.time.data.astype(f"datetime64[ms]").astype(f'float32'))
# milliseconds to days
ds['time'] = ds['time'] / (1000 * 60 * 60 * 24)
ds["time"].attrs['units'] = 'days since 1970-01-01T00:00:00'
return ds

def _classify_scene(ds):
Expand Down Expand Up @@ -131,7 +131,7 @@ def _classify_retrieval_scene(ds):
ds_towrite = ds_towrite.drop(nodim_var)

# converts time
ds_towrite = _convert_time_after_epoch(ds_towrite, resolution='ms')
ds_towrite = _convert_time_after_epoch(ds_towrite)

# add altitude direction
ds_towrite["altitude"] = ds_towrite["altitude"].assign_attrs({
Expand Down
6 changes: 6 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Changelog
.. image:: _static/images/history-solid.svg
:class: awesome-svg

0.6.5
^^^^^^^
Sep 20, 2024

- Work on CF compliance (write time as days).

0.6.4
^^^^^^^
Sep 16, 2024
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "aprofiles"
version = "0.6.4"
version = "0.6.5"
description = "Analysis of atmospheric profilers measurements"
authors = ["augustinm <[email protected]>"]
license = "GPL-3.0"
Expand Down

0 comments on commit cfc15ad

Please sign in to comment.