public bool solve(string filePath, imageInfo bm, string strGSClocation) { try { P.AttachFITS(filePath); P.ArcsecPerPixelHoriz = bm.arcSecsPerPixX; P.ArcsecPerPixelVert = bm.arcSecsPerPixY; P.RightAscension = bm.dRA; P.Declination = bm.dDec; P.Catalog = (PinPoint.CatalogType) 3; // Corrected GSC P.CatalogPath = strGSClocation; bool pRresult = P.Solve(); sd.solvedRA = P.RightAscension; sd.solvedDec = P.Declination; P.DetachFITS(); return(pRresult); } catch (System.Exception msg) { sd.plate_solve_error_msg = msg.Message; P.DetachFITS(); return(false); // Need to add code here to cater for specific exceptions (timeout, etc). } return(false); //assume that there was a problem with either of the above solves }
public void saveImageToFitsForSolveOnly(string path, imageInfo image, Array imgArray) { var imageData = (Array)ArrayFuncs.Flatten(imgArray); const double bZero = 0; const double bScale = 1.0; if (image.MaxADU <= 65535) { //bZero = 32768; //imageData = (ushort[])ArrayFuncs.ConvertArray(imageData, typeof(ushort)); } int[] dims = ArrayFuncs.GetDimensions(imgArray); // put the image data in a basic HDU of the fits BasicHDU imageHdu = FitsFactory.HDUFactory(ArrayFuncs.Curl(imageData, dims)); // Add the other fits fields to the HDU imageHdu.AddValue("BZERO", bZero, ""); imageHdu.AddValue("BSCALE", bScale, ""); imageHdu.AddValue("DATAMIN", 0.0, ""); // should this reflect the actual data values imageHdu.AddValue("DATAMAX", image.MaxADU, "pixel values above this level are considered saturated."); imageHdu.AddValue("DATE-OBS", image.LastExposureStartTime, ""); imageHdu.AddValue("XPIXSZ", image.PixelSizeX * image.BinX, "physical X dimension of the sensor's pixels in microns"); // (present only if the information is provided by the camera driver). Includes binning. imageHdu.AddValue("YPIXSZ", image.PixelSizeY * image.BinY, "physical Y dimension of the sensor's pixels in microns"); // (present only if the information is provided by the camera driver). Includes binning. imageHdu.AddValue("XBINNING", image.BinX, ""); imageHdu.AddValue("YBINNING", image.BinY, ""); imageHdu.AddValue("OBJCTRA", image.RA, "Approximate Right Ascension of image centre"); imageHdu.AddValue("OBJCTDEC", image.Dec, "Approximate Declination of image centre"); // save it var fitsImage = new Fits(); fitsImage.AddHDU(imageHdu); //Adds the actual image data (the header info already exists in imageHDU) FileStream fs = null; try { fs = new FileStream(path, FileMode.Create); using (var bds = new BufferedDataStream(fs)) { fs = null; fitsImage.Write(bds); } } finally { if (fs != null) { fs.Dispose(); } } }