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

#369: Support the old style external forcings file #471

Merged
merged 232 commits into from
Apr 14, 2023

Conversation

priscavdsluis
Copy link
Contributor

@priscavdsluis priscavdsluis commented Mar 17, 2023

Fixes #369

priscavdsluis and others added 30 commits March 17, 2023 11:10
Copy link
Member

@arthurvd arthurvd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @priscavdsluis : your new additions of yesterday look good.
I did an overall review, please see my suggestions for some minor changes here and there.

@@ -425,66 +455,73 @@ def validate_operand(cls, value):

@root_validator(skip_on_failure=True)
def validate_forcing(cls, values):
def alias(field_key: str):
return cls.__fields__[field_key].alias
class Field:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somewhat confusing name, because this is not the pydantic Field, maybe rename to _Field, or LocalField or CheckField?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

raise ValueError(error)

only_allowed_when(ifrctype, quantity, ExtOldQuantity.FrictionCoefficient)
only_allowed_when(averagingtype, method, 6)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
only_allowed_when(averagingtype, method, 6)
only_allowed_when(averagingtype, method, ExtOldMethod.Averaging)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done for each check


only_allowed_when(ifrctype, quantity, ExtOldQuantity.FrictionCoefficient)
only_allowed_when(averagingtype, method, 6)
only_allowed_when(relativesearchcellsize, method, 6)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
only_allowed_when(relativesearchcellsize, method, 6)
only_allowed_when(relativesearchcellsize, method, ExtOldMethod.Averaging)

only_allowed_when(ifrctype, quantity, ExtOldQuantity.FrictionCoefficient)
only_allowed_when(averagingtype, method, 6)
only_allowed_when(relativesearchcellsize, method, 6)
only_allowed_when(extrapoltol, method, 5)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
only_allowed_when(extrapoltol, method, 5)
only_allowed_when(extrapoltol, method, ExtOldMethod.InterpolateTime)

only_allowed_when(averagingtype, method, 6)
only_allowed_when(relativesearchcellsize, method, 6)
only_allowed_when(extrapoltol, method, 5)
only_allowed_when(percentileminmax, method, 6)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
only_allowed_when(percentileminmax, method, 6)
only_allowed_when(percentileminmax, method, ExtOldMethod.Averaging)

hydrolib/core/dflowfm/extold/models.py Outdated Show resolved Hide resolved
hydrolib/core/dflowfm/extold/models.py Outdated Show resolved Hide resolved
hydrolib/core/dflowfm/extold/models.py Outdated Show resolved Hide resolved
hydrolib/core/dflowfm/extold/models.py Outdated Show resolved Hide resolved
hydrolib/core/dflowfm/extold/models.py Outdated Show resolved Hide resolved
@veenstrajelmer
Copy link
Collaborator

"""
import hydrolib.core.dflowfm as hcdfm
hcdfm.ExtOldForcing(quantity='initialsalinity',
filename='test.nc',
varname='so',
filetype=hcdfm.ExtOldFileType.NetCDFGridData,
method=hcdfm.ExtOldMethod.InterpolateTimeAndSpaceSaveWeights, #3
operand=hcdfm.Operand.override, #O
)
"""
Results in "AttributeError: Averaging"

SpatiallyVaryingWeather = 3
"""3. Spatially varying weather"""
SpatiallyVaryingWindPressure = 3
"""3. Spatially varying wind and pressure"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a difference between windpressure and wind & pressure?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a difference between windpressure and wind & pressure?

I don't know what windpressure is. This file type here contains three fields: wind (with two vector components) and one airpressure.

@veenstrajelmer
Copy link
Collaborator

veenstrajelmer commented Apr 13, 2023

@priscavdsluis: Testing current branch status results in correct old extfile with several meteo parameters (airpressure, wind, charnock, solarradiation) and initial conditions (salinity and temperature). So successful test.

from hydrolib.core.dflowfm.extold.parser import Parser
from hydrolib.core.dflowfm.extold.serializer import Serializer
from hydrolib.core.dflowfm.polyfile.models import PolyFile
from hydrolib.core.dflowfm.tim.models import TimModel


class TracerQuantity(str, Enum):
HEADER = """
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you copy paste this from somewhere? 😄
Do you want me to review this header as well? Or, since it is just a header, let the users report any issues with it (if they find any).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this one was provided by @veenstrajelmer, but we will probably update it to a more recent one or change it such that it conforms to our own implementation.

@veenstrajelmer
Copy link
Collaborator

veenstrajelmer commented Apr 13, 2023

@priscavdsluis: Testing current branch status results in correct old extfile with several meteo parameters (airpressure, wind, charnock, solarradiation) and initial conditions (salinity and temperature). So successful test.

Tested again and still works successfully

sourcemask, filetype, valid_dependency_value="4 or 6"
)

if (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's have a very short discussion if this works as intented. It always confuses me 😊

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, this should work! 😊

@veenstrajelmer
Copy link
Collaborator

veenstrajelmer commented Apr 14, 2023

@priscavdsluis After a conversation yesterday, I discovered the quantity nudge_salinity_temperature is not supported. It is not documented and also not in the header I provided, but is mentioned in the user manual in a footnote. Could it be added? I will search for an updated header also.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 11 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@veenstrajelmer
Copy link
Collaborator

@priscavdsluis @tim-vd-aardweg Tested and all works now

@priscavdsluis priscavdsluis merged commit cbb80af into main Apr 14, 2023
@priscavdsluis priscavdsluis deleted the feat/369-support-old-ext-file branch April 14, 2023 09:32
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

Successfully merging this pull request may close these issues.

Support for old ext file
5 participants