Skip to content

CMORizer ESACCI-PERMAFROST#3545

Open
axel-lauer wants to merge 21 commits intomainfrom
cmorize_esacci_permafrost
Open

CMORizer ESACCI-PERMAFROST#3545
axel-lauer wants to merge 21 commits intomainfrom
cmorize_esacci_permafrost

Conversation

@axel-lauer
Copy link
Contributor

Description

This PR adds a downloading and formatting script for the dataset ESACCI-PERMAFROST v3.0. The following three variables are supported:

  • active layer thickness (alt)
  • permafrost ground temperature (gtd)
  • permafrost extent (pfr)

The CMORizer requires the custom CMOR tables defined in ESMValGroup/ESMValCore#2358.

Checklist

It is the responsibility of the author to make sure the pull request is ready to review. The icons indicate whether the item will be subject to the 🛠 Technical or 🧪 Scientific review.

New or updated data reformatting script

Copy link
Member

@LisaBock LisaBock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @axel-lauer !

I started the review and run in two issues:

  • there were small modifications in the downloader necessary (see comment there)
  • when starting the formatter I got the following error message:
    PermissionError: [Errno 13] Permission denied: '/work/bd0854/b380103/esacci-permafrost-weights'

Please update also the branch with the main branch.

Overwrite already downloaded files
"""
if start_date is None:
start_date = datetime(1997, 1, 1, tzinfo=datetime.timezone.utc)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gives me the following error message:
AttributeError: type object 'datetime.datetime' has no attribute 'timezone'. Did you mean: 'astimezone'?

It worked when I added from datetime import timezone and replaced datetime.timezone with timezone .

Copy link
Contributor Author

@axel-lauer axel-lauer Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just removed the time zone stuff. It seems this is not needed (any more): e74218d
I also updated with the latest main resolving the conflict in input.rst.

mip: Lyr
raw: ALT
file: 'ESACCI-PERMAFROST-L4-ALT-*-AREA4_PP-{year}-fv03.0.nc'
weights_dir: '/work/bd0854/b380103/esacci-permafrost-weights'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @axel-lauer ,
if these weights are needed, could you store them in a public/group folder or in the ESMValTool repository?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The weights file should be generated automatically and is then reused to speed up the regridding. Could you try setting
weights_dir: './esacci-permafrost-weights' in the config file? Not sure which directory to give so it works for every user on every machine.

@axel-lauer axel-lauer added this to the v2.14.0 milestone Jan 12, 2026
Copy link
Member

@LisaBock LisaBock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @axel-lauer !
Works fine for me. As soon as the changes in the ESMValCore are merged, this PR is also ready for merging.

@schlunma
Copy link
Contributor

Hello, this pull request has been marked with the v2.14.0 milestone. The release of version 2.14.0 is currently scheduled for February 2026. To get this into the new release, it would be great to get this merged by the end of January.

If you won't be able to finish this in time, don't worry - just unassign the milestone v2.14.0. If you need any support, ping myself (@schlunma; the release manager for v2.14.0) or the @ESMValGroup/technical-lead-development-team. Please note that I won't be available until the beginning of February, though.

@jlenh jlenh requested review from jlenh February 6, 2026 09:44
@jlenh jlenh added in technical review requires new ESMValCore release A new release of ESMValCore is needed to solve this issue/merge this pull request.. and removed looking for technical reviewer labels Feb 6, 2026
@jlenh jlenh modified the milestones: v2.14.0, v2.15.0 Feb 13, 2026
Copy link
Contributor

@jlenh jlenh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, just a few comments!

If you could also deal with the Codacy issues! It looks like mostly using the Path library instead of os, and some looping over dictionary keys. Let me know if you need assistance with that 😄 And there is a conflict to solve with the main branch.

The tests are failing because of the dependency on the newest ESMValCore version. I have also bumped the PR to the next version as it seems that the needed PR in ESMValCore will not be merged for v2.14.0.

# Common global attributes for CMORizer output
attributes:
dataset_id: ESACCI-PERMAFROST
version: 'v3.0'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, looking at the website, the latest version is v5.0, is there a reason why the v3.0 then?

Comment on lines +70 to +99
# description of ESACCI-PERMAFROST v3.0 polar stereographic
# grid for cdo
esagrid = (
f"gridtype = projection\n"
f"gridsize = {totalsize}\n"
f"xsize = {xsize}\n"
f"ysize = {ysize}\n"
f"xname = x\n"
f'xlongname = "x coordinate of projection"\n'
f'xunits = "m"\n'
f"yname = y\n"
f'ylongname = "y coordinate of projection"\n'
f'yunits = "m"\n'
f"xfirst = -6111475.22239475\n"
f"xinc = 926.625433138333\n"
f"yfirst = 4114895.09469662\n"
f"yinc = -926.625433138333\n"
f"grid_mapping = polar_stereographic\n"
f"grid_mapping_name = polar_stereographic\n"
f"straight_vertical_longitude_from_pole = 0.\n"
f"false_easting = 0.\n"
f"false_northing = 0.\n"
f"latitude_of_projection_origin = 90.\n"
f"standard_parallel = 71.\n"
f"longitude_of_prime_meridian = 0.\n"
f"semi_major_axis = 6378137.\n"
f"inverse_flattening = 298.257223563\n"
f'proj_params = "+proj=stere +lat_0=90 +lat_ts=71 +lon_0=0'
f' +k=1" +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs"\n'
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have, could you include a reference or a link where to find this information? Or is it part of the downloaded files? That would be helpful for reference either way.

Comment on lines +140 to +143
logger.info(
"Generating regridding weights. This will take"
" about 5-10 minutes (or more)...",
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was not that long after all 😄

Comment on lines +343 to +351
in_file = glob.glob(filepattern)[0]
if not in_file:
logger.info(
"%d: no data not found for variable %s",
loop_date.year,
short_name,
)
else:
_extract_variable(in_file, var, cfg, out_dir, loop_date.year)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to adapt the code here, otherwise you get an error if no file is found with glob.glob(filepattern) and it returns an empty list. You can similarly evaluate it in the if/else statement afterwards regardless.

Suggested change
in_file = glob.glob(filepattern)[0]
if not in_file:
logger.info(
"%d: no data not found for variable %s",
loop_date.year,
short_name,
)
else:
_extract_variable(in_file, var, cfg, out_dir, loop_date.year)
in_file = glob.glob(filepattern)
if not in_file:
logger.info(
"%d: no data not found for variable %s",
loop_date.year,
short_name,
)
else:
_extract_variable(in_file[0], var, cfg, out_dir, loop_date.year)

Copy link
Contributor

@jlenh jlenh Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually you could already replace here with a call to the Path library to deal with a Codacy error:
in_file = list(Path(in_dir).glob(var["file"].format(year=loop_date.year)))

Comment on lines +47 to +57
coord = cube.coord(axis=axis)
if axis == "T":
coord.convert_units("days since 1850-1-1 00:00:00.0")
coord.standard_name = coord_def.standard_name
coord.var_name = coord_def.out_name
coord.long_name = coord_def.long_name
coord.points = coord.core_points().astype("float64")
if len(coord.points) > 1:
if coord.bounds is not None:
coord.bounds = None
coord.guess_bounds()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering about the time axis on the output cube:

  • I do not see any bounds on the output cube for the time axis? Would it be possible maybe to add time bounds to indicate it covers the whole year?

)

# delete temporary file
os.remove(esagrid_file)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to keep this one also as a file after processing? It would avoid people having to look deep into ESMValTool's code to find the information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in scientific review in technical review observations requires new ESMValCore release A new release of ESMValCore is needed to solve this issue/merge this pull request..

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants