source: XMLIO_V2/dev/dev_rv/src4/xmlio/netcdf/inetcdf4_adv_impl.hpp @ 229

Last change on this file since 229 was 229, checked in by hozdoba, 13 years ago
File size: 1.8 KB
Line 
1/* ************************************************************************** *
2 *      Copyright © IPSL/LSCE, XMLIOServer, Avril 2010 - Octobre 2011         *
3 * ************************************************************************** */
4
5#ifndef __INETCDF4_ADV_IMPL_H__
6#define __INETCDF4_ADV_IMPL_H__
7
8/**
9 * \file    inetcdf4_adv.hpp
10 * \brief   Lecture des fichiers de données au format netCDF-4, fonctionnalités avancées (implémentation template).
11 * \author  Hervé Ozdoba
12 * \version 0.4
13 * \date    15 Juin 2011
14 */
15
16// /////////////////////////////// Définitions ////////////////////////////// //
17
18namespace xmlioserver {
19namespace io {
20   
21   template <class DataType>
22      void CINetCDF4Adv::getMissingValue(DataType & _value, const std::string & _varname)
23   {
24      std::vector<DataType> value;
25      if (this->hasAttribute("missing_value", &_varname))
26      {
27         this->readAttribute("missing_value", value, &_varname);
28         _value = value[0];
29      }
30      if (this->hasAttribute("_FillValue", &_varname))
31      {
32         this->readAttribute("_FillValue", value, &_varname);
33         _value = value[0];
34      }
35   }
36   
37   template <class DataType, std::size_t ndim>
38      bool CINetCDF4Adv::replaceMissingValue(const std::string & _varname,
39                                             boost::multi_array<DataType, ndim> & _data,
40                                             const DataType & newValue)
41   {
42       if (this->hasMissingValue(_varname))
43       {
44           DataType mvalue;
45           this->CINetCDF4Adv::getMissingValue(mvalue, _varname);
46           std::replace(_data.begin(), _data.end(), mvalue, newValue);
47           return (true);
48       }
49       return (false);
50   }
51   
52} // namespace io
53} // namespace xmlioserver
54
55#endif  // __INETCDF4_ADV_IMPL_H__
56
Note: See TracBrowser for help on using the repository browser.