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

Method for locating MAS data files is not robust #92

Open
cooperdowns opened this issue Oct 28, 2022 · 0 comments
Open

Method for locating MAS data files is not robust #92

cooperdowns opened this issue Oct 28, 2022 · 0 comments
Labels
Bug Something isn't working

Comments

@cooperdowns
Copy link
Collaborator

The current glob syntax for locating MAS data files of a specific variable (e.g. t001.hdf t002.hdf, etc.) will match with unwanted stuff, such as a random file called test.txt or tmas and then the call to read the variable (e.g. t = mas_output['t']) will crash ungracefully complaining about coordinates.

Also, if there are multiple variables matching one of the variable prefixes (e.g. t and te) then reading t would read any t and te files silently without warning.

Perhaps this issue showed up with the switch to 3 or 6 digit sequence numbers.

I believe this is the line at issue:

return sorted(glob.glob(str(directory / f"{var}*")))

And maybe this one might need to be checked/revised for 3 vs 6 issues too:

files = glob.glob(str(path / "*[0-9][0-9][0-9].*"))

I suspect a fix would be to be more stringent about the format, looking for either 3 digit or 6 digit HDF files separately and choosing one or the other (e.g. first look for f"{var}[0-9][0-9][0-9].h*" and if there are no matches then look for f"{var}[0-9][0-9][0-9][0-9][0-9][0-9].h*") but I'm not experienced enough with PsiPy IO to implement this knowing it won't cause side effects.

@cooperdowns cooperdowns added the Bug Something isn't working label Oct 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant