internal static BitArray[] ExtractBadpixel(string Badpixel, Action <string> Logger)
        {
            BitArray[] map = null;
            if (Badpixel != null)
            {
                Logger("Checking badpixel file");
                MMapFitsFile fif_bad   = MMapFitsFile.OpenReadFile(Badpixel);
                FitsImage    BadpixMap = new FitsImage(fif_bad);
                map = BadpixelFilter.CreateFilter(BadpixMap);
            }

            return(map);
        }
        public bool EnsureCentralImage(string Name, out FitsImage Image)
        {
            string ImagePath = Path.Combine(RunDir, Name + ".fits");

            if (File.Exists(ImagePath))
            {
                Image = new FitsImage(MMapFitsFile.OpenReadFile(ImagePath)); return(true);
            }
            FICHV        values = Headers[0];
            MMapFitsFile file   = MMapFitsFile.OpenWriteFile(ImagePath, values.Header);

            Image = new FitsImage(file);
            return(false);
        }
Example #3
0
		void RunPipeline()
		{
			string FieldName = textBox1.Text;
			int i;
			string[] BadpixSet = null;
			if(Pipeline.UseCoreFilter) BadpixSet = Directory.GetFiles(Config.Badpixel);
			TryGetBadzone();
			for (i = 0; i < InputFiles.Length; i++)
			{
				int CCDNum = i + 1;
				if (Pipeline.SkipCCD2 & CCDNum == 2) continue;

				string CCDStr = "CCD" + CCDNum.ToString();
				string CBP = BadpixSet == null ? null : BadpixSet.Where((x) => x.Contains(CCDStr)).First();
				List<Tracklet> Result;
				FitsImage[] fims;
				try
				{
					MMapFitsFile[] mmfs = InputFiles[i].Select((x) => MMapFitsFile.OpenReadFile(x)).ToArray();
					fims = mmfs.Select((x) => new FitsImage(x)).ToArray();
					BadzoneFilter bzf = null;
					if (Badzones != null && Badzones.ContainsKey(CCDNum))
						bzf = Badzones[CCDNum];
					Standard.PipelineArguments pa = new Standard.PipelineArguments()
					{
						Badpixel = CBP,
						RunDir = Path.Combine(textBox3.Text, CCDStr),
						Inputs = fims,
						CatalogData = CatFiles?[i]?.Select(File.ReadLines)?.ToArray(),
						Clipped = false,
						CCDBadzone = bzf,
						FieldName = textBox1.Text,
						CCDNumber = CCDNum
					};

					Pipeline.Logger = (x) => InvokeLogLine("Pipeline", x, CCDStr);

					Result = Pipeline.AnalyzeCCD(pa);
				}
				catch (Exception ex)
				{
					InvokeLogLine("Pipeline Error", "Unhandled exception of type " + ex.GetType() + " occurred.");
					InvokeLogLine("Pipeline Error", "Error message: " + ex.Message);
					InvokeLogLine("Pipeline Error", "Stack trace: " + ex.StackTrace);
					return;
				}
				this.Invoke((ResultShower)ShowResults, Result, i, fims, FieldName);
			}
		}
        /// <summary>
        /// Ensures that a certain image is present.
        /// </summary>
        /// <param name="Algorithm">Algorithm to generate the image if it is not present.</param>
        /// <param name="Model">Image to copy width, height and transform from.</param>
        /// <param name="OutputName">Path of the output image.</param>
        /// <param name="BitPix">BITPIX value of the output image.</param>
        /// <param name="ExtraProperties">List of properties to be passed to the image constructor.</param>
        /// <returns>The desired image.</returns>
        public static Image EnsureImage(Action <Image> Algorithm, Image Model, string OutputName, int BitPix = 0, List <ImageProperties> ExtraProperties = null)
        {
#warning Not Implemented; Bug.
            if (File.Exists(OutputName))
            {
                return(new FitsImage(MMapFitsFile.OpenReadFile(OutputName)));
            }
            if (BitPix == 0)
            {
                BitPix = DefaultBitPix;
            }
            Image Image = null;             //new FitsImage(new FitsFile(OutputName, true), Model.Width, Model.Height, Model.Transform, BitPix, ExtraProperties);
            Algorithm(Image);
            return(Image);
        }
Example #5
0
        private void DetectionDebugMap(string RunDir, int i, List <ImageDetection> LocalDetectionList, FitsImage DetectionSource)
        {
            FICHV        Header   = DetectionSource.CopyHeader().ChangeBitPix(16);
            MMapFitsFile DeOutput = MMapFitsFile.OpenWriteFile(RunDir + "DOutMap" + i.ToString() + ".fits", Header.Header);
            FitsImage    DeOutIm  = new FitsImage(DeOutput);
            var          DeData   = DeOutIm.LockData(new System.Drawing.Rectangle(0, 0, (int)DetectionSource.Width, (int)DetectionSource.Height), false, false);


            foreach (ImageDetection xi in LocalDetectionList)
            {
                int kat = 200 + LocalDetectionList.IndexOf(xi);
                if (xi.TryFetchProperty(out ObjectPoints pts))
                {
                    foreach (var pt in pts.PixelPoints)
                    {
                        try { DeData.Data[(int)pt.Y, (int)pt.X] = kat; }
                        catch { break; }
                    }
                }
            }
            DeOutIm.ExitLock(DeData);
            Logger("Exported detections map");
        }