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

Issue245 #347

Merged
merged 4 commits into from
Oct 24, 2024
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
Fix a bug in the graphing of explicit pools with varying valid or ref…
…erence dates, #245.
  • Loading branch information
james-d-brown committed Oct 24, 2024
commit 050433e4450dac50f65f21ade3532bc17ea5f84b
50 changes: 48 additions & 2 deletions wres-config/src/wres/config/yaml/DeclarationInterpolator.java
Original file line number Diff line number Diff line change
Expand Up @@ -942,13 +942,15 @@ private static Outputs.GraphicFormat getGraphicsFormatOptions( Outputs.GraphicFo
Outputs.GraphicFormat.Builder newOptions = options.toBuilder();

// Reference date pools?
if ( Objects.nonNull( builder.referenceDatePools() )
if ( ( Objects.nonNull( builder.referenceDatePools() )
|| DeclarationInterpolator.hasExplicitReferenceDatePools( builder.timeWindows() ) )
&& options.getShape() == Outputs.GraphicFormat.GraphicShape.DEFAULT )
{
newOptions.setShape( Outputs.GraphicFormat.GraphicShape.ISSUED_DATE_POOLS );
}
// Valid date pools?
else if ( Objects.nonNull( builder.validDatePools() )
else if ( ( Objects.nonNull( builder.validDatePools() )
|| DeclarationInterpolator.hasExplicitValidDatePools( builder.timeWindows() ) )
&& options.getShape() == Outputs.GraphicFormat.GraphicShape.DEFAULT )
{
newOptions.setShape( Outputs.GraphicFormat.GraphicShape.VALID_DATE_POOLS );
Expand All @@ -963,6 +965,50 @@ else if ( Objects.nonNull( builder.validDatePools() )
return newOptions.build();
}

/**
* @param timeWindows the time windows
* @return whether there is more than one time window with different reference dates
*/
private static boolean hasExplicitReferenceDatePools( Set<TimeWindow> timeWindows )
{
Set<Pair<Timestamp, Timestamp>> referenceDates = new HashSet<>();
for ( TimeWindow next : timeWindows )
{
Pair<Timestamp, Timestamp> pair = Pair.of( next.getEarliestReferenceTime(), next.getLatestReferenceTime() );
referenceDates.add( pair );

// Short-circuit
if ( referenceDates.size() > 1 )
{
return true;
}
}

return false;
}

/**
* @param timeWindows the time windows
* @return whether there is more than one time window with different valid dates
*/
private static boolean hasExplicitValidDatePools( Set<TimeWindow> timeWindows )
{
Set<Pair<Timestamp, Timestamp>> validDates = new HashSet<>();
for ( TimeWindow next : timeWindows )
{
Pair<Timestamp, Timestamp> pair = Pair.of( next.getEarliestValidTime(), next.getLatestValidTime() );
validDates.add( pair );

// Short-circuit
if ( validDates.size() > 1 )
{
return true;
}
}

return false;
}

/**
* Copies the evaluation units to the value threshold units when they are not declared explicitly.
*
Expand Down
Loading