-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFormTargetImageAnalysis.cs
1599 lines (1437 loc) · 79.5 KB
/
FormTargetImageAnalysis.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// --------------------------------------------------------------------------------
// VariScan module
//
// Description:
//
// Environment: Windows 10 executable, 32 and 64 bit
//
// Usage: TBD
//
// Author: (REM) Rick McAlister, [email protected]
//
// Edit Log: Rev 1.0 Initial Version
//
// Date Who Vers Description
// ----------- --- ----- -------------------------------------------------------
//
// ---------------------------------------------------------------------------------
//
using System;
using System.Collections.Generic;
using System.Deployment.Application;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;
using TheSky64Lib;
namespace VariScan
{
public partial class FormTargetImageAnalysis : Form
{
//common constants
public const double maxMagVal = 21;
public const double minMagVal = 4;
public const double MinSeparationArcSec = 5;
public const double NyquistMinimumSamples = 2;
//common procedure flags
public bool IsInitializing { get; set; }
public bool IsAnalyzing { get; set; }
public bool FitsIsOpen { get; set; }
//common TSX server objects
public ccdsoftImage TSX_Image { get; set; }
public ImageLink TSXimglnk { get; set; }
//List of paths to target image bank folders for a processing session
List<FormSampleCatalog.TargetShoot> SessionList = new List<FormSampleCatalog.TargetShoot>();
//Descriptors for data on the target currently being processed
public TargetData CurrentTargetData { get; set; }
public int? currentTargetRegistration { get; set; }
//Lists of descriptors for light sources and associated catalog information from images
StarField.FieldLightSource[] masterLightSources;
List<StarField.FieldLightSource[]> primaryLightSources = new List<StarField.FieldLightSource[]>();
List<StarField.FieldLightSource[]> differentialLightSources = new List<StarField.FieldLightSource[]>();
//Color Indexing and Transformation data
ColorIndexing TargetColorIndex;
List<double> sourceInstMag = new List<double>();
List<double> colorTransformList = new List<double>();
List<double> magnitudeTransformList = new List<double>();
//FITS file processing fields
FitsFileTSX FITImage { get; set; }
//Derived device parameters
public string ImageFilter { get; set; }
public double SaturationADU { get; set; }
public double NonLinearADU { get; set; }
public double FocalRatio { get; set; }
public double PixelScale_arcsec { get; set; }
public double FWHMSeeing_arcsec { get; set; }
public FormTargetImageAnalysis()
{
Configuration cfg = new Configuration();
IsInitializing = true;
InitializeComponent();
//Color the group box titles as Visual Studio doesn't seem to get this done on its own
SeeingGroupBox.ForeColor = Color.White;
FitsImageDataBox.ForeColor = Color.White;
InstrumentationGroupBox.ForeColor = Color.White;
FitsImageDataBox.ForeColor = Color.White;
CatalogGroupBox.ForeColor = Color.White;
TargetedVariableGroupBox.ForeColor = Color.White;
SessionGroupBox.ForeColor = Color.White;
SourceGroupBox.ForeColor = Color.White;
//CatalogGroupBox.ForeColor = Color.White;
TransformResultsBox.ForeColor = Color.White;
ReportGroupBox.ForeColor = Color.White;
Utility.ButtonGreen(DoneButton);
Utility.ButtonGreen(SelectSessionsButton);
// Acquire the version information and put it in the form header
try { this.Text = ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString(); }
catch { this.Text = " in Debug"; } //probably in debug, no version info available
this.Text = "VariScan V" + this.Text;
//Create a single, reusable object for connecting to multiple TSX images, otherwise garbage collection is a problem
TSX_Image = new ccdsoftImage();
InitializeCollectionData();
//Set window position based on ontopcheckbox
OnTopCheckBox.Checked = Convert.ToBoolean(cfg.AnalysisFormOnTop);
this.TopMost = OnTopCheckBox.Checked;
IsInitializing = false;
IsAnalyzing = false;
return;
}
public void InitializeCollectionData()
{
//Populate collectionselectionbox and choose current collection
Configuration cfg = new Configuration();
string basepath = cfg.VariScanFolderPath;
CollectionSelectionBox.Items.Clear();
foreach (string fd in Directory.EnumerateDirectories(basepath))
{
Path.GetFileName(fd);
CollectionSelectionBox.Items.Add(Path.GetFileName(fd));
}
CollectionSelectionBox.SelectedItem = Path.GetFileName(cfg.CollectionFolderPath);
CollectionManagement.OpenCollection(Path.GetFileName(cfg.CollectionFolderPath));
//Populate session controls and default target
CurrentTargetData = new TargetData();
//Populate filter and color lists
ColorIndexing colorIndex = new ColorIndexing();
string[] colors = ColorIndexing.StandardColorsList();
PrimaryColorBox.Items.AddRange(colors);
DifferentialColorBox.Items.AddRange(colors);
string[] filters = colorIndex.GetSessionFilters().ToArray();
PrimaryFilterBox.Items.AddRange(filters);
DifferentialFilterBox.Items.AddRange(filters);
PrimaryColorBox.SelectedIndex = 1; //Vj
DifferentialColorBox.SelectedIndex = 0; //Bj
if (PrimaryFilterBox.Items.Count >= 2)
PrimaryFilterBox.SelectedIndex = 0; //First filter on list
else
PrimaryFilterBox.SelectedIndex = 0;
if (DifferentialFilterBox.Items.Count >= 2)
DifferentialFilterBox.SelectedIndex = 1; //Second filter on list
else
PrimaryFilterBox.SelectedIndex = 0;
CurrentTargetData.PrimaryStandardColor = PrimaryColorBox.Text;
CurrentTargetData.DifferentialStandardColor = DifferentialColorBox.Text;
CurrentTargetData.PrimaryImageFilter = PrimaryFilterBox.Text;
CurrentTargetData.DifferentialImageFilter = DifferentialFilterBox.Text;
//Set ManualTransformValues to last set calculated
//ColorIndexing ci = new ColorIndexing();
//(double, double) trans = ci.GetAverageTransforms();
CurrentTargetData.CatalogName = TargetCatalogBox.Text;
if (TargetCatalogBox.Text == "APASS")
{
PresetColorTransformBox.Value = Convert.ToDecimal(cfg.ApassColorTransform);
PresetMagnitudeTransformBox.Value = Convert.ToDecimal(cfg.ApassMagnitudeTransform);
}
else
{
PresetColorTransformBox.Value = Convert.ToDecimal(cfg.GaiaColorTransform);
PresetMagnitudeTransformBox.Value = Convert.ToDecimal(cfg.GaiaMagnitudeTransform);
}
//Populate Fits Name list
FitsNameBox.Items.Clear();
foreach (string f in VariScanFileManager.GetCollectionFilenameList())
FitsNameBox.Items.Add(f);
if (FitsNameBox.Items.Count > 0)
FitsNameBox.SelectedIndex = 0;
//Initialize Session Dates. The first item will always be "All".
// the remainder will be session dates for session set plots
SessionSetList.Items.Clear();
SessionSetList.Items.Add("All");
//Initialize plot target fields
TargetPlotBox.Items.Clear();
foreach (string f in VariScanFileManager.GetTargetNameList())
TargetPlotBox.Items.Add(f);
if (TargetPlotBox.Items.Count > 0)
{
TargetPlotBox.SelectedIndex = 0;
foreach (DateTime f in VariScanFileManager.GetSessionDates(TargetPlotBox.SelectedItem.ToString()))
{
SessionSetList.Items.Add(f.Date.ToString("M/dd/yyyy"));
}
SessionSetList.SelectedIndex = 0;
}
return;
}
#region analysis
public void RegisterLightSources(FormSampleCatalog.TargetShoot tgtShot)
{
LogIt("Registering " + tgtShot.Target + " on " + tgtShot.Date);
List<StarField.FieldLightSource[]> unregisteredPLS = new List<StarField.FieldLightSource[]>();
List<StarField.FieldLightSource[]> unregisteredDLS = new List<StarField.FieldLightSource[]>();
List<SampleManager.SessionSample> priFiles = new List<SampleManager.SessionSample>();
List<SampleManager.SessionSample> difFiles = new List<SampleManager.SessionSample>();
primaryLightSources.Clear();
differentialLightSources.Clear();
//Housekeeping
//Clear any existing SRC files, as they might be locked and TSX will quietly crash
Configuration cfg = new Configuration();
TSX_Process.DeleteSRC(cfg.ImageBankFolder);
//Open a sample manager for the selected target
SampleManager sMgr = new SampleManager(tgtShot.Target, Convert.ToDateTime(tgtShot.Date), Convert.ToInt32(tgtShot.Set));
//Acquire primary and differential lists of fits files for this target and this session
// based on session date box and filter designations from calling parameters
//Image Link each fits file and collect the light source inventory into arrays for each image
priFiles = sMgr.SelectSessionSamples(CurrentTargetData.SessionDate, CurrentTargetData.PrimaryImageFilter);
difFiles = sMgr.SelectSessionSamples(CurrentTargetData.SessionDate, CurrentTargetData.DifferentialImageFilter);
//check for images for this target, date, filter
// exit if none
if (priFiles.Count == 0 || (difFiles.Count == 0 && !DoInstMagCheckBox.Checked))
{
LogIt("No primary and/or differential images for this date/filter in image bank");
return;
}
#region acquireImageLightSources
//Image link then list light source date for each primary image
int ith = 0; //counter
foreach (SampleManager.SessionSample sample in priFiles)
{
LogIt("Image Linking " + Path.GetFileName(sample.ImagePath));
//Image link the fits file
StarField sf = new StarField(TSX_Image, sample);
//Pick up the last date time of the primary images
CurrentTargetData.ImageDateUT = sf.FitsImageDateTime();
CurrentTargetData.AirMass = sf.AirMass();
//Center star chart and set fov for click find
//TSX_Resources.CenterStarChart(TSX_Image, CurrentTargetData.SourceRA, CurrentTargetData.SourceDec);
//Add the lightsource array
TSX_Process.MinimizeTSX();
List<StarField.FieldLightSource> unregList = sf.PositionLightSources(sf.AssembleLightSources());
DisplayCatalogData();
TSX_Process.NormalizeTSX();
if (unregList.Count > 0)
{
LogIt("Added FITS file: " + Path.GetFileName(sample.ImagePath) + " for Primary " + ith.ToString());
unregisteredPLS.Add(unregList.ToArray());
ith++;
}
else
LogIt("Primary image failed Image Link");
CurrentTargetData.ImageWidthInArcSec = TSX_Resources.ImageWidth(TSX_Image);
sf.Close();
}
//Check for results -- if no light sources then return
if (unregisteredPLS.Count < 1)
{
LogIt("Insufficient primary light sources");
return;
}
//
//Image link then list light source data for each differential image
ith = 0; //counter
foreach (SampleManager.SessionSample sample in difFiles)
{
LogIt("Image Linking " + Path.GetFileName(sample.ImagePath));
StarField sf = new StarField(TSX_Image, sample);
//Add the lightsource array
//Center star chart and set fov for click find
//TSX_Resources.CenterStarChart(TSX_Image, CurrentTargetData.SourceRA, CurrentTargetData.SourceDec);
TSX_Process.MinimizeTSX();
List<StarField.FieldLightSource> unregList = sf.PositionLightSources(sf.AssembleLightSources());
DisplayCatalogData();
TSX_Process.NormalizeTSX();
if (unregList.Count > 0)
{
LogIt("Added FITS file: " + Path.GetFileName(sample.ImagePath) + " for Differential " + ith.ToString());
unregisteredDLS.Add(unregList.ToArray());
ith++;
}
else
LogIt("Differential image failed Image Link");
sf.Close();
}
//Check for results -- if no light sources then return
if (unregisteredDLS.Count < 1 && !DoInstMagCheckBox.Checked)
{
LogIt("Insufficient differential light sources");
return;
}
#endregion
//Pick out a master list from the primary lightsources -- first one for now, Pick just the top 40 stars by instrument magnitude
masterLightSources = unregisteredPLS.First().ToArray();
LogIt("Acquiring catalog data for light sources");
//Load up target data, if in open TSX catalog(s) which would be the most current and accurate
// if the target is not in open TSX catalog(s) then use the old data from the target list
LogIt("Finding coordinates for " + tgtShot.Target);
double tRA = CurrentTargetData.TargetRA;
double tDec = CurrentTargetData.TargetDec;
try { (tRA, tDec) = TSX_Resources.FindTarget(tgtShot.Target); }
catch { LogIt("Coordinates for " + tgtShot.Target + " not found in TSX enabled catalogs."); }
CurrentTargetData.TargetRA = tRA;
CurrentTargetData.TargetDec = tDec;
//Populate the master sample image with APASS, GAIA data, as available
SourceCountBox.Text = "0/0";
ApassStarCountBox.Text = "0";
GaiaStarCountBox.Text = "0";
//Starchart must be centered and sized for ClickFind to work
TSX_Resources.CenterStarChart(TSX_Image,
CurrentTargetData.TargetRA,
CurrentTargetData.TargetDec,
CurrentTargetData.ImageWidthInArcSec);
TSX_Process.MinimizeTSX();
for (int i = 0; i < masterLightSources.Length; i++)
{
StarField.CatalogData catDat = StarField.ClickFindCatalogData(masterLightSources[i].LightSourceRA, masterLightSources[i].LightSourceDec);
masterLightSources[i].CatalogInfo = catDat;
//Set registration index for each master light source -- but may not need this
masterLightSources[i].RegistrationIndex = i;
//Update count boxes
SourceCountBox.Text = i.ToString() + " / " + masterLightSources.Length.ToString();
if (catDat.IsAPASSCataloged)
ApassStarCountBox.Text = ((Convert.ToInt32(ApassStarCountBox.Text)) + 1).ToString();
if (catDat.IsGAIACataloged)
GaiaStarCountBox.Text = ((Convert.ToInt32(GaiaStarCountBox.Text)) + 1).ToString();
}
TSX_Process.NormalizeTSX();
//Get target registration index
// use Find function rather than believing the AAVSO fields
// if a cataloged star is not located close to the location of a light source
// then quit
LogIt("Assigning light source to cataloged star");
currentTargetRegistration = Registration.ClosestLightSource(masterLightSources, tRA, tDec, MinSeparationArcSec);
if (currentTargetRegistration == null)
{
LogIt("Cannot register light source to cataloged target star");
return;
}
CurrentTargetData.MasterRegistrationIndex = (int)currentTargetRegistration;
CurrentTargetData.SourceRA = masterLightSources[(int)currentTargetRegistration].LightSourceRA;
CurrentTargetData.SourceDec = masterLightSources[(int)currentTargetRegistration].LightSourceDec;
CurrentTargetData.MasterCatalogInfo = StarField.ReadCatalogData(masterLightSources[(int)currentTargetRegistration]);
//To align all the field light source arrays based on registration number
//Register other primary samples and differential samples against master sample, including the image data selected for the master sample
//then convert to lists for more easy management
for (int i = 0; i < unregisteredPLS.Count; i++)
primaryLightSources.Add(Registration.RegisterLightSources(masterLightSources, unregisteredPLS[i], MinSeparationArcSec));
for (int i = 0; i < unregisteredDLS.Count; i++)
differentialLightSources.Add(Registration.RegisterLightSources(masterLightSources, unregisteredDLS[i], MinSeparationArcSec));
LogIt("Registration Complete");
//DO NOT remove target from master list after recording target information
// masterRegisteredList.RemoveAll(x => x.RegistrationIndex == currentTargetRegistration);
//masterRegisteredList.RemoveAll(x => ((StarField.CatalogData)x.StandardMagnitudes).IsGCVSCataloged);
CurrentTargetData.ApassStarCount = (from a in masterLightSources
where a.CatalogInfo != null && a.CatalogInfo.Value.APASSCatalogName != null
select a).Count();
CurrentTargetData.GaiaStarCount = (from a in masterLightSources
where a.CatalogInfo != null && a.CatalogInfo.Value.GAIACatalogName != null
select a).Count();
(CurrentTargetData.SourceToAPASSCatalogPositionError, CurrentTargetData.SourceToGAIACatalogPositionError) =
StarField.CalculateSeparations(CurrentTargetData.MasterCatalogInfo, CurrentTargetData.SourceRA, CurrentTargetData.SourceDec);
DisplayCatalogData();
DisplayLightSourceData();
Show();
return;
}
private bool HasCat(StarField.CatalogData catDat, string priCol, string difCol)
{
ColorIndexing.ColorDataSource priColStd = ColorIndexing.ConvertColorEnum(priCol);
ColorIndexing.ColorDataSource difColStd = ColorIndexing.ConvertColorEnum(difCol);
double priCatMag = Transformation.GetCatalogedMagnitude(priColStd, catDat, TargetCatalogBox.Text);
double difCatMag = Transformation.GetCatalogedMagnitude(difColStd, catDat, TargetCatalogBox.Text);
if (priCatMag != 0 && difCatMag != 0)
return true;
else
return false;
}
public void CalculateTransforms(string catalog)
{
//Set colors for primary and differential fields
LogIt("Calculating transforms for " + CurrentTargetData.TargetName);
ColorIndexing.ColorDataSource targetStandardColor = ColorIndexing.ConvertColorEnum(PrimaryColorBox.Text);
ColorIndexing.ColorDataSource differentialColor = ColorIndexing.ConvertColorEnum(DifferentialColorBox.Text);
ColorIndexing.ColorDataSource instrumentColor = ColorIndexing.ColorDataSource.Instrument;
//targetStandardizedMag.Clear();
colorTransformList.Clear();
magnitudeTransformList.Clear();
ColorTransformListBox.Items.Clear();
MagnitudeTransformListBox.Items.Clear();
//For each primary image, calculate the ColorTransform and MagnitudeTransform
// then calculate the standard color based on each comparison star
// then average the set of standard colors
//List for results of target color
int priIndex = 0;
foreach (StarField.FieldLightSource[] pLS in primaryLightSources)
{
//Differential image loop
int difIndex = 0;
foreach (StarField.FieldLightSource[] dLS in differentialLightSources)
{
//Color Transformation loop:
List<double> standardColorIndexList = new List<double>();
List<double> instrumentColorIndexList = new List<double>();
foreach (StarField.FieldLightSource compStar in masterLightSources)
{
if (compStar.CatalogInfo.Value.GAIACatalogPhotoVar != "Variable")
{
//Calculate Color Transform for each comparison star
// First calculate B minus V : we'll do this every time although it is not necessary
var magBV = Transformation.FormColorIndex((int)compStar.RegistrationIndex, differentialColor, pLS, targetStandardColor, pLS, catalog);
var magbv = Transformation.FormColorIndex((int)compStar.RegistrationIndex, instrumentColor, dLS, instrumentColor, pLS, catalog);
//if any value is 0 then stack it -- meaning that both light source arrays don't share a registered star
double instColorIndex = magbv.differentialMag - magbv.primaryMag;
double stdColorIndex = magBV.differentialMag - magBV.primaryMag;
bool nonZeroMags = !(magbv.primaryMag == 0 || magbv.differentialMag == 0 || magBV.primaryMag == 0 || magBV.differentialMag == 0);
bool nonZeroIndex = !(Math.Abs(instColorIndex) == 0 || Math.Abs(stdColorIndex) == 0);
if (nonZeroMags && nonZeroIndex)
{
instrumentColorIndexList.Add(instColorIndex);
standardColorIndexList.Add(stdColorIndex);
}
}
}
if (instrumentColorIndexList.Count <= 2 || standardColorIndexList.Count <= 2)
{
LogIt("Too few color differentials to create transforms");
Show();
System.Windows.Forms.Application.DoEvents();
return;
}
//Original two pass slope filter
//(filteredInstrumentCI, filteredStandardCI) = Transformation.RoughOutlierFilter(instrumentColorIndexList, standardColorIndexList);
//(double colorIntercept, double colorTransform) = Transformation.ColorTransform(ref filteredInstrumentCI, ref filteredStandardCI);
(double colorIntercept, double colorTransform) = Transformation.ColorTransform(instrumentColorIndexList, standardColorIndexList);
ColorTransformBox.Text = colorTransform.ToString("0.00");
ColorTransformListBox.Items.Add(colorTransform.ToString("0.00") + " (P" + priIndex.ToString() + " D" + difIndex.ToString() + ")");
LogIt("Color Transform for " + "(P" + priIndex.ToString() + " D" + difIndex.ToString() + "): " + colorTransform.ToString("0.00"));
ColorTransformChart.Series[0].Points.Clear();
for (int i = 0; i < instrumentColorIndexList.Count(); i++)
ColorTransformChart.Series[0].Points.AddXY(instrumentColorIndexList[i], standardColorIndexList[i]);
//Trendline
ColorTransformChart.Series[1].Points.Clear();
double xMaxC = instrumentColorIndexList.Max();
double xMinC = instrumentColorIndexList.Min();
ColorTransformChart.Series[1].Points.AddXY(xMinC, (xMinC * colorTransform) + colorIntercept);
ColorTransformChart.Series[1].Points.AddXY(xMaxC, (xMaxC * colorTransform) + colorIntercept);
colorTransformList.Add(colorTransform);
difIndex++;
CheckTransformPause();
}
//Set the color transform axis labels to associated differentials
ColorTransformChart.ChartAreas[0].AxisX.Title = DifferentialFilterBox.Text + "-" + PrimaryFilterBox.Text;
ColorTransformChart.ChartAreas[0].AxisY.Title = DifferentialColorBox.Text + "-" + PrimaryColorBox.Text;
//Magnitude Transformation loop:
List<double> standardMagnitudeIndexList = new List<double>();
List<double> instrumentMagnitudeIndexList = new List<double>();
int compStarCount = 0;
foreach (StarField.FieldLightSource compStar in masterLightSources)
{
//Create list of color index for B-v and B-V for comparison stars in this primary image
var magBV = Transformation.FormColorIndex((int)compStar.RegistrationIndex, differentialColor, pLS, targetStandardColor, pLS, catalog);
var magBv = Transformation.FormColorIndex((int)compStar.RegistrationIndex, differentialColor, pLS, instrumentColor, pLS, catalog);
//if all values are not zero then stack it
if (magBV.primaryMag != 0 && magBV.differentialMag != 0 && magBv.primaryMag != 0 && magBv.differentialMag != 0)
{
instrumentMagnitudeIndexList.Add(magBV.differentialMag - magBv.primaryMag);
standardMagnitudeIndexList.Add(magBV.differentialMag - magBV.primaryMag);
}
compStarCount++;
SourceCountBox.Text = compStarCount.ToString() + " / " + masterLightSources.Length.ToString();
Show();
}
if (instrumentMagnitudeIndexList.Count <= 2 || standardMagnitudeIndexList.Count <= 2)
{
LogIt("Too few magnitude differentials to create transforms");
Show();
System.Windows.Forms.Application.DoEvents();
return;
}
(double magIntercept, double magnitudeTransform) = Transformation.MagnitudeTransform(instrumentMagnitudeIndexList, standardMagnitudeIndexList);
MagnitudeTransformListBox.Items.Add(magnitudeTransform.ToString("0.00") + " (P " + priIndex.ToString() + ")");
LogIt("Magnitude Transform for " + "(P " + priIndex.ToString() + "): " + magnitudeTransform.ToString("0.00"));
Show();
System.Windows.Forms.Application.DoEvents();
MagnitudeTransformChart.Series[0].Points.Clear();
for (int i = 0; i < instrumentMagnitudeIndexList.Count(); i++)
MagnitudeTransformChart.Series[0].Points.AddXY(instrumentMagnitudeIndexList[i], standardMagnitudeIndexList[i]);
//Trendline
MagnitudeTransformChart.Series[1].Points.Clear();
double xMaxM = instrumentMagnitudeIndexList.Max();
double xMinM = instrumentMagnitudeIndexList.Min();
MagnitudeTransformChart.Series[1].Points.AddXY(xMinM, (xMinM * magnitudeTransform) + magIntercept);
MagnitudeTransformChart.Series[1].Points.AddXY(xMaxM, (xMaxM * magnitudeTransform) + magIntercept);
Show();
System.Windows.Forms.Application.DoEvents();
magnitudeTransformList.Add(magnitudeTransform);
priIndex++;
CheckTransformPause(); //for "stepping" through individual transform graphs
}
//Set the magnitude transform axis labels to associated differentials
MagnitudeTransformChart.ChartAreas[0].AxisX.Title = DifferentialColorBox.Text + "-" + PrimaryFilterBox.Text;
MagnitudeTransformChart.ChartAreas[0].AxisY.Title = DifferentialColorBox.Text + "-" + PrimaryColorBox.Text;
//Choose color transform from list
if (colorTransformList.Count == 1)
CurrentTargetData.ColorTransform = colorTransformList[0];
else CurrentTargetData.ColorTransform = MathNet.Numerics.Statistics.ArrayStatistics.Mean(colorTransformList.ToArray());
ColorTransformBox.Text = CurrentTargetData.ColorTransform.ToString("0.00") + " / " + colorTransformList.Count.ToString();
ColorTransformListBox.SelectedIndex = 0;
//add the color transform list to the color transform data and update the preset
PresetColorTransformBox.Value = (decimal)TargetColorIndex.AddColorTransform(colorTransformList);
//Choose Magnitude transform from list
if (magnitudeTransformList.Count == 1)
CurrentTargetData.MagnitudeTransform = magnitudeTransformList[0];
else CurrentTargetData.MagnitudeTransform = MathNet.Numerics.Statistics.ArrayStatistics.Mean(magnitudeTransformList.ToArray());
MagnitudeTransformBox.Text = CurrentTargetData.MagnitudeTransform.ToString("0.00") + " / " + magnitudeTransformList.Count.ToString();
MagnitudeTransformListBox.SelectedIndex = 0;
//add the color transform list to the color transform data and update the preset
PresetMagnitudeTransformBox.Value = (decimal)TargetColorIndex.AddMagnitudeTransform(magnitudeTransformList);
Show();
System.Windows.Forms.Application.DoEvents();
}
private void CheckTransformPause()
{
//Checks to see if transform graphs are to be paused
// then does so if checked
Configuration cfg = new Configuration();
if (StepTransformsCheckbox.Checked)
{
//MessageBox.Show("Transformation Sequence Paused");
//
System.Threading.Thread.Sleep(2000);
}
return;
}
public bool ConvertToColorStandard(string catalog)
{
//********************************************************************************
//
// Converstion to Standard Color Loop
//
//
//********************************************************************************
LogIt("Converting to color standard " + CurrentTargetData.TargetName);
sourceInstMag.Clear();
//Cull Master List to the brightest 2000 field stars (arbitrary just to speed up processing time)
// masterRegisteredList = Transformation.SortByMagnitude(masterRegisteredList, 2000);
int crossRegisteredLightSources = 0;
int standardMagnitudeCalculated = 0;
int plsIdx = 0;
int dlsIdx = 0;
//Primary field star images loop
foreach (StarField.FieldLightSource[] pLS in primaryLightSources)
{
plsIdx++;
int? priTgtIndex = Registration.FindRegisteredLightSource(pLS, CurrentTargetData.MasterRegistrationIndex);
//Differential field star images loop
if (priTgtIndex == null)
{
LogIt("No target light source found in primary registered image (P" + (plsIdx - 1).ToString() + ").");
}
else
{
foreach (StarField.FieldLightSource[] dLS in differentialLightSources)
{
dlsIdx++;
int? diffTgtIndex = Registration.FindRegisteredLightSource(dLS, CurrentTargetData.MasterRegistrationIndex);
if (diffTgtIndex == null)
{
LogIt("No target light source found in differential registered image (D" + (dlsIdx - 1).ToString() + ").");
}
else
{
//target star magnitude standardization loop
//
// v = primary instrument filter raw magnitude for light source
// b = differential instrument filter raw magnitude for light source
// V = primary standard color cataloged magnitude for nearest star to light source
// B = differential standard color cataloged magnitude for nearest star to light source
//
// Calculate the color transform of this differential image comparison star against this primary image star
// Calculate Δ(b-v) => (bTgt - vTgt) - (bFld - vFld)
// Calculate Δ(B-V) = Tbv * Δ(b - v)
// Calculate Δv = vTgt – vFld
// VTgt = Δv + Tv_bv * Δ(B - V) + VFld
//
//Compute each Vvar for combinations of all comparison stars
//
foreach (StarField.FieldLightSource compLS in masterLightSources)
{
if (compLS.CatalogInfo.Value.GAIACatalogPhotoVar != "Variable")
{
int? diffCompIndex = Registration.FindRegisteredLightSource(dLS, (int)compLS.RegistrationIndex);
int? priCompIndex = Registration.FindRegisteredLightSource(pLS, (int)compLS.RegistrationIndex);
if (diffCompIndex != null && priCompIndex != null && diffTgtIndex != null && priTgtIndex != null)
{
crossRegisteredLightSources++;
double vTgt = pLS[(int)priTgtIndex].LightSourceInstMag;
double bTgt = dLS[(int)diffTgtIndex].LightSourceInstMag;
double bFld = dLS[(int)diffCompIndex].LightSourceInstMag;
double vFld = pLS[(int)priCompIndex].LightSourceInstMag;
//double VjComp = pLS[(int)priCompIndex].ColorStandard(ColorIndexing.ConvertColorEnum(CurrentTargetData.PrimaryStandardColor));
//double BjComp = pLS[(int)priCompIndex].ColorStandard(ColorIndexing.ConvertColorEnum(CurrentTargetData.DifferentialStandardColor));
double VFld = compLS.ColorStandard(ColorIndexing.ConvertColorEnum(CurrentTargetData.PrimaryStandardColor));
//double BjComp = compLS.ColorStandard(ColorIndexing.ConvertColorEnum(CurrentTargetData.DifferentialStandardColor));
if (VFld != 0)
{
double deltaInstTgtColor = bTgt - vTgt;
double deltaInstFldColor = bFld - vFld;
double deltaInstColor = deltaInstTgtColor - deltaInstFldColor;
double tcInst = CurrentTargetData.ColorTransform * deltaInstColor;
double deltaInstMag = vTgt - vFld;
double VTgt = deltaInstMag + CurrentTargetData.MagnitudeTransform * tcInst + VFld;
sourceInstMag.Add(VTgt);
standardMagnitudeCalculated++;
}
}
}
}
}
}
}
}
LogIt(crossRegisteredLightSources.ToString() + " full registered light sources");
LogIt(standardMagnitudeCalculated.ToString() + " standard magnitude calculations.");
if (sourceInstMag.Count == 0)
{
LogIt("No usable target and/or comparison light sources.");
return false;
}
// Algorithm that picks the number of buckets based on Sturgis Rule
int sturgisRuleBuckets = (int)Math.Ceiling(Math.Log(sourceInstMag.Count, 2));
//Algorithm that picks the number of buckets based on Scott's rule 3.49*sigma/cube root of n
(double sMean, double sStdDev) = MathNet.Numerics.Statistics.ArrayStatistics.MeanStandardDeviation(sourceInstMag.ToArray());
double hWidth = 3.49 * sStdDev / (Math.Pow(sourceInstMag.Count, 0.3));
double maxVal = sourceInstMag.Max();
double minVal = sourceInstMag.Min();
int scottsRuleBuckets = 1;
if (hWidth > 0)
scottsRuleBuckets = (int)Math.Ceiling((maxVal - minVal) / hWidth);
// Algorithm that picks the number of buckets based on Rick's Rule, i.e. 100 buckets
int ricksRuleBuckets = 100;
// Pick a bucket Rule
int bucketRule = ricksRuleBuckets;
MathNet.Numerics.Statistics.Histogram histBuckets = new MathNet.Numerics.Statistics.Histogram(sourceInstMag, bucketRule);
MathNet.Numerics.Statistics.Bucket bigBucket = Utility.FullestBucket(histBuckets);
//Find the statistical median of the bigBucket
double median = (bigBucket.UpperBound + bigBucket.LowerBound) / 2;
//Find the statistical mean of the bigBucket
//by finding its members then finding the mean
List<double> bigBucketList = new List<double>();
foreach (double tsm in sourceInstMag)
if (bigBucket.Contains(tsm) == 0)
bigBucketList.Add(tsm);
//Then, find the mean of the bucket
(double bbmean, double bbmstddev) = MathNet.Numerics.Statistics.ArrayStatistics.MeanStandardDeviation(bigBucketList.ToArray());
TransformedTargetChart.Series[0].Points.Clear();
TransformedTargetChart.ChartAreas[0].AxisX.LabelStyle.Format = "0.00";
for (int i = 0; i < histBuckets.BucketCount; i++)
{
double bucketMean = (histBuckets[i].UpperBound + histBuckets[i].LowerBound) / 2;
TransformedTargetChart.Series[0].Points.AddXY(bucketMean, histBuckets[i].Count);
}
//Mode-based averages -- old algo
(double fieldmean, double fieldstddev) = MathNet.Numerics.Statistics.ArrayStatistics.MeanStandardDeviation(sourceInstMag.ToArray());
//CurrentTargetData.StandardColorMagnitude = fieldmean;
//CurrentTargetData.StandardMagnitudeError = fieldstddev;
CurrentTargetData.StandardColorMagnitude = bbmean;
CurrentTargetData.StandardMagnitudeError = bbmstddev;
TargetModeBox.Text = bbmean.ToString("0.000");
TargetStdDevBox.Text = bbmstddev.ToString("0.000");
return true;
}
public bool ConvertToInstrumentMagnitude()
{
//********************************************************************************
//
// Average all source instrument magnitudes
//
//
//********************************************************************************
LogIt("Averaging Source Instrument Magnitudes " + CurrentTargetData.TargetName);
sourceInstMag.Clear();
////Cull Master List to the brightest 2000 field stars (arbitrary just to speed up processing time)
//// masterRegisteredList = Transformation.SortByMagnitude(masterRegisteredList, 2000);
int sourceInstMagCalculated = 0;
int plsIdx = 0;
//Primary field star images loop
foreach (StarField.FieldLightSource[] pLS in primaryLightSources)
{
plsIdx++;
int? priTgtIndex = Registration.FindRegisteredLightSource(pLS, CurrentTargetData.MasterRegistrationIndex);
if (priTgtIndex == null)
{
LogIt("No target light source found in primary registered image (P" + (plsIdx - 1).ToString() + ").");
}
else
{
foreach (StarField.FieldLightSource compLS in masterLightSources)
{
int? priCompIndex = Registration.FindRegisteredLightSource(pLS, (int)compLS.RegistrationIndex);
if (priTgtIndex != null)
{
sourceInstMagCalculated++;
double vTgt = pLS[(int)priTgtIndex].LightSourceInstMag;
sourceInstMag.Add(vTgt);
}
}
}
}
LogIt(sourceInstMag.ToString() + " Source instrument magnitude calculations.");
if (sourceInstMag.Count == 0)
{
LogIt("No usable target and/or comparison light sources.");
return false;
}
// Algorithm that picks the number of buckets based on Sturgis Rule
TransformedTargetChart.Series[0].Points.Clear();
TransformedTargetChart.ChartAreas[0].AxisX.LabelStyle.Format = "0.00";
for (int i = 0; i < sourceInstMag.Count; i++)
{
TransformedTargetChart.Series[0].Points.AddXY(sourceInstMag[i], i);
}
CurrentTargetData.SourceInstrumentMagnitude = sourceInstMag.Average();
// CurrentTargetData.StandardMagnitudeError = sourceInstMag.;
//TargetModeBox.Text = bbmean.ToString("0.000");
//TargetStdDevBox.Text = bbmstddev.ToString("0.000");
return true;
}
private void DisplayFITS(StarField sf)
{
//Using FITS file information...
FITImage = new FitsFileTSX(TSX_Image);
//Compute pixel scale = 206.256 * pixel size (in microns) / focal length
//Set initial values in case the FITS words aren't there
FITImage.PixSize = FITImage.PixSize ?? 9;
FITImage.FocalLength = FITImage.FocalLength ?? 2563; //mm
FITImage.Aperture = FITImage.Aperture ?? 356.0; //mm
FITImage.Exposure = FITImage.Exposure ?? 0;
// focal length must be set to correct value in FITS header -- comes from camera set up in TSX
FocalRatio = (double)FITImage.FocalLength / (double)FITImage.Aperture;
PixelScale_arcsec = ConvertToArcSec((double)FITImage.PixSize, (double)FITImage.FocalLength);
//Set the pixel scale for an InsertWCS image linking
TSX_Image.ScaleInArcsecondsPerPixel = PixelScale_arcsec;
//set saturation threshold
SaturationADU = Math.Pow(2, (double)FITImage.PixBits) * 0.95;
//Fill in Seeing Analysis information in the windows form:
//Instrument info
FocalLengthBox.Text = ((double)FITImage.FocalLength).ToString("0");
ApertureBox.Text = ((double)FITImage.Aperture).ToString("0");
FocalRatioBox.Text = FocalRatio.ToString("0.0");
PixSizeMicronBox.Text = ((double)FITImage.PixSize).ToString("0.0");
PixSizeArcSecBox.Text = (ConvertToArcSec((double)FITImage.PixSize, (double)FITImage.FocalLength)).ToString("0.00");
MaxResolutionArcSecBox.Text = ((ConvertToArcSec((double)FITImage.PixSize, (double)FITImage.FocalLength)) * 3.3).ToString("0.00");
AirMassBox.Text = ((double)(FITImage.FitsAirMass ?? 0)).ToString("0.000");
MeanFWHMBox.Text = (sf.FWHMAvg_Pixels ?? 0.0 * TSX_Image.ScaleInArcsecondsPerPixel).ToString("0.00");
FWHMSeeing_arcsec = (sf.FWHMAvg_Pixels ?? 0.0 * (double)FITImage.PixSize) * 206.3 / ((double)FITImage.FocalLength);
SeeingClassBox.Text = GetSeeingClass(sf.FWHMAvg_Pixels ?? 0.0 * TSX_Image.ScaleInArcsecondsPerPixel, (double)FITImage.Aperture);
SeeingMeanEllipticityBox.Text = (sf.EllipticityAvg ?? 0.0).ToString("0.00");
//FitsNameBox.Text = FITImage.FitsTarget;
FitsDateBox.Text = FITImage.FitsUTCDate;
FitsTimeBox.Text = FITImage.FitsUTCTime;
FitsFilterBox.Text = FITImage.Filter;
SourceBackgroundADUBox.Text = TSX_Image.Background.ToString("0");
FitsExposureBox.Text = ((double)FITImage.Exposure).ToString("0.0");
Show();
System.Windows.Forms.Application.DoEvents();
return;
}
private void AnalyzeFitsImage(string fitsFilePath)
{
//Use fits field parameters for target info storage
//Use local variables for additional target information
double targetRA;
double targetDec;
//The current image in TSX is activated and FITS information acquired.
// The image is { sent through image link to compute WCS information for each star.
// The results are sorted by magnitude, averaged, seeing estimated and results displayed.
//
Configuration cfg = new Configuration();
//Housekeeping
//Clear any existing SRC files, as they might be locked and TSX will quietly crash
TSX_Process.DeleteSRC(cfg.ImageBankFolder);
//Read the fits file into a starfield image object
StarField sf = new StarField(TSX_Image, fitsFilePath);
//Using open FITS file information...
FITImage = new FitsFileTSX(TSX_Image);
DisplayFITS(sf);
//Get the target ra and dec from the fits file and load catalog coordinates
//(targetRA, targetDec) = TSX_Resources.FindTarget(FITImage.FitsTarget);
targetRA = (double)FITImage.FitsRA;
targetDec = (double)FITImage.FitsDec;
//Image Link the fits and create array of light sources, set flag if successful, return if not
StarField.FieldLightSource[] sfLSArray = (sf.PositionLightSources(sf.AssembleLightSources())).ToArray();
if (sfLSArray.Length == 0)
{
LogIt("Attempted Image Link of FITS image is unsuccessful");
return;
}
//Compute pixel scale = 206.256 * pixel size (in microns) / focal length
//Set initial values in case the FITS words aren't there
FITImage.PixSize = FITImage.PixSize ?? 9;
FITImage.FocalLength = FITImage.FocalLength ?? 2563; //mm
FITImage.Aperture = FITImage.Aperture ?? 356.0; //mm
FITImage.Exposure = FITImage.Exposure ?? 0;
FitsDateBox.Text = FITImage.FitsUTCDate;
FitsTimeBox.Text = FITImage.FitsUTCTime;
// ImageFilter = FITImage.Filter[0].ToString();
//CurrentTargetData.ImageDate = FITImage.FitsUTCDateTime;
//CurrentTargetData.AirMass = (double)(FITImage.FitsAirMass ?? 0);
// focal length must be set to correct value in FITS header -- comes from camera set up in TSX
FocalRatio = (double)FITImage.FocalLength / (double)FITImage.Aperture;
PixelScale_arcsec = ConvertToArcSec((double)FITImage.PixSize, (double)FITImage.FocalLength);
////Set the pixel scale for an InsertWCS image linking
//TSX_Image.ScaleInArcsecondsPerPixel = PixelScale_arcsec;
//set saturation threshold
SaturationADU = Math.Pow(2, (double)FITImage.PixBits) * 0.95;
//Fill in Seeing Analysis information in the windows form:
//Instrument info
FocalLengthBox.Text = ((double)FITImage.FocalLength).ToString("0");
ApertureBox.Text = ((double)FITImage.Aperture).ToString("0");
FocalRatioBox.Text = FocalRatio.ToString("0.0");
PixSizeMicronBox.Text = ((double)FITImage.PixSize).ToString("0.0");
PixSizeArcSecBox.Text = (ConvertToArcSec((double)FITImage.PixSize, (double)FITImage.FocalLength)).ToString("0.00");
MaxResolutionArcSecBox.Text = ((ConvertToArcSec((double)FITImage.PixSize, (double)FITImage.FocalLength)) * 3.3).ToString("0.00");
AirMassBox.Text = ((double)(FITImage.FitsAirMass ?? 0)).ToString("0.000");
double fWHMAvg_pixels = sf.FWHMAvg_Pixels ?? 0.0;
double ellipticityAvg = sf.EllipticityAvg ?? 0.0;
double FWHMAvg_arcsec = fWHMAvg_pixels * TSX_Image.ScaleInArcsecondsPerPixel;
double FWHMAvg_micron = fWHMAvg_pixels * (double)FITImage.PixSize;
MeanFWHMBox.Text = FWHMAvg_arcsec.ToString("0.00");
FWHMSeeing_arcsec = FWHMAvg_micron * 206.3 / ((double)FITImage.FocalLength);
SeeingClassBox.Text = GetSeeingClass(FWHMAvg_arcsec, (double)FITImage.Aperture);
SeeingMeanEllipticityBox.Text = ellipticityAvg.ToString("0.00");
//Create new target data for this variable target
DisplayCatalogData();
Show();
if (FitsIsOpen)
{
//Done
//Display target, date and time for fits file
//FitsNameBox.Text = FITImage.FitsTarget;
double backgroundADU = TSX_Image.Background;
SourceBackgroundADUBox.Text = backgroundADU.ToString("0");
FitsExposureBox.Text = ((double)FITImage.Exposure).ToString("0.0");
FitsFilterBox.Text = FITImage.Filter;
}
//Zero out the count and error boxes
ApassStarCountBox.Text = "0";
GaiaStarCountBox.Text = "0";
ApassToSourcePositionErrorBox.Text = "";
GaiaToSourcePositionErrorBox.Text = "";
double imas = TSX_Resources.ImageWidth(TSX_Image);
TSX_Resources.CenterStarChart(TSX_Image, targetRA, targetDec, imas);
TSX_Process.MinimizeTSX();
for (int i = 0; i < sfLSArray.Count(); i++)
{
sfLSArray[i].CatalogInfo = StarField.ClickFindCatalogData(sfLSArray[i].LightSourceRA, sfLSArray[i].LightSourceDec);
SourceCountBox.Text = i.ToString() + "/" + sfLSArray.Count().ToString();
if (sfLSArray[i].CatalogInfo.Value.APASSCatalogName != null)
ApassStarCountBox.Text = (Convert.ToInt32(ApassStarCountBox.Text) + 1).ToString();
if (sfLSArray[i].CatalogInfo.Value.GAIACatalogName != null)
GaiaStarCountBox.Text = (Convert.ToInt32(GaiaStarCountBox.Text) + 1).ToString();
}
TSX_Process.NormalizeTSX();
//Find the closest light source to the target coordinates
int? currentTargetLSIndex = Registration.ClosestLightSource(sfLSArray, targetRA, targetDec, MinSeparationArcSec);
//if no target is found then return
if (currentTargetLSIndex == null)
{
LogIt("Could not locate a light source at the target coordinates in fits image");
return;
}
CurrentTargetData.MasterRegistrationIndex = (int)currentTargetLSIndex;
StarField.FieldLightSource tgtLightSource = sfLSArray[(int)currentTargetLSIndex];
//Load the CurrentTargetData descriptor from the registered target star light source
//Find and load the catalog data for the cataloged star closest to the target light source
(double apassError, double gaiaError) =
StarField.CalculateSeparations((StarField.CatalogData)tgtLightSource.CatalogInfo, tgtLightSource.LightSourceRA, tgtLightSource.LightSourceDec);
ApassToSourcePositionErrorBox.Text = (apassError * 3600).ToString("0.0");
GaiaToSourcePositionErrorBox.Text = (gaiaError * 3600).ToString("0.0");
SourceRATextBox.Text = Utility.SexidecimalRADec(tgtLightSource.LightSourceRA, true);
SourceDecTextBox.Text = Utility.SexidecimalRADec(tgtLightSource.LightSourceDec, false);
SourceMagBox.Text = tgtLightSource.LightSourceInstMag.ToString("0.00");
SourcePeakADUBox.Text = tgtLightSource.LightSourceADU.ToString("0.00");
SourceFWHMBox.Text = tgtLightSource.LightSourceFWHM.ToString("0.00");
SourceEllipticityBox.Text = tgtLightSource.LightSourceEllipticity.ToString("0.00");
//Graph the target star
GraphSource(CurrentTargetData, sf);
return;
}
private void DisplayLightSourceData()
{
//Fills out Catalog Data group from Current Target Data
SourceMagBox.Text = CurrentTargetData.SourceInstrumentMagnitude.ToString("0.00");
SourceFWHMBox.Text = CurrentTargetData.SourceFWHM.ToString("0.00");
SourcePeakADUBox.Text = CurrentTargetData.SourceADU.ToString("0.00");
SourceEllipticityBox.Text = CurrentTargetData.SourceEllipticity.ToString("0.00");
Show();
return;
}
private void ClearLightSourceData()
{
//Clears the catalog data fields so they don't confuse the looker
SourceMagBox.Text = "";
SourceFWHMBox.Text = "";
SourcePeakADUBox.Text = "";
SourceEllipticityBox.Text = "";
Show();
return;
}
private void DisplayCatalogData()
{
//Fills out Catalog Data group from Current Target Data
if (CurrentTargetData.MasterCatalogInfo.IsAPASSCataloged)
ApassToSourcePositionErrorBox.Text = (CurrentTargetData.SourceToAPASSCatalogPositionError * 3600).ToString("0.0");
else
ApassToSourcePositionErrorBox.Text = "No Cat";
if (CurrentTargetData.MasterCatalogInfo.IsGAIACataloged)
GaiaToSourcePositionErrorBox.Text = (CurrentTargetData.SourceToGAIACatalogPositionError * 3600).ToString("0.0");
else
GaiaToSourcePositionErrorBox.Text = "No Cat";
ApassStarCountBox.Text = CurrentTargetData.ApassStarCount.ToString();
GaiaStarCountBox.Text = CurrentTargetData.GaiaStarCount.ToString();
Show();
return;
}