|
Vlasiator ebf0dd394 on dev (v5.4.0 + 1054 commits)
|
File containing write IO for vlasiator. More info at: https://agora.fmi.fi/display/CORSAIR/VLSV+File+Format. More...
#include <algorithm>#include <cmath>#include <cstdlib>#include <cstring>#include <dirent.h>#include <exception>#include <iomanip>#include <iostream>#include <limits>#include <list>#include <set>#include <sstream>#include <stdint.h>#include <string>#include <typeinfo>#include "../definitions.h"#include "vlsvreaderinterface.h"#include <vlsv_reader.h>#include <vlsv_writer.h>#include <fsgrid.hpp>
Go to the source code of this file.
Enumerations | |
| enum | GridType { SPATIALGRID , FSGRID , IONOSPHERE } |
Functions | |
| static uint64_t | convUInt (const char *ptr, const vlsv::datatype::type &dataType, const uint64_t &dataSize) |
| bool | copyArray (vlsv::Reader &input, vlsv::Writer &output, const std::string &tagName, const list< pair< string, string > > &inputAttribs, bool optional=false) |
| bool | HandleFsGrid (const string &inputFileName, vlsv::Writer &output, std::map< uint, Real > orderedData) |
| bool | getFsgridDecomposition (vlsvinterface::Reader &file, std::array< int, 3 > &decomposition) |
| bool | cloneMesh (const string &inputFileName, vlsv::Writer &output, const string &meshName, std::map< uint, Real > orderedData) |
| bool | convertMesh (vlsvinterface::Reader &vlsvReader, const string &meshName, const char *varToExtract, const uint compToExtract, map< uint, Real > *orderedData, unordered_map< size_t, size_t > &cellOrder, const bool &storeCellOrder) |
| template<class T> | |
| bool | convertSILO (const string fileName, const char *varToExtract, const uint compToExtract, map< uint, Real > *orderedData, unordered_map< size_t, size_t > &cellOrder, Real &time, const bool &storeCellOrder=false) |
| bool | shiftAverage (const map< uint, Real > *const orderedData1, const map< uint, Real > *const orderedData2, map< uint, Real > *shiftedData2) |
| bool | pDistance (const map< uint, Real > &orderedData1, const map< uint, Real > &orderedData2, creal p, Real *absolute, Real *relative, const bool doShiftAverage, const unordered_map< size_t, size_t > &cellOrder, vlsv::Writer &outputFile, const std::string &meshName, const std::string &varName) |
| bool | outputDistance (const Real p, const Real *absolute, const Real *relative, const bool shiftedAverage, const bool verboseOutput, const bool lastCall) |
| bool | outputDt (const Real dt, const bool verboseOutput, const bool lastCall) |
| bool | singleStatistics (map< uint, Real > *orderedData, Real *size, Real *mini, Real *maxi, Real *avg, Real *stdev) |
| bool | outputStats (const Real *size, const Real *mini, const Real *maxi, const Real *avg, const Real *stdev, const bool verboseOutput, const bool lastCall) |
| bool | printNonVerboseData () |
| bool | getBlockIds (vlsvinterface::Reader &vlsvReader, const unordered_map< uint64_t, pair< uint64_t, uint32_t > > &cellsWithBlocksLocations, const uint64_t &cellId, vector< uint32_t > &blockIds) |
| uint32_t | getBlockId (const double vx, const double vy, const double vz, const double dvx, const double dvy, const double dvz, const double vx_min, const double vy_min, const double vz_min, const double vx_length, const double vy_length, const double vz_length) |
| template<class T> | |
| bool | readAvgs (T &vlsvReader, string name, const unordered_map< uint64_t, pair< uint64_t, uint32_t > > &cellsWithBlocksLocations, const uint64_t &cellId, unordered_map< uint32_t, vector< double > > &avgs, uint64_t &vectorSize) |
| template<class T> | |
| bool | getCellsWithBlocksLocations (T &vlsvReader, unordered_map< uint64_t, pair< uint64_t, uint32_t > > &cellsWithBlocksLocations) |
| template<class T, class U> | |
| bool | compareAvgs (const string fileName1, const string fileName2, const bool verboseOutput, vector< uint64_t > &cellIds1, vector< uint64_t > &cellIds2) |
| bool | process2Files (const string fileName1, const string fileName2, const char *varToExtract, const uint compToExtract, const bool verboseOutput, const uint compToExtract2=0) |
| bool | processDirectory (DIR *dir, set< string > *fileList) |
| void | printHelp (const map< string, string > &defAttribs, const map< string, string > &descriptions) |
| int | main (int argn, char *args[]) |
Variables | |
| static map< string, string > | attributes |
| static int | gridName |
File containing write IO for vlasiator. More info at: https://agora.fmi.fi/display/CORSAIR/VLSV+File+Format.
Tool to compare VLSV files.
Tool to compare two VLSV files, two folders with the same number of VLSV files or a folder to a reference file. The tool assumes the files have a name syntax 'grid.[0-9]+.vlsv'. It takes four arguments.
Calling patterns are:
"$ vlsvdiff <file1> <file2> <Variable> <component>": Gives single-file statistics and distances between the two files given, for the variable and component given
"$ vlsvdiff --diff --meshname=<Meshname> <file1> <file2> <Variable> <component>": Gives single-file statistics and distances between the two files given, for the variable and component given
"$ vlsvdiff <folder1> <folder2> <Variable> <component>": Gives single-file statistics and distances between pairs of files grid*.vlsv taken in alphanumeric order in the two folders given, for the variable and component given
"$ vlsvdiff <file1> <folder2> <Variable> <component>" or "$ vlsvdiff <folder1> <file2> <Variable> <component>": Gives single-file statistics and distances between a file, and files grid*.vlsv taken in alphanumeric order in the given folder, for the variable and component given
Definition in file vlsvdiff.cpp.
| enum GridType |
| Enumerator | |
|---|---|
| SPATIALGRID | |
| FSGRID | |
| IONOSPHERE | |
Definition at line 75 of file vlsvdiff.cpp.
| bool cloneMesh | ( | const string & | inputFileName, |
| vlsv::Writer & | output, | ||
| const string & | meshName, | ||
| std::map< uint, Real > | orderedData ) |
Copy the spatial mesh from input to output.
| inputFileName | Name of the input file where the mesh is copied from. |
| output | VLSV reader for the file where the cloned mesh is written. |
| meshName | Name of the mesh. |
Definition at line 383 of file vlsvdiff.cpp.


