def test_copy_variables(tmpdir_factory, fake_nc_file):
    file = tmpdir_factory.mktemp("data").join("nc_file.nc")
    root_grp = netCDF4.Dataset(file, "w", format="NETCDF4_CLASSIC")
    var_list = ('a', 'b', 'c')
    source = netCDF4.Dataset(fake_nc_file)
    output.copy_variables(source, root_grp, var_list)
    for var in var_list:
        assert source.variables[var][:] == root_grp.variables[var][:]
Beispiel #2
0
def _save_ceilo(ceilo, output_file, location):
    """Saves the ceilometer netcdf-file."""
    dims = {'time': len(ceilo.time), 'range': len(ceilo.range)}
    rootgrp = output.init_file(output_file, dims, ceilo.data)
    output.add_file_type(rootgrp, 'lidar')
    if hasattr(ceilo, 'dataset'):
        output.copy_variables(ceilo.dataset, rootgrp, ('wavelength', ))
    rootgrp.title = f"Ceilometer file from {location}"
    rootgrp.year, rootgrp.month, rootgrp.day = ceilo.date
    rootgrp.location = location
    rootgrp.history = f"{utils.get_time()} - ceilometer file created"
    rootgrp.source = ceilo.model
    rootgrp.close()
Beispiel #3
0
def _save_mira(mmclx_file, raw_radar, output_file):
    """Saves the MIRA radar file."""
    dims = {'time': len(raw_radar.time), 'range': len(raw_radar.range)}
    rootgrp = output.init_file(output_file, dims, raw_radar.data)
    fields_from_raw = ('nfft', 'prf', 'nave', 'zrg', 'rg0', 'drg')
    output.copy_variables(netCDF4.Dataset(mmclx_file), rootgrp,
                          fields_from_raw)
    output.add_file_type(rootgrp, 'radar')
    rootgrp.title = f"Radar file from {raw_radar.location}"
    rootgrp.year, rootgrp.month, rootgrp.day = _find_measurement_date(
        raw_radar)
    rootgrp.location = raw_radar.location
    rootgrp.history = f"{utils.get_time()} - radar file created"
    rootgrp.source = raw_radar.source
    rootgrp.close()