-
Notifications
You must be signed in to change notification settings - Fork 169
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
Add/set weather variables #9326
base: master
Are you sure you want to change the base?
Conversation
…riptions. Plus added a few Unit tags
…more typos and trailing spaces
…s private), deleted variable "First' (and related lines) as not needed (replaced with test for StartDate)
…to SetWeatherVars
…of code (keep an order to outputs)
…and CO2, standardised co2 to be read from met or set via manager, etc.
…ther variables" This reverts commit 241d1af.
Our Weather models seem to be getting pretty complex (with several models and lots of public variables and/or setters). I also see repeated patterns of if statements all through the model suggesting a refactoring may be needed. |
Good points @hut104 , I am aware that there are many interdependencies, and so trying to keep that in mind when doing any changes. I will set a few tests regarding the potential flow on effect of setting Latitude. I will revert if needed or advised on that. |
My idea is to standardise the behaviour for setting weather variables, firstly the code checks if daily values were given (as a column in met file), if not then check if there is a single value (constant), finally providing a 'default' value (which is 'null' for required data (Rain, MaxT, etc.), a constant (for Wind or CO2), or a value is calculated using a function (DiffuseFraction, VP, etc.). |
… get via CalculateDayLength)
…re tested after OnPreparingNewWeatherData, to make code more robust to changes
…puted (increase robustness)
…not replacing SoilWater's)
…to SetWeatherVars
…n with changes is Weather
You’re on the right track. I think what you’re coming up against is the poor design by the weather components brought about by a design that has evolved over time. What we need is a single place (model) that stores and checks weather data and makes it available to other models that need it. It would be quite a simple model (called 'weather' like it is now). We could then have another model (as a child model maybe) that reads weather data in APSIM format, perhaps called WeatherReader (and maybe another in WTH format - called WthWeatherReader) and stores the values in 'weather'. No need for ClimateControl/ControlledEnvironement as that would be a weather component without a reader. No need for SimpleWeather either I suspect. I think Hamish wrote SimpleWeather so might need to check with him. WeatherSampler would just sample from 'Weather'. The current GUI weather graphs would also work with 'Weather'. This might be a step too far for this PR. |
I like the idea of refactoring and making sure that things don't get duplicated. I will be 'finishing' this soon by making sure WeatherSampler has the same variables / same behaviour. I will then open a new issue for refactoring, but will need some help from someone with more coding skills to separate the code properly... |
…to SetWeatherVars
…align with Weather
…to SetWeatherVars
I need a bit of help here, @hol353 |
@rcichota for vs code: for visual studio: |
@rcichota - Fixed. |
Thanks @ric394 , I can now run the units test locally. |
…to SetWeatherVars
retest this please Jenkins |
@hol353 |
@rcichota: I can reproduce the results on jenkins if I use a linux computer (which is what Jenkins is using). I've spent a couple of hours trying to work out what isn't working correctly on linux and I can't. I've tried lots of things. The problem is that this PR has a lot of changes (rearranged code and some more semi-major changes) in a lot of commits and it has never run green on Jenkins. I can't spend more time on this. You might have to go back to the beginning and reintroduce the changes slowly and carefully. As I've said several comments above, my interest is separating out the weather file reading code into a separate class and refactor out the helper code (e.g. calculating things like tav/amp/daylength/airpressure etc) into a separate weather utilities class. Perhaps we abandon this PR and start again. |
Thanks @hol353 |
My apologies for introducing simpleweather. The context was a ML application where the simulation is continually restarted, but not re-initialised (ie after link resolution), sometimes using a different weather file. I couldnt see any sense in a linked list that caches yesterdays data, some other application must be using it, so I left it in place. It is also a hit if we want to have one enormous weather file and randomly sample from it. |
Working on #9325
updating the code to: