"Fossies" - the Fresh Open Source Software Archive

Member "fimex-1.4.2/src/metgm/MetGmTags.cc" (6 Jan 2020, 6376 Bytes) of package /linux/privat/fimex-1.4.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "MetGmTags.cc" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 1.4.1_vs_1.4.2.

    1 /*
    2  * Fimex
    3  *
    4  * (C) Copyright 2011-2019, met.no
    5  *
    6  * Project Info:  https://wiki.met.no/fimex/start
    7  *
    8  * This library is free software; you can redistribute it and/or modify it
    9  * under the terms of the GNU Lesser General Public License as published by
   10  * the Free Software Foundation; either version 2.1 of the License, or
   11  * (at your option) any later version.
   12  *
   13  * This library is distributed in the hope that it will be useful, but
   14  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
   15  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
   16  * License for more details.
   17  *
   18  * You should have received a copy of the GNU Lesser General Public
   19  * License along with this library; if not, write to the Free Software
   20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
   21  * USA.
   22  */
   23 
   24 // internals
   25 //
   26 #include "MetGmTags.h"
   27 #include "MetGmHandlePtr.h"
   28 #include "MetGmGroup1Ptr.h"
   29 #include "MetGmGroup2Ptr.h"
   30 #include "MetGmGroup3Ptr.h"
   31 #include "MetGmGroup5Ptr.h"
   32 #include "MetGmVerticalTag.h"
   33 #include "MetGmDimensionsTag.h"
   34 
   35 // METGM C Lib
   36 //
   37 #include "metgm.h"
   38 
   39 // fimex
   40 //
   41 #include "fimex/CDMReader.h"
   42 #include "fimex/CDMVariable.h"
   43 
   44 namespace MetNoFimex {
   45 
   46 std::shared_ptr<MetGmTags> MetGmTags::createMetGmTagsForWriting(const CDMReader_p pCdmReader, const CDMVariable* pVariable,
   47                                                                 const std::shared_ptr<MetGmHandlePtr> mgmHandle, const unsigned short p_id)
   48 {
   49     std::shared_ptr<MetGmTags> tags = std::shared_ptr<MetGmTags>(new MetGmTags);
   50     tags->pGp3_ = MetGmGroup3Ptr::createMetGmGroup3PtrForWriting(mgmHandle, p_id);
   51     tags->dimTag_ = MetGmHDTag::createMetGmDimensionsTagForWriting(pCdmReader, pVariable);
   52     tags->pGp5_ = MetGmGroup5Ptr::createMetGmGroup5PtrForWriting(pCdmReader, pVariable, tags->pGp3_);
   53 
   54     if (tags->pGp5_.get() && tags->dimTag_.get() && tags->pGp3_.get())
   55         return tags;
   56     else
   57         return std::shared_ptr<MetGmTags>();
   58     }
   59 
   60     std::shared_ptr<MetGmTags> MetGmTags::createMetGmTagsForReading(const std::shared_ptr<MetGmGroup1Ptr> pGp1, const std::shared_ptr<MetGmGroup2Ptr> pGp2,
   61                                                                     const std::shared_ptr<MetGmVerticalTag> vTag)
   62     {
   63         std::shared_ptr<MetGmTags> tags = std::shared_ptr<MetGmTags>(new MetGmTags(pGp1, pGp2));
   64         tags->pGp3_   = MetGmGroup3Ptr::createMetGmGroup3PtrForReading(pGp1->mgmHandle());
   65         tags->dimTag_ = MetGmHDTag::createMetGmDimensionsTag(pGp1, tags->pGp3_, vTag);
   66         tags->pGp5_   = MetGmGroup5Ptr::createMetGmGroup5PtrForReading(tags->pGp3_, tags->dimTag_);
   67         return tags;
   68     }
   69 
   70     std::shared_ptr<MetGmTags> MetGmTags::createMetGmTagsForSlicedReading(const std::shared_ptr<MetGmGroup1Ptr> pGp1,
   71                                                                           const std::shared_ptr<MetGmGroup2Ptr> pGp2,
   72                                                                           const std::shared_ptr<MetGmVerticalTag> vTag)
   73     {
   74         std::shared_ptr<MetGmTags> tags = std::shared_ptr<MetGmTags>(new MetGmTags(pGp1, pGp2));
   75         tags->pGp3_   = MetGmGroup3Ptr::createMetGmGroup3PtrForReading(pGp1->mgmHandle());
   76         tags->dimTag_ = MetGmHDTag::createMetGmDimensionsTag(pGp1, tags->pGp3_, vTag);
   77         tags->pGp5_   = MetGmGroup5Ptr::createMetGmGroup5PtrForSlicedReading(tags->pGp3_, tags->dimTag_);
   78         return tags;
   79     }
   80 
   81     std::shared_ptr<MetGmTags> MetGmTags::createMetGmTagsForSlicedWriting(const CDMReader_p pCdmReader, const CDMVariable* pVariable,
   82                                                                           const std::shared_ptr<MetGmHandlePtr> mgmHandle, const unsigned short p_id)
   83     {
   84         std::shared_ptr<MetGmTags> tags = std::shared_ptr<MetGmTags>(new MetGmTags);
   85         tags->pGp3_   = MetGmGroup3Ptr::createMetGmGroup3PtrForWriting(mgmHandle, p_id);
   86         tags->dimTag_ = MetGmHDTag::createMetGmDimensionsTagForWriting(pCdmReader, pVariable);
   87         tags->pGp5_   = MetGmGroup5Ptr::createMetGmGroup5PtrForSlicedWriting(pCdmReader, pVariable, tags->pGp3_);
   88         if(tags->pGp5_.get() && tags->dimTag_.get() && tags->pGp3_.get())
   89             return tags;
   90         else
   91             return std::shared_ptr<MetGmTags>();
   92     }
   93 
   94     unsigned short MetGmTags::p_id() const
   95     {
   96         return pGp3_->p_id();
   97     }
   98     int MetGmTags::pr() const
   99     {
  100         return pGp3_->pr();
  101     }
  102     int MetGmTags::pz() const
  103     {
  104         return pGp3_->pz();
  105     }
  106     unsigned short MetGmTags::hd() const
  107     {
  108         return dimTag_->asShort();
  109     }
  110 
  111     int MetGmTags::set_nt(int nt)   { return pGp3_->set_nt(nt); }
  112     int MetGmTags::set_dt(float dt) { return pGp3_->set_dt(dt); }
  113 
  114     int MetGmTags::set_nz(int nz)   { return pGp3_->set_nz(nz); }
  115     int MetGmTags::set_pz(int pz)   { return pGp3_->set_pz(pz); }
  116     int MetGmTags::set_pr(int pr)   { return pGp3_->set_pr(pr); }
  117 
  118     int MetGmTags::set_nx(int nx)   { return pGp3_->set_nx(nx); }
  119     int MetGmTags::set_dx(float dx) { return pGp3_->set_dx(dx); }
  120     int MetGmTags::set_cx(float cx) { return pGp3_->set_cx(cx); }
  121 
  122     int MetGmTags::set_ny(int ny)   { return pGp3_->set_ny(ny); }
  123     int MetGmTags::set_dy(float dy) { return pGp3_->set_dy(dy); }
  124     int MetGmTags::set_cy(float cy) { return pGp3_->set_cy(cy); }
  125 
  126     std::shared_ptr<MetGmXTag>& MetGmTags::xTag()
  127     {
  128         return dimTag_->xTag();
  129     }
  130     std::shared_ptr<MetGmYTag>& MetGmTags::yTag()
  131     {
  132         return dimTag_->yTag();
  133     }
  134     std::shared_ptr<MetGmVerticalTag>& MetGmTags::zTag()
  135     {
  136         return dimTag_->zTag();
  137     }
  138     std::shared_ptr<MetGmTimeTag>& MetGmTags::tTag()
  139     {
  140         return dimTag_->tTag();
  141     }
  142 
  143     unsigned long MetGmTags::totalDataSize()
  144     {
  145         return dimTag_->totalSize();
  146     }
  147     unsigned long MetGmTags::sliceDataSize()
  148     {
  149         return dimTag_->sliceSize();
  150     }
  151 
  152     void MetGmTags::sliceToMetGmLayout(shared_array<float>& slice)
  153     {
  154         pGp5_->sliceToMetGmLayout(slice);
  155     }
  156 
  157     shared_array<float> MetGmTags::readDataSlices(size_t pos, size_t numberOfSlices)
  158     {
  159         return pGp5_->readDataSlices(pos, numberOfSlices);
  160     }
  161 
  162     const shared_array<float>& MetGmTags::data()
  163     {
  164         return pGp5_->data();
  165     }
  166     std::string MetGmTags::units() const
  167     {
  168         return pGp5_->units();
  169     }
  170 }