| bool compareAvgs | ( | const string | fileName1, |
| const string | fileName2, | ||
| const bool | verboseOutput, | ||
| vector< uint64_t > & | cellIds1, | ||
| vector< uint64_t > & | cellIds2 ) |
Definition at line 1317 of file vlsvdiff.cpp.


| bool convertMesh | ( | vlsvinterface::Reader & | vlsvReader, |
| const string & | meshName, | ||
| const char * | varToExtract, | ||
| const uint | compToExtract, | ||
| map< uint, Real > * | orderedData, | ||
| unordered_map< size_t, size_t > & | cellOrder, | ||
| const bool & | storeCellOrder ) |
Extracts the dataset from the VLSV file opened by convertSILO.
| vlsvReader | vlsvinterface::Reader class object used to access the VLSV file |
| meshName | Address of the string containing the name of the mesh to be extracted |
| varToExtract | Pointer to the char array containing the name of the variable to extract |
| compToExtract | Unsigned int designating the component to extract (0 for scalars) |
| orderedData | Pointer to the return argument map which will get the extracted dataset |
Definition at line 433 of file vlsvdiff.cpp.


| bool convertSILO | ( | const string | fileName, |
| const char * | varToExtract, | ||
| const uint | compToExtract, | ||
| map< uint, Real > * | orderedData, | ||
| unordered_map< size_t, size_t > & | cellOrder, | ||
| Real & | time, | ||
| const bool & | storeCellOrder = false ) |
Opens the VLSV file and extracts the mesh names. Sends for processing to convertMesh.
| fileName | String containing the name of the file to be processed |
| varToExtract | Pointer to the char array containing the name of the variable to extract |
| compToExtract | Unsigned int designating the component to extract (0 for scalars) |
| orderedData | Pointer to the return argument map which will get the extracted dataset |
Definition at line 714 of file vlsvdiff.cpp.


