//Read in suspect list private void ListSuspects() { Suspect susobj = new Suspect(); List <Suspect.Perp> susList = susobj.PerpList(); //Clear the suspect list in the form window SuspectListbox.Items.Clear(); //Add the galaxy name, event date and confirmation status to the form textbox foreach (Suspect.Perp susp in susList) { //translate the cleared status to a string string susCleared; if (susp.Suspicion) { susCleared = "Cleared"; } else { susCleared = "Suspect"; } //Assemble a string for the text box line string suspectdesc = susp.Galaxy + " \t" + susp.EventDate.ToString("yyyy-MM-dd HH:mm") + " " + susCleared; //Add the string to the form//s textbox //List the suspect only if uncleared if (!susp.Suspicion) { SuspectListbox.Items.Add(suspectdesc); } } if (SuspectListbox.Items.Count == 0) //Check for an empty list, if so then report it on the form, then { SuspectListbox.Items.Add("No Suspects in Suspect File"); } return; }
//When a suspect is chosen from the textbox list, parse the line for galaxy name and date // then have TSX open the difference image, the reference image and the current image // then have TSX set the FOV to the size of the galaxy, set the center of the chart to the // coordinates of the suspect and place the target circle over the coordinates. // //Then... // private void SuspectListbox_SelectedIndexChanged(object sender, EventArgs e) { ///If nothing selected then exit /// ///Parse the selected line for the galaxy name and image time. ///Load up the suspect data ///Lay in the clearer follow up image and prep to blink the two latest images /// //Set the cursor to wait UseWaitCursor = true; Show(); FormCrunchingNotice cForm = new FormCrunchingNotice(); cForm.Show(); BlinkButton.BackColor = Color.LightSalmon; //pull the selected suspect entry from the suspect list box string susitem; try { susitem = SuspectListbox.Items[SuspectListbox.SelectedIndex].ToString(); } catch (Exception ex) { return; } //Clear the blink list BlinkList = null; //Parse the selected entry for relavent info and create a suspect object to work with int galLen = susitem.IndexOf("\t"); string galname = susitem.Substring(0, galLen - 1); galname = galname.TrimEnd(); int dateLen = susitem.IndexOf(":") - galLen + 2; string galevent = susitem.Substring(galLen + 1, dateLen); DateTime galdate = Convert.ToDateTime(galevent); CurrentSuspect = new Suspect(); //Check to see if the stored suspect info loads ok, if so then // have TSX upload the image files and target the RA/Dec bool susLoad = CurrentSuspect.Load(galname, galdate); if (susLoad) { CurrentDrillDown = new DrillDown(CurrentSuspect.Event); CurrentDrillDown.Display(galname, CurrentSuspect.SuspectRA, CurrentSuspect.SuspectDec); sky6StarChart tsx_sc = new sky6StarChart(); sky6ObjectInformation tsx_oi = new sky6ObjectInformation(); //Get the galaxy major axis tsx_sc.Find(galname); tsx_oi.Index = 0; tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_MAJ_AXIS_MINS); double galaxis = tsx_oi.ObjInfoPropOut; //Set the FOV size to the galaxy size tsx_sc.FieldOfView = galaxis / 60; //Set the center of view to the suspect//s RA/Dec and light up the target icon //tsx_sc.Find(suspect.SuspectRA.ToString() + ", " + suspect.SuspectDec.ToString()); tsx_sc.RightAscension = CurrentSuspect.SuspectRA; tsx_sc.Declination = CurrentSuspect.SuspectDec; //Check TNS for supernova reports for 60 arc seconds around this location for the last 10 days TNSReader tnsReport = new TNSReader(); List <string> snList = tnsReport.RunLocaleQuery(CurrentSuspect.SuspectRA, CurrentSuspect.SuspectDec, 60, 10); if (snList != null) { NotesTextBox.AppendText("Supernova reported for " + snList[0] + " at this location\r\n"); } else { NotesTextBox.AppendText("No supernova report for this location\r\n"); } //Give the user an opportunity to clear the suspect by updating its status to cleared -- or not. Clipboard.Clear(); try { Clipboard.SetText(CurrentSuspect.SuspectRA.ToString() + ", " + CurrentSuspect.SuspectDec.ToString()); } catch (Exception ex) { NotesTextBox.AppendText(ex.Message); return; } //Display the suspect position information NotesTextBox.AppendText("Suspect RA and Dec written to clipboard\r\n"); LocationTextBox.Text = CurrentSuspect.SuspectRA.ToString() + ", " + CurrentSuspect.SuspectDec.ToString(); Show(); System.Windows.Forms.Application.DoEvents(); //Show followup Image in picture box CurrentFollowUpImage = CurrentDrillDown.GetFollowUpImage(ImageZoom); ImagePictureBox.SizeMode = PictureBoxSizeMode.CenterImage; ImagePictureBox.Image = CurrentFollowUpImage; BlinkButton.BackColor = Color.LightGreen; ClearButton.BackColor = Color.LightGreen; UseWaitCursor = false; } cForm.Close(); Show(); return; }
public bool NewStar(string gname, string dfilepath, string rfilepath) { //Look for star-like reminant in difference image using the TSX "ShowInventory" (Sextractor) function // return true if star-like object found, false if not. // //Open a new TSX Image object, then load and open difference image ccdsoftImage tsx_dif = new ccdsoftImage(); tsx_dif.Path = dfilepath; tsx_dif.Open(); //Prepare TSX to close the image window when closing the image tsx_dif.DetachOnClose = 0; //Look for stars using Sextractor // If fails, close the object and image try { int tdstat = tsx_dif.ShowInventory(); } catch { tsx_dif.Close(); LogEntry("No suspects: Sextractor failed on Difference Image."); return(false); } // Sextractor didnt// run into any problems, but may have found nothing // Check how many objects found, if none then close up and return false // If something is found, then leave the window open and return "true" var dMagArr = tsx_dif.InventoryArray((int)ccdsoftInventoryIndex.cdInventoryMagnitude); //double[] FWHMArr = Convert.ToDouble(tDiff.InventoryArray((int)ccdsoftInventoryIndex.cdInventoryFWHM)); var dXPosArr = tsx_dif.InventoryArray((int)ccdsoftInventoryIndex.cdInventoryX); var dYPosArr = tsx_dif.InventoryArray((int)ccdsoftInventoryIndex.cdInventoryY); //double[] ElpArr = Convert.ToDouble(tDiff.InventoryArray((int)ccdsoftInventoryIndex.cdInventoryEllipticity)); var dClsArr = tsx_dif.InventoryArray((int)ccdsoftInventoryIndex.cdInventoryClass); if (dMagArr.Length == 0) { tsx_dif.Close(); LogEntry("No suspects: No light sources found on Difference Image."); return(false); } else { //We have at least one hit in the box. Now look to see if any don//t match up with // light sources found in the reduced reference image. //Open a new TSX Image object, then load and open difference image ccdsoftImage tsx_ref = new ccdsoftImage(); tsx_ref.Path = rfilepath; tsx_ref.Open(); //Prepare TSX to close the image window when closing the image tsx_ref.DetachOnClose = 0; //Look for stars using Sextractor // If fails, close the object and image try { int cdstat = tsx_ref.ShowInventory(); } catch { tsx_ref.Close(); tsx_dif.Close(); LogEntry("No suspects: Sextractor failed on Reference Image."); return(false); } // Sextractor didnt// run into any problems, but may have found nothing // Check how many objects found, if none then close up and return false // If something is found, then leave the window open and return "true" var rMagArr = tsx_ref.InventoryArray((int)ccdsoftInventoryIndex.cdInventoryMagnitude); //double[] FWHMArr = Convert.ToDouble(tDiff.InventoryArray((int)ccdsoftInventoryIndex.cdInventoryFWHM)); var rXPosArr = tsx_ref.InventoryArray((int)ccdsoftInventoryIndex.cdInventoryX); var rYPosArr = tsx_ref.InventoryArray((int)ccdsoftInventoryIndex.cdInventoryY); //double[] ElpArr = Convert.ToDouble(tDiff.InventoryArray((int)ccdsoftInventoryIndex.cdInventoryEllipticity)); var rClsArr = tsx_ref.InventoryArray((int)ccdsoftInventoryIndex.cdInventoryClass); //So let//s make being within 20 pixels (40 arcsec) of each other sufficient for calling two light sources the same. //Proceed through the light source array looking for matches, there shouldn//t be many int proximity = 20; Boolean nomatch; for (int di = 0; di < dXPosArr.Length; di++) { double dXpos = Convert.ToDouble(dXPosArr[di]); double dYpos = Convert.ToDouble(dYPosArr[di]); double dCls = Convert.ToDouble(dClsArr[di]); nomatch = true; if (dCls >= 0.8) { for (int ri = 0; ri < rXPosArr.Length; ri++) { double rXpos = Convert.ToDouble(rXPosArr[ri]); double rYpos = Convert.ToDouble(rYPosArr[ri]); if ((Math.Abs(dXpos - rXpos) <= proximity) && (Math.Abs(dYpos - rYpos) <= proximity)) { nomatch = false; break; } } if (nomatch) { // A suspect has been found. Log it//s x,y location on the Difference image, then // Get its location (RA,Dec) by using XYToRADec method that runs yet another Image Link // on the current image file (not the cropped one), extrapolating the cropped difference image x,y // to the uncropped current image, then using TSX to convert the extrapolated X,Y to an RA,Dec. // // Add to Suspect List then, log, close, collect and return // We may do more later... LogEntry("Suspect without alibi in " + dfilepath + " at X= " + Convert.ToInt32(dXpos) + " Y= " + Convert.ToInt32(dYpos)); double xCurPos = ((dXpos - (tsx_dif.WidthInPixels) / 2)) + (grandeWidth / 2); double yCurPos = ((dYpos - (tsx_dif.HeightInPixels) / 2)) + (grandeHeight / 2); XYToRADec ss_perp = new XYToRADec(curImagePath, xCurPos, yCurPos); double pRA = ss_perp.RA; double pDec = ss_perp.Dec; LogEntry("Suspect//s coordinates (RA,Dec) = " + pRA.ToString() + " Hrs, " + pDec.ToString() + " Deg"); //Now create a new entry and save the suspect in the suspect file Suspect ss_sus = new Suspect(); ss_sus.GalaxyName = gname; ss_sus.Event = DateTime.Now; ss_sus.SuspectRA = pRA; ss_sus.SuspectDec = pDec; ss_sus.SuspectCurrentLocationX = dXpos; ss_sus.SuspectCurrentLocationY = dYpos; ss_sus.Store(); tsx_dif.Close(); tsx_dif = null; tsx_ref.Close(); tsx_ref = null; ss_perp = null; ss_sus = null; GC.Collect(); return(true); } } } //If no suspects found, log, close, collect and return; LogEntry("All suspects have alibis from Reference image."); tsx_dif.Close(); tsx_dif = null; tsx_ref.Close(); tsx_ref = null; return(false); } }