Go to the documentation of this file.
54 if (!gal.
species.
nelem())
throw runtime_error(
"No species found in lookup table file!");
78 int species_strings_varid;
79 int species_count_varid;
82 Index species_max_strlen = 0;
83 char* species_strings = NULL;
87 long species_total_nelems = 0;
91 species_total_nelems += nspecies_nelem;
92 species_count[nspecies] = nspecies_nelem;
94 for (ArrayOfSpeciesTag::const_iterator it = gal.
species[nspecies].begin();
95 it != gal.
species[nspecies].end(); it++)
96 if (it->Name().nelem() > species_max_strlen) species_max_strlen = it->Name().
nelem();
100 species_strings =
new char[species_total_nelems*species_max_strlen];
101 memset(species_strings, 0, species_total_nelems*species_max_strlen);
104 for (ArrayOfArrayOfSpeciesTag::const_iterator it1 = gal.
species.begin();
105 it1 != gal.
species.end(); it1++)
106 for (ArrayOfSpeciesTag::const_iterator it2 = it1->begin();
107 it2 != it1->end(); it2++)
109 memccpy(&species_strings[str_i], it2->Name().c_str(), 0, species_max_strlen);
110 str_i += species_max_strlen;
115 int species_strings_ncdims[2];
116 nca_def_dim(ncid,
"species_strings_nelem", species_total_nelems, &species_strings_ncdims[0]);
117 nca_def_dim(ncid,
"species_strings_length", species_max_strlen, &species_strings_ncdims[1]);
118 nca_def_var(ncid,
"species_strings", NC_CHAR, 2, &species_strings_ncdims[0],
119 &species_strings_varid);
122 throw runtime_error(
"Current lookup table contains no species!");
136 if ((retval = nc_enddef(ncid)))
nca_error(retval,
"nc_enddef");
142 if ((retval = nc_put_var_text(ncid, species_strings_varid, species_strings)))
146 delete[] species_strings;
164 #define TMPL_NC_READ_WRITE_FILE_DUMMY(what) \
165 void nca_write_to_file(const int, const what&, const Verbosity&) \
167 throw runtime_error("NetCDF support not yet implemented for this type!"); \
169 void nca_read_from_file(const int, what&, const Verbosity&) \
171 throw runtime_error("NetCDF support not yet implemented for this type!"); \
179 #undef TMPL_NC_READ_WRITE_FILE_DUMMY
void nca_get_data_Matrix(const int ncid, const String &name, Matrix &m, const bool noerror)
Read variable of type Matrix from NetCDF file.
ArrayOfIndex nonlinear_species
The species tags with non-linear treatment.
void nca_get_data_ArrayOfIndex(const int ncid, const String &name, ArrayOfIndex &aoi, const bool noerror)
Read variable of type ArrayOfIndex from NetCDF file.
This file contains basic functions to handle NetCDF data files.
bool nca_put_var_Matrix(const int ncid, const int varid, const Matrix &m)
Write variable of type Matrix to NetCDF file.
void nca_get_data_Tensor4(const int ncid, const String &name, Tensor4 &t, const bool noerror)
Read variable of type Tensor4 from NetCDF file.
This file contains private function declarations and template instantiation to handle NetCDF data fil...
An absorption lookup table.
bool nca_put_var_ArrayOfIndex(const int ncid, const int varid, const ArrayOfIndex &a)
Write variable of type ArrayOfIndex to NetCDF file.
#define TMPL_NC_READ_WRITE_FILE_DUMMY(what)
void nca_read_from_file(const int ncid, GasAbsLookup &gal, const Verbosity &)
Reads a GasAbsLookup table from a NetCDF file.
int nca_def_Vector(const int ncid, const String &name, const Vector &v)
Define NetCDF dimensions and variable for a Vector.
int nca_def_Tensor4(const int ncid, const String &name, const Tensor4 &t)
Define NetCDF dimensions and variable for a Tensor4.
bool nca_put_var_Tensor4(const int ncid, const int varid, const Tensor4 &t)
Write variable of type Tensor4 to NetCDF file.
Vector t_ref
The reference temperature profile [K].
Vector f_grid
The frequency grid [Hz].
Vector p_grid
The pressure grid for the table [Pa].
int nca_def_Matrix(const int ncid, const String &name, const Matrix &m)
Define NetCDF dimensions and variable for a Matrix.
int nca_def_ArrayOfIndex(const int ncid, const String &name, const ArrayOfIndex &a)
Define NetCDF dimensions and variable for an ArrayOfIndex.
Vector nls_pert
The vector of perturbations for the VMRs of the nonlinear species.
Tensor4 xsec
Absorption cross sections.
void nca_def_var(const int ncid, const String &name, const nc_type type, const int ndims, const int *dims, int *varid)
Define NetCDF variable.
ArrayOfArrayOfSpeciesTag species
The species tags for which the table is valid.
void nca_write_to_file(const int ncid, const GasAbsLookup &gal, const Verbosity &)
Writes a GasAbsLookup table to a NetCDF file.
void nca_def_dim(const int ncid, const String &name, const Index nelem, int *ncdim)
Define NetCDF dimension.
INDEX Index
The type to use for all integer numbers and indices.
void nca_get_data_Vector(const int ncid, const String &name, Vector &v, const bool noerror)
Read variable of type Vector from NetCDF file.
Matrix vmrs_ref
The reference VMR profiles.
Vector t_pert
The vector of temperature perturbations [K].
void nca_error(const int e, const String s)
Throws a runtime error for the given NetCDF error code.
Index nelem() const
Number of elements.
The global header file for ARTS.
void nca_get_data_ArrayOfArrayOfSpeciesTag(const int ncid, const String &name, ArrayOfArrayOfSpeciesTag &aast, const bool noerror)
Read variable of type ArrayOfArrayOfSpeciesTag from NetCDF file.
bool nca_put_var_Vector(const int ncid, const int varid, const Vector &v)
Write variable of type Vector to NetCDF file.