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

"ResultType" attribute removed - why? #140

Open
AL89 opened this issue Dec 4, 2024 · 3 comments
Open

"ResultType" attribute removed - why? #140

AL89 opened this issue Dec 4, 2024 · 3 comments

Comments

@AL89
Copy link

AL89 commented Dec 4, 2024

Hello there.

I've been using mikeio1d for a while and I really enjoy it.

However, in my opinion, an important attribute has been removed in the latest version (v0.9).

When loading a result file (.res1d) with mikeio1d.Res1D module, I was able to load various types of data using the attribute "ResultType".

So, if "Resulttype" was...

  • "RR", I would load catchment results
  • "HD", I would load network results
  • "LTSAnnual"/"LTSEvents", I would mainly load LTS results

I was just wondering why? And is there an alternative?

Thanks in advance! :)

@ryan-kipawa
Copy link
Collaborator

Hi @AL89

Thanks for bringing this to our attention! That sounds like a reasonable use case 😃. It definitely wasn't intentionally removed.

I couldn't actually find where this was removed in v0.9. Would you be able to share a minimal code snippet showing what's no longer working?

The ResultType actually exists on the C# side and can be accessed as followed from a python Res1D object:

res = Res1D("result.res1d")
result_type = res.data.ResultType

print(str(result_type))   # access it's enum name
print(int(result_type))   # access it's enum value

I could see that's maybe a bit awkward to use, and perhaps we could make an attribute on Res1D:

res = Res1D("result.res1d")
res.result_type

Open to any other suggestions if you have them 😄

@AL89
Copy link
Author

AL89 commented Dec 13, 2024

Hi @ryan-kipawa

Thanks for your message.

Oh, so it is not really deleted, it is just "hidden" in another way so to speak?

But my thought was exactly as you are suggesting - or kinda:

res = Res1D('result.res1d')
if res.result_type == 'RR':     # <- Or the old way, "ResultType" attribute, as I was using: res.ResultType
   # do something with runoff results
elif res.result_type == 'HD':
   # do something with HD results/network results
elif res.result_type in ('LTSAnnual','LTSEvents'):
   # do somrhing with LTS results
else:
   print(f'Has not taken this result type, {res.result_type}, into account. Terminating...')

But I will now use res.data.ResultType since I can see that works! So thank you! And well... false alarm! :)

@ryan-kipawa
Copy link
Collaborator

ryan-kipawa commented Dec 13, 2024

No worries, thanks for showing how you use it.

I'm working on the release for v0.10.0 now. I think for consistency with our other snakecase namings, I'll go with res.result_type. So, soon you'll be able to rely on that way, and in the meantime feel free to use res.data.ResultType :)

Edit: update is included here #148

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

2 participants