|
static |
| bool copyArray | ( | vlsv::Reader & | input, |
| vlsv::Writer & | output, | ||
| const std::string & | tagName, | ||
| const list< pair< string, string > > & | inputAttribs, | ||
| bool | optional = false ) |
Read given array data from input file, and byte-copy it to the output file.
| input | Input file reader. |
| output | Output file reader. |
| tagName | Name of the copied array. |
| inputAttributes | XML attributes for the copied array. |
| optional | If true, this parameter is OK to be missing. |
Definition at line 111 of file vlsvdiff.cpp.

| uint32_t getBlockId | ( | const double | vx, |
| const double | vy, | ||
| const double | vz, | ||
| const double | dvx, | ||
| const double | dvy, | ||
| const double | dvz, | ||
| const double | vx_min, | ||
| const double | vy_min, | ||
| const double | vz_min, | ||
| const double | vx_length, | ||
| const double | vy_length, | ||
| const double | vz_length ) |
| bool getBlockIds | ( | vlsvinterface::Reader & | vlsvReader, |
| const unordered_map< uint64_t, pair< uint64_t, uint32_t > > & | cellsWithBlocksLocations, | ||
| const uint64_t & | cellId, | ||
| vector< uint32_t > & | blockIds ) |
Definition at line 1085 of file vlsvdiff.cpp.


| bool getCellsWithBlocksLocations | ( | T & | vlsvReader, |
| unordered_map< uint64_t, pair< uint64_t, uint32_t > > & | cellsWithBlocksLocations ) |
Definition at line 1236 of file vlsvdiff.cpp.


| bool getFsgridDecomposition | ( | vlsvinterface::Reader & | file, |
| std::array< int, 3 > & | decomposition ) |
| bool HandleFsGrid | ( | const string & | inputFileName, |
| vlsv::Writer & | output, | ||
| std::map< uint, Real > | orderedData ) |
| int main | ( | int | argn, |
| char * | args[] ) |
Main function, detects which calling pattern is used and sends to the corresponding processing functions.
Definition at line 1783 of file vlsvdiff.cpp.

| bool outputDistance | ( | const Real | p, |
| const Real * | absolute, | ||
| const Real * | relative, | ||
| const bool | shiftedAverage, | ||
| const bool | verboseOutput, | ||
| const bool | lastCall ) |
In verbose mode print the distance, in non-verbose store them for later output when lastCall is true
| p | Parameter of the distance |
| absolute | Absolute value pointer |
| relative | Relative value pointer |
| shiftedAverage | Boolean parameter telling whether the dataset is average-shifted |
| verboseOutput | Boolean parameter telling whether the output is verbose or compact |
| lastCall | Boolean parameter telling whether this is the last call to the function |
Definition at line 913 of file vlsvdiff.cpp.

| bool outputDt | ( | const Real | dt, |
| const bool | verboseOutput, | ||
| const bool | lastCall ) |
In verbose mode print delta t, in non-verbose store them for later output when lastCall is true
| dt | delta t |
| verboseOutput | Boolean parameter telling whether the output is verbose or compact |
| lastCall | Boolean parameter telling whether this is the last call to the function |
Definition at line 947 of file vlsvdiff.cpp.

| bool outputStats | ( | const Real * | size, |
| const Real * | mini, | ||
| const Real * | maxi, | ||
| const Real * | avg, | ||
| const Real * | stdev, | ||
| const bool | verboseOutput, | ||
| const bool | lastCall ) |
In verbose mode print the statistics, in non-verbose store them for later output when lastCall is true
| size | Pointer to dataset size |
| mini | Pointer to dataset minimum |
| maxi | Pointer to dataset maximum |
| avg | Pointer to dataset average |
| stdev | Pointer to dataset standard deviation |
| verboseOutput | Boolean parameter telling whether the output is verbose or compact |
| lastCall | Boolean parameter telling whether this is the last call to the function |
Definition at line 1011 of file vlsvdiff.cpp.

