pylag.netcdf_logger module

Module containing classes that facilitate the writing of data to file

class pylag.netcdf_logger.NetCDFLogger(config, file_name, start_datetime, n_particles, grid_names)[source]

Bases: object

NetCDF data logger.

Objects of type NetCDFLogger can be used to write particle data to file.

Parameters
  • config (ConfigParser) – Configuration object

  • file_name (str) – Name of the *.nc output file to be generated. If the .nc extension is not present it is automatically added.

  • start_datetime (str) – String giving the simulation start date and time.

  • n_particles (int) – The number of particles.

  • grid_names (list[str]) – List of grids on which input data is defined.

close()[source]

Close the logger

Return type

None

sync()[source]

Sync data to disk

Return type

None

write(time, particle_data)[source]

Write particle data to file

Parameters
  • time (float) – The current time

  • particle_data (dict) – Dictionary containing particle data with format [‘attribute’: […]].

Return type

None

write_group_ids(group_ids)[source]

Write particle group IDs to file

Parameters

group_ids (array_like) – Particle group IDs.

Return type

None