This repository contains a Python class CF_Attributes
for managing Climate and Forecast (CF) convention metadata attributes from a CSV file, serving them in different python dictionaries in specific categories, such as global attributes, variable attributes, and others. It also combines these attributes into a unified dictionary for use if necessary.
- File Parsing: Reads and processes a CSV file containing CF attributes into Python dictionaries.
- Attribute Categorisation: Automatically categorises attributes into:
- global attributes
- coordinate variable attributes
- data variable attributes
- boundary variable attributes
- geometry container variable attributes
- quantization container variable attributes
- all variable attributes
- group Attributes
- Clone the repository:
git clone <repository-url>
- Navigate to the repository:
cd <repository-folder>
- Ensure Python 3.8 or higher is installed.
-
Update the file path to the CSV file containing CF attributes in the
CF_Attributes
class:self.file_path = '/path/to/cf_attributes.csv'
-
Initialise the
CF_Attributes
class:from cf_attributes import CF_Attributes cf_attributes = CF_Attributes()
-
Access specific categories of attributes:
cf_attributes.global_attributes cf_attributes.variable_attributes cf_attributes.data_variable_attributes cf_attributes.boundary_variable_attributes cf_attributes.geometry_container_variable_attributes cf_attributes.quantization_container_variable_attributes cf_attributes.group_attributes
The CSV file is currently stored in this repository. However, if and when the CF conventions host this as a standalone CSV file, I will write something to use that as the source.
Each attribute has the following keys:
- Attribute: The name of the attribute
- Type: The type of the attribute:
S
: StringN
: Numeric
- Use: A comma-separated list indicating where the attribute is used:
G
: Global attributesC
: Coordinate variablesD
: Data variablesBI
: Boundary variablesM
: Geometry container variablesQ
: Quantization container variablesGr
: Group attributes
- Description: A brief explanation of the attribute.
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Commit your changes.
- Push to your branch and create a pull request.
- Climate and Forecast (CF) conventions for providing guidance on metadata standards. https://cfconventions.org/