Skip to content

Time-mean output files are named for the end of the averaging interval #554

Open

Description

@xylar

A time-averaged output file is named for the instant the average was finalized, and its time value is that instant, so the file holding the mean for December of year 0 is named 0001-01 and carries time = 0001-01-01. A reader that maps files to months by name, as ncclimo and MPAS-Analysis do, takes it for January.

What happens

writeStream in IOStream.cpp uses the current clock time both for the file name (FileTime = ModelClock->getCurrentTime(), line 2529 at d086d49) and for time (OutTime(0) = ElapsedTimeR8, line 2544). Both are right for a snapshot. For a stream written by an analysis group with a ReductionPeriod, the averaging interval ends at that instant, so GlobalStats with ReductionPeriod: [1Month] and Filename: global_stats.$Y-$M.nc on develop names its December mean 0001-01.

Observed on a #481 build, whose IOStream.cpp has the same two lines: with StartTime: 0000-12-01_00:00:00, the first monthly MOC file is moc_1MonthTimeStats.0001-01.nc with time = 2678400 seconds since the start, i.e. 0001-01-01, holding the average over 0000-12-01 to 0001-01-01.

What was expected

MPAS-Ocean's timeSeriesStatsMonthly names a monthly mean for the start of the month it averages (…timeSeriesStatsMonthly.0001-01-01.nc is January of year 1), and CF asks for time to be representative of the interval, in practice its midpoint, with time_bnds giving the ends. For a stream whose fields are time means: name the file for the start of the interval, the previous ring time of the stream's alarm, and set time to the midpoint. #481 adds time_bnds to such streams from that same previous ring time, so once it is in, both follow from values already at hand.

Until then, Polaris will read the file named Y-M as the mean of the month before, so a run over calendar year 1 is read from the files 0001-02 through 0002-01.

How to reproduce

Any analysis group with ReductionPeriod: [1Month] and a $Y-$M file name; compare the file name with the interval it covers. The run above is at /lcrc/group/e3sm/ac.xylar/polaris_1.1/chrysalis/test_20260907/qu240-moc-rerun-20260909/monthly_mean_run on Chrysalis, with omega.yml beside it; ncdump -v time moc_1MonthTimeStats.0001-01.nc.


Posted by Claude Code on @xylar's behalf. The testing, analysis and wording above are AI-authored; please check them accordingly.

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