From f56b9a20c954d18b97a99b33a18038f23d91a32b Mon Sep 17 00:00:00 2001 From: augustinm Date: Fri, 18 Oct 2024 09:52:02 +0200 Subject: [PATCH] make 30 minute batch l2b files --- aprofiles/cli/utils/l2b.py | 18 +++++++++--------- docs/changelog.md | 5 +++++ pyproject.toml | 2 +- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/aprofiles/cli/utils/l2b.py b/aprofiles/cli/utils/l2b.py index 22ad29c..31f2012 100644 --- a/aprofiles/cli/utils/l2b.py +++ b/aprofiles/cli/utils/l2b.py @@ -21,12 +21,12 @@ def make_files(path_in: Path, path_out: Path, time_steps: int, progress_bar: boo unique_id = f"{ds.attrs['wigos_station_id']}_{ds.attrs['instrument_id']}" yyyymmdd = str(ds.time.data[0].astype('M8[D]')).replace('-','') - # we just work with n latest time steps - start_idx = max(0, ds.time.size - time_steps) - - for i in range(start_idx, ds.time.size): - ds1t = ds.isel(time=slice(i,i+1)) - mmhh = pd.to_datetime(ds1t.time[0].data).strftime('%H%M') - file_name = Path(path_out, f"L2B_{unique_id}{yyyymmdd}{mmhh}.nc") - ds1t.to_netcdf('out.nc') - os.rename('out.nc',file_name) + # we just work with the 6 latest time steps, that is 30 min worth of data + start_idx = max(0, ds.time.size - 6) + ds30min = ds.isel(time=slice(start_idx,ds.time.size)) + mmhh = pd.to_datetime(ds30min.time[0].data).strftime('%H%M') + + # write output file + file_name = Path(path_out, f"L2B_{unique_id}{yyyymmdd}{mmhh}.nc") + ds30min.to_netcdf('out.tmp') + os.rename('out.tmp',file_name) diff --git a/docs/changelog.md b/docs/changelog.md index 4568c4b..b5a1813 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,6 +2,11 @@ :material-history:{ style="text-align: center; font-size: xx-large; display: block" } +## 0.10.2 +Oct 18, 2024 + +- make 30 minutes batch L2b files + ## 0.10.1 Oct 10, 2024 diff --git a/pyproject.toml b/pyproject.toml index f5691d3..1371484 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "aprofiles" -version = "0.10.1" +version = "0.10.2" description = "Analysis of atmospheric profilers measurements" authors = ["augustinm "] license = "GPL-3.0"