Skip to content

file indexing for files containing more than 1yr of data fails if start or end year are not named in files #335

Description

@bitterbark

ADF run type

Model vs. Model

What happened?

If there is more than one year of data in a file, every year is not represented in the list of file names. Calling for a start or end year that is not alos one of the file names throws an error that the years are not in range (even though they are).

Eg: I have 3 years of data in each file, model run from year 1-22, so file names are

b.e30_beta02.BLT1850.ne30_t232.104_mdtf.cam.h5a.0001-01-01-10800.nc
b.e30_beta02.BLT1850.ne30_t232.104_mdtf.cam.h5a.0004-01-01-10800.nc
...
b.e30_beta02.BLT1850.ne30_t232.104_mdtf.cam.h5a.0022-01-01-10800.nc

If I try to run with start year = 2 and end year = 6, I get an error that the years are out of range. But in fact it is only seeing if the years 3 & 6 are in the set of the years from the file names:

case_climo_yrs = [int(str(i).partition(f"{hist_str}.")[2][0:4]) for i in file_list]
print(f"{case_climo_yrs=} {case_found_syr=} {case_found_eyr=}")

case_climo_yrs=[1, 4, 7, 10, 13, 16, 19, 22] case_found_syr=1 case_found_eyr=22

So we should just check if the years are in the range [case_found_syr,case_found_eyr] instead of in the set case_climo_yrs

ADF Hash you are using

5f825af

What machine were you running the ADF on?

CISL machine

What python environment were you using?

NPL (CISL machines only)

Extra info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions