-
Notifications
You must be signed in to change notification settings - Fork 9
[DOC] Update metadata + reports #123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1339,9 +1339,12 @@ def standardise_data(ds: xr.Dataset, file_name: str) -> xr.Dataset: | |
| "standard_name", "" | ||
| ): | ||
| log_debug(f"Converting heat transport variable '{var_name}' from W to PW") | ||
| # Preserve all attributes before conversion | ||
| original_attrs = ds[var_name].attrs.copy() | ||
| # Convert data from watts to petawatts (divide by 10^15) | ||
| ds[var_name] = ds[var_name] / 1e15 | ||
| # Update units attribute | ||
| # Restore all attributes and update units | ||
| ds[var_name].attrs = original_attrs | ||
| ds[var_name].attrs["units"] = "PW" | ||
|
|
||
| # If any attributes are blank or value 'n/a', remove them | ||
|
|
@@ -1447,6 +1450,16 @@ def standardise_data(ds: xr.Dataset, file_name: str) -> xr.Dataset: | |
| cleaned.pop(key, None) | ||
| log_debug(f"Removed processing directive: '{key}'") | ||
|
|
||
| # 4.4) Process remove_unwanted_attributes directive | ||
| remove_unwanted = all_yaml_metadata.get("remove_unwanted_attributes", []) | ||
| if remove_unwanted: | ||
| for attr_name in remove_unwanted: | ||
| if attr_name in cleaned: | ||
| cleaned.pop(attr_name) | ||
| log_debug(f"Removed unwanted attribute: '{attr_name}'") | ||
| # Also remove the remove_unwanted_attributes directive itself | ||
| cleaned.pop("remove_unwanted_attributes", None) | ||
|
Comment on lines
+1453
to
+1461
|
||
|
|
||
| # 5) Standardize date formats and add processing metadata | ||
|
|
||
| def standardize_date_format(date_string: str) -> str: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In
OSNAP_MOC_MHT_MFT_TimeSeries_201408_202207_2025.nc,variable_mappingindicates the source variable isMFT_ALL(mapped toMFT), andstandardise_data()appliesoriginal_variable_metadatabefore renaming. Theoriginal_variable_metadataentry is currently keyed asMFT, so it won’t be applied to the source dataset variable and the long_name/attrs may remain missing. Rename this metadata key toMFT_ALL(and keep the attrs the same) so it is applied before the rename.