OceanParcels / plasticparcels

Repository for PlasticParcels tool
MIT License
3 stars 2 forks source link

Bug in loading data using select_files() #5

Closed michaeldenes closed 5 months ago

michaeldenes commented 6 months ago

When loading data for creating the fieldsets, we use the select_files function, defined in utils.py. There is a bug when trying to load in more than two years of data, caused by the line: possible_files = sorted( glob(dirread + string_ % (yr0-1)) + glob(dirread + string_ % yr0) + glob(dirread + string_ % (yr0+1)) ) in the select_files function.

I will sort this out in the next pull request, but the solution is to replace this line with the following:

yrEnd = time_end.year

ragged_files = [glob(dirread + string_ % (yr0+i)) for i in range(-1,yrEnd-yr0+1)]
possible_files = []

for i in range(len(ragged_files)):
    for file_ in ragged_files[i]:
        possible_files.append(file_)

possible_files = sorted(possible_files)
michaeldenes commented 5 months ago

This has been solved in release v0.1.0