-
Notifications
You must be signed in to change notification settings - Fork 142
Initial files to cmorise EN4 data #4193
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
base: main
Are you sure you want to change the base?
Changes from all commits
4c0739c
80734fb
ebde5fb
cea576e
850b339
194a642
36034d2
5283551
91e7d17
1ec95c5
4c2d379
d535c97
8c5c085
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 |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| --- | ||
|
|
||
| # Filename | ||
| filename: 'EN.4.2.2.f.analysis.g10.*.nc' | ||
|
|
||
| # Common global attributes for Cmorizer output | ||
| attributes: | ||
| dataset_id: EN4 | ||
| version: '4.2.2' | ||
| tier: 2 | ||
| modeling_realm: reanaly | ||
| project_id: OBS6 | ||
| source: 'https://www.metoffice.gov.uk/hadobs/en4/download-en4-2-2.html' | ||
| reference: 'good2013jgr' | ||
| comment: 'Uses analyses with Gouretski and Reseghetti (2010) XBT corrections and Gouretski and Cheng (2020) MBT corrections applied.' | ||
|
|
||
| # Variables to cmorize | ||
| variables: | ||
| thetao: | ||
| mip: Omon | ||
| raw_var: sea_water_potential_temperature | ||
| srf_var: tos | ||
| so: | ||
| mip: Omon | ||
| raw_var: sea_water_salinity | ||
| srf_var: sos | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -332,6 +332,20 @@ datasets: | |
| - Complete the CMOR-config specifications (see instructions in the file | ||
| itself) | ||
|
|
||
| EN4: | ||
| tier: 2 | ||
| source: "https://www.metoffice.gov.uk/hadobs/en4/download-en4-2-2.html" | ||
| last_access: 2025-06-13 | ||
| info: | | ||
| EN4: quality controlled subsurface ocean temperature and salinity objective analyses. | ||
| Script tested using analyses with Gouretski and Reseghetti (2010) XBT corrections | ||
| and Gouretski and Cheng (2020) MBT corrections applied. | ||
| To download data: | ||
| - Edit the text file for your chosen years, https://www.metoffice.gov.uk/hadobs/en4/EN.4.2.2.analyses.g10.download-list.txt | ||
| - Save .txt file in directory for data to be downloaded to. | ||
| - Run 'wget -i EN.4.2.2.profiles.g10.download-list.txt' in same directory. | ||
| - Unzip files prior to running the cmorizer script. | ||
|
|
||
|
Comment on lines
+335
to
+348
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you can transfer this below the E-OBS entry for consistency please :) |
||
| E-OBS: | ||
| tier: 2 | ||
| source: http://surfobs.climate.copernicus.eu/dataaccess/access_eobs.php#datafiles | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,128 @@ | ||||||||||
| """ | ||||||||||
| CMORizer for EN4 dataset. | ||||||||||
| This script processes EN4 ocean temperature and salinity data to CMOR-compliant format for use in ESMValTool. | ||||||||||
| Tier | ||||||||||
| Tier 2: other freely-available dataset. | ||||||||||
| Source | ||||||||||
| https://www.metoffice.gov.uk/hadobs/en4/download-en4-2-2.html | ||||||||||
| Last access | ||||||||||
| 2025-06-13 | ||||||||||
| Info | ||||||||||
| EN4: quality controlled subsurface ocean temperature and salinity objective analyses. | ||||||||||
| Script tested using analyses with Gouretski and Reseghetti (2010) XBT corrections | ||||||||||
| and Gouretski and Cheng (2020) MBT corrections applied. | ||||||||||
| Download instructions | ||||||||||
| - Edit the text file for your chosen years, https://www.metoffice.gov.uk/hadobs/en4/EN.4.2.2.analyses.g10.download-list.txt | ||||||||||
| - Save .txt file in directory for data to be downloaded to. | ||||||||||
| - Run 'wget -i EN.4.2.2.profiles.g10.download-list.txt' in same directory. | ||||||||||
| - Unzip files prior to running the cmorizer script. | ||||||||||
| """ | ||||||||||
|
|
||||||||||
| import logging | ||||||||||
| from pathlib import Path | ||||||||||
|
|
||||||||||
| import iris | ||||||||||
|
|
||||||||||
| from esmvaltool.cmorizers.data import utilities as utils | ||||||||||
|
|
||||||||||
| logger = logging.getLogger(__name__) | ||||||||||
|
|
||||||||||
|
|
||||||||||
| def load_and_prepare_cube(fullpath, var, var_info, glob_attrs, cmor_table): | ||||||||||
| """ | ||||||||||
| Load and prepare a data cube for CMORization. Fix attributes, coordinates, and units. | ||||||||||
| Parameters | ||||||||||
| ---------- | ||||||||||
| fullpath : str | ||||||||||
| Path to the input file. | ||||||||||
| var : str | ||||||||||
| Name of the variable to save in output cube. | ||||||||||
| var_info : dict | ||||||||||
| Variable information dictionary. | ||||||||||
| glob_attrs : dict | ||||||||||
| Global attributes to set on the cube. | ||||||||||
| cmor_table : object | ||||||||||
| CMOR table. | ||||||||||
| Returns | ||||||||||
| ------- | ||||||||||
| iris.cube.Cube | ||||||||||
| The prepared data cube. | ||||||||||
| """ | ||||||||||
|
|
||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| glob_attrs["mip"] = var_info["mip"] | ||||||||||
| raw_var = var_info["raw_var"] | ||||||||||
| cmor_info = cmor_table.get_variable(var_info["mip"], var) | ||||||||||
|
|
||||||||||
| cubes = iris.load(fullpath, raw_var) | ||||||||||
| iris.util.equalise_attributes(cubes) | ||||||||||
| cube = cubes.concatenate_cube() | ||||||||||
|
|
||||||||||
| if cube.units == "K": | ||||||||||
| cube.convert_units("degC") | ||||||||||
|
|
||||||||||
| cube.coord("depth").units = "m" | ||||||||||
| cube = utils.fix_coords(cube) | ||||||||||
| utils.fix_var_metadata(cube, cmor_info) | ||||||||||
| utils.set_global_atts(cube, glob_attrs) | ||||||||||
|
|
||||||||||
| return cube | ||||||||||
|
|
||||||||||
|
|
||||||||||
| def extract_surface_var(cube, cmor_info): | ||||||||||
| """ | ||||||||||
| Extract the surface level variable from a data cube. | ||||||||||
| Parameters | ||||||||||
| ---------- | ||||||||||
| cube : iris.cube.Cube | ||||||||||
| Input data cube. | ||||||||||
| cmor_info : object | ||||||||||
| CMOR table object for the surface variable. | ||||||||||
| Returns | ||||||||||
| ------- | ||||||||||
| iris.cube.Cube | ||||||||||
| The extracted surface level cube. | ||||||||||
| """ | ||||||||||
| logger.info("Extracting surface level") | ||||||||||
|
|
||||||||||
| depth0 = iris.Constraint(depth=cube.coord("depth").points[0]) | ||||||||||
| surface_cube = cube.extract(depth0) | ||||||||||
|
|
||||||||||
| utils.fix_var_metadata(surface_cube, cmor_info) | ||||||||||
|
|
||||||||||
| return surface_cube | ||||||||||
|
|
||||||||||
|
|
||||||||||
| def cmorization(in_dir, out_dir, cfg, cfg_user, start_date, end_date): | ||||||||||
| """ | ||||||||||
| CMORization main function call. | ||||||||||
| """ | ||||||||||
|
Comment on lines
+107
to
+109
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| cmor_table = cfg["cmor_table"] | ||||||||||
| glob_attrs = cfg["attributes"] | ||||||||||
| fullpath = str(Path(in_dir) / cfg["filename"]) | ||||||||||
|
|
||||||||||
| for var, var_info in cfg["variables"].items(): | ||||||||||
| logger.info("Loading %s", fullpath) | ||||||||||
|
|
||||||||||
| srf_var = var_info["srf_var"] | ||||||||||
| cmor_info_srf = cmor_table.get_variable(var_info["mip"], srf_var) | ||||||||||
|
|
||||||||||
| cube = load_and_prepare_cube( | ||||||||||
| fullpath, var, var_info, glob_attrs, cmor_table | ||||||||||
| ) | ||||||||||
| surface_cube = extract_surface_var(cube, cmor_info_srf) | ||||||||||
| logger.info("Saving for %s", var) | ||||||||||
| utils.save_variable(cube, var, out_dir, glob_attrs) | ||||||||||
|
|
||||||||||
| logger.info("Saving for %s", srf_var) | ||||||||||
| utils.save_variable(surface_cube, srf_var, out_dir, glob_attrs) | ||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ | |
| --- | ||
| documentation: | ||
| description: | | ||
| Test recipe for OBS, no proprocessor or diagnostics are applied, | ||
| Test recipe for OBS, no preprocessor or diagnostics are applied, | ||
| just to check correct reading of the CMORized data. | ||
|
|
||
| title: Recipe to test run all obs cmorizers. | ||
|
|
@@ -154,6 +154,17 @@ diagnostics: | |
| type: clim, version: v2018, start_year: 2010, end_year: 2010} | ||
| scripts: null | ||
|
|
||
| EN4: | ||
| description: EN4 check | ||
| variables: | ||
| thetao: | ||
| tos: | ||
| so: | ||
| sos: | ||
|
Comment on lines
+160
to
+163
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you consistently add these variables too to |
||
| additional_datasets: | ||
| - {dataset: EN4, project: OBS6, mip: Omon, type: reanaly, | ||
| version: 4.2.2, tier: 2, start_year: 1900, end_year: 2024} | ||
| scripts: null | ||
|
Comment on lines
+157
to
+167
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And similarly to the |
||
|
|
||
| E-OBS: | ||
| description: E-OBS check | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| @article{Good2013EN4:Estimates, | ||
| title = {{EN4: Quality controlled ocean temperature and salinity profiles and monthly objective analyses with uncertainty estimates}}, | ||
| year = {2013}, | ||
| journal = {Journal of Geophysical Research: Oceans}, | ||
| author = {Good, Simon A. and Martin, Matthew J. and Rayner, Nick A.}, | ||
| number = {12}, | ||
| pages = {6704--6716}, | ||
| volume = {118}, | ||
| publisher = {Blackwell Publishing Ltd}, | ||
| doi = {10.1002/2013JC009067}, | ||
| issn = {21699291}, | ||
| keywords = {objective analysis, ocean observations, quality control, uncertainty estimation} |
Uh oh!
There was an error while loading. Please reload this page.