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); }
//Take an image via TSX. Set the autosave path to the FreshImage path; // Set exposureTime, Light Frame, AutoDark, No Autosave, Asynchronous // then TakeImage // Wait for completion status, then return // // Removed subframe setting on request for cameras with long download times private void ShootGalaxy() { Configuration sscf = new Configuration(); ccdsoftImage tsx_im = new ccdsoftImage { Path = sscf.FreshImagePath }; ccdsoftCamera tsx_cc = new ccdsoftCamera { AutoSaveOn = 0, //Autosave Off FilterIndexZeroBased = Convert.ToInt32(sscf.Filter), ExposureTime = Convert.ToDouble(sscf.Exposure), //Subframe = 0, Frame = ccdsoftImageFrame.cdLight, //ImageReduction = ccdsoftImageReduction.cdAutoDark, Asynchronous = 1 //Asynchronous on }; switch (sscf.CalibrationType) { case "None": { tsx_cc.ImageReduction = ccdsoftImageReduction.cdNone; break; } case "Auto": { tsx_cc.ImageReduction = ccdsoftImageReduction.cdAutoDark; break; } case "Full": { tsx_cc.ImageReduction = ccdsoftImageReduction.cdBiasDarkFlat; break; } } LogEntry("Imaging target for " + sscf.Exposure + " 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.Save(); freshImagePath = sscf.FreshImagePath; LogEntry("Imaging Complete"); return; }
public void Shoot(string gName, double expTime) { //Take a fresh image at 600 seconds //That will be placed in the Configuration sscfg = new Configuration(); ccdsoftImage tsx_im = new ccdsoftImage(); ccdsoftCamera tsx_cc = new ccdsoftCamera(); tsx_im.Path = FollowUpPath + "\\" + gName + ".fit"; tsx_cc.AutoSaveOn = 0; //Autosave Off //No filter change tsx_cc.ExposureTime = expTime; tsx_cc.Frame = ccdsoftImageFrame.cdLight; tsx_cc.ImageReduction = ccdsoftImageReduction.cdAutoDark; switch (sscfg.CalibrationType) { case "None": { tsx_cc.ImageReduction = ccdsoftImageReduction.cdNone; break; } case "Auto": { tsx_cc.ImageReduction = ccdsoftImageReduction.cdAutoDark; break; } case "Full": { tsx_cc.ImageReduction = ccdsoftImageReduction.cdBiasDarkFlat; break; } } tsx_cc.Asynchronous = 0; //Asynchronous on 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.Save(); }
public void Store(string filepath) //Saves the image data as a new file through TSX //Adjust to 256 bit depth because TSX DataArray is still broken // Change later { double bitdepth = 256; ccdsoftImage tsx_im = new ccdsoftImage(); tsx_im.New(pixelSizeX, pixelSizeY, pixeldepth); var imgarr = tsx_im.DataArray; for (int i = 0; i < imagePixels.Length; i++) { imgarr[i] = imagePixels[i] / bitdepth; } tsx_im.DataArray = imgarr; tsx_im.Path = filepath; tsx_im.Save(); tsx_im.DetachOnClose = 0; tsx_im.Close(); tsx_im = null; GC.Collect(); return; }
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); }