#!/usr/bin/env python3
"""
Merge spectral datasets together.
"""
import os
import sys
import header
import xarray as xr

# Get files
files = sys.argv[1:-1]
output = sys.argv[-1]
if not files:
    exit()

# Get average spectra
print("Averaging spectra")
ds = xr.open_mfdataset(
    files,
    combine='nested',
    concat_dim='record',
    decode_cf=False
)
# chunks={'f': 25},
header.timer(" * Read time")
ds = ds.mean(dim='record', keep_attrs=True)
header.timer(" * Mean time")
if os.path.exists(output):
    os.remove(output)
ds.attrs.pop('_NCProperties', None)  # causes weird error if present!
ds.to_netcdf(output)
header.timer(" * Save time")

57640444392006eb57a44b811edff93d5f1f815e
<mask token>

<mask token>
if not files:
    exit()
print('Averaging spectra')
<mask token>
header.timer(' * Read time')
<mask token>
header.timer(' * Mean time')
if os.path.exists(output):
    os.remove(output)
ds.attrs.pop('_NCProperties', None)
ds.to_netcdf(output)
header.timer(' * Save time')

<mask token>
files = sys.argv[1:-1]
output = sys.argv[-1]
if not files:
    exit()
print('Averaging spectra')
ds = xr.open_mfdataset(files, combine='nested', concat_dim='record',
    decode_cf=False)
header.timer(' * Read time')
ds = ds.mean(dim='record', keep_attrs=True)
header.timer(' * Mean time')
if os.path.exists(output):
    os.remove(output)
ds.attrs.pop('_NCProperties', None)
ds.to_netcdf(output)
header.timer(' * Save time')

<mask token>
import os
import sys
import header
import xarray as xr
files = sys.argv[1:-1]
output = sys.argv[-1]
if not files:
    exit()
print('Averaging spectra')
ds = xr.open_mfdataset(files, combine='nested', concat_dim='record',
    decode_cf=False)
header.timer(' * Read time')
ds = ds.mean(dim='record', keep_attrs=True)
header.timer(' * Mean time')
if os.path.exists(output):
    os.remove(output)
ds.attrs.pop('_NCProperties', None)
ds.to_netcdf(output)
header.timer(' * Save time')

#!/usr/bin/env python3
"""
Merge spectral datasets together.
"""
import os
import sys
import header
import xarray as xr

# Get files
files = sys.argv[1:-1]
output = sys.argv[-1]
if not files:
    exit()

# Get average spectra
print("Averaging spectra")
ds = xr.open_mfdataset(
    files,
    combine='nested',
    concat_dim='record',
    decode_cf=False
)
# chunks={'f': 25},
header.timer(" * Read time")
ds = ds.mean(dim='record', keep_attrs=True)
header.timer(" * Mean time")
if os.path.exists(output):
    os.remove(output)
ds.attrs.pop('_NCProperties', None)  # causes weird error if present!
ds.to_netcdf(output)
header.timer(" * Save time")
