Ejemplo n.º 1
0
        private void WriteAbsorptionFactors()
        {
            const string method           = nameof(WriteAbsorptionFactors);
            var          saveFolderTop    = FieldParseTools.IsValue(metadata.pathOutputData) ? metadata.pathOutputData : "";
            var          saveFolderBottom = FieldParseTools.IsValue(metadata.saveName) ? metadata.saveName : "No preset";
            var          saveDir          = Path.Combine(Directory.GetCurrentDirectory(), Settings.DefaultValues.OutputFolderName,
                                                         saveFolderTop, saveFolderBottom);
            var saveFileName = properties.FilenameFormatter(_nrAnglesTheta);
            var savePath     = Path.Combine(saveDir, saveFileName);

            Directory.CreateDirectory(saveDir);

            var headRow = (Settings.flags.useOutputPreamble ? properties.OutputPreamble() + "\n" : "") +
                          string.Join("\t", "2 theta", "A_{s,sc}", "A_{c,sc}", "A_{c,c}");
            var headCol = angles
                          .Select(v => !Settings.flags.useRadian ? AsDegree(v): v)
                          .Select(angle => angle.ToString("G", CultureInfo.InvariantCulture))
                          .ToArray();
            var data = new float[_nrAnglesTheta, 3];

            for (int i = 0; i < _nrAnglesTheta; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    data[i, j] = _absorptionFactors[i][j];
                }
            }

            ArrayWriteTools.Write2D(savePath, headCol, headRow, data);
            logger.Log(Logger.EventType.Step, $"{Context(method)}: done.");
        }
Ejemplo n.º 2
0
        protected override void Write()
        {
            //SetStatusMessage($"Step 3/{(writeFactors ? 4 : 3)}: Saving results to disk...");

            var saveFolderTop    = FieldParseTools.IsValue(metadata.pathOutputData) ? metadata.pathOutputData : "";
            var saveFolderBottom = FieldParseTools.IsValue(metadata.saveName) ? metadata.saveName : "No preset";
            var saveDir          = Path.Combine(Directory.GetCurrentDirectory(), Settings.DefaultValues.OutputFolderName,
                                                saveFolderTop, saveFolderBottom);
            var saveFileName = properties.FilenameFormatter(_nrAnglesTheta);
            var savePath     = Path.Combine(saveDir, saveFileName);

            Directory.CreateDirectory(saveDir);

            var headRow = Settings.flags.useOutputPreamble ? properties.OutputPreamble() + "\n" : null;

            if (Settings.flags.planeModeWriteSeparateFiles)
            {
                float[,] current = new float[_nrAnglesAlpha, _nrAnglesTheta];
                for (int col = 0; col < 3; col++)
                {
                    for (int j = 0; j < _nrAnglesTheta; j++)
                    {
                        for (int i = 0; i < _nrAnglesAlpha; i++)
                        {
                            current[i, j] = _absorptionFactors[i, j][col];
                        }
                    }

                    var row     = Settings.flags.useOutputPreamble ? properties.OutputPreamble(new[] { col }) + "\n" : null;
                    var caseStr = new[] { "(s,sc)", "(c,sc)", "(c,c)" }[col];
                    stopwatch.Record(Category.IO, () =>
                    {
                        ArrayWriteTools.Write2D(savePath.Replace("[mode=1]", $"[mode=1][case={caseStr}]"),
                                                null, row, current, reverse: true);
                    });
                }
            }
            else
            {
                stopwatch.Record(Category.IO,
                                 () => ArrayWriteTools.Write2D(savePath, null, headRow, _absorptionFactors, reverse: true));
            }

            SetStatusMessage("Done.");
        }