compass.landice.ismip7.remap.netcdf_file_is_valid

compass.landice.ismip7.remap.netcdf_file_is_valid(path, varname=None, require_time=False, logger=None)[source]

Return True if path exists, opens cleanly, contains varname and (optionally) a time coordinate, and its last time record can actually be read. Used to detect incomplete intermediate files left by an interrupted (timed-out) run so they can be regenerated instead of silently reused. The last-record read catches a file whose header is complete but whose data section was truncated mid-write (which opens cleanly but fails later at concatenation).

Parameters:
  • path (str) – Path to the NetCDF file to check

  • varname (str, optional) – Variable name to verify is present; if None, only checks file opens

  • require_time (bool, optional) – Whether to require a time coordinate/variable

  • logger (logging.Logger, optional) – Logger for status messages (logs incomplete-file info if provided)

Returns:

bool – True if the file is valid and complete; False otherwise