Loading...
Searching...
No Matches
fileio.h
1/*
2
3MIT License
4
5Copyright (c) 2017 FMI Open Development / Markus Peura, first.last@fmi.fi
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24
25*/
26/*
27Part of Rack development has been done in the BALTRAD projects part-financed
28by the European Union (European Regional Development Fund and European
29Neighbourhood Partnership Instrument, Baltic Sea Region Programme 2007-2013)
30*/
31
32#ifndef RACK_FILE_IO
33#define RACK_FILE_IO
34
35#include <string>
36
37#include <drain/RegExp.h>
38
39#include <drain/prog/CommandBank.h>
40#include <drain/prog/CommandInstaller.h>
41
42#include <drain/util/FileInfo.h>
43//#include <drain/image/FileGeoTIFF.h>
44
45#include "hi5/Hi5.h"
46
47#include "resources.h"
48
49namespace rack {
50
52// Edited 2017/07 such that also files without extension are considered h5 files.
53extern
55
57extern
59
60extern
62
64extern
66//const drain::RegExp textFileExtension;
67
68extern
69const drain::FileInfo jsonFileInfo;
70
71
73extern
75
77extern
79
80class CmdOutputFile : public drain::SimpleCommand<std::string> {
81
82public:
83
84 inline
85 CmdOutputFile() : drain::SimpleCommand<>(__FUNCTION__, "Output data to HDF5, text, image or GraphViz file. See also: --image, --outputRawImages.",
86 "filename", "", "<filename>.[h5|hdf5|png|pgm|txt|dat|mat|dot]|-") {
87 };
88
89 //void writeGeoTIFF(const drain::image::Image & src, const std::string & filename) const;
90
91 virtual
92 void exec() const override;
93
94 void writeProfile(const Hi5Tree & src, const std::string & filename) const;
95
96 void writeSamples(const Hi5Tree & src, const std::string & filename) const;
97
98 void writeDotGraph(const Hi5Tree & src, const std::string & filename, ODIMPathElem::group_t selector = (ODIMPathElem::ROOT | ODIMPathElem::IS_INDEXED)) const;
99
100
101};
102
103class CmdOutputTree : public drain::SimpleCommand<std::string> {
104
105public:
106
107 inline
108 CmdOutputTree() : drain::SimpleCommand<>(__FUNCTION__, "Output data as simple tree structure.",
109 "filename", "", "<filename>|-") {
110 };
111
112 void exec() const;
113
114
115};
116
117
118/*
119class CmdOutputPanel : public drain::BasicCommand {
120
121public:
122
123 inline
124 CmdOutputPanel() : drain::BasicCommand(__FUNCTION__, "Save SVG panel of latest images. See also: --image, --outputRawImages.") {
125 getParameters().link("filename", filename="");
126 getParameters().link("layout", layout, "basic");
127 };
128
129 CmdOutputPanel(const CmdOutputPanel & cmd) : drain::BasicCommand(cmd) {
130 getParameters().copyStruct(cmd.getParameters(), cmd, *this);
131 }
132
133
134 void exec() const;
135
136
137 std::string layout;
138 std::string filename;
139
140 void appendImage(TreeSVG & group, const std::string & prefix, drain::VariableMap & vmap,
141 const drain::Point2D<double> & location, const drain::image::Image & image, drain::BBox & bbox) const;
142};
143*/
144
145
146class FileModule : public drain::CommandModule<> { // : public drain::CommandGroup {
147
148public:
149
151 //virtual void initialize();
152
153};
154
155}
156
157#endif
158
159// Rack
Container and execution tools for commands derived from Command.
Definition CommandBank.h:67
Combines command installation and sectioning.
Definition CommandInstaller.h:153
Definition FileInfo.h:47
Definition RegExp.h:58
A single-parameter command.
Definition Command.h:487
Definition fileio.h:80
void writeProfile(const Hi5Tree &src, const std::string &filename) const
Definition file-prof.cpp:78
virtual void exec() const override
Run the command with current parameter values.
Definition fileio.cpp:345
void writeSamples(const Hi5Tree &src, const std::string &filename) const
Definition file-sample.cpp:82
Definition fileio.h:103
void exec() const
Run the command with current parameter values.
Definition fileio.cpp:908
A map of radar data, indexed by quantity code (DBZH, VRAD, etc).
Definition Data.h:1293
Definition fileio.h:146
static const group_t IS_INDEXED
Group index mask for groups that have an index.
Definition ODIMPath.h:159
static const group_t ROOT
Definition ODIMPath.h:102
unsigned int group_t
In H5, "groups" correspond to directories or folders in file system.
Definition ODIMPath.h:92
CommandBank & getCommandBank()
Global program command registry. Optional utility.
Definition CommandBank.cpp:52
Definition AltitudeOp.cpp:42
const drain::RegExp arrayFileExtension(".*\\.(mat)$", REG_EXTENDED|REG_ICASE)
Syntax for recognising text files.
Definition fileio.h:74
const drain::RegExp h5FileExtension
Syntax for recognising hdf5 files.
const drain::FileInfo listFileInfo("lst|vol")
Syntax for recognising hdf5 files.
Definition fileio.h:61
const drain::RegExp listFileExtension
Input file lists.
const drain::RegExp sampleFileExtension(".*\\.(dat)$", REG_EXTENDED|REG_ICASE)
Syntax for sparsely resampled data.
Definition fileio.h:78
const drain::FileInfo textFileInfo("txt")
Syntax for recognising text files.
Definition fileio.h:65