act.io.WriteDataset.write_netcdf

WriteDataset.write_netcdf(cleanup_global_atts=True, cleanup_qc_atts=True, join_char='__', make_copy=True, cf_compliant=False, delete_global_attrs=['qc_standards_version', 'qc_method', 'qc_comment'], FillValue=True, cf_convention='CF-1.8', encoding={}, **kwargs)[source]

This is a wrapper around Dataset.to_netcdf to clean up the Dataset before writing to disk. Some things are added to global attributes during ACT reading process, and QC variables attributes are modified during QC cleanup process. This will modify before writing to disk to better match Climate & Forecast standards.

Parameters:
  • cleanup_global_atts (boolean) – Option to cleanup global attributes by removing any global attribute that starts with an underscore.

  • cleanup_qc_atts (boolean) – Option to convert attributes that would be written as string array to be a single character string. CF 1.7 does not allow string attribures. Will use a single space a delimeter between values and join_char to replace white space between words.

  • join_char (str) – The character sting to use for replacing white spaces between words when converting a list of strings to single character string attributes. Main use is with the flag_meanings attribute.

  • make_copy (boolean) – Make a copy before modifying Dataset to write. For large Datasets this may add processing time and memory. If modifying the Dataset is OK try setting to False.

  • cf_compliant (boolean) – Option to output file with additional attributes to make file Climate & Forecast complient. May require runing .clean.cleanup() method on the dataset to fix other issues first. This does the best it can but it may not be truely complient. You should read the CF documents and try to make complient before writing to file.

  • delete_global_attrs (list) – Optional global attributes to be deleted. Defaults to some standard QC attributes that are not needed. Can add more or set to None to not remove the attributes.

  • FillValue (boolean) – Xarray assumes all float type variables had the missing value indicator converted to NaN upon reading. to_netcdf() will then write a _FillValue attribute set to NaN. Set FillValue to False to supress adding the _FillValue=NaN variable attribute to the written file. Set to True to allow to_netcdf() to add the attribute. If the Dataset variable already has a _FillValue attribute or a _FillValue key is provided in the encoding dictionary those will not be changed and a _FillValue will be written to NetCDF file.

  • cf_convention (str) – The Climate and Forecast convention string to add to Conventions attribute.

  • encoding (dict) – The encoding dictionary used with to_netcdf() method.

  • **kwargs (keywords) – Keywords to pass through to Dataset.to_netcdf()

Examples

ds.write.write_netcdf(path='output.nc')