@@ -63,17 +63,20 @@ def get_distance_units(attrs):
6363def _get_time_coord (node ):
6464 """Get the time information from a Raw node."""
6565 time_array = node ["RawDataTime" ]
66+ array_len = len (time_array )
67+ assert array_len > 0 , "Missing time array in ProdML file."
6668 time_attrs = time_array .attrs
6769 start_str = unbyte (time_attrs ["PartStartTime" ]).split ("+" )[0 ]
6870 start = dc .to_datetime64 (start_str .rstrip ("Z" ))
6971 end_str = unbyte (time_attrs ["PartEndTime" ]).split ("+" )[0 ]
7072 end = dc .to_datetime64 (end_str .rstrip ("Z" ))
71- step = (end - start ) / (len ( time_array ) - 1 )
73+ step = (end - start ) / (array_len - 1 )
7274 time_coord = get_coord (start = start , stop = end + step , step = step , units = "s" )
7375 # Sometimes the "PartEndTime" can be wrong. Check for this and try to
7476 # compensate. See #414.
75- last = time_array [- 1 :].astype ("datetime64[us]" )
76- diff = np .abs (time_coord .max () - last ) / step
77+ last = np .asarray (time_array [- 1 :]).astype ("datetime64[us]" )[0 ]
78+ tc_max = np .asarray (time_coord .max ()).astype ("datetime64[us]" )
79+ diff = float (np .abs ((tc_max - last ) / step ))
7780 # Note: just in case the time array is not in microseconds as it should
7881 # be, we prefer to use the iso 8601 strings in the 'PartStartTime' attrs
7982 # because they are less likely to get messed up. Therefore, we only
0 commit comments