Parsing profile with 15 minute timestepping - #513
Conversation
|
@FJanssen-TNO @KobusVanRooyen Ready for reviewing |
| f"Supported: 3600 s (1 h) or 900 s (15 min)." | ||
| ) | ||
|
|
||
| steps_per_hour = 3600 // timestep_spacing_seconds # 1 for 1-h input, 4 for 15-min input |
There was a problem hiding this comment.
rename to "org_steps_per_hour" then it is clear that this was the number of steps per hour for the original timeserie.
There was a problem hiding this comment.
suggested renaming is done
There was a problem hiding this comment.
Name has not been updated as far as I can see.
There was a problem hiding this comment.
You are right. I am surprised. I remember that I renamed. Probably I have reverted by mistake. Now i have renamed.
tolga-akan
left a comment
There was a problem hiding this comment.
@FJanssen-TNO PR is not ready yet. I will continue after vacation.
| f"Supported: 3600 s (1 h) or 900 s (15 min)." | ||
| ) | ||
|
|
||
| steps_per_hour = 3600 // timestep_spacing_seconds # 1 for 1-h input, 4 for 15-min input |
There was a problem hiding this comment.
suggested renaming is done
|
@tolga-akan There is good reason why this is happening. Timestep 0 is considered the history in MESIDO, so when you are creating a profile and you are taking the average over a longer period, you need to start your timeseries first with a another value, in the method you used, the first timestep is therefore copied. After all the averages should be correct. |
yes you are right. there is no issue wit that check now |
|
@FJanssen-TNO Ready to review |
| f"Supported: 3600 s (1 h) or 900 s (15 min)." | ||
| ) | ||
|
|
||
| steps_per_hour = 3600 // timestep_spacing_seconds # 1 for 1-h input, 4 for 15-min input |
There was a problem hiding this comment.
Name has not been updated as far as I can see.
| input_n_days = 0.25 # length of input profile in days | ||
| input_n_steps = input_n_days * 24 * (3600 / input_timestep_seconds) |
There was a problem hiding this comment.
please just use 8hrs*3600/input_timestep_seconds
There was a problem hiding this comment.
actually i liked the way I have done before, because it was parametrizing the variable with input_n_days. input_n_days is also used at the later moment in the code. anyways, i updated the line as you recommend.
| len(datetimes), | ||
| expected_n_output_intervals + 1, # +1 for closing sentinel | ||
| ) | ||
| dts = [datetimes[i + 1] - datetimes[i] for i in range(len(datetimes) - 1)] |
There was a problem hiding this comment.
Why is a nested forloop used for this? can it not be done with a vector operation?
You could use np.diff()
Also instead of datetimes you could just extract problem.times(), that will provide you with timestamps in seconds. Then the actual_step_seconds no longer needs to calcualted separately.
There was a problem hiding this comment.
it can be done only via np.diff(problem.times()). redundant check is removed
| np.testing.assert_array_equal( | ||
| expected_step_seconds, | ||
| actual_step_seconds, | ||
| ) | ||
| np.testing.assert_array_equal( | ||
| expected_step_seconds, | ||
| np.diff(problem.times()), | ||
| ) |
There was a problem hiding this comment.
I don't see the difference between these two checks.
There was a problem hiding this comment.
redundant check is removed
| parsed_input_data = pd.read_csv( | ||
| input_csv_path, | ||
| parse_dates=["DateTime"], | ||
| dayfirst=True, | ||
| ) |
There was a problem hiding this comment.
Do this before the for loop over the different day_steps as it is the same both times.
There was a problem hiding this comment.
you are right. Since I added the for loop later, I forgot to check if I call the variables unnecessarily many times. now the things can be called outside of the loop are moved out.
| np.testing.assert_array_equal( | ||
| len(averaged_profile), | ||
| expected_n_output_intervals, | ||
| err_msg=f"Unexpected averaged profile length for '{var_name}'", | ||
| ) |
There was a problem hiding this comment.
This test is unnecessary, the next test will fail if the length of the arrays is different
There was a problem hiding this comment.
yes. Thats correct. check is removed
| if len(averaged_profile) == expected_n_output_intervals + 1: | ||
| averaged_profile = averaged_profile[1:] |
There was a problem hiding this comment.
is this not required every time this test is done? Because then remove the if statement.
There was a problem hiding this comment.
This if condition is unnecessary. I forgot to remove this. Previously I added this for a debugging purpose. Now if is removed
|
|
||
| ## Added | ||
| - ESDL profile reading and writing for different types: influxdb and postgres, and inline (in ESDL file). | ||
| - Parsing of input profiles with 15-minute interval |
There was a problem hiding this comment.
Move this to "changed": Parsing of input profiles with 15-minute interval now supported.
There was a problem hiding this comment.
changelog is updated
|
|
||
| def parameters(self, ensemble_member): | ||
| parameters = super().parameters(ensemble_member) | ||
| parameters["time_step_days"] = self.__day_steps |
There was a problem hiding this comment.
For what is this parameter needed?
There was a problem hiding this comment.
thanks for highlight. parameter is not needed. I do not need to create time_step_days with __day_steps. Now I removed parameters method.
|
@FJanssen-TNO Ready for reviewing |
Currently timestepping is by default 1 hour.
The goal is to support also 15min timesteps in the data, but only if the data is also required with 15minute timesteps.