ReFRACtor
example_met_file.cc
Go to the documentation of this file.
1 #include "example_met_file.h"
2 #include "observation_id.h"
3 
4 using namespace FullPhysics;
5 using namespace blitz;
6 
7 #ifdef HAVE_LUA
8 #include "register_lua.h"
10 .def(luabind::constructor<const boost::shared_ptr<HdfFile>&, const std::string&>())
12 #endif
13 
14 //-----------------------------------------------------------------------
18 //-----------------------------------------------------------------------
19 
20 ExampleMetFile::ExampleMetFile(const boost::shared_ptr<HdfFile>& input_file, const std::string& observation_id)
21 : input(input_file)
22 {
23  ObservationId<std::string> obs_id(input_file, "observation_ids", observation_id);
24  data_index = obs_id.data_index();
25 }
26 
27 ExampleMetFile::ExampleMetFile(const std::string& input_filename, const std::string& observation_id)
28 : input(new HdfFile(input_filename))
29 {
30  ObservationId<std::string> obs_id(input, "observation_ids", observation_id);
31  data_index = obs_id.data_index();
32 }
33 
34 //-----------------------------------------------------------------------
36 //-----------------------------------------------------------------------
37 
38 double ExampleMetFile::read_scalar(const std::string& field) const
39 {
40  return input->read_field<double, 1>(field, TinyVector<int, 1>(data_index), TinyVector<int, 1>(1))(0);
41 }
42 
43 //-----------------------------------------------------------------------
45 //-----------------------------------------------------------------------
46 
47 Array<double, 1> ExampleMetFile::read_array(const std::string& Field) const
48 {
49  TinyVector<int, 2> sz = input->read_shape<2>(Field);
50  Array<double, 2> raw = input->read_field<double, 2>(Field, TinyVector<int, 2>(data_index, 0), TinyVector<int, 2>(1, sz[1]));
51  Array<double, 1> value(raw.extent(secondDim));
52 
53  value = raw(0, Range::all());
54 
55  return value;
56 }
ExampleMetFile(const boost::shared_ptr< HdfFile > &input_file, const std::string &observation_id)
Constructor.
Defines the interface for supplying meteorological data.
Definition: meteorology.h:14
Defines a simple mechanism by where a specific dataset from a HDF file is read along with some sort o...
#define REGISTER_LUA_DERIVED_CLASS(X, Y)
Definition: register_lua.h:136
This class reads and writes a HDF5 file.
Definition: hdf_file.h:39
Apply value function to a blitz array.
This class implements and example Meteorological reader that reads data from an HDF file with dataset...
Contains classes to abstract away details in various Spurr Radiative Transfer software.
Definition: doxygen_python.h:1
#define REGISTER_LUA_END()
Definition: register_lua.h:134
double value(const FullPhysics::AutoDerivative< double > &Ad)

Copyright © 2017, California Institute of Technology.
ALL RIGHTS RESERVED.
U.S. Government Sponsorship acknowledged.
Generated Fri Aug 24 2018 15:44:08