Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filename order is not consistent between platforms (Unix & Windows) #50

Open
TaylorMutch opened this issue Sep 6, 2017 · 0 comments
Open

Comments

@TaylorMutch
Copy link

TaylorMutch commented Sep 6, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant