Esempio n. 1
0
def _find_ceilo_model(full_path: str) -> str:
    if full_path.lower().endswith('.nc'):
        return 'chm15k'
    first_empty_line = utils.find_first_empty_line(full_path)
    max_number_of_empty_lines = 10
    for n in range(1, max_number_of_empty_lines):
        line = linecache.getline(full_path, first_empty_line + n)
        if not utils.is_empty_line(line):
            line = linecache.getline(full_path, first_empty_line + n + 1)
            break
    if 'CL' in line:
        return 'cl31_or_cl51'
    if 'CT' in line:
        return 'ct25k'
    raise RuntimeError('Error: Unknown ceilo model.')
Esempio n. 2
0
def _find_ceilo_model(full_path: str) -> str:
    try:
        nc = netCDF4.Dataset(full_path)
        title = nc.title
        nc.close()
        for identifier in ["cl61d", "cl61-d"]:
            if identifier in title.lower() or identifier in full_path.lower():
                return "cl61d"
        return "chm15k"
    except OSError:
        line = ""
        first_empty_line = utils.find_first_empty_line(full_path)
        max_number_of_empty_lines = 10
        for n in range(1, max_number_of_empty_lines):
            line = linecache.getline(full_path, first_empty_line + n)
            if not utils.is_empty_line(line):
                line = linecache.getline(full_path, first_empty_line + n + 1)
                break
        if "CL" in line:
            return "cl31_or_cl51"
        if "CT" in line:
            return "ct25k"
    raise RuntimeError("Error: Unknown ceilo model.")
Esempio n. 3
0
def test_is_empty_line(input, result):
    assert utils.is_empty_line(input) == result
Esempio n. 4
0
 def _find_number_of_data_lines(timestamp_line_number: int) -> int:
     for i, line in enumerate(data[timestamp_line_number:]):
         if utils.is_empty_line(line):
             return i
     raise RuntimeError("Can not parse number of data lines")
Esempio n. 5
0
 def _find_number_of_data_lines(timestamp_line):
     for i, line in enumerate(data[timestamp_line:]):
         if utils.is_empty_line(line):
             return i