-
Notifications
You must be signed in to change notification settings - Fork 3
Description
I am using a subprocess to call the clover to_netcdf on a filename pattern such as It*-Ts*-sc.tif to return a NetCDF file with a time dimensions. The problem is that the order in which the files are stacked is different between Windows and Unix systems, resulting in the order of the timesteps to be unpredicatable. I am not using the datetime-pattern parameter, but these files are not datetimes at all.
For example, if my stack of GeoTIFFs are the following:
It0001-Ts0000-sc.tif
It0001-Ts0001-sc.tif
It0001-Ts0002-sc.tif
It0001-Ts0003-sc.tif
calling glob.glob on Windows will return them in ascending order:
pattern = 'It*-Ts*-sc.tif'
files = glob.glob(pattern)
print(files)
['It0001-Ts0000-sc.tif', 'It0001-Ts0001-sc.tif', 'It0001-Ts0002-sc.tif', 'It0001-Ts0003-sc.tif', ...]
On Unix, the pattern seems unpredictable:
print(files)
['It0001-Ts0003-sc.tif', 'It0001-Ts0000-sc.tif', 'It0001-Ts0002-sc.tif', 'It0001-Ts0001-sc.tif', ...]
Would it be possible to add a sort parameter to the to_netcdf command? In my implementation I have modified clover.cli.convert.py @ line 87 to call filesnames.sort(), which puts them filenames back in the same order as they are on Windows.