Skip to content

Add pattern type to allow datetime with timedelta #601

@chebertpinard

Description

@chebertpinard

At the moment the patterns supported in earthkit.data.utils.pattern allow to substitute a datetime to a specified format in a string. It would be useful to be able to apply a timedelta to the given datetime before the substitution.

Example:

In this case we have analysis data for a date:

/home/ecmv9074/hpcperm/cmc_data/2025011200_000
/home/ecmv9074/hpcperm/cmc_data/2025011206_000
...

path: /home/ecmv9074/hpcperm/cmc_data/{date:strftime(%Y%m%d)}{date:strftime(%H)}_000

But for this same validity date the file name pattern is 6h before for the forecast file. In that case the strftime can't be use:

/home/ecmv9074/hpcperm/cmc_data/2025011118_006
/home/ecmv9074/hpcperm/cmc_data/2025011200_006
...


path: /home/ecmv9074/hpcperm/cmc_data/{date:???}{date:???}_006

The idea would be to add a new pattern TYPE that would take a date and a timedelta to substitute the resulting datetime in the string.

path: /home/ecmv9074/hpcperm/cmc_data/{date:strftimedelta(-6h;%Y%m%d)}{date:strftimedelta(-6h;%H)}_006

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions