Replace ItemInfo with fmskill.Quantity#191
Merged
ecomodeller merged 25 commits intomainfrom May 12, 2023
Merged
Conversation
Member
Author
|
This PR aims to loosen up the connection to the EUM system. The EUM information available in {Dfs0, Dfsu} files are still read, but for other model types, you are free to supply this information as strings for the name of the quantity and unit. >>> from fmskill import Quantity
>>> wl = Quantity(name="Water level", unit="m")
>>> wl
Quantity(name='Water level', unit='m')
>>> uq = Quantity.undefined()
>>> uq
Quantity(name='Undefined', unit='Undefined')
>>> wl2 = Quantity(name="Water level", unit="m")
>>> wl == wl2
True
>>> wl == uq
False
>>> wl.is_compatible(uq)
True |
Member
Author
|
And the addition of a new classDiagram
Observation <|-- PointObservation
Observation <|-- TrackObservation
TimeSeries <|-- Observation
TimeSeries <|-- PointModelResult
class TimeSeries{
+ str name
+ dataframe data
+ Quantity quantity
+ plot()
+ hist()
}
class PointModelResult{
+ float x
+ float y
}
class Observation{
+ float weight
+ str color
}
class PointObservation{
+ float x
+ float y
}
class TrackObservation{
+ float[] x
+ float[] y
}
class Quantity{
+ str name
+ str unit
}
|
jsmariegaard
reviewed
May 9, 2023
| ItemType = Optional[Union[str, int]] | ||
|
|
||
|
|
||
| @dataclass(frozen=True) |
jsmariegaard
reviewed
May 9, 2023
fmskill/types.py
Outdated
| @@ -1,7 +1,10 @@ | |||
| from datetime import datetime | |||
jsmariegaard
reviewed
May 9, 2023
| itemInfo : Optional[mikeio.ItemInfo], optional | ||
| Optionally, a MIKE IO ItemInfo (MIKE EUM system) can be given | ||
| to set or override the type and unit of the quantity, by default None | ||
| quantity : Optional[str], optional |
jsmariegaard
approved these changes
May 10, 2023
Member
jsmariegaard
left a comment
There was a problem hiding this comment.
Thanks a lot. This looks great. A few things to consider:
- Generally I think it's great to have a class "Quantity" that we can use when the source is not dfs, but I was also thinking that we maybe should support providing a str also and then potentially use mikeio.ItemInfo to try to pass that string to get a default unit or otherwise just leave the unit blank? I just think it is nice to allow simple inputs for new users.
- I guess we could also allow for ItemInfo as input to quantity... because a user may have a mix of csv and dfs´s and the ItemInfo may therefore be nearby...
- Some places the docstring still says that the type is str:
quantity : Optional[str](and the text below says "A string to identify the quantity") - try to search for it. - So far the Quantity disappears when the comparison is made (it's stored in the attrs) - should we keep it this way?
- Would it make sense in the future (not this PR) to extend the Quantity with short_name etc?
- I think it would be nice somehow to be able to restore the origin of the data (filename and item_name where applicable) - could that be stored in attrs?
- I like the .plot etc a lot. But please note that the .plot.timeseries for track observations will give 3 red series (x,y and values).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

No description provided.