private void PlotPhotometryHistory(string agnName) { //Plots out history of current star photometry Starchive pHistory = new Starchive(); List <TargetData> tDataList = new List <TargetData>(); if (FitsFilterBox.Text != null && FitsFilterBox.Text != "") { tDataList = pHistory.RetrievePhotometry(agnName, FitsFilterBox.Text); this.HistoryChart.Series[0].Points.Clear(); this.HistoryChart.Series[1].Points.Clear(); foreach (TargetData tData in tDataList) { //Star Mag is the computed Inst Mag for star in the archived image //MagScale is Mean Ratio of Catalog Mag to Inst Mag for the archived image double tgtMag = tData.APASSSourceCorrectedMagnitude; if (tgtMag != 0) { double errorBar = tData.APASSMagPopulationStandardError; HistoryChart.Series[0].ChartType = (SeriesChartType.ErrorBar); HistoryChart.Series[0].MarkerStyle = MarkerStyle.None; HistoryChart.Series[0].Points.AddXY(tData.ImageDate, tgtMag, tgtMag - errorBar, tgtMag + errorBar); HistoryChart.Series[1].Points.AddXY(tData.ImageDate, tgtMag); } } } else { MessageBox.Show("Missing filter label in FITS Filter box."); } return; }
private void ArchiveStar(TargetData varTarget) { //Method to store star mag for future reference Starchive photoSave = new Starchive(); photoSave.StorePhotometry(varTarget); return; }
public static void CreateSummaryReport(string textFilePath) { // Description: // Load the Starchive File // Create an output text file // For each element in the starchive file, // Build a string in the proposed format, with comma separation // Save the string as a line in the text file const string header = "Target Name" + "," + "Target RA(j2K)" + "," + "Target Dec(j2K)" + "," + "Image UTC" + "," + "Image Filter" + "," + "AirMass" + "," + // "Raw Source Magnitude" + "," + "Source ADU" + "," + "Reference Stars" + "," + "APASS Adj Mag" + "," + "APASS Linearity" + "," + "APASS RSquared" + "," + "APASS PSE" + "," + "GAIA Adj Mag" + "," + "GAIA Linearity" + "," + "GAIA RSquared" + "," + "GAIA PSE" + "," + "Source Position Error" + "," + "APASS Catalog Position Error" + "," + "GAIA Catalog Position Error"; Starchive sData = new Starchive(); StreamWriter csvFile = File.CreateText(textFilePath); //write header csvFile.WriteLine(header); foreach (TargetData tData in sData.RetrieveAllPhotometrySummarized()) { string bLine = tData.TargetName + "," + Utility.SexidecimalRADec(tData.TargetRA, true) + "," + Utility.SexidecimalRADec(tData.TargetDec, false) + ", " + tData.ImageDate.ToString("MMM/dd/yyyy HH:mm:ss") + "," + tData.ImageFilter.ToString() + "," + tData.AirMass.ToString() + "," + //tData.SourceUncorrectedMagnitude.ToString("0.0") + ", " + tData.SourceADU.ToString("0") + ", " + tData.APASSStarCount.ToString() + ", " + tData.APASSSourceCorrectedMagnitude.ToString("0.00") + ", " + tData.APASSMagnitudeGradient.ToString("0.000") + "," + tData.APASSMagnitudeRSquared.ToString("0.000") + "," + tData.APASSMagPopulationStandardError.ToString("0.000") + "," + tData.GAIASourceCorrectedMagnitude.ToString("0.00") + ", " + tData.GAIAMagnitudeGradient.ToString("0.000") + "," + tData.GAIAMagnitudeRSquared.ToString("0.000") + "," + tData.GAIAMagPopulationStandardError.ToString("0.000") + "," + Utility.NAGenerator((int)tData.TargetToSourcePositionError, 36000) + "," + tData.SourceToAPASSCatalogPositionError.ToString("0.0") + "," + tData.SourceToGAIACatalogPositionError.ToString("0.0"); csvFile.WriteLine(bLine); } csvFile.Close(); return; }
public static void CreateAAVSOReport(string textFilePath, string AAVSO_Observers_Code) { //https://www.aavso.org/aavso-extended-file-format const string EXTENDED = "Extended"; const string VARSURVEYNAME = "VariScan 1.0 (TheSkyX)"; const string DELIMITER = ","; const string EXCELDATETYPE = "EXCEL"; //EXCEL: the format created by Excel's NOW() function (Ex: 12/31/2007 12:59:59 a.m ) const string OBSTYPECODE = "CCD"; const string TYPE = "#TYPE"; const string OBSCODE = "#OBSCODE"; const string SOFTWARE = "#SOFTWARE"; const string DELIM = "#DELIM"; const string DATE = "#DATE"; const string OBSTYPE = "#OBSTYPE"; //Form Header string header = TYPE + "=" + EXTENDED + "\n" + OBSCODE + "=" + AAVSO_Observers_Code + "\n" + SOFTWARE + "=" + VARSURVEYNAME + "\n" + DELIM + "=" + DELIMITER + "\n" + DATE + "=" + EXCELDATETYPE + "\n" + OBSTYPE + "=" + OBSTYPECODE; Starchive sData = new Starchive(); StreamWriter csvFile = File.CreateText(textFilePath); //write header csvFile.WriteLine(header); //for each entry in the Starchive, create a line foreach (TargetData tData in sData.RetrieveAllPhotometry()) { string bline = tData.TargetName + DELIMITER; //STARID bline += tData.ImageDate.ToString() + DELIMITER; //DATE bline += tData.APASSSourceCorrectedMagnitude + DELIMITER; //MAGNITUDE bline += tData.APASSMagPopulationStandardError + DELIMITER; //MAGERR if (tData.ImageFilter.Contains("Clear")) //FILTER { bline += "CV" + DELIMITER; } else { bline += tData.ImageFilter + DELIMITER; } bline += "NO" + DELIMITER; //TRANS NOT LANDOLT STANDARDS bline += "STD" + DELIMITER; //MTYPE bline += "na" + DELIMITER; //CNAME bline += tData.SourceUncorrectedMagnitude.ToString("0.000") + DELIMITER; //CMAG bline += "na" + DELIMITER; //KNAME bline += "ensemble" + DELIMITER; //KMAG bline += tData.AirMass.ToString("0.000") + DELIMITER; //AIRMASS bline += "na" + DELIMITER; //GROUP bline += "APASS Full Frame" + DELIMITER; //CHART bline += "Full frame light source calibration to " + tData.APASSStarCount.ToString("0") + " APASS cataloged stars."; //NOTES csvFile.WriteLine(bline); } csvFile.Close(); return; }
private void ScanImagesButton_Click(object sender, EventArgs e) { //Redden the command button Utility.ButtonRed(ScanImagesButton); Show(); System.Windows.Forms.Application.DoEvents(); //Get list of targets TargetList vList = new TargetList(); List <TargetList.TargetXDescriptor> targetList = vList.GetTargetList(); for (int iTgt = 0; iTgt < targetList.Count; iTgt++) { string targetDirectoryName = targetList[iTgt].Name; FitsNameBox.Text = targetDirectoryName; Show(); System.Windows.Forms.Application.DoEvents(); IEnumerable <string> targetImages = VariScanFileManager.TargetImageList(targetDirectoryName); if (targetImages != null) { foreach (string iFile in targetImages) { //Use a direct fits reader to determine if the image has already been analyized, i.e. in Starchive (TSX is too slow) Starchive recs = new Starchive(); FitsFile fitMe = new FitsFile(iFile); FitsNameBox.Text = targetDirectoryName; FitsDateBox.Text = fitMe.FitsUTCDateTime.ToShortDateString(); FitsTimeBox.Text = fitMe.FitsUTCDateTime.ToShortTimeString(); FitsFilterBox.Text = fitMe.Filter.ToString(); Show(); System.Windows.Forms.Application.DoEvents(); if (!recs.HasMatchingPhotometryRecord(targetDirectoryName, fitMe.Filter, fitMe.FitsUTCDateTime)) { if (TSX_Image != null) { VariScanFileManager.CloseImageFile(TSX_Image); } FitsIsOpen = VariScanFileManager.DirectOpenFitsFile(TSX_Image, iFile); if (FitsIsOpen) { OpenFileNameBox.Text = iFile; FITImage = new Fits(TSX_Image); //if (!recs.HasMatchingPhotometryRecord(targetDirectoryName, FITImage.Filter, FITImage.FitsUTCDateTime)) //{ ManageTSXProcess.MinimizeTSX(); TargetedNameBox.Text = targetList[iTgt].Name; TargetedRABox.Text = Utility.SexidecimalRADec(targetList[iTgt].RA, true); TargetedDecBox.Text = Utility.SexidecimalRADec(targetList[iTgt].Dec, false); TargetedFilterBox.Text = targetList[iTgt].Filter.ToString(); TargetData tstar = Analyze(targetList[iTgt].Name, targetList[iTgt].RA, targetList[iTgt].Dec); if (tstar.IsImageLinked) { SourceRATextBox.Text = Utility.SexidecimalRADec(tstar.SourceRA, true); SourceDecTextBox.Text = Utility.SexidecimalRADec(tstar.SourceDec, false); tstar = GraphMagnitudes(tstar); tstar = GraphSource(tstar); FillPhotometrySummary(tstar); ArchiveStar(tstar); PlotPhotometryHistory(targetList[iTgt].Name); Show(); System.Windows.Forms.Application.DoEvents(); } else { //Star did not image link -- archive it as is ArchiveStar(tstar); } ManageTSXProcess.NormalizeTSX(); //} Show(); System.Windows.Forms.Application.DoEvents(); } } } } } breakLoop = false; Utility.ButtonGreen(BreakButton); //Green the command button Utility.ButtonGreen(ScanImagesButton); return; }