| bool pDistance | ( | const map< uint, Real > & | orderedData1, |
| const map< uint, Real > & | orderedData2, | ||
| creal | p, | ||
| Real * | absolute, | ||
| Real * | relative, | ||
| const bool | doShiftAverage, | ||
| const unordered_map< size_t, size_t > & | cellOrder, | ||
| vlsv::Writer & | outputFile, | ||
| const std::string & | meshName, | ||
| const std::string & | varName ) |
Compute the absolute and relative 
For 
absolute 
![$ \|X_1 - X_2\|_p = \left[\sum_i |X_1(i) - X_2(i)|^p\right]^{1/p}$](../../form_2.png)
relative 
![$ \|X_1 - X_2\|_p = \left[\sum_i |X_1(i) - X_2(i)|^p\right]^{1/p} / \|X_1\|_p $](../../form_3.png)
For 

absolute 

relative 

| orderedData1 | Pointer to the first file's data map |
| orderedData2 | Pointer to the second file's data map |
| p | Parameter of the distance formula |
| absolute | Return argument pointer, absolute value |
| relative | Return argument pointer, relative value |
| doShiftAverage | Boolean argument to determine whether to shift the second file's data |
Definition at line 810 of file vlsvdiff.cpp.


| void printHelp | ( | const map< string, string > & | defAttribs, |
| const map< string, string > & | descriptions ) |
Definition at line 1704 of file vlsvdiff.cpp.


| bool printNonVerboseData | ( | ) |
In folder-processing, non-verbose mode the data are stored during the processing and output at the end to have the data sorted properly
Definition at line 1045 of file vlsvdiff.cpp.


| bool process2Files | ( | const string | fileName1, |
| const string | fileName2, | ||
| const char * | varToExtract, | ||
| const uint | compToExtract, | ||
| const bool | verboseOutput, | ||
| const uint | compToExtract2 = 0 ) |
Read in the contents of the variable component in both files passed in strings fileName1 and fileName2, and compute statistics and distances as wished
| fileName1 | String argument giving the location of the first file to process |
| fileName2 | String argument giving the location of the second file to process |
| varToExtract | Pointer to the char array containing the name of the variable to extract |
| compToExtract | Unsigned int designating the component to extract (0 for scalars) |
| verboseOutput | Boolean parameter telling whether the output will be verbose or compact |
Definition at line 1570 of file vlsvdiff.cpp.


| bool processDirectory | ( | DIR * | dir, |
| set< string > * | fileList ) |
Creates the list of grid*.vlsv files present in the folder passed
| dir | DIR type pointer to the directory entry to process |
| fileList | Pointer to a set of strings, return argument for the produced file list |
Definition at line 1681 of file vlsvdiff.cpp.


| bool readAvgs | ( | T & | vlsvReader, |
| string | name, | ||
| const unordered_map< uint64_t, pair< uint64_t, uint32_t > > & | cellsWithBlocksLocations, | ||
| const uint64_t & | cellId, | ||
| unordered_map< uint32_t, vector< double > > & | avgs, | ||
| uint64_t & | vectorSize ) |
Definition at line 1157 of file vlsvdiff.cpp.


| bool shiftAverage | ( | const map< uint, Real > *const | orderedData1, |
| const map< uint, Real > *const | orderedData2, | ||
| map< uint, Real > * | shiftedData2 ) |
Shift the second file to the average of the first
| orderedData1 | Pointer to the reference file's data |
| orderedData2 | Pointer to the data to be shifted |
| shiftedData2 | Pointer to where the shifted data of the second file will be put |
Definition at line 757 of file vlsvdiff.cpp.

| bool singleStatistics | ( | map< uint, Real > * | orderedData, |
| Real * | size, | ||
| Real * | mini, | ||
| Real * | maxi, | ||
| Real * | avg, | ||
| Real * | stdev ) |
Compute statistics on a single file
| size | Return argument pointer, dataset size |
| mini | Return argument pointer, dataset minimum |
| maxi | Return argument pointer, dataset maximum |
| avg | Return argument pointer, dataset average |
| stdev | Return argument pointer, dataset standard deviation |
Definition at line 975 of file vlsvdiff.cpp.


|
static |
Definition at line 71 of file vlsvdiff.cpp.
|
static |
Definition at line 74 of file vlsvdiff.cpp.