/// <summary> /// method to read the post processor input from a specified or default files /// </summary> public static PostProcessorInput ReadPostProcessorInputFromFile(string inputFile) { try { // read input file then read in elements of input file if (string.IsNullOrEmpty(inputFile)) { Console.WriteLine("\nNo input file specified. Using infile.txt from root mc_post.exe folder... "); return(ReadPostProcessorInputFromFile("infile.txt")); } //get the full path for the input file var fullFilePath = Path.GetFullPath(inputFile); if (File.Exists(fullFilePath)) { return(PostProcessorInput.FromFile(fullFilePath)); } if (File.Exists(fullFilePath + ".txt")) { return(PostProcessorInput.FromFile(fullFilePath + ".txt")); } //throw a file not found exception throw new FileNotFoundException("\nThe following input file could not be found: " + fullFilePath + " - type mc_post help=infile for correct syntax"); } catch (Exception e) { Console.WriteLine(e.Message); return(null); } }
public void validate_tissue_optical_properties_are_non_negative() { var tissueInput = new MultiLayerTissueInput( new ITissueRegion[] { new LayerTissueRegion( new DoubleRange(double.NegativeInfinity, 0.0), new OpticalProperties(0.0, 1e-10, 1.0, 1.0)), new LayerTissueRegion( new DoubleRange(0.0, 100.0), new OpticalProperties(-1.0, 1.0, 0.8, 1.4)), // make mua negative new LayerTissueRegion( new DoubleRange(100.0, double.PositiveInfinity), new OpticalProperties(0.0, 1e-10, 1.0, 1.0)) }); var input = new PostProcessorInput( new List <IDetectorInput>() { new pMCROfRhoDetectorInput() { Rho = new DoubleRange(0.0, 100.0), // set perturbed ops to reference ops PerturbedOps = new List <OpticalProperties>() { tissueInput.Regions[0].RegionOP, tissueInput.Regions[1].RegionOP, tissueInput.Regions[2].RegionOP }, PerturbedRegionsIndices = new List <int>() { 1 } } }, "", "", "" ); var result = PostProcessorInputValidation.ValidateInput(input, ""); Assert.IsFalse(result.IsValid); }
// need to work on following /// <summary> /// Runs the Monte Carlo Post-processor /// </summary> public static void RunPostProcessor(PostProcessorInput input, string outputFolderPath) { // locate root folder for output, creating it if necessary var path = string.IsNullOrEmpty(outputFolderPath) ? Path.GetFullPath(Directory.GetCurrentDirectory()) : Path.GetFullPath(outputFolderPath); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } // locate destination folder for output, creating it if necessary var resultsFolder = Path.Combine(path, input.OutputName); if (!Directory.Exists(resultsFolder)) { Directory.CreateDirectory(resultsFolder); } SimulationOutput postProcessedOutput = null; var databaseGenerationInputFile = SimulationInput.FromFile(Path.Combine(input.InputFolder, input.DatabaseSimulationInputFilename + ".txt")); // check for pMC tallies first because could have ReflectanceTallies mixed in and want to load CollisionInfo // Why not mirror the "on-the-fly" code, and allow for all kinds of detector inputs simultaneously? (dc 12/21/2011) if (input.DetectorInputs.Where(di => di.TallyDetails.IspMCReflectanceTally).Any()) { IList <IDetectorInput> pMCDetectorInputs; pMCDetectorInputs = input.DetectorInputs; var postProcessor = new PhotonDatabasePostProcessor( VirtualBoundaryType.pMCDiffuseReflectance, pMCDetectorInputs, PhotonDatabaseFactory.GetpMCDatabase( // database filenames are assumed to be convention VirtualBoundaryType.pMCDiffuseReflectance, input.InputFolder), databaseGenerationInputFile ); postProcessedOutput = postProcessor.Run(); } else if (input.DetectorInputs.Where(di => di.TallyDetails.IsReflectanceTally).Any()) { var postProcessor = new PhotonDatabasePostProcessor( VirtualBoundaryType.DiffuseReflectance, input.DetectorInputs, PhotonDatabaseFactory.GetPhotonDatabase( //database filenames are assumed to be convention VirtualBoundaryType.DiffuseReflectance, input.InputFolder), databaseGenerationInputFile ); postProcessedOutput = postProcessor.Run(); } else if (input.DetectorInputs.Where(di => di.TallyDetails.IsTransmittanceTally).Any()) { var postProcessor = new PhotonDatabasePostProcessor( VirtualBoundaryType.DiffuseTransmittance, input.DetectorInputs, PhotonDatabaseFactory.GetPhotonDatabase( //database filenames are assumed to be convention VirtualBoundaryType.DiffuseTransmittance, input.InputFolder), databaseGenerationInputFile ); postProcessedOutput = postProcessor.Run(); } else if (input.DetectorInputs.Where(di => di.TallyDetails.IsSpecularReflectanceTally).Any()) { var postProcessor = new PhotonDatabasePostProcessor( VirtualBoundaryType.SpecularReflectance, input.DetectorInputs, PhotonDatabaseFactory.GetPhotonDatabase( //database filenames are assumed to be convention VirtualBoundaryType.SpecularReflectance, input.InputFolder), databaseGenerationInputFile ); postProcessedOutput = postProcessor.Run(); } var folderPath = input.OutputName; if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } // save input file to output folder with results input.ToFile(Path.Combine(resultsFolder, input.OutputName + ".txt")); // save database generation input file to output folder databaseGenerationInputFile.ToFile(Path.Combine(resultsFolder, input.OutputName + "_database_infile.txt")); if (postProcessedOutput != null) { foreach (var result in postProcessedOutput.ResultsDictionary.Values) { // save all detector data to the specified folder DetectorIO.WriteDetectorToFile(result, folderPath); } } }
public static ValidationResult ValidatePostProcessorInput(PostProcessorInput input) { return(PostProcessorInputValidation.ValidateInput(input)); }
/// <summary> /// Validate PostProcessor input with optional overriding command line "infile" option /// </summary> /// <param name="input">PostProcessor infile</param> /// <param name="inpath">command line path for inpath (where database resides)</param> /// <returns></returns> public static ValidationResult ValidatePostProcessorInput(PostProcessorInput input, string inpath) { return(PostProcessorInputValidation.ValidateInput(input, inpath)); }