Release 1.1.2: improve processing status and inspect stellar elongation
All checks were successful
Release AstroFrame / packages (push) Successful in 1m9s
All checks were successful
Release AstroFrame / packages (push) Successful in 1m9s
This commit is contained in:
parent
65ded0b606
commit
5ad7a6a79e
12 changed files with 258 additions and 41 deletions
|
|
@ -1,6 +1,6 @@
|
|||
<Project>
|
||||
<PropertyGroup>
|
||||
<Version>1.1.1</Version>
|
||||
<Version>1.1.2</Version>
|
||||
<Authors>Elijah Kuntz</Authors>
|
||||
<Product>AstroFrame</Product>
|
||||
</PropertyGroup>
|
||||
|
|
|
|||
9
docs/release-notes/1.1.2.md
Normal file
9
docs/release-notes/1.1.2.md
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# AstroFrame 1.1.2
|
||||
|
||||
- Show live process memory usage in the bottom status bar during analysis and export, and hide it when processing ends.
|
||||
- Give the processing progress bar a contrasting blue fill and a slightly thicker track.
|
||||
- Use muted green, gold and rose colors in the quality graph to match the rest of the interface.
|
||||
- Apply the spatial overlay to both selected and nearby frames when comparing, including after switching frames or reopening comparison.
|
||||
- Add **Inspect elongation** beside **Reset view**. Enlarge strong source stars without smoothing, highlight their fitted ellipse and major/minor axes, and show crop ellipticity alongside the frame measurements. Shape guides can be hidden. A suitable aligned KEEP exposure supplies matching comparison stars; selected stars remain available when no comparison exists.
|
||||
|
||||
Validation: 87 engine checks, 23 updater checks, 10 mocked publisher checks, and isolated Windows desktop interaction/rendering checks at 96 and 144 DPI. Source reads, star matching, rotated elongation, missing comparisons, cancellation and changed-source refusal are covered. Development verification uses copied workspace caches and leaves the installed application untouched. The server release workflow builds Windows and Linux packages and checks the packaged Linux settings page.
|
||||
|
|
@ -121,6 +121,14 @@ For later releases, use the automatic tag workflow above, or validate/build/publ
|
|||
|
||||
## Verification
|
||||
|
||||
For preview and processing-status changes, build the source and run the isolated Windows diagnostic against a saved project analyzed by the current engine. The FITS sources must still be available. The helper copies its metadata and caches into a fresh workspace folder before exercising controls or saving test decisions:
|
||||
|
||||
```powershell
|
||||
./tools/Verify-Preview.ps1 -FixtureProject 'path/to/saved-project' -Output artifacts/preview-verification
|
||||
```
|
||||
|
||||
This checks comparison overlays, zoom/pan, processing-memory visibility, elongation crops and guide toggling, absent comparisons, loading cancellation, and native window controls. It renders normal and minimum-size controls at 96 and 144 DPI. Inspect the PNG files in the output's `qa` directory. It launches only the source build in diagnostic mode, which bypasses installed settings and updates.
|
||||
|
||||
`./tools/Verify-ReleaseAutomation.ps1` exercises version/tag mismatch, upload failure, draft resumption, conflicting assets, immutable published releases and package integrity with a mocked release API. It never publishes a real release.
|
||||
|
||||
`tests/AstroFrame.Updates.Validation` covers settings recovery, network failures, concurrent checks, restart safety, save failure, real package checksums, corruption rejection and downgrade prevention. An optional release-feed argument adds real-package checks:
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ public sealed partial class MainWindow
|
|||
bitmap.Render(this);bitmap.Save(System.IO.Path.Combine(output,name+".png"));
|
||||
}
|
||||
Check(project==null&&selected==null&&visible.Count==0,"ordinary startup starts a fresh session");
|
||||
Check(!memoryUsage.IsVisible&&!memoryTimer.IsEnabled&&!progress.IsVisible&&!inspectElongation.IsEnabled,"idle startup hides processing stats and disables star inspection");
|
||||
Check(Background==Palette.Background&&TransparencyBackgroundFallback==Palette.Background&&NativeWindowBackground.IsApplied(this),"managed and native startup backgrounds match the application grey");
|
||||
Capture("fresh-session");
|
||||
await updates.Check();Check(settingsButton.Background==Palette.Update&&settingsButton.Classes.Contains("update-available"),"available update turns Settings cerulean blue");
|
||||
|
|
@ -42,11 +43,38 @@ public sealed partial class MainWindow
|
|||
Select(visible.Skip(1).First());await WaitForPreviews();Check(viewport.Zoom==zoom&&viewport.Pan==pan,"zoom and position persist when switching frames");
|
||||
previewMode.SelectedIndex=1;displayStretch.Value=.26;spatial.IsChecked=true;compare.IsChecked=true;await WaitForPreviews();await Task.Delay(150);
|
||||
Check(preview.Viewport==comparison.Viewport&&viewport.Zoom==zoom&&viewport.Pan==pan,"comparison, overlay and nebula view preserve the same viewport");
|
||||
Capture("comparison-overlay");
|
||||
Check(preview.Spatial&&comparison.Spatial&&comparison.HasImage,"Overlay applies to both loaded comparison frames");
|
||||
Capture("zoom-overlay-update");Width=1120;Height=740;await Task.Delay(150);Capture("minimum-zoom",144);
|
||||
resetView.RaiseEvent(new RoutedEventArgs(Avalonia.Controls.Button.ClickEvent));Check(viewport.Zoom==1&&viewport.Pan==default,"Reset view resets both zoom and position");
|
||||
var bounds=resetView.TranslatePoint(default,this)!.Value;
|
||||
Check(bounds.X>=0&&bounds.X+resetView.Bounds.Width<=Bounds.Width,"Reset view stays visible at minimum window width");
|
||||
Capture("minimum-reset",144);
|
||||
spatial.IsChecked=false;Check(!preview.Spatial&&!comparison.Spatial,"Overlay turns off on both frames");
|
||||
spatial.IsChecked=true;compare.IsChecked=false;compare.IsChecked=true;Select(visible[0]);await WaitForPreviews();await Task.Delay(150);
|
||||
Check(preview.Spatial&&comparison.Spatial&&comparison.HasImage,"Overlay persists on both panes after toggling comparison and changing frame");
|
||||
Capture("comparison-fit",144);
|
||||
Busy(true);progress.Value=57;status.Text="Analyzing lights · 57 / 100 · "+selected!.Name;await Task.Delay(1100);
|
||||
Check(memoryUsage.IsVisible&&memoryTimer.IsEnabled&&memoryUsage.Text!.StartsWith("Memory: ")&&memoryUsage.Text.EndsWith(" MB"),"processing shows a live process memory statistic");
|
||||
Check(!inspectElongation.IsEnabled,"star inspection is disabled during processing");
|
||||
var memoryBounds=memoryUsage.TranslatePoint(default,this)!.Value;
|
||||
Check(memoryBounds.X>=0&&memoryBounds.X+memoryUsage.Bounds.Width<=Bounds.Width&&status.Bounds.Right<=memoryBounds.X,"long processing filenames leave room for the memory statistic");
|
||||
Capture("processing",144);Busy(false);
|
||||
Check(!memoryUsage.IsVisible&&!memoryTimer.IsEnabled&&memoryUsage.Text==""&&!progress.IsVisible,"finishing processing stops the timer and removes the memory statistic");
|
||||
Check(inspectElongation.IsEnabled,"selected measured frame enables star inspection");
|
||||
inspectElongation.RaiseEvent(new RoutedEventArgs(Avalonia.Controls.Button.ClickEvent));var stars=starInspector!;await stars.Loading;await Task.Delay(150);
|
||||
Check(stars.HasDetail&&stars.Crops.Count>0&&stars.Crops.Any(c=>c.Shape!=null),"Inspect elongation button opens enlarged source crops with fitted shape guides");
|
||||
using(var starBitmap=new RenderTargetBitmap(new PixelSize((int)stars.Bounds.Width,(int)stars.Bounds.Height),new Vector(96,96))){starBitmap.Render(stars);starBitmap.Save(System.IO.Path.Combine(output,"elongation.png"));}
|
||||
var guides=stars.GetVisualDescendants().OfType<CheckBox>().Single();guides.IsChecked=false;
|
||||
Check(stars.Crops.All(c=>!c.ShowGuides),"shape guides can be hidden to inspect the original star pixels");
|
||||
guides.IsChecked=true;stars.Width=660;stars.Height=520;await Task.Delay(150);
|
||||
using(var starBitmap=new RenderTargetBitmap(new PixelSize((int)(stars.Bounds.Width*1.5),(int)(stars.Bounds.Height*1.5)),new Vector(144,144))){starBitmap.Render(stars);starBitmap.Save(System.IO.Path.Combine(output,"elongation-minimum.png"));}
|
||||
stars.Close();Check(starInspector==null,"closing the elongation window releases it");
|
||||
var single=new StarInspector(new AstroFrame.Engine.Project{Frames=[selected!]},projectDirectory,selected!);single.Show(this);await single.Loading;await Task.Delay(100);
|
||||
Check(single.HasDetail&&single.Crops.Count>0&&single.Crops.Count<=8,"elongation window shows selected stars when no KEEP comparison exists");
|
||||
using(var starBitmap=new RenderTargetBitmap(new PixelSize((int)single.Bounds.Width,(int)single.Bounds.Height),new Vector(96,96))){starBitmap.Render(single);starBitmap.Save(System.IO.Path.Combine(output,"elongation-single.png"));}
|
||||
single.Close();inspectElongation.RaiseEvent(new RoutedEventArgs(Avalonia.Controls.Button.ClickEvent));var cancelledStars=starInspector!;cancelledStars.Close();await cancelledStars.Loading;
|
||||
Check(starInspector==null&&!cancelledStars.HasDetail,"closing star inspection while loading cancels cleanly");
|
||||
await SmokeTest(System.IO.Path.Combine(output,"smoke-checks.txt"));
|
||||
File.WriteAllLines(System.IO.Path.Combine(output,"interaction-checks.txt"),results);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@ public sealed partial class MainWindow:Window
|
|||
readonly PreviewViewport viewport=new();
|
||||
readonly ExposureView preview,comparison;
|
||||
readonly Button resetView=Button("Reset view");
|
||||
readonly Button inspectElongation=Button("Inspect elongation");
|
||||
readonly DispatcherTimer memoryTimer=new(){Interval=TimeSpan.FromSeconds(1)};
|
||||
StarInspector? starInspector;
|
||||
readonly Border previewPanel,comparisonBorder,previewControls;
|
||||
readonly ComboBox previewMode=new(){ItemsSource=new[]{"Frame view","Nebula view"},SelectedIndex=0,MinWidth=150};
|
||||
readonly Slider displayStretch=new(){Minimum=.08,Maximum=.40,Value=.18};
|
||||
|
|
@ -36,9 +39,10 @@ public sealed partial class MainWindow:Window
|
|||
readonly TextBlock exposureName=Palette.Label("",11,Palette.Muted),exposureStatus=Palette.Label("",12);
|
||||
readonly TextBlock title=Palette.Label("Light frames",18),subtitle=Palette.Label("Choose a folder to begin",11,Palette.Muted);
|
||||
readonly TextBlock status=Palette.Label("",11,Palette.Muted);
|
||||
readonly TextBlock memoryUsage=Palette.Label("",11,Palette.Muted);
|
||||
readonly TextBlock keep=Palette.Label("—",22,Palette.Keep),review=Palette.Label("—",22,Palette.Review),reject=Palette.Label("—",22,Palette.Reject),integration=Palette.Label("—",22);
|
||||
readonly TextBlock keepTime=Palette.Label("",11,Palette.Muted),reviewTime=Palette.Label("",11,Palette.Muted),rejectTime=Palette.Label("",11,Palette.Muted),totalTime=Palette.Label("",11,Palette.Muted);
|
||||
readonly ProgressBar progress=new(){Height=3,Minimum=0,Maximum=100,IsVisible=false};
|
||||
readonly ProgressBar progress=new(){Height=5,Minimum=0,Maximum=100,IsVisible=false,Foreground=Palette.Progress,Background=Palette.Line};
|
||||
readonly Button analyze=Button("Analyze lights",true),export=Button("Export accepted"),stop=Button("Cancel");
|
||||
readonly CheckBox spatial=new(){Content="Spatial overlay",FontSize=12},compare=new(){Content="Compare nearby",FontSize=12};
|
||||
Frame? selected;List<Frame> visible=[];
|
||||
|
|
@ -84,8 +88,10 @@ public sealed partial class MainWindow:Window
|
|||
var columns=new Grid{ColumnDefinitions=new("*,61,48,44"),Margin=new(14,8,14,8)};int ci=0;foreach(string label in new[]{"Time (UTC)","Decision","Stars","FWHM"}){var text=Palette.Label(label,10,Palette.Muted);if(ci>1)text.HorizontalAlignment=HorizontalAlignment.Right;Grid.SetColumn(text,ci++);columns.Children.Add(text);}Grid.SetRow(columns,2);queue.Children.Add(columns);
|
||||
frames.Background=Brushes.Transparent;frames.Padding=new(0);frames.ItemTemplate=new FuncDataTemplate<Frame>((f,_)=>f==null?new Border():FrameRow(f));frames.SelectionChanged+=(_,_)=>{if(!refreshing&&frames.SelectedItem is Frame f)Select(f);};Grid.SetRow(frames,3);queue.Children.Add(frames);var queuePanel=Panel(queue);queuePanel.Margin=new(0,0,16,0);body.Children.Add(queuePanel);
|
||||
var center=new Grid{RowDefinitions=new("Auto,Auto,*,Auto,Auto,Auto"),Margin=new(0,0,16,0),MinWidth=310};Grid.SetColumn(center,1);body.Children.Add(center);
|
||||
var previewHeading=new Grid{ColumnDefinitions=new("*,Auto,Auto"),Margin=new(0,6,0,8)};previewHeading.Children.Add(Palette.Label("Exposure preview",14));position.HorizontalAlignment=HorizontalAlignment.Right;position.VerticalAlignment=VerticalAlignment.Center;Grid.SetColumn(position,1);previewHeading.Children.Add(position);
|
||||
resetView.Padding=new(9,5);resetView.FontSize=11;resetView.Margin=new(10,0,0,0);resetView.Click+=(_,_)=>viewport.Reset();ToolTip.SetTip(resetView,"Reset image zoom and position");Grid.SetColumn(resetView,2);previewHeading.Children.Add(resetView);center.Children.Add(previewHeading);
|
||||
var previewHeading=new Grid{ColumnDefinitions=new("*,Auto"),RowDefinitions=new("Auto,Auto"),Margin=new(0,6,0,8)};previewHeading.Children.Add(Palette.Label("Exposure preview",14));position.HorizontalAlignment=HorizontalAlignment.Right;position.VerticalAlignment=VerticalAlignment.Center;Grid.SetColumn(position,1);previewHeading.Children.Add(position);
|
||||
var previewActions=new WrapPanel{Margin=new(0,8,0,0)};
|
||||
resetView.Padding=new(9,5);resetView.FontSize=11;resetView.Click+=(_,_)=>viewport.Reset();ToolTip.SetTip(resetView,"Reset image zoom and position");previewActions.Children.Add(resetView);
|
||||
inspectElongation.Padding=new(9,5);inspectElongation.FontSize=11;inspectElongation.Margin=new(8,0,0,0);inspectElongation.IsEnabled=false;inspectElongation.Click+=(_,_)=>ShowElongation();ToolTip.SetTip(inspectElongation,"Enlarge source stars and highlight their shape, with a matched KEEP frame when available");previewActions.Children.Add(inspectElongation);Grid.SetRow(previewActions,1);Grid.SetColumnSpan(previewActions,2);previewHeading.Children.Add(previewActions);center.Children.Add(previewHeading);
|
||||
var viewRow=new Grid{ColumnDefinitions=new("Auto,*,Auto")};previewMode.MinWidth=125;previewMode.FontSize=11;viewRow.Children.Add(previewMode);var switches=new StackPanel{Orientation=Orientation.Horizontal,VerticalAlignment=VerticalAlignment.Center};spatial.Content="Overlay";compare.Content="Compare";spatial.Margin=new(0,0,12,0);switches.Children.Add(spatial);switches.Children.Add(compare);Grid.SetColumn(switches,2);viewRow.Children.Add(switches);Grid.SetRow(viewRow,1);center.Children.Add(viewRow);
|
||||
previewWorkspace.Children.Add(previewPanel);Grid.SetColumn(comparisonBorder,1);previewWorkspace.Children.Add(comparisonBorder);comparisonBorder.IsVisible=false;Grid.SetRow(previewWorkspace,2);center.Children.Add(previewWorkspace);
|
||||
Grid.SetRow(previewControls,3);center.Children.Add(previewControls);
|
||||
|
|
@ -95,11 +101,12 @@ public sealed partial class MainWindow:Window
|
|||
var right=new Grid{RowDefinitions=new("2*,3*"),MinWidth=320};Grid.SetColumn(right,2);body.Children.Add(right);
|
||||
var graphs=new Grid{RowDefinitions=new("Auto,*"),Margin=new(12)};var graphHeader=new Grid{ColumnDefinitions=new("*,Auto"),Margin=new(0,0,0,8)};var graphTitle=Palette.Label("Quality",14);graphTitle.VerticalAlignment=VerticalAlignment.Center;graphHeader.Children.Add(graphTitle);metric.MaxWidth=205;metric.FontSize=11;Grid.SetColumn(metric,1);graphHeader.Children.Add(metric);graphs.Children.Add(graphHeader);Grid.SetRow(chart,1);graphs.Children.Add(chart);var graphPanel=Panel(graphs);graphPanel.Margin=new(0,0,0,14);right.Children.Add(graphPanel);
|
||||
inspector.Margin=new(14);details.Child=new ScrollViewer{Content=inspector,HorizontalScrollBarVisibility=Avalonia.Controls.Primitives.ScrollBarVisibility.Disabled};details.Background=Palette.Panel;details.BorderBrush=Palette.Line;details.BorderThickness=new(.5);details.CornerRadius=new(2);Grid.SetRow(details,1);right.Children.Add(details);root.Children.Add(body);
|
||||
var footer=new Grid{RowDefinitions=new("Auto,Auto"),Margin=new(20,7,20,7)};footer.Children.Add(progress);var footerLine=new Grid{ColumnDefinitions=new("*,Auto")};footerLine.Children.Add(status);stop.IsVisible=false;Grid.SetColumn(stop,1);footerLine.Children.Add(stop);Grid.SetRow(footerLine,1);footer.Children.Add(footerLine);Grid.SetRow(footer,3);root.Children.Add(footer);Content=root;
|
||||
var footer=new Grid{RowDefinitions=new("Auto,Auto"),Margin=new(20,7,20,7)};footer.Children.Add(progress);var footerLine=new Grid{ColumnDefinitions=new("*,Auto,Auto")};status.TextTrimming=TextTrimming.CharacterEllipsis;status.VerticalAlignment=VerticalAlignment.Center;footerLine.Children.Add(status);memoryUsage.IsVisible=false;memoryUsage.Margin=new(14,0,14,0);memoryUsage.VerticalAlignment=VerticalAlignment.Center;ToolTip.SetTip(memoryUsage,"AstroFrame process RAM currently resident in physical memory");Grid.SetColumn(memoryUsage,1);footerLine.Children.Add(memoryUsage);stop.IsVisible=false;Grid.SetColumn(stop,2);footerLine.Children.Add(stop);Grid.SetRow(footerLine,1);footer.Children.Add(footerLine);Grid.SetRow(footer,3);root.Children.Add(footer);Content=root;
|
||||
memoryTimer.Tick+=(_,_)=>UpdateMemoryUsage();
|
||||
analyze.Click+=async(_,_)=>await Analyze();export.Click+=async(_,_)=>await ExportAccepted();stop.Click+=(_,_)=>cancellation?.Cancel();
|
||||
filter.SelectionChanged+=(_,_)=>{if(!refreshing)RefreshFrames();};sort.SelectionChanged+=(_,_)=>{if(!refreshing)RefreshFrames();};metric.SelectionChanged+=(_,_)=>{chart.Metric=QualityChart.Metrics[Math.Max(0,metric.SelectedIndex)];chart.InvalidateVisual();};
|
||||
chart.FrameClicked+=f=>{if(!visible.Contains(f))filter.SelectedIndex=0;frames.SelectedItem=f;frames.ScrollIntoView(f);Select(f);};
|
||||
spatial.IsCheckedChanged+=(_,_)=>{preview.Spatial=spatial.IsChecked==true;preview.InvalidateVisual();};compare.IsCheckedChanged+=(_,_)=>UpdateComparison();
|
||||
spatial.IsCheckedChanged+=(_,_)=>{preview.Spatial=comparison.Spatial=spatial.IsChecked==true;preview.InvalidateVisual();comparison.InvalidateVisual();};compare.IsCheckedChanged+=(_,_)=>UpdateComparison();
|
||||
ToolTip.SetTip(spatial,"Pink shows the strongest excess sky brightness against the clean session reference, excluding weak background residuals. Grid colors show regional stellar flux. This is supporting evidence, not an exact cloud boundary.");
|
||||
KeyDown+=async(_,e)=>
|
||||
{
|
||||
|
|
@ -109,7 +116,7 @@ public sealed partial class MainWindow:Window
|
|||
if(e.Key==Key.Z&&e.KeyModifiers.HasFlag(KeyModifiers.Control)&&undo.Count>0){var item=undo.Pop();item.Frame.Override=item.Verdict;item.Frame.Note=item.Note;item.Frame.ReviewedAt=item.At;await Save();RefreshFrames(item.Frame);e.Handled=true;}
|
||||
};
|
||||
Closing+=(_,e)=>{if(busy){e.Cancel=true;cancellation?.Cancel();status.Text="Stopping safely; close again when finished";}};
|
||||
Closed+=(_,_)=>{preview.Dispose();comparison.Dispose();};ShowEmpty();InitializeUpdates();
|
||||
Closed+=(_,_)=>{memoryTimer.Stop();starInspector?.Close();preview.Dispose();comparison.Dispose();};ShowEmpty();InitializeUpdates();
|
||||
}
|
||||
static Button Button(string text,bool primary=false)=>new(){Content=text,Padding=new(12,7),CornerRadius=new(2),Background=primary?Palette.Accent:Palette.Raised,Foreground=primary?Palette.Background:Palette.Text};
|
||||
static Border Panel(Control child)=>new(){Background=Palette.Panel,BorderBrush=Palette.Line,BorderThickness=new(.5),CornerRadius=new(2),ClipToBounds=true,Child=child};
|
||||
|
|
@ -207,10 +214,11 @@ public sealed partial class MainWindow:Window
|
|||
await NativeDesktopChecks.Verify(this,Check);
|
||||
File.WriteAllLines(report,results);projectDirectory=original;
|
||||
}
|
||||
void ShowNoSelection(){inspector.Children.Clear();position.Text="";exposureName.Text="No exposures match this filter";exposureStatus.Text="";details.IsVisible=false;preview.Load(projectDirectory,null);comparison.Load(projectDirectory,null);chart.Selected=null;}
|
||||
void ShowNoSelection(){selected=null;inspectElongation.IsEnabled=false;inspector.Children.Clear();position.Text="";exposureName.Text="No exposures match this filter";exposureStatus.Text="";details.IsVisible=false;preview.Load(projectDirectory,null);comparison.Load(projectDirectory,null);chart.Selected=null;}
|
||||
void Select(Frame f)
|
||||
{
|
||||
selected=f;chart.Selected=f;chart.InvalidateVisual();details.IsVisible=true;inspector.Children.Clear();
|
||||
inspectElongation.IsEnabled=!busy&&f.Measured&&f.Error=="";
|
||||
position.Text=$"{visible.IndexOf(f)+1:N0} / {visible.Count:N0}";
|
||||
preview.Load(projectDirectory,f,project?.Frames);preview.Spatial=spatial.IsChecked==true;UpdateComparison();
|
||||
exposureName.Text=f.Name;ToolTip.SetTip(exposureName,f.Name);exposureStatus.Text=f.Status+" · "+f.Time+" UTC"+(f.Override.HasValue?" · Manual":"");exposureStatus.Foreground=Palette.Verdict(f.Effective);
|
||||
|
|
@ -233,6 +241,7 @@ public sealed partial class MainWindow:Window
|
|||
{
|
||||
bool show=compare.IsChecked==true;comparisonBorder.IsVisible=show;previewWorkspace.ColumnDefinitions[1].Width=show?new GridLength(1,GridUnitType.Star):new GridLength(0);previewPanel.Margin=show?new(0,0,6,0):new(0);
|
||||
preview.Caption=show?"Selected":"";comparison.Caption=show?"Nearby":"";preview.InvalidateVisual();
|
||||
comparison.Spatial=spatial.IsChecked==true;
|
||||
if(selected==null||project==null||!show){comparison.Load(projectDirectory,null);return;}
|
||||
var nearby=project.Frames.Where(f=>f.Session==selected.Session&&f.Id!=selected.Id&&f.Timestamp.HasValue&&selected.Timestamp.HasValue&&f.Error=="").OrderBy(f=>Math.Abs((f.Timestamp!.Value-selected.Timestamp!.Value).TotalSeconds)).FirstOrDefault();comparison.Load(projectDirectory,nearby,project.Frames);ToolTip.SetTip(comparisonBorder,nearby==null?"No comparable nearby exposure":"Nearby · "+nearby.Time+" · "+nearby.Status);
|
||||
}
|
||||
|
|
@ -252,7 +261,21 @@ public sealed partial class MainWindow:Window
|
|||
}
|
||||
async Task<string?> Folder(string title)
|
||||
{var result=await StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions{Title=title,AllowMultiple=false});return result.FirstOrDefault()?.TryGetLocalPath();}
|
||||
void Busy(bool value){busy=value;analyze.IsEnabled=!value;export.IsEnabled=!value&&project?.Complete==true;frames.IsEnabled=sessions.IsEnabled=chart.IsEnabled=filter.IsEnabled=sort.IsEnabled=metric.IsEnabled=!value;inspector.IsEnabled=!value;stop.IsVisible=progress.IsVisible=value;}
|
||||
void Busy(bool value)
|
||||
{
|
||||
busy=value;analyze.IsEnabled=!value;export.IsEnabled=!value&&project?.Complete==true;frames.IsEnabled=sessions.IsEnabled=chart.IsEnabled=filter.IsEnabled=sort.IsEnabled=metric.IsEnabled=!value;inspector.IsEnabled=!value;stop.IsVisible=progress.IsVisible=memoryUsage.IsVisible=value;
|
||||
inspectElongation.IsEnabled=!value&&selected?.Measured==true&&selected.Error=="";
|
||||
if(value){starInspector?.Close();UpdateMemoryUsage();memoryTimer.Start();}else{memoryTimer.Stop();memoryUsage.Text="";}
|
||||
}
|
||||
void UpdateMemoryUsage()
|
||||
{
|
||||
if(!busy)return;using var process=System.Diagnostics.Process.GetCurrentProcess();memoryUsage.Text=$"Memory: {process.WorkingSet64/1048576.0:N0} MB";
|
||||
}
|
||||
void ShowElongation()
|
||||
{
|
||||
if(busy||saving||updates.Applying||project==null||selected?.Measured!=true||selected.Error!="")return;
|
||||
starInspector?.Close();starInspector=new StarInspector(project,projectDirectory,selected);var opened=starInspector;opened.Closed+=(_,_)=>{if(starInspector==opened)starInspector=null;};opened.Show(this);
|
||||
}
|
||||
async Task Analyze()
|
||||
{
|
||||
if(busy||saving||updates.Applying)return;
|
||||
|
|
|
|||
|
|
@ -13,39 +13,49 @@ public sealed class StarInspector:Window
|
|||
{
|
||||
readonly List<WriteableBitmap> bitmaps=[];
|
||||
readonly CancellationTokenSource cancellation=new();
|
||||
public Task Loading {get;private set;}=Task.CompletedTask;
|
||||
public bool HasDetail {get;private set;}
|
||||
public List<StarCropView> Crops {get;}=[];
|
||||
public StarInspector(Project project,string directory,Frame selected,string? capture=null)
|
||||
{
|
||||
Title="AstroFrame · Matched star detail";Width=900;Height=790;MinWidth=660;MinHeight=520;Background=Palette.Background;FontFamily="Inter";WindowStartupLocation=WindowStartupLocation.CenterOwner;
|
||||
var token=cancellation.Token;
|
||||
Title="AstroFrame · Stellar elongation";Width=900;Height=790;MinWidth=660;MinHeight=520;Background=TransparencyBackgroundFallback=Palette.Background;FontFamily="Inter";WindowStartupLocation=WindowStartupLocation.CenterOwner;NativeWindowBackground.Apply(this);
|
||||
var panel=new StackPanel{Margin=new(24),Spacing=12};Content=new Border{Background=Palette.Background,Child=new ScrollViewer{Content=panel}};var progress=Palette.Label("Reading matched source stars…",16);panel.Children.Add(progress);
|
||||
Opened+=async(_,_)=>
|
||||
Opened+=(_,_)=>Loading=LoadDetail();
|
||||
async Task LoadDetail()
|
||||
{
|
||||
try
|
||||
{
|
||||
var peer=StellarDetail.Comparison(project,selected)??throw new InvalidDataException("No comparable KEEP exposure in this session");
|
||||
var detail=await Task.Run(async()=>{using var memory=await ResourcePolicy.Acquire(ResourcePolicy.EstimateFrameBytes(selected.Width,selected.Height,selected.Bayer!=""?2:1)*2,cancellation.Token);return StellarDetail.Read(directory,selected,peer,cancellation.Token);},cancellation.Token);
|
||||
cancellation.Token.ThrowIfCancellationRequested();panel.Children.Clear();panel.Children.Add(Palette.Label("Matched stars · original source samples",21));
|
||||
panel.Children.Add(new TextBlock{Text="Identical stars, aligned between exposures. Each crop has its own brightness normalization. Pixels are enlarged without smoothing; Bayer samples are combined 2×2. Judge shape here, and transparency from the flux measurements.",FontSize=12,Foreground=Palette.Muted,TextWrapping=TextWrapping.Wrap});
|
||||
var peer=StellarDetail.Comparison(project,selected);
|
||||
var detail=await Task.Run(async()=>{using var memory=await ResourcePolicy.Acquire(ResourcePolicy.EstimateFrameBytes(selected.Width,selected.Height,selected.Bayer!=""?2:1)*(peer==null?1:2),token);return StellarDetail.Read(directory,selected,peer,token);},token);
|
||||
token.ThrowIfCancellationRequested();panel.Children.Clear();panel.Children.Add(Palette.Label("Stellar elongation · enlarged source stars",21));
|
||||
panel.Children.Add(new TextBlock{Text="Blue outlines and long axes highlight the star shape; gold lines mark the short axes. Ellipticity is 1 − b/a: 0 is round, higher values are more elongated. Guides and crop values use source core moments. Frame values below summarize the strong stars across the image.",FontSize=12,Foreground=Palette.Muted,TextWrapping=TextWrapping.Wrap});
|
||||
panel.Children.Add(new TextBlock{Text="Pixels are enlarged without smoothing, with separate brightness normalization per crop. Bayer samples are combined 2×2. "+(peer==null?"No aligned KEEP exposure is available; showing the selected stars.":"Both columns show the same stars in aligned exposures. Judge transparency from the flux measurements."),FontSize=12,Foreground=Palette.Muted,TextWrapping=TextWrapping.Wrap});
|
||||
var guides=new CheckBox{Content="Show shape guides",IsChecked=true,FontSize=12};guides.IsCheckedChanged+=(_,_)=>{foreach(var crop in Crops){crop.ShowGuides=guides.IsChecked==true;crop.InvalidateVisual();}};panel.Children.Add(guides);
|
||||
var header=new Grid{ColumnDefinitions=new("45,*,*")};
|
||||
TextBlock Label(string text)=>new(){Text=text,Foreground=Palette.Text,TextWrapping=TextWrapping.Wrap,FontSize=12,Margin=new(8,0)};
|
||||
var left=Label(selected.Status+" · "+selected.Time+" UTC\n"+selected.Name+$"\nFWHM {selected.Fwhm:0.00} px · ellipticity {selected.Ellipticity:0.00}");Grid.SetColumn(left,1);header.Children.Add(left);
|
||||
var right=Label(peer.Status+" · "+peer.Time+" UTC\n"+peer.Name+$"\nFWHM {peer.Fwhm:0.00} px · ellipticity {peer.Ellipticity:0.00}");Grid.SetColumn(right,2);header.Children.Add(right);panel.Children.Add(header);
|
||||
if(peer!=null){var right=Label(peer.Status+" · "+peer.Time+" UTC\n"+peer.Name+$"\nFWHM {peer.Fwhm:0.00} px · ellipticity {peer.Ellipticity:0.00}");Grid.SetColumn(right,2);header.Children.Add(right);}panel.Children.Add(header);
|
||||
foreach(var star in detail.Stars)
|
||||
{
|
||||
var row=new Grid{ColumnDefinitions=new("45,*,*"),Margin=new(0,6)};row.Children.Add(Palette.Label(star.Number.ToString("00"),12,Palette.Muted));
|
||||
foreach(var entry in new[]{(Pixels:star.Selected,Column:1),(Pixels:star.Comparison,Column:2)})
|
||||
foreach(var entry in new[]{(Sample:star.Selected,Column:1),(Sample:star.Comparison,Column:2)})
|
||||
{
|
||||
var bitmap=Gray(entry.Pixels,detail.Size);bitmaps.Add(bitmap);var image=new Image{Source=bitmap,Width=130,Height=130,HorizontalAlignment=HorizontalAlignment.Left,Margin=new(8,0)};RenderOptions.SetBitmapInterpolationMode(image,BitmapInterpolationMode.None);Grid.SetColumn(image,entry.Column);row.Children.Add(image);
|
||||
if(entry.Sample==null)continue;
|
||||
var bitmap=Gray(entry.Sample.Pixels,detail.Size);bitmaps.Add(bitmap);var crop=new StarCropView(bitmap,entry.Sample.Shape){Width=130,Height=130,HorizontalAlignment=HorizontalAlignment.Left};Crops.Add(crop);
|
||||
var cell=new StackPanel{Spacing=5,Margin=new(8,0)};cell.Children.Add(crop);cell.Children.Add(Palette.Label(entry.Sample.Shape is {} shape?$"Ellipticity {shape.Ellipticity:0.00}":"Shape fit unavailable",11,Palette.Muted));Grid.SetColumn(cell,entry.Column);row.Children.Add(cell);
|
||||
}
|
||||
panel.Children.Add(row);
|
||||
}
|
||||
HasDetail=true;
|
||||
if(capture!=null)
|
||||
{
|
||||
await Task.Delay(200);if(Content is Control content){using var bitmap=new RenderTargetBitmap(new PixelSize((int)content.Bounds.Width,(int)content.Bounds.Height),new Vector(96,96));bitmap.Render(content);bitmap.Save(capture);}((IClassicDesktopStyleApplicationLifetime)Application.Current!.ApplicationLifetime!).Shutdown(0);
|
||||
}
|
||||
}
|
||||
catch(OperationCanceledException){}
|
||||
catch(Exception e){progress.Text="Star detail unavailable: "+e.Message;if(capture!=null){File.WriteAllText(capture+".error",e.ToString());((IClassicDesktopStyleApplicationLifetime)Application.Current!.ApplicationLifetime!).Shutdown(1);}}
|
||||
};
|
||||
catch(Exception e){panel.Children.Clear();panel.Children.Add(new TextBlock{Text="Star detail unavailable: "+e.Message,Foreground=Palette.Muted,TextWrapping=TextWrapping.Wrap});if(capture!=null){File.WriteAllText(capture+".error",e.ToString());((IClassicDesktopStyleApplicationLifetime)Application.Current!.ApplicationLifetime!).Shutdown(1);}}
|
||||
}
|
||||
Closing+=(_,_)=>cancellation.Cancel();Closed+=(_,_)=>{foreach(var bitmap in bitmaps)bitmap.Dispose();cancellation.Dispose();};
|
||||
}
|
||||
static WriteableBitmap Gray(byte[] pixels,int size)
|
||||
|
|
@ -54,3 +64,24 @@ public sealed class StarInspector:Window
|
|||
for(int y=0;y<size;y++){for(int x=0;x<size;x++){byte v=pixels[y*size+x];row[4*x]=row[4*x+1]=row[4*x+2]=v;row[4*x+3]=255;}Marshal.Copy(row,0,locked.Address+y*locked.RowBytes,row.Length);}return bitmap;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class StarCropView:Control
|
||||
{
|
||||
readonly WriteableBitmap bitmap;
|
||||
public StarShape? Shape {get;}
|
||||
public bool ShowGuides {get;set;}=true;
|
||||
public StarCropView(WriteableBitmap bitmap,StarShape? shape)
|
||||
{this.bitmap=bitmap;Shape=shape;RenderOptions.SetBitmapInterpolationMode(this,BitmapInterpolationMode.None);ClipToBounds=true;}
|
||||
public override void Render(DrawingContext context)
|
||||
{
|
||||
base.Render(context);context.DrawImage(bitmap,new Rect(bitmap.Size),new Rect(Bounds.Size));
|
||||
if(!ShowGuides||Shape is not {} shape)return;
|
||||
double scale=Bounds.Width/bitmap.Size.Width,c=Math.Cos(shape.Angle),s=Math.Sin(shape.Angle);
|
||||
Point Map(double x,double y)=>new((shape.X+c*x-s*y)*scale,(shape.Y+s*x+c*y)*scale);
|
||||
double a=shape.Major/2,b=shape.Minor/2;
|
||||
var ellipse=new StreamGeometry();using(var path=ellipse.Open())
|
||||
{path.BeginFigure(Map(a,0),false);for(int i=1;i<=64;i++){double t=i*Math.PI/32;path.LineTo(Map(a*Math.Cos(t),b*Math.Sin(t)));}path.EndFigure(true);}
|
||||
context.DrawGeometry(null,new Pen(Palette.Progress,1.2),ellipse);
|
||||
context.DrawLine(new Pen(Palette.Progress,1.2),Map(-a,0),Map(a,0));context.DrawLine(new Pen(Palette.Review,1),Map(0,-b),Map(0,b));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public static class Palette
|
|||
public static readonly IBrush Background=Brush("#151617"),Panel=Brush("#1E2021"),Raised=Brush("#292B2D"),Muted=Brush("#A2A5A7"),Text=Brush("#E6E7E7"),Accent=Brush("#D3D5D4"),Keep=Brush("#A8BFB0"),Review=Brush("#D5BF91"),Reject=Brush("#DBA2A6"),Line=Brush("#3B3E40");
|
||||
public static IBrush Brush(string hex)=>new SolidColorBrush(Color.Parse(hex));
|
||||
public static IBrush Verdict(Verdict v)=>v switch{AstroFrame.Engine.Verdict.Keep=>Keep,AstroFrame.Engine.Verdict.Reject=>Reject,_=>Review};
|
||||
public static readonly IBrush Update=Brush("#007BA7"),GraphKeep=Brush("#68DE96"),GraphReview=Brush("#F2C366"),GraphReject=Brush("#FF8794");
|
||||
public static readonly IBrush Update=Brush("#007BA7"),Progress=Brush("#7CABC3"),GraphKeep=Keep,GraphReview=Review,GraphReject=Reject;
|
||||
public static IBrush GraphVerdict(Verdict v)=>v switch{AstroFrame.Engine.Verdict.Keep=>GraphKeep,AstroFrame.Engine.Verdict.Reject=>GraphReject,_=>GraphReview};
|
||||
public static TextBlock Label(string text,double size=13,IBrush? color=null)=>new(){Text=text,FontSize=size,Foreground=color??Text};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,44 +1,74 @@
|
|||
namespace AstroFrame.Engine;
|
||||
|
||||
public sealed record StarSnippet(int Number,byte[] Selected,byte[] Comparison);
|
||||
public sealed record StarDetail(string SelectedName,string ComparisonName,List<StarSnippet> Stars,int Size=13);
|
||||
public sealed record StarShape(double X,double Y,double Major,double Minor,double Angle)
|
||||
{
|
||||
public double Ellipticity=>1-Minor/Major;
|
||||
}
|
||||
public sealed record StarSample(byte[] Pixels,StarShape? Shape);
|
||||
public sealed record StarSnippet(int Number,StarSample Selected,StarSample? Comparison);
|
||||
public sealed record StarDetail(string SelectedName,string? ComparisonName,List<StarSnippet> Stars,int Size=13);
|
||||
/// <summary>Read-only matched source samples for human morphology review; no quality decisions.</summary>
|
||||
public static class StellarDetail
|
||||
{
|
||||
public static Frame? Comparison(Project project,Frame selected)
|
||||
{
|
||||
double normal=selected.Baselines.GetValueOrDefault("Ellipticity"),width=selected.Baselines.GetValueOrDefault("FWHM");
|
||||
var available=project.Frames.Where(f=>f.Id!=selected.Id&&f.Session==selected.Session&&f.Effective==Verdict.Keep&&f.Error==""&&f.MatchFraction>.5);
|
||||
if(!Aligned(selected))return null;
|
||||
var available=project.Frames.Where(f=>f.Id!=selected.Id&&f.Session==selected.Session&&f.Effective==Verdict.Keep&&f.Measured&&f.Error==""&&f.MatchFraction>.5&&f.ReferenceId==selected.ReferenceId&&f.Width==selected.Width&&f.Height==selected.Height&&Aligned(f));
|
||||
var representative=available.Where(f=>(normal<=0||f.Ellipticity<normal+.06)&&(width<=0||f.Fwhm<width*1.15)).ToArray();
|
||||
return (representative.Length>0?representative:available).OrderBy(f=>Math.Abs((f.Timestamp.GetValueOrDefault()-selected.Timestamp.GetValueOrDefault()).TotalSeconds)).FirstOrDefault();
|
||||
}
|
||||
public static StarDetail Read(string directory,Frame selected,Frame comparison,CancellationToken ct=default)
|
||||
static bool Aligned(Frame f)=>f.ReferenceId!=""&&f.Alignment.Length==4&&f.Alignment.All(double.IsFinite)&&f.Alignment[0]*f.Alignment[0]+f.Alignment[1]*f.Alignment[1]>=.5;
|
||||
public static StarDetail Read(string directory,Frame selected,Frame? comparison,CancellationToken ct=default)
|
||||
{
|
||||
ImagePlane Source(Frame f)
|
||||
{var info=new FileInfo(f.Path);if(!info.Exists||info.Length!=f.Length||info.LastWriteTimeUtc.Ticks!=f.Modified)throw new IOException("Source changed; reanalyze before inspecting");return Fits.Read(f.Path,ct);}
|
||||
var a=Source(selected);var b=Source(comparison);List<Star> stars;
|
||||
var a=Source(selected);var b=comparison==null?null:Source(comparison);List<Star> stars;
|
||||
if(ProjectStore.LoadCatalog(directory,selected))stars=selected.Stars;
|
||||
else{var measured=Fits.Inspect(selected.Path);new StellarDetector().Measure(measured,a,ct);stars=measured.Stars;}
|
||||
if(selected.ReferenceId!=comparison.ReferenceId||selected.Alignment.Length!=4||comparison.Alignment.Length!=4)throw new InvalidDataException("Matched source comparison is unavailable: no shared reliable alignment");
|
||||
double aspect=(double)selected.Height/selected.Width;var from=selected.Alignment;var to=comparison.Alignment;List<Star> chosen=[];List<StarSnippet> snippets=[];
|
||||
foreach(var s in stars)
|
||||
if(comparison!=null&&(selected.ReferenceId!=comparison.ReferenceId||selected.Width!=comparison.Width||selected.Height!=comparison.Height||!Aligned(selected)||!Aligned(comparison)))throw new InvalidDataException("Matched source comparison is unavailable: no shared reliable alignment");
|
||||
double aspect=(double)selected.Height/selected.Width;var from=selected.Alignment;List<Star> chosen=[];List<StarSnippet> snippets=[];
|
||||
// Use the strong-star population that supplies the frame shape metric, spread across the field.
|
||||
foreach(var s in stars.OrderByDescending(s=>s.Flux).Take(250))
|
||||
{
|
||||
ct.ThrowIfCancellationRequested();if(s.X<.04||s.X>.96||s.Y<.04||s.Y>.96||chosen.Any(t=>Math.Pow(t.X-s.X,2)+Math.Pow((t.Y-s.Y)*aspect,2)<.04*.04))continue;
|
||||
double sx=s.X-from[2],sy=s.Y*aspect-from[3],d=from[0]*from[0]+from[1]*from[1];if(d<.5)throw new InvalidDataException("Unreliable image alignment");
|
||||
double rx=(from[0]*sx+from[1]*sy)/d,ry=(-from[1]*sx+from[0]*sy)/d,x=to[0]*rx-to[1]*ry+to[2],y=(to[1]*rx+to[0]*ry+to[3])/aspect;
|
||||
if(x<.04||x>.96||y<.04||y>.96)continue;chosen.Add(s);
|
||||
snippets.Add(new(snippets.Count+1,Crop(a,s.X,s.Y),Crop(b,x,y)));if(snippets.Count==8)break;
|
||||
ct.ThrowIfCancellationRequested();if(!CanCrop(a,s.X,s.Y)||chosen.Any(t=>Math.Pow(t.X-s.X,2)+Math.Pow((t.Y-s.Y)*aspect,2)<.04*.04))continue;
|
||||
StarSample? other=null;
|
||||
if(comparison!=null&&b!=null)
|
||||
{
|
||||
var to=comparison.Alignment;double sx=s.X-from[2],sy=s.Y*aspect-from[3],d=from[0]*from[0]+from[1]*from[1];
|
||||
double rx=(from[0]*sx+from[1]*sy)/d,ry=(-from[1]*sx+from[0]*sy)/d,x=to[0]*rx-to[1]*ry+to[2],y=(to[1]*rx+to[0]*ry+to[3])/aspect;
|
||||
if(!CanCrop(b,x,y))continue;other=Crop(b,x,y,Noise(comparison,x,y));
|
||||
}
|
||||
chosen.Add(s);snippets.Add(new(snippets.Count+1,Crop(a,s.X,s.Y,Noise(selected,s.X,s.Y)),other));if(snippets.Count==8)break;
|
||||
}
|
||||
if(snippets.Count==0)throw new InvalidDataException("No suitable matched stars in the overlapping field");
|
||||
return new(selected.Name,comparison.Name,snippets);
|
||||
return new(selected.Name,comparison?.Name,snippets);
|
||||
}
|
||||
static byte[] Crop(ImagePlane image,double px,double py)
|
||||
static bool CanCrop(ImagePlane image,double x,double y)=>double.IsFinite(x)&&double.IsFinite(y)&&Math.Round(x*image.Width)>=9&&Math.Round(x*image.Width)<image.Width-9&&Math.Round(y*image.Height)>=9&&Math.Round(y*image.Height)<image.Height-9;
|
||||
static double Noise(Frame f,double x,double y)
|
||||
{int tile=Math.Clamp((int)(y*4),0,3)*3+Math.Clamp((int)(x*3),0,2);return f.Regions.Count==12?f.Regions[tile].Noise:f.Noise;}
|
||||
static StarSample Crop(ImagePlane image,double px,double py,double noise)
|
||||
{
|
||||
int x=(int)Math.Round(px*image.Width),y=(int)Math.Round(py*image.Height);double peak=double.MinValue;int bestX=x,bestY=y;
|
||||
for(int dy=-2;dy<=2;dy++)for(int dx=-2;dx<=2;dx++)if(image.Pixels[(y+dy)*image.Width+x+dx]>peak){peak=image.Pixels[(y+dy)*image.Width+x+dx];bestX=x+dx;bestY=y+dy;}
|
||||
List<double> edge=[];for(int dy=-6;dy<=6;dy++)for(int dx=-6;dx<=6;dx++)if(dx*dx+dy*dy>=25)edge.Add(image.Pixels[(bestY+dy)*image.Width+bestX+dx]);
|
||||
double sky=Robust.Median(edge),range=Math.Max(1,peak-sky);byte[] pixels=new byte[169];
|
||||
for(int dy=-6;dy<=6;dy++)for(int dx=-6;dx<=6;dx++)pixels[(dy+6)*13+dx+6]=(byte)Math.Clamp(255*(image.Pixels[(bestY+dy)*image.Width+bestX+dx]-sky)/range,0,255);
|
||||
return pixels;
|
||||
double[] samples=new double[169];for(int dy=-6;dy<=6;dy++)for(int dx=-6;dx<=6;dx++)samples[(dy+6)*13+dx+6]=image.Pixels[(bestY+dy)*image.Width+bestX+dx];
|
||||
double sky=Sky(samples),range=Math.Max(1,peak-sky);byte[] pixels=samples.Select(v=>(byte)Math.Clamp(255*(v-sky)/range,0,255)).ToArray();
|
||||
return new(pixels,Describe(samples,noise));
|
||||
}
|
||||
static double Sky(IReadOnlyList<double> samples)=>Robust.Median(Enumerable.Range(0,169).Where(i=>{int x=i%13-6,y=i/13-6;return x*x+y*y>=25&&x*x+y*y<=36;}).Select(i=>samples[i]));
|
||||
/// <summary>Core second moments in source-sample coordinates; guides do not change classification.</summary>
|
||||
public static StarShape? Describe(IReadOnlyList<double> samples,double noise=0)
|
||||
{
|
||||
if(samples.Count!=169||samples.Any(v=>!double.IsFinite(v))||!double.IsFinite(noise))return null;
|
||||
double sky=Sky(samples),sum=0,mx=0,my=0,xx=0,yy=0,xy=0;
|
||||
for(int y=-4;y<=4;y++)for(int x=-4;x<=4;x++)
|
||||
{
|
||||
if(x*x+y*y>16)continue;double weight=Math.Max(0,samples[(y+6)*13+x+6]-sky-Math.Max(0,noise));
|
||||
sum+=weight;mx+=x*weight;my+=y*weight;xx+=x*x*weight;yy+=y*y*weight;xy+=x*y*weight;
|
||||
}
|
||||
if(sum<=0)return null;mx/=sum;my/=sum;xx=xx/sum-mx*mx;yy=yy/sum-my*my;xy=xy/sum-mx*my;
|
||||
double d=Math.Sqrt((xx-yy)*(xx-yy)+4*xy*xy),major=(xx+yy+d)/2,minor=(xx+yy-d)/2;
|
||||
if(minor<.18||major>12||Math.Abs(mx)>2||Math.Abs(my)>2)return null;
|
||||
return new(mx+6.5,my+6.5,2.35482*Math.Sqrt(major),2.35482*Math.Sqrt(minor),.5*Math.Atan2(2*xy,xx-yy));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ static class ImageRegression
|
|||
}
|
||||
finally{Directory.Delete(directory,true);}
|
||||
}
|
||||
static void WriteFits(string path,float[] pixels,int width,int height,int n)
|
||||
internal static void WriteFits(string path,float[] pixels,int width,int height,int n)
|
||||
{
|
||||
string Card(string key,string value)=>(key.PadRight(8)+"= "+value).PadRight(80);
|
||||
string date=new DateTime(2026,9,20,8,0,0,DateTimeKind.Utc).AddSeconds(n*30).ToString("yyyy-MM-ddTHH:mm:ss",CultureInfo.InvariantCulture);
|
||||
|
|
|
|||
|
|
@ -129,4 +129,5 @@ await ImageRegression.Run(Check);
|
|||
QualityRegression.Run(Check);
|
||||
OverlayRegression.Run(Check);
|
||||
PreviewRegression.Run(Check);
|
||||
StellarDetailRegression.Run(Check);
|
||||
Console.WriteLine($"{passed} checks passed. Synthetic tests validate mechanics, not astrophotography stack quality.");
|
||||
|
|
|
|||
51
tests/AstroFrame.Validation/StellarDetailRegression.cs
Normal file
51
tests/AstroFrame.Validation/StellarDetailRegression.cs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
using AstroFrame.Engine;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
static class StellarDetailRegression
|
||||
{
|
||||
public static void Run(Action<bool,string> check)
|
||||
{
|
||||
double[] Gaussian(double major,double minor,double angle)=>Enumerable.Range(0,169).Select(i=>
|
||||
{
|
||||
double x=i%13-6,y=i/13-6,u=x*Math.Cos(angle)+y*Math.Sin(angle),v=-x*Math.Sin(angle)+y*Math.Cos(angle);
|
||||
return 1000+3000*Math.Exp(-.5*(u*u/(major*major)+v*v/(minor*minor)));
|
||||
}).ToArray();
|
||||
var round=StellarDetail.Describe(Gaussian(1,1,0))!;
|
||||
var stretched=StellarDetail.Describe(Gaussian(1.4,.7,.6))!;
|
||||
check(round.Ellipticity<.001&&stretched.Ellipticity>.45&&Math.Abs(stretched.Angle-.6)<.03,"source-moment guides distinguish round stars from rotated elongation");
|
||||
check(Math.Abs(stretched.X-6.5)<.01&&Math.Abs(stretched.Y-6.5)<.01,"shape guides remain centered on source pixel centers");
|
||||
check(StellarDetail.Describe(Enumerable.Repeat(1000.0,169).ToArray())==null&&StellarDetail.Describe([double.NaN])==null,"empty or invalid stellar profiles do not invent shape guides");
|
||||
string directory=Path.Combine(Path.GetTempPath(),"AstroFrame-stars-"+Guid.NewGuid());Directory.CreateDirectory(directory);
|
||||
try
|
||||
{
|
||||
const int size=64;var positions=new[]{(X:14,Y:16),(X:40,Y:38),(X:18,Y:43)};List<Frame> frames=[];
|
||||
for(int n=0;n<2;n++)
|
||||
{
|
||||
float[] pixels=Enumerable.Repeat(1000f,size*size).ToArray();
|
||||
foreach(var p in positions)for(int y=0;y<size;y++)for(int x=0;x<size;x++)
|
||||
{
|
||||
double dx=x-p.X-(n==0?0:3),dy=y-p.Y+(n==0?0:2),u=dx*Math.Cos(.6)+dy*Math.Sin(.6),v=-dx*Math.Sin(.6)+dy*Math.Cos(.6),a=n==0?1.4:1,b=n==0?.7:1;
|
||||
pixels[y*size+x]+=(float)(3000*Math.Exp(-.5*(u*u/(a*a)+v*v/(b*b))));
|
||||
}
|
||||
string path=Path.Combine(directory,$"star{n}.fit");ImageRegression.WriteFits(path,pixels,size,size,n);
|
||||
var f=Fits.Inspect(path);f.Measured=true;f.Session="shared";f.Automatic=Verdict.Keep;f.MatchFraction=1;f.ReferenceId="reference";f.Alignment=[1,0,n==0?0:3.0/size,n==0?0:-2.0/size];
|
||||
f.Stars=positions.Select(p=>new Star((double)p.X/size,(double)p.Y/size,100,3,n==0?.5:0)).ToList();frames.Add(f);
|
||||
}
|
||||
var project=new Project{Frames=frames};ProjectStore.Save(project,directory);
|
||||
byte[] hash=SHA256.HashData(File.ReadAllBytes(frames[0].Path));
|
||||
check(StellarDetail.Comparison(project,frames[0])==frames[1],"elongation inspector selects an aligned same-session KEEP comparison");
|
||||
var detail=StellarDetail.Read(directory,frames[0],frames[1]);
|
||||
check(detail.Stars.Count==3&&detail.Stars.All(s=>s.Selected.Shape!.Ellipticity>.45&&s.Comparison!.Shape!.Ellipticity<.01),"aligned shifted source crops compare the same elongated and round stars");
|
||||
check(hash.SequenceEqual(SHA256.HashData(File.ReadAllBytes(frames[0].Path)))&&frames[0].Automatic==Verdict.Keep,"source inspection preserves FITS bytes and frame decisions");
|
||||
frames[1].Override=Verdict.Reject;
|
||||
check(StellarDetail.Comparison(project,frames[0])==null&&StellarDetail.Read(directory,frames[0],null).Stars.All(s=>s.Comparison==null),"source elongation remains inspectable without a suitable KEEP exposure");
|
||||
frames[1].Override=null;frames[1].ReferenceId="different";
|
||||
check(StellarDetail.Comparison(project,frames[0])==null,"unrelated reference alignments are excluded from star comparison");
|
||||
using var cancel=new CancellationTokenSource();cancel.Cancel();bool cancelled=false;try{StellarDetail.Read(directory,frames[0],null,cancel.Token);}catch(OperationCanceledException){cancelled=true;}
|
||||
check(cancelled,"source star inspection cancels during read");
|
||||
frames[0].Modified--;bool refused=false;try{StellarDetail.Read(directory,frames[0],null);}catch(IOException){refused=true;}
|
||||
check(refused,"changed sources are refused by the elongation inspector");
|
||||
}
|
||||
finally{Directory.Delete(directory,true);}
|
||||
}
|
||||
}
|
||||
36
tools/Verify-Preview.ps1
Normal file
36
tools/Verify-Preview.ps1
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
param(
|
||||
[Parameter(Mandatory)][string]$FixtureProject,
|
||||
[string]$Output='artifacts/preview-verification'
|
||||
)
|
||||
$ErrorActionPreference='Stop'
|
||||
$repository=Split-Path $PSScriptRoot
|
||||
Set-Location $repository
|
||||
if (![OperatingSystem]::IsWindows()) { throw 'This diagnostic checks the Windows desktop UI.' }
|
||||
$fixture=(Resolve-Path -LiteralPath $FixtureProject).Path
|
||||
if (!(Test-Path -LiteralPath (Join-Path $fixture 'project.json'))) { throw 'Supply a saved project with current analysis and available read-only FITS sources.' }
|
||||
$destination=[IO.Path]::GetFullPath((Join-Path $repository $Output))
|
||||
$artifactRoot=[IO.Path]::GetFullPath((Join-Path $repository 'artifacts'))+[IO.Path]::DirectorySeparatorChar
|
||||
if (!$destination.StartsWith($artifactRoot,[StringComparison]::OrdinalIgnoreCase)) { throw 'Diagnostic output must stay inside workspace artifacts/.' }
|
||||
if (Test-Path -LiteralPath $destination) { throw 'Choose a fresh output directory to preserve earlier verification results.' }
|
||||
New-Item -ItemType Directory -Path $destination | Out-Null
|
||||
Copy-Item -LiteralPath $fixture -Destination (Join-Path $destination 'fixture') -Recurse
|
||||
New-Item -ItemType Directory -Force artifacts/test-temp, .tools/http-cache | Out-Null
|
||||
$env:TEMP=Join-Path $repository 'artifacts/test-temp'
|
||||
$env:TMP=$env:TEMP
|
||||
$env:NUGET_HTTP_CACHE_PATH=Join-Path $repository '.tools/http-cache'
|
||||
$env:AVALONIA_TELEMETRY_OPTOUT='1'
|
||||
$env:DOTNET_ROOT=Join-Path $repository '.tools/dotnet'
|
||||
$application=Join-Path $repository 'src/AstroFrame.Desktop/bin/Release/net8.0/AstroFrame.Desktop.exe'
|
||||
if (!(Test-Path -LiteralPath $application)) { throw 'Build the source with ./Build.ps1 first.' }
|
||||
$report=Join-Path $destination 'qa'
|
||||
New-Item -ItemType Directory -Path $report | Out-Null
|
||||
$process=Start-Process -FilePath $application -ArgumentList @('--verify-ui',('"'+(Join-Path $destination 'fixture')+'"'),('"'+$report+'"')) -WindowStyle Hidden -PassThru
|
||||
if (!$process.WaitForExit(30000)) { Stop-Process -Id $process.Id -Force; throw 'Source desktop verification timed out.' }
|
||||
if ($process.ExitCode -ne 0) {
|
||||
$errorReport=Join-Path $report 'error.txt'
|
||||
if (Test-Path -LiteralPath $errorReport) { Get-Content -LiteralPath $errorReport }
|
||||
throw "Source desktop verification failed (exit $($process.ExitCode))."
|
||||
}
|
||||
Get-Content -LiteralPath (Join-Path $report 'interaction-checks.txt')
|
||||
Get-Content -LiteralPath (Join-Path $report 'smoke-checks.txt')
|
||||
Write-Host "Rendered preview, processing status and elongation captures: $report"
|
||||
Loading…
Add table
Add a link
Reference in a new issue