public static void SaveFlatImage(string targetName, string filterName, string targetPA, string sidePoint) { //The NH image directory originates from the SetUp form and stored in the //Configuration file. LogEvent lg = new LogEvent(); SessionControl openSession = new SessionControl(); TargetPlan tPlan = new TargetPlan(openSession.CurrentTargetName); //Get Humason directory name, create image directory if it doesn't exist yet string nhDirName = openSession.HumasonDirectoryPath; string nhImageDirName = nhDirName + "\\Images"; if (!Directory.Exists(nhImageDirName)) { Directory.CreateDirectory(nhImageDirName); } //Create date name for image sub-directory, create if it doesn't exist yet DateTime sequenceStartDate = tPlan.SequenceStartTime; string targetImageDir = nhImageDirName + "\\" + sequenceStartDate.ToString("yyyyMMdd"); if (!Directory.Exists(targetImageDir)) { Directory.CreateDirectory(targetImageDir); } //Create Data Files directory if it doesn't exit yet string targetImageDataDir = targetImageDir + "\\Calibration Files"; if (!Directory.Exists(targetImageDataDir)) { Directory.CreateDirectory(targetImageDataDir); } //Reduce target PA to integer string, i.e. scrape off the decimal targetPA = (Convert.ToDouble(targetPA)).ToString("0"); string targetImageDataPath = targetImageDataDir + "\\" + filterName + targetName + "_" + targetPA + "PA" + sidePoint + "." + openSession.SequentialFileNumber.ToString() + ".fit"; //open TSX camera and get the last image ccdsoftImage tsxi = new ccdsoftImage(); int camStatus = tsxi.AttachToActiveImager(); //save handling an exception here until some future date tsxi.setFITSKeyword("OBJECT", "Humason Flat Field"); AstroImage tsxc = new AstroImage(); if (tPlan.RotatorEnabled) { tsxi.setFITSKeyword("ROTATOR", Rotator.RealRotatorPA.ToString()); } //Set save path and save tsxi.Path = targetImageDataPath; tsxi.Save(); lg.LogIt("Flat saved: " + targetImageDataPath); }
private bool ShootTarget(TargetList.TargetXDescriptor currentTarget) { Configuration cfg = new Configuration(); int repetitions = Convert.ToInt32(cfg.ImagesPerSample); ccdsoftCamera tsx_cc = new ccdsoftCamera { AutoSaveOn = 0, //Autosave Off FilterIndexZeroBased = freshImageFilter, ExposureTime = freshImageExposure, Subframe = 0, Frame = ccdsoftImageFrame.cdLight, Asynchronous = 1 //Asynchronous on }; //Set up for noise reduction, if any switch (cfg.CalibrationType) { case "None": { tsx_cc.ImageReduction = ccdsoftImageReduction.cdNone; LogEntry("No image calibration."); break; } case "Auto": { tsx_cc.ImageReduction = ccdsoftImageReduction.cdAutoDark; LogEntry("Auto Dark image calibration set"); break; } case "Full": { tsx_cc.ImageReduction = ccdsoftImageReduction.cdBiasDarkFlat; Reduction calLib = new Reduction(); string binning = "1X1"; int camTemp = (int)tsx_cc.TemperatureSetPoint; if (!calLib.SetReductionGroup(freshImageFilter, freshImageExposure, camTemp, binning)) { LogEntry("No calibration library found: " + "B_" + binning + "T_" + camTemp + "E_" + freshImageFilter.ToString("0") + "F_" + freshImageFilter.ToString("0")); return(false); break; } LogEntry("Full image calibration set: " + calLib.ReductionGroupName); break; } } //Loop on repetitions of image do { SetNextImagePath(cfg.ImageBankFolder + "\\" + freshImageName); ccdsoftImage tsx_im = new ccdsoftImage { Path = freshImagePath }; LogEntry("Imaging " + currentTarget.Name + " at RA: " + Utility.SexidecimalRADec(freshImageRA, true) + " / Dec: " + Utility.SexidecimalRADec(freshImageDec, false)); LogEntry("Filter set to " + freshImageFilter.ToString("0")); LogEntry("Imaging target for " + freshImageExposure.ToString("0.0") + " secs"); tsx_cc.TakeImage(); //Wait for completion while (tsx_cc.State != ccdsoftCameraState.cdStateNone) { System.Threading.Thread.Sleep(1000); System.Windows.Forms.Application.DoEvents(); } tsx_im.AttachToActiveImager(); tsx_im.setFITSKeyword("OBJECT", freshImageName); tsx_im.Save(); repetitions--; } while (repetitions > 0); LogEntry("Imaging target Complete"); return(true); }
/// <summary> /// Saves the most recent image capture to Humason image directory for that night (as defined by start time) /// </summary> /// <param name="targetName"></param> /// <param name="filterName"></param> /// <param name="targetPA"></param> /// <param name="sidePoint"></param> public static void SaveLightImage(string targetName, string filterName, string targetPA, string sidePoint) { //The NH image directory originates from the NH form and stored in the Session class. //Get Humason directory name, create image directory if it doesn't exist yet LogEvent lg = new LogEvent(); SessionControl openSession = new SessionControl(); string nhDirName = openSession.HumasonDirectoryPath; string nhImageDirName = nhDirName + "\\Images"; if (!Directory.Exists(nhImageDirName)) { Directory.CreateDirectory(nhImageDirName); } //Create date name for image sub-directory, create if it doesn't exist yet TargetPlan tPlan = new TargetPlan(openSession.CurrentTargetName); DateTime sequenceStartDate = tPlan.SequenceStartTime; string targetImageDir = nhImageDirName + "\\" + sequenceStartDate.ToString("yyyyMMdd") + "_" + targetName; if (!Directory.Exists(targetImageDir)) { Directory.CreateDirectory(targetImageDir); } //Create Data Files directory if it doesn't exit yet string targetImageDataDir = targetImageDir + "\\Data Files"; if (!Directory.Exists(targetImageDataDir)) { Directory.CreateDirectory(targetImageDataDir); } //Reduce target PA to integer string, i.e. scrape off the decimal targetPA = (Convert.ToDouble(targetPA)).ToString("0"); string targetImageDataPath = targetImageDataDir + "\\" + filterName + targetName + "_" + targetPA + sidePoint + "." + openSession.SequentialFileNumber.ToString() + ".fit"; //open TSX camera and get the last image ccdsoftImage tsxi = new ccdsoftImage(); int camStatus = tsxi.AttachToActiveImager(); //save handling an exception here until some future date //Add some FITSKeywords for future reference //Correct the OBJECT Keyword if using coordinates instead of a target name tsxi.setFITSKeyword("OBJECT", targetName); //Enter the rotator angle if (tPlan.RotatorEnabled) { tsxi.setFITSKeyword("ROTATOR", Rotator.RealRotatorPA.ToString()); } //Enter Image Position Angle as saved tsxi.setFITSKeyword("ORIENTAT", tPlan.TargetPA); //Set save path and save tsxi.Path = targetImageDataPath; tsxi.Save(); lg.LogIt("Image saved: " + targetImageDataPath); }