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

ScheduleDay: new timeseries method and interpolation options #5111

Merged
merged 73 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
76f4f41
Introduce new getValues method on ScheduleDay.
joseph-robertson Mar 13, 2024
48ac02d
Stub model test for new method.
joseph-robertson Mar 13, 2024
0242a8c
Formatting.
joseph-robertson Mar 13, 2024
389f6cb
Typo.
joseph-robertson Mar 13, 2024
6e075a3
Update scheduleday files and get new tests passing.
joseph-robertson Mar 14, 2024
27865fa
Return timeseries instead of separate getTimes and getValues.
joseph-robertson Mar 18, 2024
80ef75b
Clean up and try again.
joseph-robertson Mar 18, 2024
f01fba7
Update idd for new interpolation method keys.
joseph-robertson Mar 19, 2024
a365a99
Update model files and tests.
joseph-robertson Mar 19, 2024
d96338a
Update ft and rt files and tests.
joseph-robertson Mar 19, 2024
9fa369a
Get interpolation working on timeseries.
joseph-robertson Mar 19, 2024
3282bda
Stub new AverageInterp in vector files.
joseph-robertson Mar 19, 2024
47d03f3
Take a cut at the average interpolation.
joseph-robertson Mar 21, 2024
aed3dea
One more typo.
joseph-robertson Mar 21, 2024
7bee45b
Move average interp code into AverageInterp.
joseph-robertson Mar 22, 2024
8f1aed5
Formatting.
joseph-robertson Mar 22, 2024
81cfbd0
Cache timeseries results and clear when object changes.
joseph-robertson Mar 25, 2024
07992ed
Add AverageInterp no-op case to matrix cpp.
joseph-robertson Mar 25, 2024
b178a6b
Update docs for new timeseries method.
joseph-robertson Mar 25, 2024
f9a2eae
Set left endpoint of getvalue.
joseph-robertson Mar 25, 2024
d1d7708
Update left endpoint per method and update tests.
joseph-robertson Mar 26, 2024
6c7198e
Merge branch 'develop' into dayschedule-getvalues
joseph-robertson Mar 27, 2024
160585a
Interpolate using seconds instead of days.
joseph-robertson Mar 27, 2024
686b725
Need ti in seconds and not days.
joseph-robertson Mar 27, 2024
e742966
Try updating timestep with cache clear.
joseph-robertson Mar 27, 2024
2ded730
New protected method for clearing ts, and friend timestep.
joseph-robertson Mar 27, 2024
bfb876f
Updates for vt and deprecating interp setter.
joseph-robertson Mar 27, 2024
dd39ffd
Building but tests failing.
joseph-robertson Mar 28, 2024
4af6ee3
Fix the new vt.
joseph-robertson Mar 28, 2024
9be8c90
Remove deprecation of old setter.
joseph-robertson Mar 28, 2024
bb57a4d
Add one more test showing change in getValue for small enough timestep.
joseph-robertson Mar 28, 2024
9b82fed
Merge branch 'develop' into dayschedule-getvalues
joseph-robertson Apr 15, 2024
f8fcada
Merge branch 'develop' into dayschedule-getvalues
jmarrec Apr 18, 2024
6c33a6b
Update comments and release notes.
joseph-robertson Apr 18, 2024
e8b0015
Update ti default to -9999, add assert, update comments.
joseph-robertson Apr 18, 2024
c74f8b6
Few more updates to release notes.
joseph-robertson Apr 18, 2024
d2c195d
Introduce new getValues method on ScheduleDay.
joseph-robertson Mar 13, 2024
5037966
Stub model test for new method.
joseph-robertson Mar 13, 2024
96e9514
Formatting.
joseph-robertson Mar 13, 2024
d55dc20
Typo.
joseph-robertson Mar 13, 2024
a58faef
Update scheduleday files and get new tests passing.
joseph-robertson Mar 14, 2024
94685d5
Return timeseries instead of separate getTimes and getValues.
joseph-robertson Mar 18, 2024
1549488
Clean up and try again.
joseph-robertson Mar 18, 2024
a75a333
Update idd for new interpolation method keys.
joseph-robertson Mar 19, 2024
838df44
Update model files and tests.
joseph-robertson Mar 19, 2024
2b919ab
Update ft and rt files and tests.
joseph-robertson Mar 19, 2024
8eede82
Get interpolation working on timeseries.
joseph-robertson Mar 19, 2024
8da8085
Stub new AverageInterp in vector files.
joseph-robertson Mar 19, 2024
85da8ef
Take a cut at the average interpolation.
joseph-robertson Mar 21, 2024
065d022
One more typo.
joseph-robertson Mar 21, 2024
1104600
Move average interp code into AverageInterp.
joseph-robertson Mar 22, 2024
4af64a0
Formatting.
joseph-robertson Mar 22, 2024
dc202f1
Cache timeseries results and clear when object changes.
joseph-robertson Mar 25, 2024
30fd11d
Add AverageInterp no-op case to matrix cpp.
joseph-robertson Mar 25, 2024
8d50877
Update docs for new timeseries method.
joseph-robertson Mar 25, 2024
825b270
Set left endpoint of getvalue.
joseph-robertson Mar 25, 2024
bbd26f8
Update left endpoint per method and update tests.
joseph-robertson Mar 26, 2024
e257209
Interpolate using seconds instead of days.
joseph-robertson Mar 27, 2024
a22dbb2
Need ti in seconds and not days.
joseph-robertson Mar 27, 2024
1389577
Try updating timestep with cache clear.
joseph-robertson Mar 27, 2024
805f14c
New protected method for clearing ts, and friend timestep.
joseph-robertson Mar 27, 2024
740a0b2
Updates for vt and deprecating interp setter.
joseph-robertson Mar 27, 2024
f20d840
Building but tests failing.
joseph-robertson Mar 28, 2024
881d27c
Fix the new vt.
joseph-robertson Mar 28, 2024
1794d58
Remove deprecation of old setter.
joseph-robertson Mar 28, 2024
e4cef89
Add one more test showing change in getValue for small enough timestep.
joseph-robertson Mar 28, 2024
138cbad
Update comments and release notes.
joseph-robertson Apr 18, 2024
4572fc0
Update ti default to -9999, add assert, update comments.
joseph-robertson Apr 18, 2024
ceba909
Few more updates to release notes.
joseph-robertson Apr 18, 2024
012f076
Missing include
jmarrec Apr 25, 2024
90e86c6
Merge branch 'dayschedule-getvalues' of github.com:NREL/OpenStudio in…
joseph-robertson Apr 25, 2024
fddbc7d
Update assert and get optional timestep object.
joseph-robertson Apr 25, 2024
7493115
Merge branch 'develop' into dayschedule-getvalues
joseph-robertson Apr 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/model/ScheduleDay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ namespace model {
DateTimeVector dateTimes = ts.dateTimes();
Vector values = ts.values();

unsigned N = dateTimes.size();
const unsigned N = dateTimes.size();
OS_ASSERT(values.size() == N);

if (N == 0) {
Expand Down Expand Up @@ -255,7 +255,7 @@ namespace model {
std::vector<double> values = this->values(); // these are already sorted
std::vector<openstudio::Time> times = this->times(); // these are already sorted

unsigned N = times.size();
const unsigned N = times.size();
OS_ASSERT(values.size() == N);

TimeSeries result;
Expand Down
16 changes: 12 additions & 4 deletions src/utilities/data/Matrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,31 @@ UTILITIES_API bool operator!=(const Matrix& lhs, const Matrix& rhs);

/// linear interpolation of the function v = f(x, y) at point xi, yi
/// assumes that x and y are strictly increasing
/// ti is the total seconds of the timestep interval; it is used for
/// AverageInterp and must be positive
UTILITIES_API double interp(const Vector& x, const Vector& y, const Matrix& v, double xi, double yi, InterpMethod interpMethod = LinearInterp,
ExtrapMethod extrapMethod = NoneExtrap, double ti = 0.0);
ExtrapMethod extrapMethod = NoneExtrap, double ti = -9999.0);

/// linear interpolation of the function v = f(x, y) at points xi, yi
/// assumes that x and y are strictly increasing
/// ti is the total seconds of the timestep interval; it is used for
/// AverageInterp and must be positive
UTILITIES_API Vector interp(const Vector& x, const Vector& y, const Matrix& v, const Vector& xi, double yi, InterpMethod interpMethod = LinearInterp,
ExtrapMethod extrapMethod = NoneExtrap, double ti = 0.0);
ExtrapMethod extrapMethod = NoneExtrap, double ti = -9999.0);

/// linear interpolation of the function v = f(x, y) at points xi, yi
/// assumes that x and y are strictly increasing
/// ti is the total seconds of the timestep interval; it is used for
/// AverageInterp and must be positive
UTILITIES_API Vector interp(const Vector& x, const Vector& y, const Matrix& v, double xi, const Vector& yi, InterpMethod interpMethod = LinearInterp,
ExtrapMethod extrapMethod = NoneExtrap, double ti = 0.0);
ExtrapMethod extrapMethod = NoneExtrap, double ti = -9999.0);

