melodies_monet.util.write_util

Functions

compress_variable(da)

Function to compress a variable from a float to integer and adds netcdf attributes for CF convention.

compute_scale_and_offset(mn, mx, n[, dtype])

Calculates the scale and offset to be used for a variable

get_min_max(da)

Function to return the maximum and minimum value

pack_value(values, scale_factor, offset, dtype)

Values to pack the array with scale factors from a float to integers

write_analysis_ncf(obj[, output_dir, ...])

Function to write netcdf4 files with some compression for floats from an attribute of the analysis class (models, obs, paired).

write_ncf(dset, output_name[, title, verbose])

Function to write netcdf4 files with some compression for floats

write_pkl(obj, output_name)

Function to write a pickle file from an attribute of the analysis class (models, obs, paired)

melodies_monet.util.write_util.compress_variable(da)

Function to compress a variable from a float to integer and adds netcdf attributes for CF convention.

Parameters

da (type) – Description of parameter da.

Returns

type – Description of returned object.

melodies_monet.util.write_util.compute_scale_and_offset(mn, mx, n, dtype=<class 'numpy.float32'>)

Calculates the scale and offset to be used for a variable

Parameters
  • mn (float) – minimum value.

  • mx (float) – maximum value.

  • n (number of bits) – default is 32bit.

  • dtype (numpy dtype) – default is numpy.float32.

Returns

type – Description of returned object.

melodies_monet.util.write_util.get_min_max(da)

Function to return the maximum and minimum value

Parameters

da (type) – Description of parameter da.

Returns

type – Description of returned object.

melodies_monet.util.write_util.pack_value(values, scale_factor, offset, dtype)

Values to pack the array with scale factors from a float to integers

Parameters
  • values (type) – Description of parameter values.

  • scale_factor (type) – Description of parameter scale_factor.

  • offset (type) – Description of parameter offset.

  • dtype (type) – Description of parameter dtype.

Returns

type – Description of returned object.

melodies_monet.util.write_util.write_analysis_ncf(obj, output_dir='', fn_prefix=None, keep_groups=None, title='')

Function to write netcdf4 files with some compression for floats from an attribute of the analysis class (models, obs, paired). Writes the objects within the attribute as separate files. Any characters in variable names that are not allowed in netcdf4 variables names will be dropped. Full variable names will always be saved in the variable attribute long_name.

Parameters
  • obj (dict) – Dict containing attribute of the driver analysis class (model, observation or paired).

  • output_dir (str) – Directory to save files in.

  • fn_prefix (str) – Prefix to add to the group name when saving.

  • keep_groups (list) – List of groups that should be saved. Other groups will not be saved.

Returns

None

melodies_monet.util.write_util.write_ncf(dset, output_name, title='', *, verbose=True)

Function to write netcdf4 files with some compression for floats

Parameters
  • dset (type) – Description of parameter dset.

  • output_name (type) – Description of parameter output_name.

Returns

type – Description of returned object.

melodies_monet.util.write_util.write_pkl(obj, output_name)

Function to write a pickle file from an attribute of the analysis class (models, obs, paired)

Parameters
  • obj (type) – Description of parameter obj.

  • output_name (str) – Description of parameter output_name.

Returns

None