-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add longitude animation for geostationary projection
- Loading branch information
1 parent
d79eb4d
commit 631f129
Showing
30 changed files
with
460 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
Sanchez.Workflow/Steps/Geostationary/Reprojected/SetTargetLongitude.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Ardalis.GuardClauses; | ||
using Sanchez.Processing.Extensions; | ||
using Sanchez.Processing.Models; | ||
using Sanchez.Workflow.Extensions; | ||
using Sanchez.Workflow.Models.Data; | ||
using WorkflowCore.Interface; | ||
using WorkflowCore.Models; | ||
using Range = Sanchez.Processing.Models.Angles.Range; | ||
|
||
namespace Sanchez.Workflow.Steps.Geostationary.Reprojected | ||
{ | ||
internal class SetTargetLongitude : StepBody | ||
{ | ||
private readonly RenderOptions _options; | ||
|
||
public SetTargetLongitude(RenderOptions options) => _options = options; | ||
public double? Longitude { get; set; } | ||
|
||
/// <summary> | ||
/// Timestamp of currently-processed step. | ||
/// </summary> | ||
public DateTime? TargetTimestamp { get; set; } | ||
|
||
public List<DateTime>? TimeIntervals { get; set; } | ||
|
||
public override ExecutionResult Run(IStepExecutionContext context) | ||
{ | ||
Guard.Against.Null(TargetTimestamp, nameof(TargetTimestamp)); | ||
|
||
var geostationaryOptions = _options.GeostationaryRender!; | ||
|
||
Longitude = geostationaryOptions.EndLongitude == null | ||
? geostationaryOptions.Longitude | ||
: GetTimelapseLongitude(geostationaryOptions); | ||
|
||
return ExecutionResult.Next(); | ||
} | ||
|
||
private double GetTimelapseLongitude(GeostationaryRenderOptions geostationaryOptions) | ||
{ | ||
Guard.Against.Null(TimeIntervals, nameof(TimeIntervals)); | ||
Guard.Against.Zero(TimeIntervals.Count, nameof(TimeIntervals)); | ||
|
||
var currentIndex = TimeIntervals.IndexOf(TargetTimestamp!.Value); | ||
if (currentIndex < 0) throw new InvalidOperationException($"Unable to find timestamp {TargetTimestamp} in timelapse"); | ||
|
||
var start = geostationaryOptions.Longitude!.Value; | ||
var end = geostationaryOptions.EndLongitude!.Value; | ||
|
||
var range = new Range(start, end).UnwrapLongitude(); | ||
var offset = (range.End - range.Start) * (currentIndex / ((double) TimeIntervals.Count - 1)); | ||
|
||
return (start + offset).NormaliseLongitude(); | ||
} | ||
} | ||
|
||
public static class SetTargetLongitudeExtensions | ||
{ | ||
internal static IStepBuilder<TData, SetTargetLongitude> SetTargetLongitude<TStep, TData>(this IStepBuilder<TData, TStep> builder) | ||
where TStep : IStepBody | ||
where TData : GeostationaryTimelapseWorkflowData | ||
=> builder | ||
.Then<TStep, SetTargetLongitude, TData>() | ||
.Input(step => step.TargetTimestamp, data => data.TargetTimestamp) | ||
.Input(step => step.TimeIntervals, data => data.TimeIntervals) | ||
.Output(data => data.Longitude, step => step.Longitude); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.