-
Notifications
You must be signed in to change notification settings - Fork 8
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
Dev #175
Dev #175
Changes from 6 commits
08d89d8
2a6db66
1fe314c
1dd50cc
730d342
cf32241
b70acbf
98120ed
4378335
f07267e
a9633aa
6a840b7
e48e864
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -279,6 +279,8 @@ def run(self, **kwargs): | |
|
||
copy = get_value(self, kwargs, "copy", False) | ||
|
||
ihot = get_value(self, kwargs, "ihot", 1) | ||
|
||
pwd = os.getcwd() | ||
|
||
self.origin = self.model.rpath | ||
|
@@ -336,7 +338,6 @@ def run(self, **kwargs): | |
info["config_file"] = os.path.join(ppath, "param.nml") | ||
|
||
# update the properties | ||
|
||
info["rdate"] = self.rdate | ||
info["start_date"] = self.sdate | ||
info["time_frame"] = self.time_frame | ||
|
@@ -362,7 +363,10 @@ def run(self, **kwargs): | |
logger.debug("create restart file") | ||
|
||
# check for combine hotstart | ||
hotout = int((self.sdate - self.rdate).total_seconds() / info["params"]["core"]["dt"]) | ||
if ihot == 2: | ||
hotout = int((self.sdate - self.rdate).total_seconds() / info["params"]["core"]["dt"]) | ||
elif ihot == 1: | ||
hotout = self.parameters["nhot_write"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should (almost) always add an What if the user adds an invalid if instead we have: else:
raise ValueError("Acceptable values for `ihot` are 1 and 2, not: %s", ihot) it will be immediately apparent what the issue is. For the record, ideally, we should be validating the user input as soon as we get it, but to do that properly will require a major restructure so let's keep it simple for now. |
||
logger.debug("hotout_it = {}".format(hotout)) | ||
|
||
# link restart file | ||
|
@@ -430,20 +434,32 @@ def run(self, **kwargs): | |
logger.warning("meteo files present\n") | ||
|
||
# modify param file | ||
rnday_new = (self.sdate - self.rdate).total_seconds() / (3600 * 24.0) + pd.to_timedelta( | ||
self.time_frame | ||
).total_seconds() / (3600 * 24.0) | ||
hotout_write = int(rnday_new * 24 * 3600 / info["params"]["core"]["dt"]) | ||
info["parameters"].update( | ||
{ | ||
"ihot": 2, | ||
"rnday": rnday_new, | ||
"start_hour": self.rdate.hour, | ||
"start_day": self.rdate.day, | ||
"start_month": self.rdate.month, | ||
"start_year": self.rdate.year, | ||
} | ||
) | ||
if ihot == 2: | ||
rnday_new = (self.sdate - self.rdate).total_seconds() / (3600 * 24.0) + pd.to_timedelta( | ||
self.time_frame | ||
).total_seconds() / (3600 * 24.0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The formatting is ugly here. Either introduce new variables or maybe try some variation of this (I didn't test it): rnday_new = (self.sdate - self.rdate) + pd.to_timedelta(self.time_frame)
rnday_new = rnday_new.total_seconds() / (3600 * 24.0)
... |
||
hotout_write = int(rnday_new * 24 * 3600 / info["params"]["core"]["dt"]) | ||
info["parameters"].update( | ||
{ | ||
"ihot": 2, | ||
"rnday": rnday_new, | ||
"start_hour": self.rdate.hour, | ||
"start_day": self.rdate.day, | ||
"start_month": self.rdate.month, | ||
"start_year": self.rdate.year, | ||
} | ||
) | ||
elif ihot == 1: | ||
info["parameters"].update( | ||
{ | ||
"ihot": 1, | ||
"start_hour": self.sdate.hour, | ||
"start_day": self.sdate.day, | ||
"start_month": self.sdate.month, | ||
"start_year": self.sdate.year, | ||
} | ||
) | ||
# else: | ||
|
||
m.config(output=True, **info) # save param.nml | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would even suppress assigning
self.obs
(above here line 1755:self.obs = tg_database
)otherwise it gets written to
<module>_model.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with the new implementation tg_database (and thus
self.obs
) is always a filename, either originally or after usingsearvey
,