/// linear interpolation of the function v = f(x, y) at points xi, yi
/// assumes that x and y are strictly increasing
/// ti is the total seconds of the timestep interval; it is used for
/// AverageInterp and must be positive
UTILITIES_API Matrix interp(const Vector& x, const Vector& y, const Matrix& v, const Vector& xi, const Vector& yi,
InterpMethod interpMethod = LinearInterp, ExtrapMethod extrapMethod = NoneExtrap, double ti = 0.0);
InterpMethod interpMethod = LinearInterp, ExtrapMethod extrapMethod = NoneExtrap, double ti = -9999.0);

/// matrix product
UTILITIES_API Matrix prod(const Matrix& lop, const Matrix& rop);
Expand Down
3 changes: 2 additions & 1 deletion src/utilities/data/Vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,11 @@ InterpInfo interpInfo(const Vector& x, double xi, double ti) {

result.ia = (unsigned)(it - begin - 1);
result.ib = (unsigned)(it - begin);
if (ti == 0.0) {
if (ti < 0.0) {
result.wa = (x(result.ib) - xi) / (x(result.ib) - x(result.ia));
result.wb = (xi - x(result.ia)) / (x(result.ib) - x(result.ia));
} else {
OS_ASSERT(ti > 0.0);
joseph-robertson marked this conversation as resolved.
Show resolved Hide resolved
result.wb = xi - x(result.ia);
result.wa = ti - result.wb;
if ((result.wb > 0.0) && (result.wb < ti)) {
Expand Down
13 changes: 8 additions & 5 deletions src/utilities/data/Vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,21 @@ struct UTILITIES_API InterpInfo
};

/** Linear interpolation of the function y = f(x) at point xi. Assumes that x is strictly
* increasing. */
* increasing. ti is the total seconds of the timestep interval; it is used for
* AverageInterp and must be positive. */
UTILITIES_API InterpInfo interpInfo(const Vector& x, double xi, double ti);

/** Linear interpolation of the function y = f(x) at point xi. Assumes that x is strictly
* increasing */
* increasing. ti is the total seconds of the timestep interval; it is used for
* AverageInterp and must be positive. */
UTILITIES_API double interp(const Vector& x, const Vector& y, double xi, InterpMethod interpMethod = LinearInterp,
ExtrapMethod extrapMethod = NoneExtrap, double ti = 0.0);
ExtrapMethod extrapMethod = NoneExtrap, double ti = -9999.0);

/** Linear interpolation of the function y = f(x) at points xi. Assumes that x is strictly
* increasing. */
* increasing. ti is the total seconds of the timestep interval; it is used for
* AverageInterp and must be positive. */
UTILITIES_API Vector interp(const Vector& x, const Vector& y, const Vector& xi, InterpMethod interpMethod = LinearInterp,
ExtrapMethod extrapMethod = NoneExtrap, double ti = 0.0);
ExtrapMethod extrapMethod = NoneExtrap, double ti = -9999.0);

//@}
/** @name Common Methods and Vector Operations */
Expand Down